Differences From Artifact [ac798fd712]:
- File src/OFString+JSONValue.m — part of check-in [c7f0229795] at 2020-01-02 01:51:34 on branch trunk — Update copyright (user: js, size: 13034) [annotate] [blame] [check-ins using] [more...]
To Artifact [2f361d6379]:
- File
src/OFString+JSONValue.m
— part of check-in
[b6ee372b98]
at
2020-08-11 19:45:36
on branch trunk
— OFString: Rework number parsing API
This solves the old signed vs. unsigned problem and allows for more
bases than just 8, 10 and 16, as well as auto-detection of the base (if
base is 0). (user: js, size: 13084) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
524 525 526 527 528 529 530 |
return dictionary;
}
static inline OFNumber *
parseNumber(const char **pointer, const char *stop, size_t *line)
{
| | | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 |
return dictionary;
}
static inline OFNumber *
parseNumber(const char **pointer, const char *stop, size_t *line)
{
bool isNegative = (*pointer < stop && (*pointer)[0] == '-');
bool hasDecimal = false;
size_t i;
OFString *string;
OFNumber *number;
for (i = 0; *pointer + i < stop; i++) {
if ((*pointer)[i] == '.')
|
| ︙ | ︙ | |||
553 554 555 556 557 558 559 |
length: i];
*pointer += i;
@try {
if (hasDecimal)
number = [OFNumber numberWithDouble:
string.doubleValue];
| < < < > > > | | | 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 |
length: i];
*pointer += i;
@try {
if (hasDecimal)
number = [OFNumber numberWithDouble:
string.doubleValue];
else if ([string isEqual: @"Infinity"])
number = [OFNumber numberWithDouble: INFINITY];
else if ([string isEqual: @"-Infinity"])
number = [OFNumber numberWithDouble: -INFINITY];
else if (isNegative)
number = [OFNumber numberWithLongLong:
[string longLongValueWithBase: 0]];
else
number = [OFNumber numberWithUnsignedLongLong:
[string unsignedLongLongValueWithBase: 0]];
} @finally {
[string release];
}
return number;
}
|
| ︙ | ︙ |