3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
8 * Full author contact details are available in file CREDITS.
14 #include "LaTeX.h" // TeXErrors
19 #include "support/FileInfo.h"
20 #include "support/filetools.h"
21 #include "support/systemcall.h"
22 #include "support/path.h"
23 #include "support/lstrings.h"
25 #include "support/BoostFormat.h"
29 using namespace lyx::support;
35 Chktex::Chktex(string const & chktex, string const & f, string const & p)
36 : cmd(chktex), file(f), path(p)
41 int Chktex::run(TeXErrors &terr)
44 string log = OnlyFilename(ChangeExtension(file, ".log"));
45 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
47 int result = one.startscript(Systemcall::Wait, tmp);
49 result = scanLogFile(terr);
57 int Chktex::scanLogFile(TeXErrors & terr)
62 string const tmp = OnlyFilename(ChangeExtension(file, ".log"));
65 boost::format msg(STRCONV(_("ChkTeX warning id # %1$d")));
67 string const msg(_("ChkTeX warning id # "));
69 ifstream ifs(tmp.c_str());
70 while (getline(ifs, token)) {
76 token = split(token, srcfile, ':');
77 token = split(token, line, ':');
78 token = split(token, pos, ':');
79 token = split(token, warno, ':');
80 token = split(token, warning, ':');
82 int const lineno = atoi(line);
86 terr.insertError(lineno, STRCONV(msg.str()), warning);
89 terr.insertError(lineno, msg + warno, warning);