summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-11-30 20:06:24 +0100
committerEike Rathke <erack@redhat.com>2018-12-01 12:07:24 +0100
commit673bd16887c354981120f7ebea44b25b0ab2e41e (patch)
tree3c7d10fe7eee88405bb4d85113c2de41410abe0e /sal
parent5fd429a3e20d0fb91d96be9ded39f81325432509 (diff)
A leading or trailing group separator character is not a group separator
Also a group separator character followed by a non-digit is not. Change-Id: Id57e43fe7692706c5532fb05ad394224265c2750 Reviewed-on: https://gerrit.libreoffice.org/64358 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit a4146c38a07ff51b37d40c2e953f54b0a746a8b7) Reviewed-on: https://gerrit.libreoffice.org/64367
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/math.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 447aabc365f8..9fd7983f8787 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -811,8 +811,12 @@ double stringToDouble(CharT const * pBegin, CharT const * pEnd,
if (!bDone) // do not recognize e.g. NaN1.23
{
- // leading zeros and group separators may be safely ignored
- while (p != pEnd && (*p == CharT('0') || *p == cGroupSeparator))
+ // Leading zeros and group separators between digits may be safely
+ // ignored. p0 < p implies that there was a leading 0 already,
+ // consecutive group separators may not happen as *(p+1) is checked for
+ // digit.
+ while (p != pEnd && (*p == CharT('0') || (*p == cGroupSeparator
+ && p0 < p && p+1 < pEnd && rtl::isAsciiDigit(*(p+1)))))
{
++p;
}
@@ -833,6 +837,12 @@ double stringToDouble(CharT const * pBegin, CharT const * pEnd,
{
break;
}
+ else if (p == p0 || (p+1 == pEnd) || !rtl::isAsciiDigit(*(p+1)))
+ {
+ // A leading or trailing (not followed by a digit) group
+ // separator character is not a group separator.
+ break;
+ }
}
// fraction part of mantissa