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
This commit is contained in:
Georg Baum 2006-11-12 10:58:00 +00:00
parent eca902c2bd
commit ef91176cbf
4 changed files with 26 additions and 21 deletions

View File

@ -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 <boost/format.hpp>
#include <fstream>
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<char_type> 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, ':');

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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));
}
}