Fix mathed bugs

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_1_6@1407 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2001-01-26 22:33:07 +00:00
parent 0194a1ab33
commit e3bd167f2a
5 changed files with 44 additions and 8 deletions

View File

@ -1,3 +1,13 @@
2001-01-26 Dekel Tsur <dekelts@tau.ac.il>
* src/mathed/math_parser.C (LexGetArg): Fix crash when loading
corrupt files.
* src/mathed/formula.C (LocalDispatch): Before inserting a label
in an eqnarray, move the cursor to the top level.
* src/mathed/math_iter.C (getLabel): Test if crow == 0.
2001-01-26 Volodymyr M . Lisivka <lvm_ukr@yahoo.com>
* lib/kbd/koi8-u.kmap: new file.

View File

@ -939,8 +939,13 @@ 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);
UpdateLocal(bv);
}
break;
}
@ -1055,8 +1060,20 @@ 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

View File

@ -999,3 +999,5 @@ MathedRowSt * MathedXIter::adjustVerticalSt()
}
return mrow;
}
string MathedXIter::error_label = "$mathed-error$";

View File

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

View File

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