summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-06-27 21:54:59 +0200
committerEike Rathke <erack@redhat.com>2016-06-27 21:57:52 +0200
commit9a6527a98fb968b3fe6bc293ff7520a9480d43d0 (patch)
tree69e8bc1768eca1dcd4fcf783f799e122a2e47a54 /sal
parent1511f5c399182c003c19cc18b316f2fdaac0501d (diff)
stringToDouble() do not parse separator without digit as 0.0
Occurred in CSV import without "detect special numbers" activated for data like ,., where the . dot resulted in a numeric cell value 0 Change-Id: Ie715d7a8ed02196b59968a92919ad286b3bedf64
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/math.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 92de8b63f658..c694e587bb1b 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -694,6 +694,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
while (p != pEnd && (*p == CharT('0') || *p == cGroupSeparator))
++p;
+ CharT const * pFirstSignificant = p;
long nValExp = 0; // carry along exponent of mantissa
// integer part of mantissa
@@ -741,7 +742,19 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
if ( fFrac != 0.0 )
fVal += rtl::math::pow10Exp( fFrac, nFracExp );
else if ( nValExp < 0 )
+ {
+ if (pFirstSignificant + 1 == p)
+ {
+ // No digit at all, only separator(s) without integer or
+ // fraction part. Bail out. No number. No error.
+ if (pStatus != nullptr)
+ *pStatus = eStatus;
+ if (pParsedEnd != nullptr)
+ *pParsedEnd = pBegin;
+ return fVal;
+ }
nValExp = 0; // no digit other than 0 after decimal point
+ }
}
if ( nValExp > 0 )