jscript: Use jsstr_substr in jsregexp.c where possible.

This commit is contained in:
Jacek Caban 2013-03-04 10:57:24 +01:00 committed by Alexandre Julliard
parent 6e3895ad76
commit 20e85dd21b
1 changed files with 6 additions and 5 deletions

View File

@ -346,10 +346,10 @@ static HRESULT create_match_array(script_ctx_t *ctx, jsstr_t *input,
return hres; return hres;
for(i=0; i < result->paren_count; i++) { for(i=0; i < result->paren_count; i++) {
if(result->parens[i].index == -1) if(result->parens[i].index != -1)
str = jsstr_empty(); str = jsstr_substr(input, result->parens[i].index, result->parens[i].length);
else else
str = jsstr_alloc_len(input->str+result->parens[i].index, result->parens[i].length); str = jsstr_empty();
if(!str) { if(!str) {
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
break; break;
@ -866,7 +866,7 @@ static HRESULT RegExpConstr_leftContext(script_ctx_t *ctx, vdisp_t *jsthis, WORD
case DISPATCH_PROPERTYGET: { case DISPATCH_PROPERTYGET: {
jsstr_t *ret; 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) if(!ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -892,7 +892,8 @@ static HRESULT RegExpConstr_rightContext(script_ctx_t *ctx, vdisp_t *jsthis, WOR
case DISPATCH_PROPERTYGET: { case DISPATCH_PROPERTYGET: {
jsstr_t *ret; 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) if(!ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;