Jacek Caban : jscript: Better handling of to_integer result in String. lastIndexOf.
Alexandre Julliard
julliard at winehq.org
Thu May 3 14:23:49 CDT 2012
Module: wine
Branch: master
Commit: d49635f08acaa5ed6bfc167a1759d8a9687d68c1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d49635f08acaa5ed6bfc167a1759d8a9687d68c1
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu May 3 10:40:57 2012 +0200
jscript: Better handling of to_integer result in String.lastIndexOf.
---
dlls/jscript/string.c | 12 +++++-------
dlls/jscript/tests/api.js | 2 ++
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index d74f8cf..62cc6f0 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -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;
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 8d8e819..b25f0ae 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -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);
More information about the wine-cvs
mailing list