From baa07477d2c70debf13fce84980ac9539109ea91 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 3 May 2012 10:40:45 +0200 Subject: [PATCH] jscript: Bettter handling of to_number result in String.indexOf. --- dlls/jscript/string.c | 10 ++++------ dlls/jscript/tests/api.js | 2 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index 9f6dc4f9ce0..d74f8cf1e87 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -494,15 +494,13 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI if(arg_cnt(dp) >= 2) { VARIANT ival; + double d; hres = to_integer(ctx, get_arg(dp,1), ei, &ival); if(SUCCEEDED(hres)) { - if(V_VT(&ival) == VT_I4) - pos = V_VT(&ival) > 0 ? V_I4(&ival) : 0; - else - pos = V_R8(&ival) > 0.0 ? length : 0; - if(pos > length) - pos = length; + d = num_val(&ival); + if(d > 0.0) + pos = is_int32(d) ? min((int)d, length) : length; } } diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index 861019f4789..8d8e819853f 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -475,6 +475,8 @@ tmp = "abcd".indexOf("bc",0,"test"); ok(tmp === 1, "indexOf = " + tmp); tmp = "abcd".indexOf(); ok(tmp == -1, "indexOf = " + tmp); +tmp = "abcd".indexOf("b", bigInt); +ok(tmp == -1, "indexOf = " + tmp); tmp = "abcd".lastIndexOf("bc",1); ok(tmp === 1, "lastIndexOf = " + tmp); -- 2.11.4.GIT