NSPropertyList: use strtod to handle inf and nan

Apple's implementation seems to understand these things. We should too.
This commit is contained in:
Mingye Wang 2020-02-20 12:05:32 +08:00
parent a76677623a
commit 69b202274a

View file

@ -345,7 +345,7 @@ foundIgnorableWhitespace: (NSString *)string
} }
else if ([elementName isEqualToString: @"real"]) else if ([elementName isEqualToString: @"real"])
{ {
ASSIGN(plist, [NSNumber numberWithDouble: [value doubleValue]]); ASSIGN(plist, [NSNumber numberWithDouble: strtod([value cString], 0)]);
} }
else if ([elementName isEqualToString: @"true"]) else if ([elementName isEqualToString: @"true"])
{ {
@ -1170,11 +1170,11 @@ static id parsePlItem(pldata* pld)
else if (type == 'R') else if (type == 'R')
{ {
unichar buf[len]; unichar buf[len];
double d = 0.0;
for (i = 0; i < len; i++) buf[i] = ptr[i]; for (i = 0; i < len; i++) buf[i] = ptr[i];
GSScanDouble(buf, len, &d); buf[len] = '\0';
result = [[NSNumber alloc] initWithDouble: d]; result = [[NSNumber alloc]
initWithDouble: strtod(buf, 0)]];
} }
else else
{ {