basic/source/sbx/sbxscan.cxx | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-)
New commits: commit a3a7927408a26a70e5789df5246bff165b5b43c3 Author: Mike Kaganski <[email protected]> AuthorDate: Mon Dec 23 09:46:31 2024 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Dec 23 11:22:11 2024 +0100 Simplify a bit The previous code made sure that cNonIntntlDecSep is always equal to IntntlDecSep (in the code handling bOnlyIntntl). Frop the redundancy, and make the variable names simpler. Change-Id: I31c994cd49bdbf007e110f593297acf112cc420b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179198 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx index 729fce58aace..d3a605cd112b 100644 --- a/basic/source/sbx/sbxscan.cxx +++ b/basic/source/sbx/sbxscan.cxx @@ -73,21 +73,19 @@ static bool ImpStrChr( std::u16string_view str, sal_Unicode c ) { return str.fin ErrCode ImpScan( const OUString& rWSrc, double& nVal, SbxDataType& rType, sal_uInt16* pLen, bool bOnlyIntntl ) { - sal_Unicode cIntntlDecSep, cIntntlGrpSep, cIntntlDecSepAlt; - sal_Unicode cNonIntntlDecSep = '.'; + sal_Unicode cDecSep, cGrpSep, cDecSepAlt; if( bOnlyIntntl ) { - ImpGetIntntlSep( cIntntlDecSep, cIntntlGrpSep, cIntntlDecSepAlt ); - cNonIntntlDecSep = cIntntlDecSep; + ImpGetIntntlSep(cDecSep, cGrpSep, cDecSepAlt); // Ensure that the decimal separator alternative is really one. - if (cIntntlDecSepAlt && cIntntlDecSepAlt == cNonIntntlDecSep) - cIntntlDecSepAlt = 0; + if (cDecSepAlt == cDecSep) + cDecSepAlt = 0; } else { - cIntntlDecSep = cNonIntntlDecSep; - cIntntlGrpSep = 0; // no group separator accepted in non-i18n - cIntntlDecSepAlt = 0; + cDecSep = '.'; + cGrpSep = 0; // no group separator accepted in non-i18n + cDecSepAlt = 0; } const sal_Unicode* const pStart = rWSrc.getStr(); @@ -106,9 +104,9 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, SbxDataType& rType, p++; bMinus = true; } - if( rtl::isAsciiDigit( *p ) || ((*p == cNonIntntlDecSep || *p == cIntntlDecSep || - (cIntntlGrpSep && *p == cIntntlGrpSep) || (cIntntlDecSepAlt && *p == cIntntlDecSepAlt)) && - rtl::isAsciiDigit( *(p+1) ))) + if (rtl::isAsciiDigit(*p) + || ((*p == cDecSep || (cGrpSep && *p == cGrpSep) || (cDecSepAlt && *p == cDecSepAlt)) + && rtl::isAsciiDigit(*(p + 1)))) { // tdf#118442: Whitespace and minus are skipped; store the position to calculate index const sal_Unicode* const pDigitsStart = p; @@ -116,27 +114,25 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, SbxDataType& rType, short decsep = 0; short ndig = 0; short ncdig = 0; // number of digits after decimal point - OUStringBuffer aSearchStr(OUString::Concat("0123456789DEde") + OUStringChar(cNonIntntlDecSep)); - if( cIntntlDecSep != cNonIntntlDecSep ) - aSearchStr.append(cIntntlDecSep); - if( cIntntlDecSepAlt && cIntntlDecSepAlt != cNonIntntlDecSep ) - aSearchStr.append(cIntntlDecSepAlt); - if( bOnlyIntntl ) - aSearchStr.append(cIntntlGrpSep); + OUStringBuffer aSearchStr("0123456789DEde" + OUStringChar(cDecSep)); + if (cDecSepAlt) + aSearchStr.append(cDecSepAlt); + if (cGrpSep) + aSearchStr.append(cGrpSep); const OUString pSearchStr = aSearchStr.makeStringAndClear(); static constexpr OUStringLiteral pDdEe = u"DdEe"; while( ImpStrChr( pSearchStr, *p ) ) { aBuf.append( *p ); - if( bOnlyIntntl && *p == cIntntlGrpSep ) + if (cGrpSep && *p == cGrpSep) { p++; continue; } - if( *p == cNonIntntlDecSep || *p == cIntntlDecSep || (cIntntlDecSepAlt && *p == cIntntlDecSepAlt) ) + if (*p == cDecSep || (cDecSepAlt && *p == cDecSepAlt)) { // Use the separator that is passed to stringToDouble() - aBuf[p - pDigitsStart] = cIntntlDecSep; + aBuf[p - pDigitsStart] = cDecSep; p++; if( ++decsep > 1 ) continue; @@ -175,7 +171,7 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, SbxDataType& rType, rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok; sal_Int32 nParseEnd = 0; - nVal = rtl::math::stringToDouble( aBuf, cIntntlDecSep, cIntntlGrpSep, &eStatus, &nParseEnd ); + nVal = rtl::math::stringToDouble(aBuf, cDecSep, cGrpSep, &eStatus, &nParseEnd); if( eStatus != rtl_math_ConversionStatus_Ok || nParseEnd != aBuf.getLength() ) bRes = false; commit e40b541d7ae6acdcfda19e54a12a4dbc59bfbd09 Author: Mike Kaganski <[email protected]> AuthorDate: Mon Dec 23 09:31:28 2024 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Dec 23 11:21:56 2024 +0100 Fix a copypasta From commit 9e9f39d171cafa035d7b8e74187e25c3581cb89d (resolved rhbz#919020 Basic CDbl() and CSng() scan localized number, 2013-03-19) Change-Id: I871d7fb06ccb5d15723f7acfb57701890607055f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179197 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx index dbb45c34b88e..729fce58aace 100644 --- a/basic/source/sbx/sbxscan.cxx +++ b/basic/source/sbx/sbxscan.cxx @@ -107,7 +107,7 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, SbxDataType& rType, bMinus = true; } if( rtl::isAsciiDigit( *p ) || ((*p == cNonIntntlDecSep || *p == cIntntlDecSep || - (cIntntlDecSep && *p == cIntntlGrpSep) || (cIntntlDecSepAlt && *p == cIntntlDecSepAlt)) && + (cIntntlGrpSep && *p == cIntntlGrpSep) || (cIntntlDecSepAlt && *p == cIntntlDecSepAlt)) && rtl::isAsciiDigit( *(p+1) ))) { // tdf#118442: Whitespace and minus are skipped; store the position to calculate index
