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 * ======================================================
17 #include <cstdlib> // atoi
20 #pragma implementation
24 #include "LaTeX.h" // TeXErrors
25 #include "support/filetools.h"
27 #include "support/FileInfo.h"
29 #include "support/syscall.h"
30 #include "support/syscontr.h"
31 #include "support/path.h"
40 Chktex::Chktex(string const & chktex, string const & f, string const & p)
41 : cmd(chktex), file(f), path(p)
46 int Chktex::run(TeXErrors &terr)
49 string log = ChangeExtension(file, ".log", true);
50 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
52 int result= one.startscript(Systemcalls::System, tmp);
54 result = scanLogFile(terr);
62 int Chktex::scanLogFile(TeXErrors & terr)
67 string tmp = ChangeExtension(file, ".log", true);
69 ifstream ifs(tmp.c_str());
70 while (getline(ifs, token)) {
71 string srcfile, line, pos, warno, warning;
72 token = split(token, srcfile, ':');
73 token = split(token, line, ':');
74 token = split(token, pos, ':');
75 token = split(token, warno, ':');
76 token = split(token, warning, ':');
78 int lineno = atoi(line.c_str());
79 warno = _("ChkTeX warning id #") + warno;
80 terr.insertError(lineno, warno, warning);