mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
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:
parent
8f51e134b4
commit
8c1402faba
@ -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>
|
2001-11-22 John Levon <moz@compsoc.man.ac.uk>
|
||||||
|
|
||||||
* BufferView2.C:
|
* BufferView2.C:
|
||||||
|
30
src/buffer.C
30
src/buffer.C
@ -286,6 +286,7 @@ ErtComp ert_comp;
|
|||||||
|
|
||||||
#warning And _why_ is this here? (Lgb)
|
#warning And _why_ is this here? (Lgb)
|
||||||
int unknown_layouts;
|
int unknown_layouts;
|
||||||
|
int unknown_tokens;
|
||||||
|
|
||||||
} // anon
|
} // anon
|
||||||
|
|
||||||
@ -301,6 +302,7 @@ int unknown_layouts;
|
|||||||
bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
|
bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
|
||||||
{
|
{
|
||||||
unknown_layouts = 0;
|
unknown_layouts = 0;
|
||||||
|
unknown_tokens = 0;
|
||||||
#ifndef NO_COMPABILITY
|
#ifndef NO_COMPABILITY
|
||||||
ert_comp.contents.erase();
|
ert_comp.contents.erase();
|
||||||
ert_comp.active = false;
|
ert_comp.active = false;
|
||||||
@ -367,6 +369,18 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
|
|||||||
_("When reading " + fileName()));
|
_("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;
|
return the_end_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1151,14 +1165,14 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
|||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
// This should be insurance for the future: (Asger)
|
// This should be insurance for the future: (Asger)
|
||||||
lex.printError("Unknown token `$$Token'. "
|
++unknown_tokens;
|
||||||
"Inserting as text.");
|
lex.eatLine();
|
||||||
string::const_iterator cit = token.begin();
|
string const s = _("Unknown token: ") + token
|
||||||
string::const_iterator end = token.end();
|
+ " " + lex.text() + "\n";
|
||||||
for (; cit != end; ++cit) {
|
|
||||||
par->insertChar(pos, (*cit), font);
|
InsetError * new_inset = new InsetError(s);
|
||||||
++pos;
|
par->insertInset(pos, new_inset);
|
||||||
}
|
|
||||||
#ifndef NO_COMPABILITY
|
#ifndef NO_COMPABILITY
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user