]> git.lyx.org Git - features.git/commitdiff
Add more debug statments, and use the same channel for the same class of error.
authorJosé Matox <jamatos@lyx.org>
Mon, 16 Aug 2004 00:16:17 +0000 (00:16 +0000)
committerJosé Matox <jamatos@lyx.org>
Mon, 16 Aug 2004 00:16:17 +0000 (00:16 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8950 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/text.C

index b6fa72604a8f318838c550f1352304399d3992ac..3817d1e3682bdbb8fedb4f521957431782687129 100644 (file)
@@ -1,3 +1,10 @@
+2004-08-16  José Matos  <jamatos@lyx.org>
+
+       * 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  <jamatos@lyx.org>
 
        * lyxlex.C (getString): fix comment, buffer::readBody is now
index 8d607ebf25c3f7d2c6769e6020ba148c7a57316d..5d9aa6f0578d9087a255eb7dd7959b52f1770024 100644 (file)
@@ -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;
 }