>>>>> "Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes:
Andre> On Fri, Aug 30, 2002 at 01:37:31AM +0300, Gady Kozma wrote: >> Lyx 1.2.1 adds spurious { } when reading 1.2.0 files with _ inside >> the labels. Actually, this problem seem to manifest in various >> random versions of lyx. The patch attached should solve this >> problem permanently. I even had a test case which could crash lyx >> (with an out-of-memory error) with the old code but I erased it by >> mistake. Andre> Hey, cool. People contributing to the math parser ;-) I took this patch and updated it a bit, in particular to make \label{\foo} work correctly. Is there a reason why Token::asString returns "foo" and not "\foo" in this case?? Andre> Three things: 1. I believe catActive is ok, too. Not sure, Andre> though. Yes, I think it is. Andre> 2. Could please ask the people who reported the bugs to chekc Andre> whether it solves _their_ problem too? [I believe it does, but Andre> as this should go to the stable branch I'd better be sure] I tried everything I could think of. Andre> 3. Could you adjust indentation and spacing according to "the Andre> rest of LyX" (at least for the next patch, I'd do that for this Andre> one) Done. Please comment. I am willing to commit this patch if nobody complains. JMarc PS: Andre', why are there so many console messages that do not go to Debug::MATHED channel?
Index: src/mathed/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ChangeLog,v retrieving revision 1.226.2.8 diff -u -p -r1.226.2.8 ChangeLog --- src/mathed/ChangeLog 15 Aug 2002 11:57:43 -0000 1.226.2.8 +++ src/mathed/ChangeLog 11 Sep 2002 14:06:46 -0000 @@ -1,3 +1,11 @@ +2002-09-11 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * 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 <[EMAIL PROTECTED]> * formulabase.C (updateLocal): Index: src/mathed/formula.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formula.C,v retrieving revision 1.190 diff -u -p -r1.190 formula.C --- src/mathed/formula.C 2 May 2002 07:30:49 -0000 1.190 +++ src/mathed/formula.C 11 Sep 2002 14:06:46 -0000 @@ -445,7 +445,9 @@ InsetFormula::localDispatch(BufferView * // 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); } Index: src/mathed/math_parser.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parser.C,v retrieving revision 1.197.2.3 diff -u -p -r1.197.2.3 math_parser.C --- src/mathed/math_parser.C 13 Aug 2002 10:13:21 -0000 1.197.2.3 +++ src/mathed/math_parser.C 11 Sep 2002 14:06:46 -0000 @@ -1170,9 +1170,49 @@ void Parser::parse_into1(MathArray & arr */ 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") {