mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 06:19:36 +00:00
Fix mathed bugs.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1406 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f04a7e4745
commit
0a2b9f4b81
@ -1,3 +1,12 @@
|
||||
2001-01-26 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* math_parser.C (LexGetArg): Fix crash when loading corrupt files.
|
||||
|
||||
* formula.C (LocalDispatch): Before inserting a label in an
|
||||
eqnarray, move the cursor to the top level.
|
||||
|
||||
* math_iter.C (getLabel): Test if crow == 0.
|
||||
|
||||
2001-01-15 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* math_draw.C (Metrics): Use the correct GetString.
|
||||
|
@ -939,6 +939,11 @@ InsetFormula::LocalDispatch(BufferView * bv,
|
||||
//BUG
|
||||
// mt->SetNumbered(!mt->IsNumbered());
|
||||
|
||||
#warning This is a terrible hack! We should find a better solution.
|
||||
while (mathcursor->getLabel() == MathedXIter::error_label) {
|
||||
if (LocalDispatch(bv, LFUN_LEFT, string()) == FINISHED)
|
||||
return DISPATCHED;
|
||||
}
|
||||
mathcursor->setNumbered();
|
||||
UpdateLocal(bv);
|
||||
}
|
||||
@ -1055,18 +1060,25 @@ InsetFormula::LocalDispatch(BufferView * bv,
|
||||
if (par->GetType() < LM_OT_PAR)
|
||||
break;
|
||||
|
||||
string old_label = (par->GetType() == LM_OT_MPARN)
|
||||
string old_label = (par->GetType() == LM_OT_MPARN ||
|
||||
par->GetType() == LM_OT_MPAR)
|
||||
? mathcursor->getLabel() : label;
|
||||
|
||||
#warning This is a terrible hack! We should find a better solution.
|
||||
/// This is needed becuase in some positions mathcursor->cursor->crow
|
||||
/// is equal to 0, and therefore the label cannot be inserted.
|
||||
/// So we move the cursor left until mathcursor->cursor->crow != 0.
|
||||
while (old_label == MathedXIter::error_label) {
|
||||
if (LocalDispatch(bv, LFUN_LEFT, string()) == FINISHED)
|
||||
return DISPATCHED;
|
||||
old_label = mathcursor->getLabel();
|
||||
}
|
||||
|
||||
string new_label = arg;
|
||||
if (new_label.empty()) {
|
||||
#ifdef LABEL_INIT
|
||||
string default_label = (lyxrc.label_init_length >= 0) ? "eq:" : "";
|
||||
pair<bool, string> res = old_label.empty()
|
||||
? askForText(_("Enter new label to insert:"), default_label)
|
||||
#else
|
||||
pair<bool, string> res = old_label.empty()
|
||||
? askForText(_("Enter new label to insert:"))
|
||||
#endif
|
||||
: askForText(_("Enter label:"), old_label);
|
||||
if (!res.first)
|
||||
break;
|
||||
|
@ -999,3 +999,5 @@ MathedRowSt * MathedXIter::adjustVerticalSt()
|
||||
}
|
||||
return mrow;
|
||||
}
|
||||
|
||||
string MathedXIter::error_label = "$mathed-error$";
|
||||
|
@ -222,8 +222,10 @@ class MathedXIter: public MathedIter {
|
||||
///
|
||||
bool setLabel(string const & label);
|
||||
///
|
||||
static string error_label;
|
||||
///
|
||||
string const & getLabel() const {
|
||||
return crow->getLabel();
|
||||
return crow ? crow->getLabel() : error_label;
|
||||
}
|
||||
///
|
||||
bool setNumbered(bool);
|
||||
|
@ -99,6 +99,7 @@ enum lexcode_enum {
|
||||
};
|
||||
|
||||
static lexcode_enum lexcode[256];
|
||||
#warning Replace with string
|
||||
static char yytext[256];
|
||||
static int yylineno;
|
||||
static istream * yyis;
|
||||
@ -154,10 +155,13 @@ char LexGetArg(char lf, bool accept_spaces= false)
|
||||
yyis->get(cc);
|
||||
c = cc;
|
||||
if (c > ' ') {
|
||||
if (!lf) lf = c; else
|
||||
if (c != lf)
|
||||
if (!lf)
|
||||
lf = c;
|
||||
else if (c != lf) {
|
||||
lyxerr << "Math parse error: unexpected '"
|
||||
<< c << "'" << endl;
|
||||
return '\0';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -176,7 +180,7 @@ char LexGetArg(char lf, bool accept_spaces= false)
|
||||
if (c == lf) ++bcnt;
|
||||
if (c == rg) --bcnt;
|
||||
if ((c > ' ' || (c == ' ' && accept_spaces)) && bcnt > 0) *(p++) = c;
|
||||
} while (bcnt > 0 && yyis->good());
|
||||
} while (bcnt > 0 && yyis->good() && p-yytext < 255);
|
||||
*p = '\0';
|
||||
return rg;
|
||||
}
|
||||
@ -275,7 +279,8 @@ int yylex(void)
|
||||
}
|
||||
if (lexcode[c] == LexAlpha || lexcode[c] == LexDigit) {
|
||||
char * p = &yytext[0];
|
||||
while (lexcode[c] == LexAlpha || lexcode[c] == LexDigit) {
|
||||
while ((lexcode[c] == LexAlpha || lexcode[c] == LexDigit)
|
||||
&& p-yytext < 255) {
|
||||
*p = c;
|
||||
yyis->get(cc);
|
||||
c = cc;
|
||||
|
Loading…
Reference in New Issue
Block a user