X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FChktex.C;h=981999f303fb0c5b33275982cabc356d824e91ae;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=bb9258c207d60c570e0e835bbe7b4454f31f827c;hpb=342cdf432246110db37bee4e0aebb4b72c933ddb;p=lyx.git diff --git a/src/Chktex.C b/src/Chktex.C index bb9258c207..981999f303 100644 --- a/src/Chktex.C +++ b/src/Chktex.C @@ -16,22 +16,25 @@ #include "LaTeX.h" // TeXErrors #include "support/convert.h" +#include "support/docstream.h" #include "support/filetools.h" #include "support/lstrings.h" #include "support/systemcall.h" #include -#include -using lyx::support::ChangeExtension; -using lyx::support::OnlyFilename; -using lyx::support::split; -using lyx::support::Systemcall; +namespace lyx { + +using support::changeExtension; +using support::FileName; +using support::makeAbsPath; +using support::onlyFilename; +using support::split; +using support::Systemcall; using std::getline; using std::string; -using std::ifstream; Chktex::Chktex(string const & chktex, string const & f, string const & p) @@ -43,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); @@ -58,23 +61,27 @@ 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(_("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, ':'); @@ -95,3 +102,6 @@ int Chktex::scanLogFile(TeXErrors & terr) } return retval; } + + +} // namespace lyx