Revert a thinko from commit 876010cbc4

Indeed, the cDecSeparator and cGroupSeparator require that the buffer
uses the proper character type, otherwise it won't be possible to use
Unicode separators in rtl_math_doubleToUString.

Change-Id: Id26bed72776475c1be5b092e3ffcff0e75ffe557
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151451
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2023-05-07 08:07:40 +02:00
parent 31e2b4746a
commit 4cec737a53
2 changed files with 12 additions and 4 deletions
+8
View File
@@ -328,6 +328,14 @@ public:
'.', aGroups, ',', true);
CPPUNIT_ASSERT_EQUAL( OUString("1,000"), aRes);
// Check non-ASCII separators: Arabic decimal separator U+066B, thousand separator U+066C
fVal = 123456.78;
aRes = rtl::math::doubleToUString( fVal,
rtl_math_StringFormat_Automatic,
2,
u'٫', aGroups, u'٬', true);
CPPUNIT_ASSERT_EQUAL( OUString(u"1٬23٬456٫78"), aRes);
fVal = 4503599627370495.0;
aRes = rtl::math::doubleToUString( fVal,
rtl_math_StringFormat_Automatic,
+4 -4
View File
@@ -1416,7 +1416,7 @@ void doubleToString(rtl_tString** pResult, sal_Int32* pResultCapacity, sal_Int32
return (n + d / 2) / d * d;
};
auto append = [](rtl_tString** s, sal_Int32* pCapacity, sal_Int32 rOffset, std::string_view sv)
auto append = [](rtl_tString** s, sal_Int32* pCapacity, sal_Int32 rOffset, auto sv)
{
if (!pCapacity)
newFromStr_WithLength(s, sv.data(), sv.size());
@@ -1569,8 +1569,8 @@ void doubleToString(rtl_tString** pResult, sal_Int32* pResultCapacity, sal_Int32
// max(nDigits) = max(nDecPlaces) + 1 + max(nExp) + 1 = 20 + 1 + 308 + 1 = 330
// max(nBuf) = max(nDigits) + max(nDecPlaces) + 10 + max(nDigits) * 2 = 330 * 3 + 20 + 10 = 1020
assert(nBuf <= 1024);
char* const pBuf = static_cast<char*>(alloca(nBuf));
char* p = pBuf;
auto* const pBuf = static_cast<Char_T<rtl_tString>*>(alloca(nBuf * sizeof(Char_T<rtl_tString>)));
auto* p = pBuf;
if (bSign)
*p++ = '-';
@@ -1718,7 +1718,7 @@ void doubleToString(rtl_tString** pResult, sal_Int32* pResultCapacity, sal_Int32
*p++ = nExp % 10 + '0';
}
append(pResult, pResultCapacity, nResultOffset, std::string_view(pBuf, p - pBuf));
append(pResult, pResultCapacity, nResultOffset, std::basic_string_view(pBuf, p - pBuf));
}
template <sal_Int32 maxLen, typename C, typename T> sal_Int32 SAL_CALL valueOfFP(C* pStr, T f)