mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
GSScanDouble() OSX compatibility fix.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37010 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b53f054489
commit
975d312084
2 changed files with 23 additions and 8 deletions
|
@ -1,3 +1,11 @@
|
|||
2013-08-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* 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 <rfm@gnu.org>
|
||||
|
||||
* Source/NSIndexPath.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
|
||||
|
||||
|
|
Loading…
Reference in a new issue