Commit d49635f0 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Better handling of to_integer result in String.lastIndexOf.

parent baa07477
......@@ -538,7 +538,7 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
VARIANT *retv, jsexcept_t *ei)
{
BSTR search_str, val_str;
DWORD length, pos, search_len;
DWORD length, pos = 0, search_len;
const WCHAR *str;
INT ret = -1;
HRESULT hres;
......@@ -568,15 +568,13 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
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)
pos = is_int32(d) ? min((int)d, length) : length;
}
}else {
pos = length;
......
......@@ -496,6 +496,8 @@ tmp = "aaaa".lastIndexOf("a",2);
ok(tmp == 2, "lastIndexOf = " + tmp);
tmp = strObj.lastIndexOf("b");
ok(tmp === 1, "lastIndexOf = " + tmp);
tmp = "bbb".lastIndexOf("b", bigInt);
ok(tmp === 2, "lastIndexOf = " + tmp);
tmp = "".toLowerCase();
ok(tmp === "", "''.toLowerCase() = " + tmp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment