Jacek Caban : jscript: Bettter handling of to_number result in String. indexOf.
Alexandre Julliard
julliard at winehq.org
Thu May 3 14:23:49 CDT 2012
Module: wine
Branch: master
Commit: baa07477d2c70debf13fce84980ac9539109ea91
URL: http://source.winehq.org/git/wine.git/?a=commit;h=baa07477d2c70debf13fce84980ac9539109ea91
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu May 3 10:40:45 2012 +0200
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 9f6dc4f..d74f8cf 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 861019f..8d8e819 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);
More information about the wine-cvs
mailing list