Module: wine Branch: master Commit: 9dd50eae0669417e9f3c16cd4604f337e76db850 URL: https://source.winehq.org/git/wine.git/?a=commit;h=9dd50eae0669417e9f3c16cd4...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Aug 8 15:26:06 2019 +0200
jscript: Allow 0x strings with explicit radix 16 in parseInt.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/global.c | 2 ++ dlls/jscript/tests/api.js | 6 ++++++ 2 files changed, 8 insertions(+)
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c index 100cf40..33e6415 100644 --- a/dlls/jscript/global.c +++ b/dlls/jscript/global.c @@ -336,6 +336,8 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, }else { radix = 10; } + }else if(radix == 16 && *ptr == '0' && (ptr[1] == 'x' || ptr[1] == 'X')) { + ptr += 2; }
i = char_to_int(*ptr++); diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index 40a1b2d..58a0cd3 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -156,6 +156,12 @@ i = parseInt("1", 37); ok(isNaN(i), "parseInt('1', 37) = " + i); i = parseInt("1", 36); ok(i === 1, "parseInt('1', 36) = " + i); +i = parseInt("0x1f", 16); +ok(i === 31, "parseInt('0xf', 16) = " + i); +i = parseInt("0x", 16); +ok(isNaN(i), "parseInt('0x', 16) = " + i); +i = parseInt("0x1f", 17); +ok(i === 0, "parseInt('0xf', 16) = " + i);
tmp = encodeURI("abc"); ok(tmp === "abc", "encodeURI('abc') = " + tmp);