basic/source/inc/rtlproto.hxx     |    1 -
 basic/source/runtime/methods1.cxx |    9 ---------
 basic/source/sbx/sbxbool.cxx      |    3 +--
 basic/source/sbx/sbxbyte.cxx      |    3 +--
 basic/source/sbx/sbxchar.cxx      |    3 +--
 basic/source/sbx/sbxconv.hxx      |    3 +++
 basic/source/sbx/sbxdbl.cxx       |    3 +--
 basic/source/sbx/sbxint.cxx       |    7 +++----
 basic/source/sbx/sbxlng.cxx       |    3 +--
 basic/source/sbx/sbxscan.cxx      |   14 ++++++++++++--
 basic/source/sbx/sbxsng.cxx       |    3 +--
 basic/source/sbx/sbxuint.cxx      |    3 +--
 basic/source/sbx/sbxulng.cxx      |    3 +--
 basic/source/sbx/sbxvalue.cxx     |    5 ++---
 basic/source/sbx/sbxvar.cxx       |    5 ++---
 15 files changed, 30 insertions(+), 38 deletions(-)

New commits:
commit 1ecde0f5d1384946c3e684846e681121b3001219
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Aug 29 18:13:21 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Aug 30 07:34:31 2024 +0200

    Simplify default ImpScan usage
    
    Drop LibreOffice6FloatingPointMode, and move the check introcuced in
    commit 47aabde053a1472dc32770da29d68c8de5bd7919 (Make the tdf#97983
    changes to BASIC optional) into a simplified ImpScan overload.
    
    Change-Id: Ibef723878179113a5403d2a3c55ded9df9cb292d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172595
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/basic/source/inc/rtlproto.hxx b/basic/source/inc/rtlproto.hxx
index ed594583a36d..ad341778c049 100644
--- a/basic/source/inc/rtlproto.hxx
+++ b/basic/source/inc/rtlproto.hxx
@@ -255,7 +255,6 @@ extern void SbRtl_CDec(StarBASIC * pBasic, SbxArray & rPar, 
bool bWrite);
 
 extern void SbRtl_Partition(StarBASIC * pBasic, SbxArray & rPar, bool bWrite);
 
-extern bool LibreOffice6FloatingPointMode();
 extern double Now_Impl();
 extern void Wait_Impl( bool bDurationBased, SbxArray& rPar );
 
diff --git a/basic/source/runtime/methods1.cxx 
b/basic/source/runtime/methods1.cxx
index 4730f7633038..fa6527b5afd2 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -61,8 +61,6 @@
 #include <com/sun/star/i18n/LocaleCalendar2.hpp>
 #include <com/sun/star/sheet/XFunctionAccess.hpp>
 
-#include <officecfg/Office/Scripting.hxx>
-
 #include <memory>
 
 using namespace comphelper;
@@ -2931,13 +2929,6 @@ void SbRtl_Me(StarBASIC *, SbxArray & rPar, bool)
 
 #endif
 
-bool LibreOffice6FloatingPointMode()
-{
-    static bool bMode = std::getenv("LIBREOFFICE6FLOATINGPOINTMODE") != 
nullptr;
-
-    return bMode || 
officecfg::Office::Scripting::Basic::Compatibility::UseLibreOffice6FloatingPointConversion::get();
-}
-
 sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam, sal_Int16 
