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/syscall.h"
29 #include "support/syscontr.h"
30 #include "support/path.h"
31 #include "support/lstrings.h"
42 Chktex::Chktex(string const & chktex, string const & f, string const & p)
43 : cmd(chktex), file(f), path(p)
48 int Chktex::run(TeXErrors &terr)
51 string log = OnlyFilename(ChangeExtension(file, ".log"));
52 string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
54 int result= one.startscript(Systemcalls::System, tmp);
56 result = scanLogFile(terr);
64 int Chktex::scanLogFile(TeXErrors & terr)
69 string tmp = OnlyFilename(ChangeExtension(file, ".log"));
71 ifstream ifs(tmp.c_str());
72 while (getline(ifs, token)) {
78 token = split(token, srcfile, ':');
79 token = split(token, line, ':');
80 token = split(token, pos, ':');
81 token = split(token, warno, ':');
82 token = split(token, warning, ':');
84 int lineno = lyx::atoi(line);
85 warno = _("ChkTeX warning id #") + warno;
86 terr.insertError(lineno, warno, warning);