X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FChktex.C;h=981999f303fb0c5b33275982cabc356d824e91ae;hb=8765ab59cdddad67284007813ef25934ea0042ce;hp=0651672dedd374e4cb68c1c261a04f8a48639ee2;hpb=91de22ef340abbf1e9ba7d422bcd9024fa90d63f;p=lyx.git diff --git a/src/Chktex.C b/src/Chktex.C index 0651672ded..981999f303 100644 --- a/src/Chktex.C +++ b/src/Chktex.C @@ -11,22 +11,30 @@ #include #include "Chktex.h" -#include "LaTeX.h" // TeXErrors #include "gettext.h" +#include "LaTeX.h" // TeXErrors + +#include "support/convert.h" +#include "support/docstream.h" #include "support/filetools.h" #include "support/lstrings.h" -#include "support/lyxlib.h" #include "support/systemcall.h" -#include "support/BoostFormat.h" +#include -#include -using namespace lyx::support; +namespace lyx { + +using support::changeExtension; +using support::FileName; +using support::makeAbsPath; +using support::onlyFilename; +using support::split; +using support::Systemcall; -using std::ifstream; using std::getline; +using std::string; Chktex::Chktex(string const & chktex, string const & f, string const & p) @@ -38,7 +46,7 @@ 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); @@ -53,34 +61,38 @@ int Chktex::run(TeXErrors &terr) int Chktex::scanLogFile(TeXErrors & terr) { - string token; int retval = 0; - string const tmp = OnlyFilename(ChangeExtension(file, ".log")); + // FIXME: Find out whether onlyFilename() is really needed, + // or whether makeAbsPath(onlyFilename()) is a noop here + FileName const tmp(makeAbsPath(onlyFilename(changeExtension(file, ".log")))); #if USE_BOOST_FORMAT - boost::format msg(STRCONV(_("ChkTeX warning id # %1$d"))); + boost::basic_format msg(_("ChkTeX warning id # %1$d")); #else - string const msg(_("ChkTeX warning id # ")); + docstring const msg(_("ChkTeX warning id # ")); #endif - ifstream ifs(tmp.c_str()); + docstring token; + // FIXME UNICODE + // We have no idea what the encoding of the error file is + idocfstream ifs(tmp.toFilesystemEncoding().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 const lineno = atoi(line); + int const lineno = convert(line); #if USE_BOOST_FORMAT msg % warno; - terr.insertError(lineno, STRCONV(msg.str()), warning); + terr.insertError(lineno, msg.str(), warning); msg.clear(); #else terr.insertError(lineno, msg + warno, warning); @@ -90,3 +102,6 @@ int Chktex::scanLogFile(TeXErrors & terr) } return retval; } + + +} // namespace lyx