Skip to content

Commit 4355df0

Browse files
committed
Parse -0 correctly. Fixes SBJson#88.
1 parent f689659 commit 4355df0

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Classes/SBJsonTokeniser.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,11 @@ - (sbjson_token_t)getNumberToken:(NSObject**)token {
257257
return sbjson_token_eof;
258258
}
259259

260+
unsigned long long mantissa = 0;
261+
int mantissa_length = 0;
262+
260263
if (ch == '0') {
264+
mantissa_length++;
261265
if (![_stream getNextUnichar:&ch])
262266
return sbjson_token_eof;
263267

@@ -267,9 +271,6 @@ - (sbjson_token_t)getNumberToken:(NSObject**)token {
267271
}
268272
}
269273

270-
unsigned long long mantissa = 0;
271-
int mantissa_length = 0;
272-
273274
while ([digits characterIsMember:ch]) {
274275
mantissa *= 10;
275276
mantissa += (ch - '0');

Tests/Data/valid/number/integer/input

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
-98877665544332211009988776655443322110,
33
-1,
44
0,
5+
-0,
56
1,
67
98877665544332211009988776655443322110
78
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[-98877665544332211009988776655443322110,-1,0,1,98877665544332211009988776655443322110]
1+
[-98877665544332211009988776655443322110,-1,0,0,1,98877665544332211009988776655443322110]

0 commit comments

Comments
 (0)