Avoid unnecessary exceptions.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33516 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2010-02-19 16:31:15 +00:00
parent 90e28136b6
commit f5cc73f583
3 changed files with 12 additions and 16 deletions

View File

@ -1310,21 +1310,17 @@ void Buffer::writeLaTeXSource(odocstream & os,
// We don't know the encoding of inputpath
docstring const inputpath = from_utf8(latex_path(original_path));
docstring uncodable_glyphs;
Encoding const * const enc = runparams.encoding;
if (enc) {
for (size_t n = 0; n < inputpath.size(); ++n) {
docstring const glyph = docstring(1, inputpath[n]);
try {
if (runparams.encoding
&& runparams.encoding->latexChar(inputpath[n]) != glyph) {
docstring const glyph =
docstring(1, inputpath[n]);
if (enc->latexChar(inputpath[n], true) != glyph) {
LYXERR0("Uncodable character '"
<< glyph
<< "' in input path!");
uncodable_glyphs += glyph;
}
} catch (EncodingException & /* e */) {
LYXERR0("Uncodable character '"
<< glyph
<< "' in input path!");
uncodable_glyphs += glyph;
}
}

View File

@ -344,7 +344,7 @@ void Encoding::init() const
}
docstring Encoding::latexChar(char_type c, bool for_mathed) const
docstring Encoding::latexChar(char_type c, bool no_commands) const
{
// assure the used encoding is properly initialized
init();
@ -355,7 +355,7 @@ docstring Encoding::latexChar(char_type c, bool for_mathed) const
return docstring(1, c);
if (encodable_.find(c) != encodable_.end())
return docstring(1, c);
if (for_mathed)
if (no_commands)
return docstring();
// c cannot (or should not) be encoded in this encoding

View File

@ -75,7 +75,7 @@ public:
* LaTeX macro is known, a warning is given of lyxerr, and the
* character is returned.
*/
docstring latexChar(char_type c, bool for_mathed = false) const;
docstring latexChar(char_type c, bool no_commands = false) const;
/// Which LaTeX package handles this encoding?
Package package() const { return package_; }
/// A list of all characters usable in this encoding