[Libreoffice-commits] core.git: i18npool/source sal/rtl

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Dec 1 00:10:55 UTC 2018


 i18npool/source/characterclassification/cclass_unicode_parser.cxx |   14 ++++++++--
 sal/rtl/math.cxx                                                  |   14 ++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)

New commits:
commit a4146c38a07ff51b37d40c2e953f54b0a746a8b7
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Fri Nov 30 20:06:24 2018 +0100
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Sat Dec 1 01:10:25 2018 +0100

    A leading or trailing group separator character is not a group separator
    
    Also a group separator character followed by a non-digit is not.
    
    Change-Id: Id57e43fe7692706c5532fb05ad394224265c2750
    Reviewed-on: https://gerrit.libreoffice.org/64358
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/i18npool/source/characterclassification/cclass_unicode_parser.cxx b/i18npool/source/characterclassification/cclass_unicode_parser.cxx
index 3c040a5a0085..7af1dd8baf45 100644
--- a/i18npool/source/characterclassification/cclass_unicode_parser.cxx
+++ b/i18npool/source/characterclassification/cclass_unicode_parser.cxx
@@ -822,8 +822,18 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32
                 if ( nMask & ParserFlags::VALUE )
                 {
                     if (current == cGroupSep)
-                        nParseTokensType |= KParseTokens::GROUP_SEPARATOR_IN_NUMBER;
-                    if ((current == cDecimalSep || (bDecSepAltUsed = (cDecimalSepAlt && current == cDecimalSepAlt))) &&
+                    {
+                        if (getFlags(nextChar) & ParserFlags::VALUE_DIGIT)
+                            nParseTokensType |= KParseTokens::GROUP_SEPARATOR_IN_NUMBER;
+                        else
+                        {
+                            // Trailing group separator character is not a
+                            // group separator.
+                            eState = ssStopBack;
+                        }
+                    }
+                    else if ((current == cDecimalSep ||
+                                (bDecSepAltUsed = (cDecimalSepAlt && current == cDecimalSepAlt))) &&
                             ++nDecSeps > 1)
                     {
                         if (nCodePoints == 2)
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 14b0577532ab..46b7ef88f3d0 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -811,8 +811,12 @@ double stringToDouble(CharT const * pBegin, CharT const * pEnd,
 
     if (!bDone) // do not recognize e.g. NaN1.23
     {
-        // leading zeros and group separators may be safely ignored
-        while (p != pEnd && (*p == CharT('0') || *p == cGroupSeparator))
+        // Leading zeros and group separators between digits may be safely
+        // ignored. p0 < p implies that there was a leading 0 already,
+        // consecutive group separators may not happen as *(p+1) is checked for
+        // digit.
+        while (p != pEnd && (*p == CharT('0') || (*p == cGroupSeparator
+                        && p0 < p && p+1 < pEnd && rtl::isAsciiDigit(*(p+1)))))
         {
             ++p;
         }
@@ -833,6 +837,12 @@ double stringToDouble(CharT const * pBegin, CharT const * pEnd,
             {
                 break;
             }
+            else if (p == p0 || (p+1 == pEnd) || !rtl::isAsciiDigit(*(p+1)))
+            {
+                // A leading or trailing (not followed by a digit) group
+                // separator character is not a group separator.
+                break;
+            }
         }
 
         // fraction part of mantissa


More information about the Libreoffice-commits mailing list