commit 2a78c1c6621cb8542b47d6585e2230549c9c0227
Author: Richard Heck <rgh...@lyx.org>
Date:   Sat Feb 24 00:44:26 2018 -0500

    Fix bug #10938.
---
 src/tex2lyx/tex2lyx.cpp |   42 +++++++++++++++++++-----------------------
 src/tex2lyx/tex2lyx.h   |    5 ++---
 2 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/src/tex2lyx/tex2lyx.cpp b/src/tex2lyx/tex2lyx.cpp
index fc6ea1e..1db7d0d 100644
--- a/src/tex2lyx/tex2lyx.cpp
+++ b/src/tex2lyx/tex2lyx.cpp
@@ -172,30 +172,26 @@ void add_known_theorem(string const & theorem, string 
const & o1,
 }
 
 
-Layout const * findLayoutWithoutModule(TextClass const & textclass,
+Layout const * findLayoutWithoutModule(TextClass const & tc,
                                        string const & name, bool command)
 {
-       DocumentClass::const_iterator it = textclass.begin();
-       DocumentClass::const_iterator en = textclass.end();
-       for (; it != en; ++it) {
-               if (it->latexname() == name &&
-                   ((command && it->isCommand()) || (!command && 
it->isEnvironment())))
-                       return &*it;
+       for (auto const & lay : tc) {
+               if (lay.latexname() == name &&
+                   ((command && lay.isCommand()) || (!command && 
lay.isEnvironment())))
+                       return &lay;
        }
        return 0;
 }
 
 
-InsetLayout const * findInsetLayoutWithoutModule(TextClass const & textclass,
+InsetLayout const * findInsetLayoutWithoutModule(TextClass const & tc,
                                                  string const & name, bool 
command)
 {
-       DocumentClass::InsetLayouts::const_iterator it = 
textclass.insetLayouts().begin();
-       DocumentClass::InsetLayouts::const_iterator en = 
textclass.insetLayouts().end();
-       for (; it != en; ++it) {
-               if (it->second.latexname() == name &&
-                   ((command && it->second.latextype() == 
InsetLayout::COMMAND) ||
-                    (!command && it->second.latextype() == 
InsetLayout::ENVIRONMENT)))
-                       return &(it->second);
+       for (auto const & ilay : tc.insetLayouts()) {
+               if (ilay.second.latexname() == name &&
+                   ((command && ilay.second.latextype() == 
InsetLayout::COMMAND) ||
+                    (!command && ilay.second.latextype() == 
InsetLayout::ENVIRONMENT)))
+                       return &(ilay.second);
        }
        return 0;
 }
@@ -359,29 +355,29 @@ bool checkModule(string const & name, bool command)
                Layout const * layout = findLayoutWithoutModule(*c, name, 
command);
                InsetLayout const * insetlayout = layout ? 0 :
                        findInsetLayoutWithoutModule(*c, name, command);
-               docstring preamble;
+               docstring dpre;
                if (layout)
-                       preamble = layout->preamble();
+                       dpre = layout->preamble();
                else if (insetlayout)
-                       preamble = insetlayout->preamble();
-               if (preamble.empty())
+                       dpre = insetlayout->preamble();
+               if (dpre.empty())
                        continue;
                bool add = false;
                if (command) {
                        FullCommand const & cmd =
                                possible_textclass_commands['\\' + name];
-                       if (preamble.find(cmd.def) != docstring::npos)
+                       if (dpre.find(cmd.def) != docstring::npos)
                                add = true;
                } else if (theorem) {
                        FullCommand const & thm =
                                possible_textclass_theorems[name];
-                       if (preamble.find(thm.def) != docstring::npos)
+                       if (dpre.find(thm.def) != docstring::npos)
                                add = true;
                } else {
                        FullEnvironment const & env =
                                possible_textclass_environments[name];
-                       if (preamble.find(env.beg) != docstring::npos &&
-                           preamble.find(env.end) != docstring::npos)
+                       if (dpre.find(env.beg) != docstring::npos &&
+                           dpre.find(env.end) != docstring::npos)
                                add = true;
                }
                if (add) {
diff --git a/src/tex2lyx/tex2lyx.h b/src/tex2lyx/tex2lyx.h
index 5c3595f..a1bd9b4 100644
--- a/src/tex2lyx/tex2lyx.h
+++ b/src/tex2lyx/tex2lyx.h
@@ -103,10 +103,9 @@ extern void add_known_environment(std::string const & 
environment,
        docstring const & end);
 extern void add_known_theorem(std::string const & theorem,
        std::string const & o1, bool o2, docstring const & definition);
-extern Layout const * findLayoutWithoutModule(TextClass const & textclass,
+extern Layout const * findLayoutWithoutModule(TextClass const & tc,
        std::string const & name, bool command);
-extern InsetLayout const * findInsetLayoutWithoutModule(
-       TextClass const & textclass, std::string const & name, bool command);
+extern InsetLayout const * findInsetLayoutWithoutModule(TextClass const & tc, 
std::string const & name, bool command);
 /*!
  * Check whether a module provides command (if \p command is true) or
  * environment (if \p command is false) \p name, and add the module to the

Reply via email to