[Libreoffice-commits] core.git: basic/qa basic/source

Joshua Williams (via logerrit) logerrit at kemper.freedesktop.org
Sun May 23 05:14:41 UTC 2021


 basic/qa/basic_coverage/test_string_literal_comparison.vb |   19 ++++++++++++++
 basic/source/comp/exprnode.cxx                            |    8 ++---
 2 files changed, 23 insertions(+), 4 deletions(-)

New commits:
commit 6cdfd89413eab85dba7b975199358cb8fae44661
Author:     Joshua Williams <joshmackwilliams at protonmail.com>
AuthorDate: Fri May 21 19:29:52 2021 -0500
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun May 23 07:14:07 2021 +0200

    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 at collabora.com>

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 );


More information about the Libreoffice-commits mailing list