Piotr Caban : jscript: Make String_match generic.
Alexandre Julliard
julliard at winehq.org
Mon Jul 13 07:56:41 CDT 2009
Module: wine
Branch: master
Commit: 0cb6bf5b28486dea0b04a809988405d39e136052
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0cb6bf5b28486dea0b04a809988405d39e136052
Author: Piotr Caban <piotr.caban at gmail.com>
Date: Sun Jul 12 19:51:15 2009 +0200
jscript: Make String_match generic.
---
dlls/jscript/string.c | 41 ++++++++++++++++++++++++++++++++++++-----
1 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index 0c9e3d6..a291ea1 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -585,12 +585,13 @@ static HRESULT String_link(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
static HRESULT String_match(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- StringInstance *This = (StringInstance*)dispex;
+ const WCHAR *str;
match_result_t *match_result;
DispatchEx *regexp;
DispatchEx *array;
VARIANT var, *arg_var;
- DWORD match_cnt, i;
+ DWORD length, match_cnt, i;
+ BSTR val_str;
HRESULT hres = S_OK;
TRACE("\n");
@@ -623,22 +624,50 @@ static HRESULT String_match(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
}
}
- hres = regexp_match(regexp, This->str, This->length, FALSE, &match_result, &match_cnt);
+ if(!is_class(dispex, JSCLASS_STRING)) {
+ VARIANT this;
+
+ V_VT(&this) = VT_DISPATCH;
+ V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
+
+ hres = to_string(dispex->ctx, &this, ei, &val_str);
+ if(FAILED(hres)) {
+ jsdisp_release(regexp);
+ return hres;
+ }
+
+ str = val_str;
+ length = SysStringLen(val_str);
+ }
+ else {
+ StringInstance *this = (StringInstance*)dispex;
+
+ str = this->str;
+ length = this->length;
+ }
+
+ hres = regexp_match(regexp, str, length, FALSE, &match_result, &match_cnt);
jsdisp_release(regexp);
- if(FAILED(hres))
+ if(FAILED(hres)) {
+ SysFreeString(val_str);
return hres;
+ }
if(!match_cnt) {
TRACE("no match\n");
if(retv)
V_VT(retv) = VT_NULL;
+
+ SysFreeString(val_str);
return S_OK;
}
hres = create_array(dispex->ctx, match_cnt, &array);
- if(FAILED(hres))
+ if(FAILED(hres)) {
+ SysFreeString(val_str);
return hres;
+ }
V_VT(&var) = VT_BSTR;
@@ -655,6 +684,8 @@ static HRESULT String_match(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
break;
}
+ SysFreeString(val_str);
+
if(SUCCEEDED(hres) && retv) {
V_VT(retv) = VT_DISPATCH;
V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(array);
More information about the wine-cvs
mailing list