From 84e30e328a5aa1daea39ba0e59b2cd5391d41e78 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 11 Sep 2002 14:47:04 +0000 Subject: [PATCH] fix label parsing git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH-1_2_X@5264 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 8 +++++++ src/mathed/formula.C | 4 +++- src/mathed/math_parser.C | 46 +++++++++++++++++++++++++++++++++++++--- status.12x | 3 +++ 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index d531ba94aa..9871895539 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,11 @@ +2002-09-11 Jean-Marc Lasgouttes + + * math_parser.C (parse_into1): fix reading labels containing + special characters like underscores (adaptation of a patch from + Gady Kozma) + + * formula.C (localDispatch): make annoying warning less annoying + 2002-08-15 Jean-Marc Lasgouttes * formulabase.C (updateLocal): diff --git a/src/mathed/formula.C b/src/mathed/formula.C index c145aa8fb5..2162380f1a 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -445,7 +445,9 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, // break; // Nothing to do if (!new_label.empty()) { - lyxerr << "setting label to '" << new_label << "'\n"; + lyxerr[Debug::MATHED] + << "setting label to '" << new_label + << "'" << endl; hull()->numbered(row, true); } diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index dac2042199..c0176eefc4 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -1170,9 +1170,49 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code) */ else if (t.cs() == "label") { - MathArray ar; - parse_into(ar, FLAG_ITEM, code); - curr_label_ = asString(ar); + int counter = -1; + + curr_label_.erase(); + while (good()) { + Token const & t = getToken(); + + switch (t.cat()) { + case catBegin: + if (counter != -1) + curr_label_ += t.asString(); + counter++; + break; + case catEnd: + if (counter != 0) + curr_label_ += t.asString(); + counter--; + break; + case catNewline: + // this is not allowed inside + // a label and the most + // reasonable assumption is + // that a } was forgotten. + counter = -1; + break; + case catIgnore: + // do we have a macro name? + if (t.cs().empty()) + continue; + curr_label_ += '\\' + t.asString(); + break; + case catEscape: + case catParameter: + continue; + default: + // all the rest are perfectly + // OK characters. + curr_label_ += t.asString(); + break; + } + + if (counter < 0) + break; + } } else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") { diff --git a/status.12x b/status.12x index dbac5fd10f..3a7092e3c5 100644 --- a/status.12x +++ b/status.12x @@ -36,6 +36,9 @@ What's new ** Bug fixes +- fix bug where special characters in equations label confuse LyX + (this was a new bug in 1.2.1) + - fix bug with citation keys that contain spaces - fix bug with graphics files which name contain a '.'