diff --git a/ChangeLog b/ChangeLog index fb6ba857a..9bafb35e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-08-22 Richard Frith-Macdonald + + * Source/NSScanner.m: GSScanDouble() permit overlong mantissa (more + digits than can be represented in a double) and ignore excess digits + for compatibility with OSX. Inspired by testplant branch r37004 + which tries to allow more digits at the cost of breaking parsing + in locales where the decimal point is a comma rather than a dot. + 2013-08-22 Richard Frith-Macdonald * Source/NSIndexPath.m: diff --git a/Source/NSScanner.m b/Source/NSScanner.m index 7edba57d0..72f4bf578 100644 --- a/Source/NSScanner.m +++ b/Source/NSScanner.m @@ -1289,19 +1289,26 @@ GSScanDouble(unichar *buf, unsigned length, double *result) mantissaLength++; } } - if (dotPos < 0) - { - dotPos = mantissaLength; - } - if (0 == mantissaLength) { return NO; // No mantissa ... not a double } - if (19 == mantissaLength - || (18 == mantissaLength && pos < length && isdigit(buf[pos]))) + if (mantissaLength > 18) { - return NO; // Mantissa is too long. + /* Mantissa too long ... ignore excess. + */ + if (19 == mantissaLength && (dotPos < 0 || dotPos >= mantissaLength)) + { + mantissaLength--; + } + else + { + mantissaLength = 19; + } + } + if (dotPos < 0) + { + dotPos = mantissaLength; } dotPos -= mantissaLength; // Exponent offset for decimal point