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.
16 #include "LaTeX.h" // TeXErrors
18 #include "support/convert.h"
19 #include "support/filetools.h"
20 #include "support/lstrings.h"
21 #include "support/systemcall.h"
23 #include <boost/format.hpp>
27 using lyx::support::ChangeExtension;
28 using lyx::support::OnlyFilename;
29 using lyx::support::split;
30 using lyx::support::Systemcall;
37 Chktex::Chktex(string const & chktex, string const & f, string const & p)
38 : cmd(chktex), file(f), path(p)
43 int Chktex::run(TeXErrors &terr)
46 string log = OnlyFilename(ChangeExtension(file, ".log"));
47 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
49 int result = one.startscript(Systemcall::Wait, tmp);
51 result = scanLogFile(terr);
59 int Chktex::scanLogFile(TeXErrors & terr)
64 string const tmp = OnlyFilename(ChangeExtension(file, ".log"));
67 boost::format msg(_("ChkTeX warning id # %1$d"));
69 string const msg(_("ChkTeX warning id # "));
71 ifstream ifs(tmp.c_str());
72 while (getline(ifs, token)) {
78 token = split(token, srcfile, ':');
79 token = split(token, line, ':');
80 token = split(token, pos, ':');
81 token = split(token, warno, ':');
82 token = split(token, warning, ':');
84 int const lineno = convert<int>(line);
88 terr.insertError(lineno, msg.str(), warning);
91 terr.insertError(lineno, msg + warno, warning);