]> git.lyx.org Git - lyx.git/blobdiff - src/Chktex.C
include sys/time.h
[lyx.git] / src / Chktex.C
index e0b3991379df9d3f8c589d2bbe4f92ab754d4dba..1e7f62d2bc7724506ecaa9f364aff8fd13fcd51a 100644 (file)
@@ -1,35 +1,34 @@
 /* This file is part of
- * ====================================================== 
- * 
- *           LyX, The Document Processor        
+ * ======================================================
+ *
+ *           LyX, The Document Processor
  *          Copyright 1995 Matthias Ettrich
  *           Copyright 1995-2001 The LyX Team.
  *
  *           This file is Copyright 1997-1998
  *           Asger Alstrup
  *
- * ====================================================== 
+ * ======================================================
  */
 
 #include <config.h>
 
-#include <fstream>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "Chktex.h"
 #include "LaTeX.h" // TeXErrors
-#include "support/filetools.h"
 #include "lyxlex.h"
-#include "support/FileInfo.h"
 #include "debug.h"
-#include "support/syscall.h"
-#include "support/syscontr.h"
-#include "support/path.h"
 #include "gettext.h"
 
+#include "support/FileInfo.h"
+#include "support/filetools.h"
+#include "support/systemcall.h"
+#include "support/path.h"
+#include "support/lstrings.h"
+
+#include "BoostFormat.h"
+
+#include <fstream>
+
 using std::ifstream;
 using std::getline;
 
@@ -48,8 +47,8 @@ int Chktex::run(TeXErrors &terr)
        // run bibtex
        string log = OnlyFilename(ChangeExtension(file, ".log"));
        string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
-        Systemcalls one;
-       int result= one.startscript(Systemcalls::System, tmp);
+       Systemcall one;
+       int result= one.startscript(Systemcall::Wait, tmp);
        if (result == 0) {
                result = scanLogFile(terr);
        } else {
@@ -64,8 +63,13 @@ int Chktex::scanLogFile(TeXErrors & terr)
        string token;
        int retval = 0;
 
-       string tmp = OnlyFilename(ChangeExtension(file, ".log"));
+       string const tmp = OnlyFilename(ChangeExtension(file, ".log"));
 
+#if USE_BOOST_FORMAT
+       boost::format msg(_("ChkTeX warning id # %1$d"));
+#else
+       string const msg(_("ChkTeX warning id # "));
+#endif
        ifstream ifs(tmp.c_str());
        while (getline(ifs, token)) {
                string srcfile;
@@ -79,9 +83,16 @@ int Chktex::scanLogFile(TeXErrors & terr)
                token = split(token, warno, ':');
                token = split(token, warning, ':');
 
-               int lineno = lyx::atoi(line);
-               warno = _("ChkTeX warning id #") + warno;
-               terr.insertError(lineno, warno, warning);
+               int const lineno = lyx::atoi(line);
+
+#if USE_BOOST_FORMAT
+               msg % warno;
+               terr.insertError(lineno, msg.str(), warning);
+               msg.clear();
+#else
+               terr.insertError(lineno, msg + warno, warning);
+#endif
+
                ++retval;
        }
        return retval;