]> git.lyx.org Git - features.git/commitdiff
Avoid unnecessary exceptions.
authorEnrico Forestieri <forenr@lyx.org>
Fri, 19 Feb 2010 16:31:15 +0000 (16:31 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Fri, 19 Feb 2010 16:31:15 +0000 (16:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33516 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Encoding.cpp
src/Encoding.h

index 4876f9fc5a802fc78ae9c780d4e7236035e76b40..690806974e58d0c448fd5378ea3513ec9acf242e 100644 (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;
-                       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();
index 2aece9a25c3127b258855ee0fd3938d42b668ce9..0bc8b0c4cb51f4a5b8ebab50f6583b8296e0b00d 100644 (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
index f955fa966ace9f0585769aca497d2678c2bb24f0..1f367366a82dde25abb282b00ec83db45873b02f 100644 (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