]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathParser.C
we rely on Windows and maybe Linux on a Qt bug
[lyx.git] / src / mathed / MathParser.C
index eda20fefffdd9a678d852bc87d47f3700b710870..abbe9e90c4c9174924bb5251959994a539ae0910 100644 (file)
@@ -213,11 +213,22 @@ enum CatCode {
        catInvalid     // 15   <delete>
 };
 
-CatCode theCatcode[256];
+CatCode theCatcode[128];
 
 
-inline CatCode catcode(unsigned char c)
+inline CatCode catcode(char_type c)
 {
+       /* The only characters that are not catOther lie in the pure ASCII
+        * range. Therefore theCatcode has only 128 entries.
+        * TeX itself deals with 8bit characters, so if needed this table
+        * could be enlarged to 256 entries.
+        * Any larger value does not make sense, since the fact that we use
+        * unicode internally does not change Knuth's TeX engine.
+        * Apart from that a table for the full 21bit UCS4 range would waste
+        * too much memory. */
+       if (c >= 128)
+               return catOther;
+
        return theCatcode[c];
 }
 
@@ -816,10 +827,17 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                cell->back() = MathAtom(new InsetMathScript(cell->back(), up));
                        InsetMathScript * p = cell->back().nucleus()->asScriptInset();
                        // special handling of {}-bases
-                       // is this always correct?
-                       if (p->nuc().size() == 1 
-                           && p->nuc().back()->asBraceInset())
-                               p->nuc() = p->nuc().back()->asNestInset()->cell(0);
+                       // Here we could remove the brace inset for things
+                       // like {a'}^2 and add the braces back in
+                       // InsetMathScript::write().
+                       // We do not do it, since it is not possible to detect
+                       // reliably whether the braces are needed because the
+                       // nucleus contains more than one symbol, or whether
+                       // they are needed for unknown commands like \xx{a}_0
+                       // or \yy{a}{b}_0. This was done in revision 14819
+                       // in an unreliable way. See this thread
+                       // http://www.mail-archive.com/lyx-devel%40lists.lyx.org/msg104917.html
+                       // for more details.
                        parse(p->cell(p->idxOfScript(up)), FLAG_ITEM, mode);
                        if (limits) {
                                p->limits(limits);
@@ -1267,7 +1285,10 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                }
 
                else if (t.cs() == "xymatrix") {
-                       cell->push_back(createInsetMath(t.cs()));
+                       odocstringstream os;
+                       while (good() && nextToken().cat() != catBegin)
+                               os << getToken().asInput();
+                       cell->push_back(createInsetMath(t.cs() + os.str()));
                        parse2(cell->back(), FLAG_ITEM, mode, false);
                }
 
@@ -1441,7 +1462,7 @@ void mathed_parse_normal(InsetMathGrid & grid, string const & str)
 
 void initParser()
 {
-       fill(theCatcode, theCatcode + 256, catOther);
+       fill(theCatcode, theCatcode + 128, catOther);
        fill(theCatcode + 'a', theCatcode + 'z' + 1, catLetter);
        fill(theCatcode + 'A', theCatcode + 'Z' + 1, catLetter);