From eb065995b10ca55e93c4d465027f40312142dc1d Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sun, 27 Sep 2009 17:29:01 +0000 Subject: [PATCH] Fix bug #6246: InsetMathKern is broken git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31474 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathKern.cpp | 10 ++++++++-- src/mathed/MathParser.cpp | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/mathed/InsetMathKern.cpp b/src/mathed/InsetMathKern.cpp index ccb01c411b..7f990f9968 100644 --- a/src/mathed/InsetMathKern.cpp +++ b/src/mathed/InsetMathKern.cpp @@ -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()) << ']'; } diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 36be12c2ec..d259a19332 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -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") { -- 2.39.2