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

U-DESKTOP-8OSNV7RDrRobotto (via logerrit) logerrit at kemper.freedesktop.org
Sun Jan 5 20:43:15 UTC 2020


 basic/qa/vba_tests/typename.vb   |    6 ++++++
 basic/source/comp/exprgen.cxx    |    4 +++-
 basic/source/runtime/runtime.cxx |   14 ++++++++++++--
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit 0b4f8bf571baf2ccd5a8aafdc4deb41867420be3
Author:     U-DESKTOP-8OSNV7R\DrRobotto <andreas.heinisch at yahoo.de>
AuthorDate: Tue Dec 24 12:22:34 2019 +0100
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Jan 5 21:42:27 2020 +0100

    tdf#129596 Distinguish between integer and long while loading immediate values
    
    During the generation of CONST_ expressions, distinguish between
    integer and long and load the correct value in the immediate load step.
    
    Change-Id: Ib4eb65d7fae3163043899ad8234816b1ebd7316b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85779
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/basic/qa/vba_tests/typename.vb b/basic/qa/vba_tests/typename.vb
index 4ec2f3e31063..7e49a4d61cdc 100644
--- a/basic/qa/vba_tests/typename.vb
+++ b/basic/qa/vba_tests/typename.vb
@@ -61,6 +61,12 @@ Function verify_testTypeName() As String
     date1 = TypeName(l1)
     TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
 
+    ' tdf#129596 - Types of constant values
+    TestLog_ASSERT TypeName(32767) = "Integer", "the return TypeName(32767) is: " & TypeName(32767)
+    TestLog_ASSERT TypeName(-32767) = "Integer", "the return TypeName(-32767) is: " & TypeName(-32767)
+    TestLog_ASSERT TypeName(1048575) = "Long", "the return TypeName(1048575) is: " & TypeName(1048575)
+    TestLog_ASSERT TypeName(-1048575) = "Long", "the return TypeName(-1048575) is: " & TypeName(-1048575)
+
     result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
     verify_testTypeName = result
 
diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx
old mode 100644
new mode 100755
index d1ebb48c4c09..3981bef2fb5e
--- a/basic/source/comp/exprgen.cxx
+++ b/basic/source/comp/exprgen.cxx
@@ -72,8 +72,10 @@ void SbiExprNode::Gen( SbiCodeGen& rGen, RecursiveMode eRecMode )
         case SbxEMPTY:
             rGen.Gen( SbiOpcode::EMPTY_ );
             break;
+        case SbxLONG:
         case SbxINTEGER:
-            rGen.Gen( SbiOpcode::CONST_,  static_cast<short>(nVal) );
+            nStringId = rGen.GetParser()->aGblStrings.Add(nVal, eType);
+            rGen.Gen( SbiOpcode::CONST_, nStringId );
             break;
         case SbxSTRING:
             nStringId = rGen.GetParser()->aGblStrings.Add( aStrVal );
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
old mode 100644
new mode 100755
index d2cb9fe988b5..3a9cb95264d5
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -2803,8 +2803,18 @@ void SbiRuntime::StepLOADSC( sal_uInt32 nOp1 )
 void SbiRuntime::StepLOADI( sal_uInt32 nOp1 )
 {
     SbxVariable* p = new SbxVariable;
-    p->PutInteger( static_cast<sal_Int16>( nOp1 ) );
-    PushVar( p );
+
+    OUString aStr = pImg->GetString(static_cast<short>(nOp1));
+    double n = ::rtl::math::stringToDouble(aStr, '.', ',');
+    if (n >= SbxMININT && n <= SbxMAXINT)
+    {
+        p->PutInteger(static_cast<sal_Int16>(n));
+    }
+    else
+    {
+        p->PutLong(static_cast<sal_Int32>(n));
+    }
+    PushVar(p);
 }
 
 // store a named argument in Argv (+Arg-no. from 1!)


More information about the Libreoffice-commits mailing list