Module: wine Branch: master Commit: 0143201eac5257b806bb72f621ad73668f88fd68 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0143201eac5257b806bb72f621...
Author: Jacek Caban jacek@codeweavers.com Date: Thu May 3 10:40:13 2012 +0200
jscript: Better handling of to_integer result in String.charAt.
---
dlls/jscript/string.c | 10 +++------- dlls/jscript/tests/api.js | 2 ++ 2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index b629d57..bf9312d 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -303,19 +303,15 @@ static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
if(arg_cnt(dp)) { VARIANT num; + double d;
hres = to_integer(ctx, get_arg(dp, 0), ei, &num); if(FAILED(hres)) { SysFreeString(val_str); return hres; } - - if(V_VT(&num) == VT_I4) { - pos = V_I4(&num); - }else { - WARN("pos = %lf\n", V_R8(&num)); - pos = -1; - } + d = num_val(&num); + pos = is_int32(d) ? d : -1; }
if(!retv) { diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index c1ae808..f92cd48 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -308,6 +308,8 @@ tmp = "abc".charAt(0,2); ok(tmp === "a", "'abc',charAt(0.2) = " + tmp); tmp = "abc".charAt(NaN); ok(tmp === "a", "'abc',charAt(NaN) = " + tmp); +tmp = "abc".charAt(bigInt); +ok(tmp === "", "'abc',charAt(bigInt) = " + tmp);
tmp = "abc".charCodeAt(0); ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);