mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Hopefully complete fix to bug #5935
Make several Parser methods return copies of tokens, because the vector containing the token may get reallocated when it grows. Revert now useless changeset 29557. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29627 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
416a6cd1c0
commit
3e3179b4d4
@ -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';
|
||||
|
@ -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)
|
||||
|
@ -1139,7 +1139,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
bool const use_natbib = used_packages.find("natbib") != used_packages.end();
|
||||
bool const use_jurabib = used_packages.find("jurabib") != used_packages.end();
|
||||
while (p.good()) {
|
||||
Token const t = p.get_token();
|
||||
Token const & t = p.get_token();
|
||||
|
||||
#ifdef FILEDEBUG
|
||||
cerr << "t: " << t << " flags: " << flags << "\n";
|
||||
|
Loading…
Reference in New Issue
Block a user