jscript: Use parse_decimal for parsing JSON numeric literals starting with 0.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-03-21 14:55:55 +01:00 committed by Alexandre Julliard
parent 9240ed581f
commit b9a57de048
2 changed files with 8 additions and 12 deletions

View File

@ -261,19 +261,12 @@ static HRESULT parse_json_value(json_parse_ctx_t *ctx, jsval_t *r)
skip_spaces(ctx); skip_spaces(ctx);
} }
if(!isdigitW(*ctx->ptr)) if(*ctx->ptr == '0' && ctx->ptr + 1 < ctx->end && isdigitW(ctx->ptr[1]))
break; break;
if(*ctx->ptr == '0') {
ctx->ptr++;
n = 0;
if(is_identifier_char(*ctx->ptr))
break;
}else {
hres = parse_decimal(&ctx->ptr, ctx->end, &n); hres = parse_decimal(&ctx->ptr, ctx->end, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; break;
}
*r = jsval_number(sign*n); *r = jsval_number(sign*n);
return S_OK; return S_OK;

View File

@ -1887,7 +1887,10 @@ ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
["[false,{},{\"x\": []}]", [false,{},{x:[]}]], ["[false,{},{\"x\": []}]", [false,{},{x:[]}]],
["0", 0], ["0", 0],
["- 1", -1], ["- 1", -1],
["1e2147483648", Infinity] ["1e2147483648", Infinity],
["0.5", 0.5],
["0e5", 0],
[".5", 0.5]
]; ];
function json_cmp(x, y) { function json_cmp(x, y) {