]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #6246: InsetMathKern is broken
authorEnrico Forestieri <forenr@lyx.org>
Sun, 27 Sep 2009 17:29:01 +0000 (17:29 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sun, 27 Sep 2009 17:29:01 +0000 (17:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31474 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathKern.cpp
src/mathed/MathParser.cpp

index ccb01c411ba816b22b751bed83cc4eba331bb1fd..7f990f996842ff99068b19794feb5d72186a6695 100644 (file)
@@ -57,13 +57,19 @@ void InsetMathKern::draw(PainterInfo &, int, int) const
 
 void InsetMathKern::write(WriteStream & os) const
 {
-       os << "\\kern" << from_utf8(wid_.asLatexString()) << ' ';
+       if (wid_.empty())
+               os << "\\kern" << ' ';
+       else
+               os << "\\kern" << from_utf8(wid_.asLatexString()) << ' ';
 }
 
 
 void InsetMathKern::normalize(NormalStream & os) const
 {
-       os << "[kern " << from_utf8(wid_.asLatexString()) << ']';
+       if (wid_.empty())
+               os << "[kern]";
+       else
+               os << "[kern " << from_utf8(wid_.asLatexString()) << ']';
 }
 
 
index 36be12c2ec94a29a5c4508013c7016e45af82b96..d259a19332dacb0b093586952c734640cd2a2e3e 100644 (file)
@@ -1552,17 +1552,24 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                else if (t.cs() == "kern") {
                        // FIXME: A hack...
                        docstring s;
+                       int num_tokens = 0;
                        while (true) {
                                Token const & t = getToken();
+                               ++num_tokens;
                                if (!good()) {
-                                       putback();
+                                       s.clear();
+                                       while (num_tokens--)
+                                               putback();
                                        break;
                                }
                                s += t.character();
                                if (isValidLength(to_utf8(s)))
                                        break;
                        }
-                       cell->push_back(MathAtom(new InsetMathKern(s)));
+                       if (s.empty())
+                               cell->push_back(MathAtom(new InsetMathKern));
+                       else
+                               cell->push_back(MathAtom(new InsetMathKern(s)));
                }
 
                else if (t.cs() == "label") {