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
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 92de8b6..c694e58 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 )