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 #pragma implementation
21 #include "LaTeX.h" // TeXErrors
26 #include "support/FileInfo.h"
27 #include "support/filetools.h"
28 #include "support/systemcall.h"
29 #include "support/path.h"
30 #include "support/lstrings.h"
32 #include "BoostFormat.h"
43 Chktex::Chktex(string const & chktex, string const & f, string const & p)
44 : cmd(chktex), file(f), path(p)
49 int Chktex::run(TeXErrors &terr)
52 string log = OnlyFilename(ChangeExtension(file, ".log"));
53 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
55 int result= one.startscript(Systemcall::Wait, tmp);
57 result = scanLogFile(terr);
65 int Chktex::scanLogFile(TeXErrors & terr)
70 string const tmp = OnlyFilename(ChangeExtension(file, ".log"));
73 boost::format msg(_("ChkTeX warning id # %1$d"));
75 string const msg(_("ChkTeX warning id # "));
77 ifstream ifs(tmp.c_str());
78 while (getline(ifs, token)) {
84 token = split(token, srcfile, ':');
85 token = split(token, line, ':');
86 token = split(token, pos, ':');
87 token = split(token, warno, ':');
88 token = split(token, warning, ':');
90 int const lineno = lyx::atoi(line);
94 terr.insertError(lineno, msg.str(), warning);
97 terr.insertError(lineno, msg + warno, warning);