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/lstrings.h"
22 #include "support/lyxlib.h"
23 #include "support/path.h"
24 #include "support/systemcall.h"
26 #include "support/BoostFormat.h"
30 using namespace lyx::support;
36 Chktex::Chktex(string const & chktex, string const & f, string const & p)
37 : cmd(chktex), file(f), path(p)
42 int Chktex::run(TeXErrors &terr)
45 string log = OnlyFilename(ChangeExtension(file, ".log"));
46 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
48 int result = one.startscript(Systemcall::Wait, tmp);
50 result = scanLogFile(terr);
58 int Chktex::scanLogFile(TeXErrors & terr)
63 string const tmp = OnlyFilename(ChangeExtension(file, ".log"));
66 boost::format msg(STRCONV(_("ChkTeX warning id # %1$d")));
68 string const msg(_("ChkTeX warning id # "));
70 ifstream ifs(tmp.c_str());
71 while (getline(ifs, token)) {
77 token = split(token, srcfile, ':');
78 token = split(token, line, ':');
79 token = split(token, pos, ':');
80 token = split(token, warno, ':');
81 token = split(token, warning, ':');
83 int const lineno = atoi(line);
87 terr.insertError(lineno, STRCONV(msg.str()), warning);
90 terr.insertError(lineno, msg + warno, warning);