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/filetools.h"
19 #include "support/lstrings.h"
20 #include "support/lyxlib.h"
21 #include "support/systemcall.h"
23 #include <boost/format.hpp>
27 using lyx::support::atoi;
28 using lyx::support::ChangeExtension;
29 using lyx::support::OnlyFilename;
30 using lyx::support::split;
31 using lyx::support::Systemcall;
38 Chktex::Chktex(string const & chktex, string const & f, string const & p)
39 : cmd(chktex), file(f), path(p)
44 int Chktex::run(TeXErrors &terr)
47 string log = OnlyFilename(ChangeExtension(file, ".log"));
48 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
50 int result = one.startscript(Systemcall::Wait, tmp);
52 result = scanLogFile(terr);
60 int Chktex::scanLogFile(TeXErrors & terr)
65 string const tmp = OnlyFilename(ChangeExtension(file, ".log"));
68 boost::format msg(_("ChkTeX warning id # %1$d"));
70 string const msg(_("ChkTeX warning id # "));
72 ifstream ifs(tmp.c_str());
73 while (getline(ifs, token)) {
79 token = split(token, srcfile, ':');
80 token = split(token, line, ':');
81 token = split(token, pos, ':');
82 token = split(token, warno, ':');
83 token = split(token, warning, ':');
85 int const lineno = atoi(line);
89 terr.insertError(lineno, msg.str(), warning);
92 terr.insertError(lineno, msg + warno, warning);