diff options
author | Joshua Williams <joshmackwilliams@protonmail.com> | 2021-05-21 19:29:52 -0500 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-05-24 12:08:41 +0200 |
commit | 073a78b8c4080e6fc9e4e61a614616edcb4153dc (patch) | |
tree | dd6d0d181ca551f105e50a2382b3416bbfa7206e | |
parent | c4767868f1ee024efdd672cb21de9e3258c56694 (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>
-rw-r--r-- | basic/qa/basic_coverage/test_string_literal_comparison.vb | 19 | ||||
-rw-r--r-- | basic/source/comp/exprnode.cxx | 8 |
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 ); |