Can anybody see anything wrogn with this?
[It works, just asking...]
Counting the unknown tokes seems to be broken (before and after applying
this patch)
Andre'
Index: buffer.C
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.547
diff -u -p -r1.547 buffer.C
--- buffer.C2 Dec 2003 12:39:10 - 1.547
+++ buffer.C2 Dec 2003 14:00:04 -
@@ -390,6 +390,7 @@ void unknownClass(string const & unknown
} // anon
+
int Buffer::readHeader(LyXLex & lex)
{
int unknown_tokens = 0;
@@ -435,9 +436,8 @@ int Buffer::readHeader(LyXLex & lex)
// if par = 0 normal behavior
// else insert behavior
// Returns false if "\end_document" is not read (Asger)
-bool Buffer::readBody(LyXLex & lex, ParagraphList::iterator pit)
+bool Buffer::readBody(LyXLex & lex, ParagraphList::iterator)
{
- Paragraph::depth_type depth = 0;
bool the_end_read = false;
if (paragraphs().empty()) {
@@ -458,67 +458,10 @@ bool Buffer::readBody(LyXLex & lex, Para
tmpbuf.readHeader(lex);
}
- while (lex.isOK()) {
- lex.nextToken();
- string const token = lex.getString();
-
- if (token.empty())
- continue;
-
- lyxerr[Debug::PARSER] << "Handling token: `"
- << token << '\'' << endl;
-
- if (token == "\\end_document") {
- the_end_read = true;
- continue;
- }
-
- readParagraph(lex, token, paragraphs(), pit, depth);
- }
+ if (text().read(*this, lex))
+ the_end_read = true;
return the_end_read;
-}
-
-
-int Buffer::readParagraph(LyXLex & lex, string const & token,
- ParagraphList & pars, ParagraphList::iterator & pit,
- lyx::depth_type & depth)
-{
- static Change current_change;
- int unknown = 0;
-
- if (token == "\\begin_layout") {
- lex.pushToken(token);
-
- Paragraph par;
- par.params().depth(depth);
- if (params().tracking_changes)
- par.trackChanges();
- LyXFont f(LyXFont::ALL_INHERIT, params().language);
- par.setFont(0, f);
-
- // insert after
- if (pit != pars.end())
- ++pit;
-
- pit = pars.insert(pit, par);
-
- // FIXME: goddamn InsetTabular makes us pass a Buffer
- // not BufferParams
- ::readParagraph(*this, *pit, lex);
-
- } else if (token == "\\begin_deeper") {
- ++depth;
- } else if (token == "\\end_deeper") {
- if (!depth) {
- lex.printError("\\end_deeper: " "depth is already null");
- } else {
- --depth;
- }
- } else {
- ++unknown;
- }
- return unknown;
}
Index: buffer.h
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.h,v
retrieving revision 1.174
diff -u -p -r1.174 buffer.h
--- buffer.h28 Nov 2003 15:08:38 - 1.174
+++ buffer.h2 Dec 2003 14:00:04 -
@@ -96,12 +96,6 @@ public:
*/
bool readBody(LyXLex &, ParagraphList::iterator pit);
- /// This parses a single token
- int readParagraph(LyXLex &, std::string const & token,
- ParagraphList & pars,
- ParagraphList::iterator & pit,
- lyx::depth_type & depth);
-
///
void insertStringAsLines(ParagraphList::iterator &, lyx::pos_type &,
LyXFont const &, std::string const &);
Index: lyxtext.h
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.266
diff -u -p -r1.266 lyxtext.h
--- lyxtext.h 2 Dec 2003 12:39:11 - 1.266
+++ lyxtext.h 2 Dec 2003 14:00:04 -
@@ -393,6 +393,8 @@ public:
///
void write(Buffer const & buf, std::ostream & os) const;
+ /// returns whether we've seen our usual 'end' marker
+ bool read(Buffer const & buf, LyXLex & lex);
public:
///
Index: paragraph_funcs.C
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.C,v
retrieving revision 1.90
diff -u -p -r1.90 paragraph_funcs.C
--- paragraph_funcs.C 28 Nov 2003 15:53:25 - 1.90
+++ paragraph_funcs.C 2 Dec 2003 14:00:04 -
@@ -303,7 +303,8 @@ int getEndLabel(ParagraphList::iterator
namespace {
-int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & token)
+int readParToken(Buffer const & buf, Para