mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
jscript: Bettter handling of to_number result in String.indexOf.
This commit is contained in:
parent
621180e81c
commit
baa07477d2
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user