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
17 #include "support/filetools.h"
18 #include "support/lstrings.h"
19 #include "support/lyxlib.h"
20 #include "support/systemcall.h"
22 #include "support/BoostFormat.h"
26 using namespace lyx::support;
32 Chktex::Chktex(string const & chktex, string const & f, string const & p)
33 : cmd(chktex), file(f), path(p)
38 int Chktex::run(TeXErrors &terr)
41 string log = OnlyFilename(ChangeExtension(file, ".log"));
42 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
44 int result = one.startscript(Systemcall::Wait, tmp);
46 result = scanLogFile(terr);
54 int Chktex::scanLogFile(TeXErrors & terr)
59 string const tmp = OnlyFilename(ChangeExtension(file, ".log"));
62 boost::format msg(STRCONV(_("ChkTeX warning id # %1$d")));
64 string const msg(_("ChkTeX warning id # "));
66 ifstream ifs(tmp.c_str());
67 while (getline(ifs, token)) {
73 token = split(token, srcfile, ':');
74 token = split(token, line, ':');
75 token = split(token, pos, ':');
76 token = split(token, warno, ':');
77 token = split(token, warning, ':');
79 int const lineno = atoi(line);
83 terr.insertError(lineno, STRCONV(msg.str()), warning);
86 terr.insertError(lineno, msg + warno, warning);