Kaydet (Commit) 9a6527a9 authored tarafından Eike Rathke's avatar Eike Rathke

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
üst 1511f5c3
...@@ -694,6 +694,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, ...@@ -694,6 +694,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
while (p != pEnd && (*p == CharT('0') || *p == cGroupSeparator)) while (p != pEnd && (*p == CharT('0') || *p == cGroupSeparator))
++p; ++p;
CharT const * pFirstSignificant = p;
long nValExp = 0; // carry along exponent of mantissa long nValExp = 0; // carry along exponent of mantissa
// integer part of mantissa // integer part of mantissa
...@@ -741,7 +742,19 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, ...@@ -741,7 +742,19 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
if ( fFrac != 0.0 ) if ( fFrac != 0.0 )
fVal += rtl::math::pow10Exp( fFrac, nFracExp ); fVal += rtl::math::pow10Exp( fFrac, nFracExp );
else if ( nValExp < 0 ) 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 nValExp = 0; // no digit other than 0 after decimal point
}
} }
if ( nValExp > 0 ) if ( nValExp > 0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment