summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorJoshua Williams <joshmackwilliams@protonmail.com>2021-05-21 19:29:52 -0500
committerAndras Timar <andras.timar@collabora.com>2021-05-26 11:49:49 +0200
commite851a48f87a81bb3393ac63013446cbc5033c0fc (patch)
tree8117c24a3e70a5fd719ce180b2be70cce715cbe3 /basic
parent9e6bb7e208a848498eae5f261a11776e1dc2b859 (diff)
tdf#142180 Swapped comparison operators for static strings
It seems that, for some reason, the comparison operators for strings in basic were swapped in the code that evaluates string comparisons at compile-time. This is what caused bug #142180. This commit simply swaps the operators and should fix the bug. Change-Id: I14f90db8598f2f7f8b709e26902986e1f64af576 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115983 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 6cdfd89413eab85dba7b975199358cb8fae44661) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115961 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'basic')
-rw-r--r--basic/qa/basic_coverage/test_string_literal_comparison.vb19
-rw-r--r--basic/source/comp/exprnode.cxx8
2 files changed, 23 insertions, 4 deletions
diff --git a/basic/qa/basic_coverage/test_string_literal_comparison.vb b/basic/qa/basic_coverage/test_string_literal_comparison.vb
new file mode 100644
index 000000000000..af63ede517dc
--- /dev/null
+++ b/basic/qa/basic_coverage/test_string_literal_comparison.vb
@@ -0,0 +1,19 @@
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Function doUnitTest as Integer
+ ' tdf#142180 - Invalid text comparison result in Basic
+
+ doUnitTest = 0
+ If ( "Z" < "A" ) Then Exit Function
+ If ( "A" > "Z" ) Then Exit Function
+ If ( "A" < "A" ) Then Exit Function
+ If ( "A" > "A" ) Then Exit Function
+ If ( "Z" <= "A" ) Then Exit Function
+ If ( "A" >= "Z" ) Then Exit Function
+ doUnitTest = 1
+End Function
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index 1771da0017f3..4192ceb8d49d 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -274,16 +274,16 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* pParser)
nVal = ( eRes != 0 ) ? SbxTRUE : SbxFALSE;
break;
case LT:
- nVal = ( eRes < 0 ) ? SbxTRUE : SbxFALSE;
+ nVal = ( eRes > 0 ) ? SbxTRUE : SbxFALSE;
break;
case GT:
- nVal = ( eRes > 0 ) ? SbxTRUE : SbxFALSE;
+ nVal = ( eRes < 0 ) ? SbxTRUE : SbxFALSE;
break;
case LE:
- nVal = ( eRes <= 0 ) ? SbxTRUE : SbxFALSE;
+ nVal = ( eRes >= 0 ) ? SbxTRUE : SbxFALSE;
break;
case GE:
- nVal = ( eRes >= 0 ) ? SbxTRUE : SbxFALSE;
+ nVal = ( eRes <= 0 ) ? SbxTRUE : SbxFALSE;
break;
default:
pParser->Error( ERRCODE_BASIC_CONVERSION );