Commit f0c0c142 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Moved string concatenation to helper function.

parent 3b197749
...@@ -1447,22 +1447,13 @@ static HRESULT add_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsval_t * ...@@ -1447,22 +1447,13 @@ static HRESULT add_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsval_t *
hres = to_string(ctx, r, &rstr); hres = to_string(ctx, r, &rstr);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
unsigned len1, len2;
jsstr_t *ret_str; jsstr_t *ret_str;
len1 = jsstr_length(lstr); ret_str = jsstr_concat(lstr, rstr);
len2 = jsstr_length(rstr); if(ret_str)
ret_str = jsstr_alloc_buf(len1+len2);
if(ret_str) {
if(len1)
memcpy(ret_str->str, lstr->str, len1*sizeof(WCHAR));
if(len2)
memcpy(ret_str->str+len1, rstr->str, len2*sizeof(WCHAR));
*ret = jsval_string(ret_str); *ret = jsval_string(ret_str);
}else { else
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
}
} }
jsstr_release(lstr); jsstr_release(lstr);
......
...@@ -66,6 +66,25 @@ int jsstr_cmp(jsstr_t *str1, jsstr_t *str2) ...@@ -66,6 +66,25 @@ int jsstr_cmp(jsstr_t *str1, jsstr_t *str2)
return ret; return ret;
} }
jsstr_t *jsstr_concat(jsstr_t *str1, jsstr_t *str2)
{
unsigned len1, len2;
jsstr_t *ret;
len1 = jsstr_length(str1);
len2 = jsstr_length(str2);
ret = jsstr_alloc_buf(len1+len2);
if(!ret)
return NULL;
if(len1)
memcpy(ret->str, str1->str, len1*sizeof(WCHAR));
if(len2)
memcpy(ret->str+len1, str2->str, len2*sizeof(WCHAR));
return ret;
}
static jsstr_t *empty_str, *nan_str; static jsstr_t *empty_str, *nan_str;
jsstr_t *jsstr_nan(void) jsstr_t *jsstr_nan(void)
......
...@@ -60,6 +60,7 @@ static inline BOOL jsstr_eq(jsstr_t *str1, jsstr_t *str2) ...@@ -60,6 +60,7 @@ static inline BOOL jsstr_eq(jsstr_t *str1, jsstr_t *str2)
} }
int jsstr_cmp(jsstr_t*,jsstr_t*) DECLSPEC_HIDDEN; int jsstr_cmp(jsstr_t*,jsstr_t*) DECLSPEC_HIDDEN;
jsstr_t *jsstr_concat(jsstr_t*,jsstr_t*) DECLSPEC_HIDDEN;
jsstr_t *jsstr_nan(void) DECLSPEC_HIDDEN; jsstr_t *jsstr_nan(void) DECLSPEC_HIDDEN;
jsstr_t *jsstr_empty(void) DECLSPEC_HIDDEN; jsstr_t *jsstr_empty(void) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment