From fa0dfd0bb648c590a7cb24958ef837245b6955d0 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 24 Sep 2012 15:41:53 +0200 Subject: [PATCH] jscript: Properly invoke regexp matching in String.split. --- dlls/jscript/string.c | 42 ++++++++++++++++-------------------- dlls/jscript/tests/regexp.js | 22 +++++++++++++++++++ 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index e7216df838c..6387896b2ca 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -1081,12 +1081,11 @@ static HRESULT String_small(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - match_result_t *match_result = NULL; - DWORD length, match_cnt, i, match_len = 0; - const WCHAR *str, *ptr, *ptr2; + match_result_t match_result; + DWORD length, i, match_len = 0; + const WCHAR *str, *ptr, *ptr2, *cp; unsigned limit = UINT32_MAX; - BOOL use_regexp = FALSE; - jsdisp_t *array; + jsdisp_t *array, *regexp = NULL; BSTR val_str, match_str = NULL, tmp_str; HRESULT hres; @@ -1110,23 +1109,16 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi } if(is_object_instance(argv[0])) { - jsdisp_t *regexp; - regexp = iface_to_jsdisp((IUnknown*)get_object(argv[0])); if(regexp) { - if(is_class(regexp, JSCLASS_REGEXP)) { - use_regexp = TRUE; - hres = regexp_match(ctx, regexp, str, length, TRUE, &match_result, &match_cnt); - } - jsdisp_release(regexp); - if(FAILED(hres)) { - SysFreeString(val_str); - return hres; + if(!is_class(regexp, JSCLASS_REGEXP)) { + jsdisp_release(regexp); + regexp = NULL; } } } - if(!use_regexp) { + if(!regexp) { hres = to_string(ctx, argv[0], &match_str); if(FAILED(hres)) { SysFreeString(val_str); @@ -1143,12 +1135,13 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi hres = create_array(ctx, 0, &array); if(SUCCEEDED(hres)) { - ptr = str; + ptr = cp = str; for(i=0; iboldandcoded".split(/<(\/)?([^<>]+)>/) ; +ok(r.length === 4, "r.length = " + r.length); + /* another standard violation */ r = "1 12 \t3".split(re = /(\s)+/g).join(";"); ok(r === "1;12;3", "r = " + r);