authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-05-31 03:22:11 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-05-31 03:22:11 -07:00
log84fbe4db83738537df46119a31a806874f098240
tree2bb82a3257258cecba78762058d963df56e5926d
parentf0d1007533c84b73fa1968b97a2b430723248138

fix leading zero handling

(count was actually inaccurate here because of zig#18027

1 files changed, 3 insertions(+), 6 deletions(-)

json.zig+3-6
...@@ -172,13 +172,10 @@ fn parseNumber(alloc: std.mem.Allocator, p: *Parser) anyerror!?ValueIndex {...@@ -172,13 +172,10 @@ fn parseNumber(alloc: std.mem.Allocator, p: *Parser) anyerror!?ValueIndex {
172172
173 if (try p.eatByte('-')) |c| {173 if (try p.eatByte('-')) |c| {
174 try characters.append(c);174 try characters.append(c);
175
176 if (try p.eatByte('0')) |_| {
177 if (p.slice()[0] != '.') return try p.addNumber(alloc, "-0");
178 }
179 }175 }
180 if (try p.eatByte('0')) |_| {176 if (try p.eatByte('0')) |c| {
181 if (p.slice()[0] != '.') return try p.addNumber(alloc, "0");177 try characters.append(c);
178 if (try p.eatRange('1', '9')) |_| return error.JsonExpectedTODO;
182 }179 }
183 while (try p.eatRange('0', '9')) |d| {180 while (try p.eatRange('0', '9')) |d| {
184 try characters.append(d);181 try characters.append(d);