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)
66 string tmp = ChangeExtension(file, ".log", true);
68 if (!lex.setFile(tmp)) {
69 // Unable to open file. Return at once
75 token = lex.GetString();
76 else // blank line in the file being read
79 string srcfile, line, pos, warno, warning;
80 token=split(token, srcfile, ':');
81 token=split(token, line, ':');
82 token=split(token, pos, ':');
83 token=split(token, warno, ':');
84 token=split(token, warning, ':');
86 int lineno = atoi(line.c_str());
87 warno = _("ChkTeX warning id #") + warno;
88 terr.insertError(lineno, warno, warning);