mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
07ae82508f
commit
afc7c42eca
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>
|
2013-08-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSIndexPath.m:
|
* Source/NSIndexPath.m:
|
||||||
|
|
|
@ -1289,19 +1289,26 @@ GSScanDouble(unichar *buf, unsigned length, double *result)
|
||||||
mantissaLength++;
|
mantissaLength++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dotPos < 0)
|
|
||||||
{
|
|
||||||
dotPos = mantissaLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 == mantissaLength)
|
if (0 == mantissaLength)
|
||||||
{
|
{
|
||||||
return NO; // No mantissa ... not a double
|
return NO; // No mantissa ... not a double
|
||||||
}
|
}
|
||||||
if (19 == mantissaLength
|
if (mantissaLength > 18)
|
||||||
|| (18 == mantissaLength && pos < length && isdigit(buf[pos])))
|
|
||||||
{
|
{
|
||||||
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
|
dotPos -= mantissaLength; // Exponent offset for decimal point
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue