From 2f298af791ee08afd2729e53f11d96cd39ca65d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Matox?= Date: Mon, 16 Aug 2004 00:16:17 +0000 Subject: [PATCH] Add more debug statments, and use the same channel for the same class of error. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8950 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 7 +++++++ src/text.C | 37 +++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index b6fa72604a..3817d1e368 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2004-08-16 José Matos + + * text.C (readParToken, readParagraph, read): report all unknown tokens. + For the same level of importance use the same chanel to report problems. + (read): add code to deal with \begin_body and \end_body. + + 2004-08-15 José Matos * lyxlex.C (getString): fix comment, buffer::readBody is now diff --git a/src/text.C b/src/text.C index 8d607ebf25..5d9aa6f057 100644 --- a/src/text.C +++ b/src/text.C @@ -159,7 +159,7 @@ int numberOfHfills(Paragraph const & par, Row const & row) } -int readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, +void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, string const & token, LyXFont & font) { static Change change; @@ -187,11 +187,9 @@ int readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, bool hasLayout = tclass.hasLayout(layoutname); if (!hasLayout) { - lyxerr << "Layout '" << layoutname << "' does not" - << " exist in textclass '" << tclass.name() - << "'." << endl; - lyxerr << "Trying to use default layout instead." - << endl; + buf.error(ErrorItem(_("Unknown layout"), + bformat(_("Layout '%1$s' does not exists in textclass '%2$s'\nTrying to use the default instead.\n"), + layoutname, tclass.name()), par.id(), 0, par.size())); layoutname = tclass.defaultLayoutName(); } @@ -219,7 +217,6 @@ int readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, string line = lex.getString(); buf.error(ErrorItem(_("Unknown Inset"), line, par.id(), 0, par.size())); - return 1; } } else if (token == "\\family") { lex.next(); @@ -345,23 +342,19 @@ int readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, buf.error(ErrorItem(_("Unknown token"), bformat(_("Unknown token: %1$s %2$s\n"), token, lex.getString()), par.id(), 0, par.size())); - return 1; } - return 0; } -int readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex) +void readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex) { - int unknown = 0; - lex.nextToken(); string token = lex.getString(); LyXFont font; while (lex.isOK()) { - unknown += readParToken(buf, par, lex, token, font); + readParToken(buf, par, lex, token, font); lex.nextToken(); token = lex.getString(); @@ -385,9 +378,8 @@ int readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex) << "Missing \\end_layout.\n"; break; } + lyxerr << "Paragraph token unknown: `" << token << '\'' << endl; } - - return unknown; } @@ -1867,13 +1859,18 @@ bool LyXText::read(Buffer const & buf, LyXLex & lex) break; } + if (token == "\\end_body") { + continue; + } + + if (token == "\\begin_body") { + continue; + } + if (token == "\\end_document") { return false; } - // FIXME: ugly. - int unknown = 0; - if (token == "\\begin_layout") { lex.pushToken(token); @@ -1897,9 +1894,9 @@ bool LyXText::read(Buffer const & buf, LyXLex & lex) --depth; } } else { - ++unknown; + lyxerr << "Handling unknown body token: `" + << token << '\'' << endl; } - } return true; } -- 2.39.2