diff options
-rw-r--r-- | sal/qa/rtl/math/test-rtl-math.cxx | 14 | ||||
-rw-r--r-- | sal/rtl/math.cxx | 7 |
2 files changed, 20 insertions, 1 deletions
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx index f4df71e78ac3..f6ab314fbd21 100644 --- a/sal/qa/rtl/math/test-rtl-math.cxx +++ b/sal/qa/rtl/math/test-rtl-math.cxx @@ -75,6 +75,20 @@ public: CPPUNIT_ASSERT(std::isnan(res)); res = rtl::math::stringToDouble( + OUString("+NaN"), + '.', ',', &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end); + CPPUNIT_ASSERT_EQUAL(0.0, res); + + res = rtl::math::stringToDouble( + OUString("-NaN"), + '.', ',', &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end); + CPPUNIT_ASSERT_EQUAL(0.0, res); + + res = rtl::math::stringToDouble( OUString("+1.#NAN"), '.', ',', &status, &end); CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx index 5d4ed6061f97..feb3a2b1852d 100644 --- a/sal/rtl/math.cxx +++ b/sal/rtl/math.cxx @@ -835,16 +835,21 @@ double stringToDouble(CharT const * pBegin, CharT const * pEnd, } bool bSign; + bool explicitSign = false; if (p0 != pEnd && *p0 == CharT('-')) { bSign = true; + explicitSign = true; ++p0; } else { bSign = false; if (p0 != pEnd && *p0 == CharT('+')) + { + explicitSign = true; ++p0; + } } CharT const * p = p0; @@ -853,7 +858,7 @@ double stringToDouble(CharT const * pBegin, CharT const * pEnd, // #i112652# XMLSchema-2 if ((pEnd - p) >= 3) { - if ((CharT('N') == p[0]) && (CharT('a') == p[1]) + if (!explicitSign && (CharT('N') == p[0]) && (CharT('a') == p[1]) && (CharT('N') == p[2])) { p += 3; |