Module: wine Branch: master Commit: 9b02d2d5a3c83a8819e4e1b4a83a2c789dab9b27 URL: http://source.winehq.org/git/wine.git/?a=commit;h=9b02d2d5a3c83a8819e4e1b4a8...
Author: Jacek Caban jacek@codeweavers.com Date: Thu May 3 10:41:23 2012 +0200
jscript: Better handling of to_integer result in String.substring.
---
dlls/jscript/string.c | 27 +++++++++------------------ 1 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index 773e3a3..3b7e700 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -1302,6 +1302,7 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, INT start=0, end; DWORD length; VARIANT v; + double d; HRESULT hres;
TRACE("\n"); @@ -1317,15 +1318,9 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return hres; }
- if(V_VT(&v) == VT_I4) { - start = V_I4(&v); - if(start < 0) - start = 0; - else if(start >= length) - start = length; - }else { - start = V_R8(&v) < 0.0 ? 0 : length; - } + d = num_val(&v); + if(d >= 0) + start = is_int32(d) ? min((int)d, length) : length; }
if(arg_cnt(dp) >= 2) { @@ -1335,15 +1330,11 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return hres; }
- if(V_VT(&v) == VT_I4) { - end = V_I4(&v); - if(end < 0) - end = 0; - else if(end > length) - end = length; - }else { - end = V_R8(&v) < 0.0 ? 0 : length; - } + d = num_val(&v); + if(d >= 0) + end = is_int32(d) ? min((int)d, length) : length; + else + end = 0; }else { end = length; }