[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sal/rtl
Eike Rathke (via logerrit)
logerrit at kemper.freedesktop.org
Sat Nov 28 11:51:30 UTC 2020
sal/rtl/math.cxx | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
New commits:
commit 8ee421198ed2ffdabcde76778a3b10bd19a27766
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Fri Nov 27 17:29:05 2020 +0100
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Sat Nov 28 12:50:56 2020 +0100
Consistently use RTL_CONSTASCII_LENGTH(), tdf#136272 follow-up
This is a combination of 2 commits.
Consistently use RTL_CONSTASCII_LENGTH(), tdf#136272 follow-up
The mix with SAL_N_ELEMENTS() was confusing and even wrong in one
case.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106764
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins
(cherry picked from commit 1a0f9a9c56e7b7952b813b3efd34f9be6c853957)
Fix comment
I2ae6e3cadc0f182c4798e5d33b0c7f07fbcbbff6
(cherry picked from commit b8404ae521a9c2d183d4e076a7884627ba353e4b)
Change-Id: Ife73342b0efc01ed4e76e217d372fc32500c9b2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106782
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 7d46c754b433..6ed4906270e0 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -292,7 +292,7 @@ void doubleToString(typename T::String ** pResult,
constexpr char pDig[] = "7976931348623157";
constexpr char pRou[] = "8087931459623267"; // the only up-carry is 80
static_assert(SAL_N_ELEMENTS(pDig) == SAL_N_ELEMENTS(pRou), "digit count mismatch");
- constexpr sal_Int32 nDig2 = SAL_N_ELEMENTS(pRou) - 2;
+ constexpr sal_Int32 nDig2 = RTL_CONSTASCII_LENGTH(pRou) - 2;
sal_Int32 nCapacity = RTL_CONSTASCII_LENGTH(pRou) + 8; // + "-1.E+308"
const char pSlot[5][2][3] =
{ // rounded, not
@@ -314,7 +314,7 @@ void doubleToString(typename T::String ** pResult,
T::appendAscii(pResult, pResultCapacity, &nResultOffset,
RTL_CONSTASCII_STRINGPARAM("-"));
- nDecPlaces = std::clamp<sal_Int32>( nDecPlaces, 0, SAL_N_ELEMENTS(pRou));
+ nDecPlaces = std::clamp<sal_Int32>( nDecPlaces, 0, RTL_CONSTASCII_LENGTH(pRou));
if (nDecPlaces == 0)
{
T::appendAscii(pResult, pResultCapacity, &nResultOffset,
@@ -338,11 +338,11 @@ void doubleToString(typename T::String ** pResult,
{
const sal_Int32 nDec = nDecPlaces - nDig2;
nDecPlaces -= nDec;
- // nDec-1 is also offset into slot, rounded(-1=0) or not(-2=1)
+ // nDec-1 is also offset into slot, rounded(1-1=0) or not(2-1=1)
const size_t nSlot = ((fValue < fB3) ? 4 : ((fValue < fB2) ? 3
: ((fValue < fB1) ? 2 : ((fValue < DBL_MAX) ? 1 : 0))));
- T::appendAscii(pResult, pResultCapacity, &nResultOffset, pDig, nDecPlaces - 1);
+ T::appendAscii(pResult, pResultCapacity, &nResultOffset, pDig, nDecPlaces);
T::appendAscii(pResult, pResultCapacity, &nResultOffset, pSlot[nSlot][nDec-1], nDec);
}
}
More information about the Libreoffice-commits
mailing list