The branch, master, has been updated. - Log -----------------------------------------------------------------
commit 21be4a31ccc1621852a5efde45fc63b84f366259 Author: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Fri Feb 15 23:18:32 2013 +0100 Fix bug with reading of verbatim environment The kind of putback() functionality that we need is more tricky than I thought at first... diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp index d7d3144..f5f5f46 100644 --- a/src/tex2lyx/Parser.cpp +++ b/src/tex2lyx/Parser.cpp @@ -115,6 +115,34 @@ void debugToken(std::ostream & os, Token const & t, unsigned int flags) // +// Wrapper +// + +void iparserdocstream::putback(char_type c) +{ + s_ += c; +} + + +void iparserdocstream::put_almost_back(docstring s) +{ + s_ = s + s_; +} + + +iparserdocstream & iparserdocstream::get(char_type &c) +{ + if (s_.empty()) + is_.get(c); + else { + c = s_[0]; + s_.erase(0,1); + } + return *this; +} + + +// // Parser // @@ -143,12 +171,11 @@ Parser::~Parser() void Parser::deparse() { + string s; for(size_type i = pos_ ; i < tokens_.size() ; ++i) { - docstring const s = from_utf8(tokens_[i].asInput()); - //cerr << "deparsing [" << to_utf8(s) << "]" <<endl; - foreach(char_type c, s) - is_.putback(c); + s += tokens_[i].asInput(); } + is_.put_almost_back(from_utf8(s)); tokens_.erase(tokens_.begin() + pos_, tokens_.end()); // make sure that next token is read tokenize_one(); diff --git a/src/tex2lyx/Parser.h b/src/tex2lyx/Parser.h index 5a4fc29..5f8b1fa 100644 --- a/src/tex2lyx/Parser.h +++ b/src/tex2lyx/Parser.h @@ -127,22 +127,19 @@ public: idocstream & docstream() { return is_; }; - void putback(char_type c) { s_ += c; }; - - iparserdocstream & get(char_type &c) - { - if (s_.empty()) - is_.get(c); - else { - c = s_[0]; - s_.erase(0,1); - } - return *this; - }; + // add to the list of characters to read before actually reading + // the stream + void putback(char_type c); + + // add before the list of characters to read before actually reading + // the stream + void put_almost_back(docstring s); + + iparserdocstream & get(char_type &c); private: /// idocstream & is_; - /// + /// characters to read before actually reading the stream docstring s_; }; ----------------------------------------------------------------------- Summary of changes: src/tex2lyx/Parser.cpp | 35 +++++++++++++++++++++++++++++++---- src/tex2lyx/Parser.h | 23 ++++++++++------------- 2 files changed, 41 insertions(+), 17 deletions(-) hooks/post-receive -- The LyX Source Repository