]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathParser.cpp
Add \makeat switches to babel settings if necessary.
[lyx.git] / src / mathed / MathParser.cpp
index 30e5c004a30f459bb8c6cfa6a6c1ad62d3867783..9752320095312a75ff1b857d007ee0e679b50c27 100644 (file)
@@ -536,7 +536,6 @@ char_type Parser::getChar()
 {
        if (!good()) {
                error("The input stream is not well...");
-               putback();
                return 0;
        }
        return tokens_[pos_++].character();
@@ -545,9 +544,12 @@ char_type Parser::getChar()
 
 docstring Parser::getArg(char_type left, char_type right)
 {
+       docstring result;
        skipSpaces();
 
-       docstring result;
+       if (!good())
+               return result;
+
        char_type c = getChar();
 
        if (c != left)
@@ -1016,7 +1018,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                Token const & t = getToken();
                                if (t.cat() == catNewline)
                                        break;
-                               s += t.asString();
+                               s += t.asInput();
                        }
                        cell->push_back(MathAtom(new InsetMathComment(buf, s)));
                        skipSpaces();
@@ -1828,13 +1830,15 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                error("'}' expected in \\" + t.cs());
                                return success_;
                        }
+                       bool termination;
                        docstring rem;
                        do {
                                cmd = Encodings::fromLaTeXCommand(cmd,
-                                       Encodings::MATH_CMD | Encodings::TEXT_CMD, rem);
+                                       Encodings::MATH_CMD | Encodings::TEXT_CMD,
+                                       termination, rem);
                                for (size_t i = 0; i < cmd.size(); ++i)
                                        cell->push_back(MathAtom(new InsetMathChar(cmd[i])));
-                               if (rem.size()) {
+                               if (!rem.empty()) {
                                        char_type c = rem[0];
                                        cell->push_back(MathAtom(new InsetMathChar(c)));
                                        cmd = rem.substr(1);
@@ -1923,9 +1927,10 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                                }
                                        }
                                        bool is_combining;
+                                       bool termination;
                                        char_type c = Encodings::fromLaTeXCommand(cmd,
                                                Encodings::MATH_CMD | Encodings::TEXT_CMD,
-                                               is_combining);
+                                               is_combining, termination);
                                        if (is_combining) {
                                                if (cat == catLetter)
                                                        cmd += '{';
@@ -1935,9 +1940,24 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                                        cmd += '}';
                                                c = Encodings::fromLaTeXCommand(cmd,
                                                        Encodings::MATH_CMD | Encodings::TEXT_CMD,
-                                                       is_combining);
+                                                       is_combining, termination);
                                        }
                                        if (c) {
+                                               if (termination) {
+                                                       if (nextToken().cat() == catBegin) {
+                                                               getToken();
+                                                               if (nextToken().cat() == catEnd) {
+                                                                       getToken();
+                                                                       num_tokens += 2;
+                                                               } else
+                                                                       putback();
+                                                       } else {
+                                                               while (nextToken().cat() == catSpace) {
+                                                                       getToken();
+                                                                       ++num_tokens;
+                                                               }
+                                                       }
+                                               }
                                                is_unicode_symbol = true;
                                                cell->push_back(MathAtom(new InsetMathChar(c)));
                                        } else {