1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-2001 The LyX Team.
8 * This file is Copyright 1997-1998
11 * ======================================================
17 #include "LaTeX.h" // TeXErrors
22 #include "support/FileInfo.h"
23 #include "support/filetools.h"
24 #include "support/systemcall.h"
25 #include "support/path.h"
26 #include "support/lstrings.h"
28 #include "support/BoostFormat.h"
39 Chktex::Chktex(string const & chktex, string const & f, string const & p)
40 : cmd(chktex), file(f), path(p)
45 int Chktex::run(TeXErrors &terr)
48 string log = OnlyFilename(ChangeExtension(file, ".log"));
49 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
51 int result= one.startscript(Systemcall::Wait, tmp);
53 result = scanLogFile(terr);
61 int Chktex::scanLogFile(TeXErrors & terr)
66 string const tmp = OnlyFilename(ChangeExtension(file, ".log"));
69 boost::format msg(_("ChkTeX warning id # %1$d"));
71 string const msg(_("ChkTeX warning id # "));
73 ifstream ifs(tmp.c_str());
74 while (getline(ifs, token)) {
80 token = split(token, srcfile, ':');
81 token = split(token, line, ':');
82 token = split(token, pos, ':');
83 token = split(token, warno, ':');
84 token = split(token, warning, ':');
86 int const lineno = lyx::atoi(line);
90 terr.insertError(lineno, msg.str(), warning);
93 terr.insertError(lineno, msg + warno, warning);