From 2e771bf78d982b33a8789183a03319a932b569eb Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Wed, 2 May 2012 13:37:32 +0200 Subject: [PATCH] Fix bug #8089: Handle spaces at the end of the stream If the stream is good (i.e. there are still tokens) and we expect an argument, we call getArg(). However, if there are only spaces, the stream suddenly isn't good anymore after 'skipSpaces' and we would get an error when calling 'getChar'. Therefore we have to check whether the stream is still good. MathParser: Do not rewind the stream if we can't read from it If the stream is not good, we don't need to 'putback', because we didn't read anything yet. If we now do rewind the stream, we are asking for problems as in bug #8089. This was introduced in [3cafb856\lyxgit] to fix bug #4318. (cherry picked from commit 26dcfcd34374f86562af56dfe5f858d10ea587db) (cherry picked from commit 1ef930c05826340d7497d6994338f6d63772de5f) --- src/mathed/MathParser.cpp | 6 ++++-- status.20x | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 0b5da9838b..713e5554b5 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -535,7 +535,6 @@ char_type Parser::getChar() { if (!good()) { error("The input stream is not well..."); - putback(); return 0; } return tokens_[pos_++].character(); @@ -544,9 +543,12 @@ char_type Parser::getChar() docstring Parser::getArg(char_type left, char_type right) { + docstring result; skipSpaces(); - docstring result; + if (!good()) + return result; + char_type c = getChar(); if (c != left) diff --git a/status.20x b/status.20x index 20faef72a8..7aa77c9478 100644 --- a/status.20x +++ b/status.20x @@ -103,6 +103,8 @@ What's new - Fixed assertion on selection of insets in RTL text (bug 7518). +- Fixed an infinite loop when pasting '\\ ' into math (bug 8089). + - Don't reset the selected format each time we click into a new paragraph in View->Source (bug 7997).