OSX compatibility fix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35532 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-09-05 08:42:21 +00:00
parent 9ce62100fe
commit b099149311
2 changed files with 19 additions and 16 deletions

View file

@ -1,3 +1,10 @@
2012-09-05 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSScanner.m: Compatibility tweak reported by hns@computer.org
A string like '1.2eX' where X is not a numeric exponent, needs to be
scanned as a float/double up to (but not including) the 'e' (or 'E')
rather than being treated as a badly formatted float/double.
2012-09-04 Fred Kiefer <FredKiefer@gmx.de>
* Tests/base/NSXMLDocument/cdata.m: New test case for CDATA.

View file

@ -724,32 +724,28 @@ typedef GSString *ivars;
/* Check for trailing exponent */
if ((_scanLocation < myLength()) && ((c == 'e') || (c == 'E')))
{
unsigned int expScanLocation = _scanLocation;
int expval;
_scanLocation++;
if ([self _scanInt: &expval])
{
/* Check for exponent overflow */
if (num)
{
if ((exponent > 0) && (expval > (LONG_MAX - exponent)))
exponent = LONG_MAX;
else if ((exponent < 0) && (expval < (LONG_MIN - exponent)))
exponent = LONG_MIN;
else
exponent += expval;
}
/* Check for exponent overflow */
if (num)
{
if ((exponent > 0) && (expval > (LONG_MAX - exponent)))
exponent = LONG_MAX;
else if ((exponent < 0) && (expval < (LONG_MIN - exponent)))
exponent = LONG_MIN;
else
exponent += expval;
}
}
else
{
#ifdef _ACCEPT_BAD_EXPONENTS_
/* Numbers like 1.23eFOO are accepted (as 1.23). */
_scanLocation = expScanLocation;
#else
/* Numbers like 1.23eFOO are rejected. */
_scanLocation = saveScanLocation;
return NO;
#endif
}
}
if (value)