From: Enrico Forestieri Date: Fri, 19 Feb 2010 16:31:15 +0000 (+0000) Subject: Avoid unnecessary exceptions. X-Git-Tag: 2.0.0~3992 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=f5cc73f583d07bd9f8f356d27a58545ad2e344f9;p=features.git Avoid unnecessary exceptions. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33516 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 4876f9fc5a..690806974e 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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; - 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) { + Encoding const * const enc = runparams.encoding; + if (enc) { + for (size_t n = 0; n < inputpath.size(); ++n) { + 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; } } @@ -1340,9 +1336,9 @@ void Buffer::writeLaTeXSource(odocstream & os, "or change the path name."), inputpath, uncodable_glyphs)); } else { os << "\\makeatletter\n" - << "\\def\\input@path{{" - << inputpath << "/}}\n" - << "\\makeatother\n"; + << "\\def\\input@path{{" + << inputpath << "/}}\n" + << "\\makeatother\n"; d->texrow.newline(); d->texrow.newline(); d->texrow.newline(); diff --git a/src/Encoding.cpp b/src/Encoding.cpp index 2aece9a25c..0bc8b0c4cb 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -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 diff --git a/src/Encoding.h b/src/Encoding.h index f955fa966a..1f367366a8 100644 --- a/src/Encoding.h +++ b/src/Encoding.h @@ -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