nFirstDay )
 {
     Date aRefDate(1899'12'30);
diff --git a/basic/source/sbx/sbxbool.cxx b/basic/source/sbx/sbxbool.cxx
index 2f5f031329f2..fd9002b4eff3 100644
--- a/basic/source/sbx/sbxbool.cxx
+++ b/basic/source/sbx/sbxbool.cxx
@@ -21,7 +21,6 @@
 #include <basic/sberrors.hxx>
 #include "sbxconv.hxx"
 #include "sbxres.hxx"
-#include <rtlproto.hxx>
 
 enum SbxBOOL ImpGetBool( const SbxValues* p )
 {
@@ -81,7 +80,7 @@ enum SbxBOOL ImpGetBool( const SbxValues* p )
                     double n;
                     SbxDataType t;
                     sal_uInt16 nLen = 0;
-                    if( ImpScan( *p->pOUString, n, t, &nLen, 
!LibreOffice6FloatingPointMode() ) == ERRCODE_NONE )
+                    if( ImpScan( *p->pOUString, n, t, &nLen ) == ERRCODE_NONE )
                     {
                         if( nLen == p->pOUString->getLength() )
                         {
diff --git a/basic/source/sbx/sbxbyte.cxx b/basic/source/sbx/sbxbyte.cxx
index 071fcd6338f3..30387a4f1232 100644
--- a/basic/source/sbx/sbxbyte.cxx
+++ b/basic/source/sbx/sbxbyte.cxx
@@ -24,7 +24,6 @@
 //#include <basic/sbx.hxx>
 #include <basic/sberrors.hxx>
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 
 #include <rtl/math.hxx>
 
@@ -166,7 +165,7 @@ start:
             {
                 double d;
                 SbxDataType t;
-                if( ImpScan( *p->pOUString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+                if( ImpScan( *p->pOUString, d, t, nullptr ) != ERRCODE_NONE )
                     nRes = 0;
                 else if( d > SbxMAXBYTE )
                 {
diff --git a/basic/source/sbx/sbxchar.cxx b/basic/source/sbx/sbxchar.cxx
index f3a6715a2911..466b16f143b2 100644
--- a/basic/source/sbx/sbxchar.cxx
+++ b/basic/source/sbx/sbxchar.cxx
@@ -20,7 +20,6 @@
 #include <comphelper/errcode.hxx>
 #include <basic/sberrors.hxx>
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 
 #include <rtl/math.hxx>
 
@@ -148,7 +147,7 @@ start:
             {
                 double d;
                 SbxDataType t;
-                if( ImpScan( *p->pOUString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+                if( ImpScan( *p->pOUString, d, t, nullptr ) != ERRCODE_NONE )
                     nRes = 0;
                 else if( d > SbxMAXCHAR )
                 {
diff --git a/basic/source/sbx/sbxconv.hxx b/basic/source/sbx/sbxconv.hxx
index a3837d9a3dbf..8f11122bd319 100644
--- a/basic/source/sbx/sbxconv.hxx
+++ b/basic/source/sbx/sbxconv.hxx
@@ -64,6 +64,9 @@ extern void ImpCvtNum( double nNum, short nPrec, OUString& 
rRes, bool bCoreStrin
 extern ErrCode ImpScan
     ( const OUString& rSrc, double& nVal, SbxDataType& rType, sal_uInt16* pLen,
       bool bOnlyIntntl );
+// A version that uses defaults / compatibility settings for bOnlyIntntl
+extern ErrCode ImpScan
+    ( const OUString& rSrc, double& nVal, SbxDataType& rType, sal_uInt16* pLen 
);
 
 // with advanced evaluation (International, "TRUE"/"FALSE")
 extern bool ImpConvStringExt( OUString& rSrc, SbxDataType eTargetType );
diff --git a/basic/source/sbx/sbxdbl.cxx b/basic/source/sbx/sbxdbl.cxx
index 10cdbc203b0d..fa6ca01d6219 100644
--- a/basic/source/sbx/sbxdbl.cxx
+++ b/basic/source/sbx/sbxdbl.cxx
@@ -21,7 +21,6 @@
 
 #include <comphelper/errcode.hxx>
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 #include <runtime.hxx>
 
 double ImpGetDouble( const SbxValues* p )
@@ -79,7 +78,7 @@ double ImpGetDouble( const SbxValues* p )
             {
                 double d;
                 SbxDataType t;
-                if( ImpScan( *p->pOUString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+                if( ImpScan( *p->pOUString, d, t, nullptr ) != ERRCODE_NONE )
                 {
                     nRes = 0;
 #if HAVE_FEATURE_SCRIPTING
diff --git a/basic/source/sbx/sbxint.cxx b/basic/source/sbx/sbxint.cxx
index 1b57239ddba9..14b1727433d4 100644
--- a/basic/source/sbx/sbxint.cxx
+++ b/basic/source/sbx/sbxint.cxx
@@ -23,7 +23,6 @@
 #include <comphelper/errcode.hxx>
 #include <basic/sberrors.hxx>
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 
 #include <rtl/math.hxx>
 
@@ -140,7 +139,7 @@ start:
             {
                 double d;
                 SbxDataType t;
-                if( ImpScan( *p->pOUString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+                if( ImpScan( *p->pOUString, d, t, nullptr ) != ERRCODE_NONE )
                     nRes = 0;
                 else
                     nRes = ImpDoubleToInteger(d);
@@ -383,7 +382,7 @@ start:
                     // Check if really 0 or invalid conversion
                     double d;
                     SbxDataType t;
-                    if( ImpScan( *p->pOUString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+                    if( ImpScan( *p->pOUString, d, t, nullptr ) != 
ERRCODE_NONE )
                         nRes = 0;
                     else
                         nRes = ImpDoubleToSalInt64(d);
@@ -638,7 +637,7 @@ start:
                     // Check if really 0 or invalid conversion
                     double d;
                     SbxDataType t;
-                    if( ImpScan( *p->pOUString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+                    if( ImpScan( *p->pOUString, d, t, nullptr ) != 
ERRCODE_NONE )
                         nRes = 0;
                     else
                         nRes = ImpDoubleToSalUInt64(d);
diff --git a/basic/source/sbx/sbxlng.cxx b/basic/source/sbx/sbxlng.cxx
index e129406e2f3a..a49b6928758c 100644
--- a/basic/source/sbx/sbxlng.cxx
+++ b/basic/source/sbx/sbxlng.cxx
@@ -22,7 +22,6 @@
 #include <comphelper/errcode.hxx>
 #include <basic/sberrors.hxx>
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 
 #include <rtl/math.hxx>
 
@@ -103,7 +102,7 @@ start:
             {
                 double d;
                 SbxDataType t;
-                if( ImpScan( *p->pOUString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+                if( ImpScan( *p->pOUString, d, t, nullptr ) != ERRCODE_NONE )
                     nRes = 0;
                 else
                     nRes = ImpDoubleToLong(d);
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index 87f4455ca5d2..eef04bbad20e 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -19,6 +19,7 @@
 
 #include <sal/config.h>
 
+#include <cstdlib>
 #include <string_view>
 
 #include <config_features.h>
@@ -26,7 +27,6 @@
 #include <comphelper/errcode.hxx>
 #include <unotools/resmgr.hxx>
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 
 #include <unotools/syslocale.hxx>
 #include <unotools/charclass.hxx>
@@ -49,6 +49,7 @@
 #include <svl/numformat.hxx>
 #include <svl/zforlist.hxx>
 #include <o3tl/string_view.hxx>
+#include <officecfg/Office/Scripting.hxx>
 
 
 void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep, 
sal_Unicode& rcDecimalSepAlt )
@@ -262,6 +263,15 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
     return ERRCODE_NONE;
 }
 
+ErrCode ImpScan(const OUString& rSrc, double& nVal, SbxDataType& rType, 
sal_uInt16* pLen)
+{
+    using namespace officecfg::Office::Scripting;
+    static const bool bEnv = std::getenv("LIBREOFFICE6FLOATINGPOINTMODE") != 
nullptr;
+    bool bMode = bEnv || 
Basic::Compatibility::UseLibreOffice6FloatingPointConversion::get();
+
+    return ImpScan(rSrc, nVal, rType, pLen, !bMode);
+}
+
 // port for CDbl in the Basic
 ErrCode SbxValue::ScanNumIntnl( const OUString& rSrc, double& nVal, bool 
bSingle )
 {
@@ -403,7 +413,7 @@ bool SbxValue::Scan( const OUString& rSrc, sal_uInt16* pLen 
)
     {
         double n;
         SbxDataType t;
-        eRes = ImpScan( rSrc, n, t, pLen, !LibreOffice6FloatingPointMode() );
+        eRes = ImpScan( rSrc, n, t, pLen );
         if( eRes == ERRCODE_NONE )
         {
             if( !IsFixed() )
diff --git a/basic/source/sbx/sbxsng.cxx b/basic/source/sbx/sbxsng.cxx
index 27109971609a..706cab89a3a4 100644
--- a/basic/source/sbx/sbxsng.cxx
+++ b/basic/source/sbx/sbxsng.cxx
@@ -22,7 +22,6 @@
 #include <comphelper/errcode.hxx>
 #include <basic/sberrors.hxx>
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 
 float ImpGetSingle( const SbxValues* p )
 {
@@ -107,7 +106,7 @@ start:
             {
                 double d;
                 SbxDataType t;
-                if( ImpScan( *p->pOUString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+                if( ImpScan( *p->pOUString, d, t, nullptr ) != ERRCODE_NONE )
                     nRes = 0;
                 else if( d > SbxMAXSNG )
                 {
diff --git a/basic/source/sbx/sbxuint.cxx b/basic/source/sbx/sbxuint.cxx
index d536ec99e217..2f4f369607bd 100644
--- a/basic/source/sbx/sbxuint.cxx
+++ b/basic/source/sbx/sbxuint.cxx
@@ -22,7 +22,6 @@
 #include <comphelper/errcode.hxx>
 #include <basic/sberrors.hxx>
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 
 sal_uInt16 ImpGetUShort( const SbxValues* p )
 {
@@ -136,7 +135,7 @@ start:
             {
                 double d;
                 SbxDataType t;
-                if( ImpScan( *p->pOUString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+                if( ImpScan( *p->pOUString, d, t, nullptr ) != ERRCODE_NONE )
                     nRes = 0;
                 else
                     nRes = ImpDoubleToUShort(d);
diff --git a/basic/source/sbx/sbxulng.cxx b/basic/source/sbx/sbxulng.cxx
index 68ae31457088..8ccde8088006 100644
--- a/basic/source/sbx/sbxulng.cxx
+++ b/basic/source/sbx/sbxulng.cxx
@@ -22,7 +22,6 @@
 #include <comphelper/errcode.hxx>
 #include <basic/sberrors.hxx>
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 
 sal_uInt32 ImpGetULong( const SbxValues* p )
 {
@@ -103,7 +102,7 @@ start:
             {
                 double d;
                 SbxDataType t;
-                if( ImpScan( *p->pOUString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+                if( ImpScan( *p->pOUString, d, t, nullptr ) != ERRCODE_NONE )
                     nRes = 0;
                 else
                     nRes = ImpDoubleToULong(d);
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index e3bbdd2f1e4c..ca1264609ed8 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -31,7 +31,6 @@
 #include <basic/sbx.hxx>
 #include <sbunoobj.hxx>
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 #include <runtime.hxx>
 #include <filefmt.hxx>
 
@@ -1328,7 +1327,7 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
                 RTL_TEXTENCODING_ASCII_US);
             double d;
             SbxDataType t;
-            if( ImpScan( aVal, d, t, nullptr, !LibreOffice6FloatingPointMode() 
) != ERRCODE_NONE || t == SbxDOUBLE )
+            if( ImpScan( aVal, d, t, nullptr ) != ERRCODE_NONE || t == 
SbxDOUBLE )
             {
                 aData.nSingle = 0.0F;
                 return false;
@@ -1343,7 +1342,7 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
             OUString aVal = read_uInt16_lenPrefixed_uInt8s_ToOUString(r,
                 RTL_TEXTENCODING_ASCII_US);
             SbxDataType t;
-            if( ImpScan( aVal, aData.nDouble, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+            if( ImpScan( aVal, aData.nDouble, t, nullptr ) != ERRCODE_NONE )
             {
                 aData.nDouble = 0.0;
                 return false;
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index cc57a804bc61..2d86029c5ad1 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -26,7 +26,6 @@
 #include <runtime.hxx>
 #include "sbxres.hxx"
 #include "sbxconv.hxx"
-#include <rtlproto.hxx>
 #include <sbunoobj.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <sal/log.hxx>
@@ -457,7 +456,7 @@ bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 
nVer )
                     rStrm, RTL_TEXTENCODING_ASCII_US);
             double d;
             SbxDataType t;
-            if( ImpScan( aTmpString, d, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE || t == SbxDOUBLE )
+            if( ImpScan( aTmpString, d, t, nullptr ) != ERRCODE_NONE || t == 
SbxDOUBLE )
             {
                 aTmp.nSingle = 0;
                 return false;
@@ -472,7 +471,7 @@ bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 
nVer )
             aTmpString = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm,
                                                                         
RTL_TEXTENCODING_ASCII_US);
             SbxDataType t;
-            if( ImpScan( aTmpString, aTmp.nDouble, t, nullptr, 
!LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
+            if( ImpScan( aTmpString, aTmp.nDouble, t, nullptr ) != 
ERRCODE_NONE )
             {
                 aTmp.nDouble = 0;
                 return false;

Reply via email to