1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-2000 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"
41 Chktex::Chktex(string const & chktex, string const & f, string const & p)
42 : cmd(chktex), file(f), path(p)
47 int Chktex::run(TeXErrors &terr)
50 string log = OnlyFilename(ChangeExtension(file, ".log"));
51 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
53 int result= one.startscript(Systemcalls::System, tmp);
55 result = scanLogFile(terr);
63 int Chktex::scanLogFile(TeXErrors & terr)
68 string tmp = OnlyFilename(ChangeExtension(file, ".log"));
70 ifstream ifs(tmp.c_str());
71 while (getline(ifs, token)) {
72 string srcfile, line, pos, warno, warning;
73 token = split(token, srcfile, ':');
74 token = split(token, line, ':');
75 token = split(token, pos, ':');
76 token = split(token, warno, ':');
77 token = split(token, warning, ':');
79 int lineno = atoi(line.c_str());
80 warno = _("ChkTeX warning id #") + warno;
81 terr.insertError(lineno, warno, warning);