Differences From Artifact [0e3855dae5]:
- File src/OFString+JSONValue.m — part of check-in [e0b9167693] at 2016-02-21 15:37:42 on branch trunk — Make use of C99-style for loops (user: js, size: 13187) [annotate] [blame] [check-ins using]
To Artifact [eaa788e234]:
- File
src/OFString+JSONValue.m
— part of check-in
[1e9a23441b]
at
2016-05-29 14:34:35
on branch trunk
— OFString+JSONValue: Remove restrict
It makes no sense here. (user: js, size: 13008) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
29 30 31 32 33 34 35 | #import "OFNumber.h" #import "OFNull.h" #import "OFInvalidJSONException.h" int _OFString_JSONValue_reference; | | | | < | < | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#import "OFNumber.h"
#import "OFNull.h"
#import "OFInvalidJSONException.h"
int _OFString_JSONValue_reference;
static id nextObject(const char **pointer, const char *stop, size_t *line,
size_t depth, size_t depthLimit);
static void
skipWhitespaces(const char **pointer, const char *stop, size_t *line)
{
while (*pointer < stop && (**pointer == ' ' || **pointer == '\t' ||
**pointer == '\r' || **pointer == '\n')) {
if (**pointer == '\n')
(*line)++;
(*pointer)++;
}
}
static void
skipComment(const char **pointer, const char *stop, size_t *line)
{
if (**pointer != '/')
return;
if (*pointer + 1 >= stop)
return;
|
| ︙ | ︙ | |||
92 93 94 95 96 97 98 | (*pointer)++; } } else (*pointer)--; } static void | | < | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
(*pointer)++;
}
} else
(*pointer)--;
}
static void
skipWhitespacesAndComments(const char **pointer, const char *stop, size_t *line)
{
const char *old = NULL;
while (old != *pointer) {
old = *pointer;
skipWhitespaces(pointer, stop, line);
|
| ︙ | ︙ | |||
137 138 139 140 141 142 143 | if (ret == 0) return 0xFFFF; return ret; } static inline OFString* | | < | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
if (ret == 0)
return 0xFFFF;
return ret;
}
static inline OFString*
parseString(const char **pointer, const char *stop, size_t *line)
{
char *buffer;
size_t i = 0;
char delimiter = **pointer;
if (++(*pointer) + 1 >= stop)
return nil;
|
| ︙ | ︙ | |||
289 290 291 292 293 294 295 | } free(buffer); return nil; } static inline OFString* | | | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
}
free(buffer);
return nil;
}
static inline OFString*
parseIdentifier(const char **pointer, const char *stop)
{
char *buffer;
size_t i = 0;
if ((buffer = malloc(stop - *pointer)) == NULL)
return nil;
|
| ︙ | ︙ | |||
389 390 391 392 393 394 395 | * It is never possible to end with an identifier, thus we should never * reach stop. */ return nil; } static inline OFMutableArray* | | | | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
* It is never possible to end with an identifier, thus we should never
* reach stop.
*/
return nil;
}
static inline OFMutableArray*
parseArray(const char **pointer, const char *stop, size_t *line,
size_t depth, size_t depthLimit)
{
OFMutableArray *array = [OFMutableArray array];
if (++(*pointer) >= stop)
return nil;
if (++depth > depthLimit)
|
| ︙ | ︙ | |||
446 447 448 449 450 451 452 | (*pointer)++; return array; } static inline OFMutableDictionary* | | | | 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
(*pointer)++;
return array;
}
static inline OFMutableDictionary*
parseDictionary(const char **pointer, const char *stop, size_t *line,
size_t depth, size_t depthLimit)
{
OFMutableDictionary *dictionary = [OFMutableDictionary dictionary];
if (++(*pointer) >= stop)
return nil;
if (++depth > depthLimit)
|
| ︙ | ︙ | |||
525 526 527 528 529 530 531 | (*pointer)++; return dictionary; } static inline OFNumber* | | < | 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
(*pointer)++;
return dictionary;
}
static inline OFNumber*
parseNumber(const char **pointer, const char *stop, size_t *line)
{
bool isHex = (*pointer + 1 < stop && (*pointer)[1] == 'x');
bool hasDecimal = false;
size_t i;
OFString *string;
OFNumber *number;
|
| ︙ | ︙ | |||
575 576 577 578 579 580 581 | [string release]; } return number; } static id | | | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
[string release];
}
return number;
}
static id
nextObject(const char **pointer, const char *stop, size_t *line,
size_t depth, size_t depthLimit)
{
skipWhitespacesAndComments(pointer, stop, line);
if (*pointer >= stop)
return nil;
switch (**pointer) {
|
| ︙ | ︙ |