summaryrefslogtreecommitdiff
path: root/basic/source
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2022-06-03 09:41:05 +0200
committerAndras Timar <andras.timar@collabora.com>2022-06-09 11:02:06 +0200
commit2c4909def706e28168398b95af179d003bc25106 (patch)
tree3082c88868b986f41835e05c1497f22eaa080805 /basic/source
parent5e48e5dfa8bb9cb5f98e992c24967959afd24abe (diff)
tdf#149402 - BASIC: Don't extend comment if line ends in a whitespace
Change-Id: I8adf530e77a0e65329fa59ac2873b99f48befac4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135336 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de> (cherry picked from commit fbce18558a58cddf910b788a67c2f2d4d25d68e9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135378 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'basic/source')
-rw-r--r--basic/source/comp/scanner.cxx7
-rw-r--r--basic/source/inc/scanner.hxx1
2 files changed, 7 insertions, 1 deletions
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index d391e7b6dff2..8c63dcd6643c 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -53,6 +53,7 @@ SbiScanner::SbiScanner(const OUString& rBuf, StarBASIC* p)
, bVBASupportOn(false)
, bPrevLineExtentsComment(false)
, bClosingUnderscore(false)
+ , bLineEndsWithWhitespace(false)
, bInStatement(false)
{
}
@@ -186,6 +187,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 +666,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 (asicCharClass::isWhitespace)
+ if (bCompatible && !bLineEndsWithWhitespace && aLine[nLineIdx + nLen - 1] == '_'
+ && aLine[nLineIdx + nLen - 2] == ' ')
bPrevLineExtentsComment = true;
nCol2 = nCol2 + nLen;
nLineIdx = -1;
diff --git a/basic/source/inc/scanner.hxx b/basic/source/inc/scanner.hxx
index 39dda9fa391c..cc3cbb5d7b41 100644
--- a/basic/source/inc/scanner.hxx
+++ b/basic/source/inc/scanner.hxx
@@ -62,6 +62,7 @@ protected:
bool bVBASupportOn; // true: OPTION VBASupport 1 otherwise default False
bool bPrevLineExtentsComment; // true: Previous line is comment and ends on "... _"
bool bClosingUnderscore; // true: Closing underscore followed by end of line
+ bool bLineEndsWithWhitespace; // true: Line ends with whitespace (BasicCharClass::isWhitespace)
bool bInStatement;
void GenError( ErrCode );