X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FChktex.C;h=09c48a7eabe1a45963a5e7d861c3439839d6df72;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=f9752dac258479543fee37734e9de278c9679aaf;hpb=b016d9d77324649f6fef8af9bb1c871fb7dafa33;p=lyx.git diff --git a/src/Chktex.C b/src/Chktex.C index f9752dac25..09c48a7eab 100644 --- a/src/Chktex.C +++ b/src/Chktex.C @@ -1,44 +1,40 @@ -/* This file is part of - * ====================================================== +/** + * \file Chktex.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * LyX, The Document Processor - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. + * \author Asger Alstrup * - * This file is Copyright 1997-1998 - * Asger Alstrup - * - * ====================================================== + * Full author contact details are available in file CREDITS. */ #include -#ifdef __GNUG__ -#pragma implementation -#endif - #include "Chktex.h" -#include "LaTeX.h" // TeXErrors -#include "lyxlex.h" -#include "debug.h" #include "gettext.h" -#include "support/FileInfo.h" +#include "LaTeX.h" // TeXErrors + +#include "support/convert.h" +#include "support/docstream.h" #include "support/filetools.h" -#include "support/systemcall.h" -#include "support/path.h" #include "support/lstrings.h" +#include "support/systemcall.h" -#include "BoostFormat.h" +#include -#include -using std::ifstream; +namespace lyx { + +using support::changeExtension; +using support::onlyFilename; +using support::split; +using support::Systemcall; + using std::getline; +using std::string; +using std::ifstream; -/* - * CLASS Chktex - */ Chktex::Chktex(string const & chktex, string const & f, string const & p) : cmd(chktex), file(f), path(p) @@ -49,10 +45,10 @@ Chktex::Chktex(string const & chktex, string const & f, string const & p) int Chktex::run(TeXErrors &terr) { // run bibtex - string log = OnlyFilename(ChangeExtension(file, ".log")); + string log = onlyFilename(changeExtension(file, ".log")); string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log; Systemcall one; - int result= one.startscript(Systemcall::Wait, tmp); + int result = one.startscript(Systemcall::Wait, tmp); if (result == 0) { result = scanLogFile(terr); } else { @@ -64,28 +60,45 @@ int Chktex::run(TeXErrors &terr) int Chktex::scanLogFile(TeXErrors & terr) { - string token; int retval = 0; - string tmp = OnlyFilename(ChangeExtension(file, ".log")); + string const tmp = onlyFilename(changeExtension(file, ".log")); - ifstream ifs(tmp.c_str()); +#if USE_BOOST_FORMAT + boost::basic_format msg(_("ChkTeX warning id # %1$d")); +#else + docstring const msg(_("ChkTeX warning id # ")); +#endif + docstring token; + // FIXME UNICODE + // We have no idea what the encoding of the error file is + idocfstream ifs(tmp.c_str()); while (getline(ifs, token)) { - string srcfile; - string line; - string pos; - string warno; - string warning; + docstring srcfile; + docstring line; + docstring pos; + docstring warno; + docstring warning; token = split(token, srcfile, ':'); token = split(token, line, ':'); token = split(token, pos, ':'); token = split(token, warno, ':'); token = split(token, warning, ':'); - int lineno = lyx::atoi(line); - warno = boost::io::str(boost::format(_("ChkTeX warning id # %1$d")) % warno); - terr.insertError(lineno, warno, warning); + int const lineno = convert(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; } + + +} // namespace lyx