diff options
Diffstat (limited to 'basic/source/comp/scanner.cxx')
-rw-r--r-- | basic/source/comp/scanner.cxx | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index a0d9b9ab6c76..45b65a29b129 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -27,9 +27,11 @@ #include <svl/numformat.hxx> #include <svl/zforlist.hxx> #include <rtl/character.hxx> +#include <o3tl/string_view.hxx> +#include <utility> -SbiScanner::SbiScanner(const OUString& rBuf, StarBASIC* p) - : aBuf(rBuf) +SbiScanner::SbiScanner(OUString _aBuf, StarBASIC* p) + : aBuf(std::move(_aBuf)) , nLineIdx(-1) , nSaveLineIdx(-1) , pBasic(p) @@ -53,6 +55,7 @@ SbiScanner::SbiScanner(const OUString& rBuf, StarBASIC* p) , bVBASupportOn(false) , bPrevLineExtentsComment(false) , bClosingUnderscore(false) + , bLineEndsWithWhitespace(false) , bInStatement(false) { } @@ -160,8 +163,8 @@ void SbiScanner::scanGoto() if(n + 1 < aLine.getLength()) { - OUString aTemp = aLine.copy(n, 2); - if(aTemp.equalsIgnoreAsciiCase("to")) + std::u16string_view aTemp = aLine.subView(n, 2); + if(o3tl::equalsIgnoreAsciiCase(aTemp, u"to")) { aSym = "goto"; nLineIdx += n + 2 - nCol; @@ -186,6 +189,8 @@ bool SbiScanner::readLine() while(nBufPos < nEnd && BasicCharClass::isWhitespace(aBuf[nEnd - 1])) --nEnd; + // tdf#149402 - check if line ends with a whitespace + bLineEndsWithWhitespace = (n > nEnd); aLine = aBuf.copy(nBufPos, nEnd - nBufPos); // Fast-forward past the line ending @@ -663,7 +668,9 @@ PrevLineCommentLbl: bPrevLineExtentsComment = false; aSym = "REM"; sal_Int32 nLen = aLine.getLength() - nLineIdx; - if( bCompatible && aLine[nLineIdx + nLen - 1] == '_' && aLine[nLineIdx + nLen - 2] == ' ' ) + // tdf#149402 - don't extend comment if line ends in a whitespace (BasicCharClass::isWhitespace) + if (bCompatible && !bLineEndsWithWhitespace && aLine[nLineIdx + nLen - 1] == '_' + && aLine[nLineIdx + nLen - 2] == ' ') bPrevLineExtentsComment = true; nCol2 = nCol2 + nLen; nLineIdx = -1; @@ -701,6 +708,8 @@ eoln: aSym = "\n"; nColLock = 0; bClosingUnderscore = false; + // tdf#149157 - break multiline continuation in a comment after a new line + bPrevLineExtentsComment = false; return true; } } |