summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sal/qa/rtl/math/test-rtl-math.cxx6
-rw-r--r--sal/rtl/math.cxx4
2 files changed, 10 insertions, 0 deletions
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx
index 3ebdb157d463..c0ccaaae5225 100644
--- a/sal/qa/rtl/math/test-rtl-math.cxx
+++ b/sal/qa/rtl/math/test-rtl-math.cxx
@@ -81,6 +81,12 @@ public:
CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
CPPUNIT_ASSERT_EQUAL(sal_Int32(RTL_CONSTASCII_LENGTH("1")), end);
CPPUNIT_ASSERT_EQUAL(1.0, res);
+ res = rtl::math::stringToDouble(
+ rtl::OUString("0e"),
+ sal_Unicode('.'), sal_Unicode(','), &status, &end);
+ CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(RTL_CONSTASCII_LENGTH("1")), end);
+ CPPUNIT_ASSERT_EQUAL(0.0, res);
}
CPPUNIT_TEST_SUITE(Test);
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index f66039a4a3ad..3bca17156c3a 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -819,6 +819,10 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
// offset
while (p != pEnd && rtl::isAsciiDigit(*p))
++p;
+ if (p == pFirstExpDigit)
+ { // no digits in exponent, reset end of scan
+ p = pExponent;
+ }
}
else
{