[LyX/master] If the ending delimiter is at the end of the file, then the test pimpl_->is will return false no matter what. So we need a different way to check if the delimiter was found.

Richard Kimberly Heck rikiheck at lyx.org
Sat May 6 21:52:41 UTC 2023


commit 8fac7d70355fefb8c777aeeeb971660b020adf4c
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Sat May 6 15:29:16 2023 -0400

    If the ending delimiter is at the end of the file, then the test
        pimpl_->is
    will return false no matter what. So we need a different way to
    check if the delimiter was found.
---
 src/Lexer.cpp |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/Lexer.cpp b/src/Lexer.cpp
index c6402ae..ab052f5 100644
--- a/src/Lexer.cpp
+++ b/src/Lexer.cpp
@@ -690,6 +690,7 @@ docstring Lexer::getLongString(docstring const & endtoken)
 	docstring str;
 	docstring prefix;
 	bool firstline = true;
+	bool foundend = false;
 
 	while (pimpl_->is) { //< eatLine only reads from is, not from pushTok
 		if (!eatLine())
@@ -701,8 +702,10 @@ docstring Lexer::getLongString(docstring const & endtoken)
 		LYXERR(Debug::PARSER, "LongString: `" << tmpstr << '\'');
 
 		// We do a case independent comparison, like searchKeyword does.
-		if (compare_no_case(token, endtoken) == 0)
+		if (compare_no_case(token, endtoken) == 0) {
+			foundend = true;
 			break;
+		}
 
 		if (firstline) {
 			size_t i = tmpstr.find_first_not_of(from_ascii(" \t"));
@@ -720,7 +723,7 @@ docstring Lexer::getLongString(docstring const & endtoken)
 		str += tmpstr + '\n';
 	}
 
-	if (!pimpl_->is)
+	if (!foundend)
 		printError("Long string not ended by `" + to_utf8(endtoken) + '\'');
 
 	return str;


More information about the lyx-cvs mailing list