[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - sal/qa sal/rtl

Stephan Bergmann sbergman at redhat.com
Thu Oct 17 10:02:49 PDT 2013


 sal/qa/rtl/math/test-rtl-math.cxx |    6 ++++++
 sal/rtl/math.cxx                  |    4 ++++
 2 files changed, 10 insertions(+)

New commits:
commit 5f13aa4eae758e6592b73b3de3a62a5d94c45a9f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Oct 17 18:01:47 2013 +0200

    fdo#70319 "exponent followed by at least on digit" also for special case 0.0
    
    Change-Id: I07e7917417b8a22cf6d64f2b7a447f9084b9fa2d
    (cherry picked from commit 7bbd58eafc3146abcefc73d2d1ca6869bb47ef5a)
    Reviewed-on: https://gerrit.libreoffice.org/6294
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx
index 3ebdb15..c0ccaaa 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 f66039a..3bca171 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
             {


More information about the Libreoffice-commits mailing list