Better handling of unknown tokens

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3071 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2001-11-25 17:58:05 +00:00
parent 8f51e134b4
commit 8c1402faba
2 changed files with 29 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2001-11-25 Dekel Tsur <dekelts@tau.ac.il>
* buffer.C (parseSingleLyXformat2Token): Insert an error inset
when encountering an unknown token.
(readLyXformat2): Show an error message if there were unknown tokens.
2001-11-22 John Levon <moz@compsoc.man.ac.uk>
* BufferView2.C:

View File

@ -286,6 +286,7 @@ ErtComp ert_comp;
#warning And _why_ is this here? (Lgb)
int unknown_layouts;
int unknown_tokens;
} // anon
@ -301,6 +302,7 @@ int unknown_layouts;
bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
{
unknown_layouts = 0;
unknown_tokens = 0;
#ifndef NO_COMPABILITY
ert_comp.contents.erase();
ert_comp.active = false;
@ -367,6 +369,18 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
_("When reading " + fileName()));
}
if (unknown_tokens > 0) {
string s = _("Encountered ");
if (unknown_tokens == 1) {
s += _("one unknown token");
} else {
s += tostr(unknown_tokens);
s += _(" unknown tokens");
}
WriteAlert(_("Textclass Loading Error!"), s,
_("When reading " + fileName()));
}
return the_end_read;
}
@ -1151,14 +1165,14 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
} else {
#endif
// This should be insurance for the future: (Asger)
lex.printError("Unknown token `$$Token'. "
"Inserting as text.");
string::const_iterator cit = token.begin();
string::const_iterator end = token.end();
for (; cit != end; ++cit) {
par->insertChar(pos, (*cit), font);
++pos;
}
++unknown_tokens;
lex.eatLine();
string const s = _("Unknown token: ") + token
+ " " + lex.text() + "\n";
InsetError * new_inset = new InsetError(s);
par->insertInset(pos, new_inset);
#ifndef NO_COMPABILITY
}
#endif