Module: wine Branch: master Commit: b9a57de04840c6b234ff4102e25f6978f8f60c1b URL: https://source.winehq.org/git/wine.git/?a=commit;h=b9a57de04840c6b234ff4102e...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Mar 21 14:55:55 2019 +0100
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
---
dlls/jscript/json.c | 15 ++++----------- dlls/jscript/tests/api.js | 5 ++++- 2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/dlls/jscript/json.c b/dlls/jscript/json.c index b5e6e10..5a0ec14 100644 --- a/dlls/jscript/json.c +++ b/dlls/jscript/json.c @@ -261,19 +261,12 @@ static HRESULT parse_json_value(json_parse_ctx_t *ctx, jsval_t *r) skip_spaces(ctx); }
- if(!isdigitW(*ctx->ptr)) + if(*ctx->ptr == '0' && ctx->ptr + 1 < ctx->end && isdigitW(ctx->ptr[1])) 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); - if(FAILED(hres)) - return hres; - } + hres = parse_decimal(&ctx->ptr, ctx->end, &n); + if(FAILED(hres)) + break;
*r = jsval_number(sign*n); return S_OK; diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index ff6a6b7..38b2e66 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -1887,7 +1887,10 @@ ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN"); ["[false,{},{"x": []}]", [false,{},{x:[]}]], ["0", 0], ["- 1", -1], - ["1e2147483648", Infinity] + ["1e2147483648", Infinity], + ["0.5", 0.5], + ["0e5", 0], + [".5", 0.5] ];
function json_cmp(x, y) {