From 20e85dd21b05436ee9393f0eac77231b69f13139 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 4 Mar 2013 10:57:24 +0100 Subject: [PATCH] jscript: Use jsstr_substr in jsregexp.c where possible. --- dlls/jscript/jsregexp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dlls/jscript/jsregexp.c b/dlls/jscript/jsregexp.c index d2915801f1..f9b9992f53 100644 --- a/dlls/jscript/jsregexp.c +++ b/dlls/jscript/jsregexp.c @@ -346,10 +346,10 @@ static HRESULT create_match_array(script_ctx_t *ctx, jsstr_t *input, return hres; for(i=0; i < result->paren_count; i++) { - if(result->parens[i].index == -1) - str = jsstr_empty(); + if(result->parens[i].index != -1) + str = jsstr_substr(input, result->parens[i].index, result->parens[i].length); else - str = jsstr_alloc_len(input->str+result->parens[i].index, result->parens[i].length); + str = jsstr_empty(); if(!str) { hres = E_OUTOFMEMORY; break; @@ -866,7 +866,7 @@ static HRESULT RegExpConstr_leftContext(script_ctx_t *ctx, vdisp_t *jsthis, WORD case DISPATCH_PROPERTYGET: { jsstr_t *ret; - ret = jsstr_alloc_len(ctx->last_match->str, ctx->last_match_index); + ret = jsstr_substr(ctx->last_match, 0, ctx->last_match_index); if(!ret) return E_OUTOFMEMORY; @@ -892,7 +892,8 @@ static HRESULT RegExpConstr_rightContext(script_ctx_t *ctx, vdisp_t *jsthis, WOR case DISPATCH_PROPERTYGET: { jsstr_t *ret; - ret = jsstr_alloc(ctx->last_match->str+ctx->last_match_index+ctx->last_match_length); + ret = jsstr_substr(ctx->last_match, ctx->last_match_index+ctx->last_match_length, + jsstr_length(ctx->last_match) - ctx->last_match_index - ctx->last_match_length); if(!ret) return E_OUTOFMEMORY;