1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-1999 The LyX Team.
8 * This file is Copyright 1997-1998
11 *======================================================
16 #include <cstdlib> // atoi
19 #pragma implementation
23 #include "LaTeX.h" // TeXErrors
24 #include "support/filetools.h"
26 #include "support/FileInfo.h"
28 #include "support/syscall.h"
29 #include "support/syscontr.h"
30 #include "support/path.h"
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 = ChangeExtension(file, ".log", true);
47 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
49 int result= one.startscript(Systemcalls::System, tmp);
51 result = scanLogFile(terr);
59 int Chktex::scanLogFile(TeXErrors &terr)
64 string tmp = ChangeExtension(file, ".log", true);
66 ifstream ifs(tmp.c_str());
67 while (getline(ifs, token)) {
68 string srcfile, line, pos, warno, warning;
69 token = split(token, srcfile, ':');
70 token = split(token, line, ':');
71 token = split(token, pos, ':');
72 token = split(token, warno, ':');
73 token = split(token, warning, ':');
75 int lineno = atoi(line.c_str());
76 warno = _("ChkTeX warning id #") + warno;
77 terr.insertError(lineno, warno, warning);