fix label parsing

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH-1_2_X@5264 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-09-11 14:47:04 +00:00
parent 5314a45316
commit 84e30e328a
4 changed files with 57 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2002-09-11 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* 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 <lasgouttes@freesurf.fr>
* formulabase.C (updateLocal):

View File

@ -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);
}

View File

@ -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") {

View File

@ -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 '.'