From c3cb9d012292d955855110f8d09623e2f8ef7952 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 13 May 2009 09:56:02 +0000 Subject: [PATCH] backport fix for tex2lyx bug http://www.lyx.org/trac/ticket/5935 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29653 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/Parser.cpp | 12 ++++++++---- src/tex2lyx/Parser.h | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp index b110cf0f12..10ccaf33b8 100644 --- a/src/tex2lyx/Parser.cpp +++ b/src/tex2lyx/Parser.cpp @@ -166,28 +166,32 @@ void Parser::push_back(Token const & t) } -Token const & Parser::prev_token() const +// We return a copy here because the tokens_ vector may get reallocated +Token const Parser::prev_token() const { static const Token dummy; return pos_ > 1 ? tokens_[pos_ - 2] : dummy; } -Token const & Parser::curr_token() const +// We return a copy here because the tokens_ vector may get reallocated +Token const Parser::curr_token() const { static const Token dummy; return pos_ > 0 ? tokens_[pos_ - 1] : dummy; } -Token const & Parser::next_token() +// We return a copy here because the tokens_ vector may get reallocated +Token const Parser::next_token() { static const Token dummy; return good() ? tokens_[pos_] : dummy; } -Token const & Parser::get_token() +// We return a copy here because the tokens_ vector may get reallocated +Token const Parser::get_token() { static const Token dummy; //cerr << "looking at token " << tokens_[pos_] << " pos: " << pos_ << '\n'; diff --git a/src/tex2lyx/Parser.h b/src/tex2lyx/Parser.h index 48ce6af68d..6db96d90b5 100644 --- a/src/tex2lyx/Parser.h +++ b/src/tex2lyx/Parser.h @@ -180,13 +180,13 @@ public: /// void push_back(Token const & t); /// The previous token. - Token const & prev_token() const; + Token const prev_token() const; /// The current token. - Token const & curr_token() const; + Token const curr_token() const; /// The next token. - Token const & next_token(); + Token const next_token(); /// Make the next token current and return that. - Token const & get_token(); + Token const get_token(); /// \return whether the current token starts a new paragraph bool isParagraph(); /// skips spaces (and comments if \p skip_comments is true)