From ef91176cbf85439821736dbe16e748745c65a977 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sun, 12 Nov 2006 10:58:00 +0000 Subject: [PATCH] Unicode: Do the conversion of error messages to docstring where they are read in, because we don't know the encoding of external files. * src/LaTeX.C (LaTeX::scanLogFile): Convert error strings to docstring and add a comment that this could be wrong * src/Chktex.C (Chktex::scanLogFile): Ditto * src/LaTeX.h (TeXErrors::error_desc): Convert to docstring (TeXErrors::error_text): Convert to docstring * src/buffer_funcs.C (bufferErrors): no from_utf8 needed anymore git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15875 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Chktex.C | 23 ++++++++++++----------- src/LaTeX.C | 10 +++++++--- src/LaTeX.h | 10 +++++----- src/buffer_funcs.C | 4 ++-- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/Chktex.C b/src/Chktex.C index fc492f48cd..09c48a7eab 100644 --- a/src/Chktex.C +++ b/src/Chktex.C @@ -16,14 +16,13 @@ #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 - namespace lyx { @@ -61,23 +60,25 @@ int Chktex::run(TeXErrors &terr) int Chktex::scanLogFile(TeXErrors & terr) { - string token; int retval = 0; string const tmp = onlyFilename(changeExtension(file, ".log")); #if USE_BOOST_FORMAT - boost::format msg(to_utf8(_("ChkTeX warning id # %1$d"))); + boost::basic_format msg(_("ChkTeX warning id # %1$d")); #else - string const msg(to_utf8(_("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.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, ':'); diff --git a/src/LaTeX.C b/src/LaTeX.C index 64afbe93c6..8c8091fe4f 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -95,8 +95,8 @@ docstring runMessage(unsigned int count) * CLASS TEXERRORS */ -void TeXErrors::insertError(int line, string const & error_desc, - string const & error_text) +void TeXErrors::insertError(int line, docstring const & error_desc, + docstring const & error_text) { Error newerr(line, error_desc, error_text); errors.push_back(newerr); @@ -671,7 +671,11 @@ int LaTeX::scanLogFile(TeXErrors & terr) last_line = line; } if (line_count <= 5) { - terr.insertError(line, desc, errstr); + // FIXME UNICODE + // We have no idea what the encoding of the log file is + // (probably pure ascii, but maybe some localized + // latex compilers or packages exist) + terr.insertError(line, from_utf8(desc), from_utf8(errstr)); ++num_errors; } } diff --git a/src/LaTeX.h b/src/LaTeX.h index 1f52dab188..4ac520bac9 100644 --- a/src/LaTeX.h +++ b/src/LaTeX.h @@ -38,16 +38,16 @@ private: /// Error () : error_in_line(0) {} /// - Error(int line, std::string const & desc, std::string const & text) + Error(int line, docstring const & desc, docstring const & text) : error_in_line(line), error_desc(desc), error_text(text) {} /// what line in the TeX file the error occured in int error_in_line; /// The kind of error - std::string error_desc; + docstring error_desc; /// The line/cmd that caused the error. - std::string error_text; + docstring error_text; }; public: /// @@ -57,8 +57,8 @@ public: /// Errors::const_iterator end() const { return errors.end(); } /// - void insertError(int line, std::string const & error_desc, - std::string const & error_text); + void insertError(int line, docstring const & error_desc, + docstring const & error_text); private: /// Errors errors; diff --git a/src/buffer_funcs.C b/src/buffer_funcs.C index 94a018aa22..ef7ce3e08d 100644 --- a/src/buffer_funcs.C +++ b/src/buffer_funcs.C @@ -233,8 +233,8 @@ void bufferErrors(Buffer const & buf, TeXErrors const & terr, pos_end); } while (found && id_start == id_end && pos_start == pos_end); - errorList.push_back(ErrorItem(from_utf8(cit->error_desc), - from_utf8(cit->error_text), id_start, pos_start, pos_end)); + errorList.push_back(ErrorItem(cit->error_desc, + cit->error_text, id_start, pos_start, pos_end)); } }