mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 12:19:49 +00:00
jscript: Use helpers to access string buffer in global.c.
This commit is contained in:
parent
20530c55b8
commit
e67169c114
1 changed files with 37 additions and 32 deletions
|
@ -278,7 +278,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
|
|||
jsval_t *r)
|
||||
{
|
||||
jsstr_t *ret_str, *str;
|
||||
const WCHAR *ptr;
|
||||
const WCHAR *ptr, *buf;
|
||||
DWORD len = 0;
|
||||
WCHAR *ret;
|
||||
HRESULT hres;
|
||||
|
@ -291,11 +291,11 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
hres = to_string(ctx, argv[0], &str);
|
||||
hres = to_flat_string(ctx, argv[0], &str, &buf);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
for(ptr = str->str; *ptr; ptr++) {
|
||||
for(ptr = buf; *ptr; ptr++) {
|
||||
if(*ptr > 0xff)
|
||||
len += 6;
|
||||
else if(is_ecma_nonblank(*ptr))
|
||||
|
@ -311,7 +311,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
|
|||
}
|
||||
|
||||
len = 0;
|
||||
for(ptr = str->str; *ptr; ptr++) {
|
||||
for(ptr = buf; *ptr; ptr++) {
|
||||
if(*ptr > 0xff) {
|
||||
ret[len++] = '%';
|
||||
ret[len++] = 'u';
|
||||
|
@ -343,6 +343,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
|
|||
jsval_t *r)
|
||||
{
|
||||
bytecode_t *code;
|
||||
const WCHAR *src;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("\n");
|
||||
|
@ -364,8 +365,12 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
|
|||
return E_UNEXPECTED;
|
||||
}
|
||||
|
||||
src = jsstr_flatten(get_string(argv[0]));
|
||||
if(!src)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
TRACE("parsing %s\n", debugstr_jsval(argv[0]));
|
||||
hres = compile_script(ctx, get_string(argv[0])->str, NULL, NULL, TRUE, FALSE, &code);
|
||||
hres = compile_script(ctx, src, NULL, NULL, TRUE, FALSE, &code);
|
||||
if(FAILED(hres)) {
|
||||
WARN("parse (%s) failed: %08x\n", debugstr_jsval(argv[0]), hres);
|
||||
return throw_syntax_error(ctx, hres, NULL);
|
||||
|
@ -438,10 +443,10 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
|
|||
jsval_t *r)
|
||||
{
|
||||
BOOL neg = FALSE, empty = TRUE;
|
||||
const WCHAR *ptr;
|
||||
DOUBLE ret = 0.0;
|
||||
INT radix=0, i;
|
||||
jsstr_t *str;
|
||||
WCHAR *ptr;
|
||||
HRESULT hres;
|
||||
|
||||
if(!argc) {
|
||||
|
@ -463,11 +468,12 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
|
|||
}
|
||||
}
|
||||
|
||||
hres = to_string(ctx, argv[0], &str);
|
||||
hres = to_flat_string(ctx, argv[0], &str, &ptr);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
for(ptr = str->str; isspaceW(*ptr); ptr++);
|
||||
while(isspaceW(*ptr))
|
||||
ptr++;
|
||||
|
||||
switch(*ptr) {
|
||||
case '+':
|
||||
|
@ -520,7 +526,7 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
|
|||
LONGLONG d = 0, hlp;
|
||||
jsstr_t *val_str;
|
||||
int exp = 0;
|
||||
WCHAR *str;
|
||||
const WCHAR *str;
|
||||
BOOL ret_nan = TRUE, positive = TRUE;
|
||||
HRESULT hres;
|
||||
|
||||
|
@ -530,12 +536,10 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
hres = to_string(ctx, argv[0], &val_str);
|
||||
hres = to_flat_string(ctx, argv[0], &val_str, &str);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
str = val_str->str;
|
||||
|
||||
while(isspaceW(*str)) str++;
|
||||
|
||||
if(*str == '+')
|
||||
|
@ -625,7 +629,7 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
|
|||
jsval_t *r)
|
||||
{
|
||||
jsstr_t *ret_str, *str;
|
||||
const WCHAR *ptr;
|
||||
const WCHAR *ptr, *buf;
|
||||
DWORD len = 0;
|
||||
WCHAR *ret;
|
||||
HRESULT hres;
|
||||
|
@ -638,11 +642,11 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
hres = to_string(ctx, argv[0], &str);
|
||||
hres = to_flat_string(ctx, argv[0], &str, &buf);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
for(ptr = str->str; *ptr; ptr++) {
|
||||
for(ptr = buf; *ptr; ptr++) {
|
||||
if(*ptr == '%') {
|
||||
if(hex_to_int(*(ptr+1))!=-1 && hex_to_int(*(ptr+2))!=-1)
|
||||
ptr += 2;
|
||||
|
@ -661,7 +665,7 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
|
|||
}
|
||||
|
||||
len = 0;
|
||||
for(ptr = str->str; *ptr; ptr++) {
|
||||
for(ptr = buf; *ptr; ptr++) {
|
||||
if(*ptr == '%') {
|
||||
if(hex_to_int(*(ptr+1))!=-1 && hex_to_int(*(ptr+2))!=-1) {
|
||||
ret[len] = (hex_to_int(*(ptr+1))<<4) + hex_to_int(*(ptr+2));
|
||||
|
@ -758,8 +762,8 @@ static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD
|
|||
static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
const WCHAR *ptr, *uri;
|
||||
jsstr_t *str, *ret;
|
||||
const WCHAR *ptr;
|
||||
DWORD len = 0, i;
|
||||
char buf[4];
|
||||
WCHAR *rptr;
|
||||
|
@ -773,11 +777,11 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
hres = to_string(ctx, argv[0], &str);
|
||||
hres = to_flat_string(ctx, argv[0], &str, &uri);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
for(ptr = str->str; *ptr; ptr++) {
|
||||
for(ptr = uri; *ptr; ptr++) {
|
||||
if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
|
||||
len++;
|
||||
}else {
|
||||
|
@ -797,7 +801,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
for(ptr = str->str; *ptr; ptr++) {
|
||||
for(ptr = uri; *ptr; ptr++) {
|
||||
if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
|
||||
*rptr++ = *ptr;
|
||||
}else {
|
||||
|
@ -823,10 +827,11 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
|
|||
static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
const WCHAR *ptr, *uri;
|
||||
jsstr_t *str, *ret_str;
|
||||
unsigned len = 0;
|
||||
WCHAR *ptr, *ret;
|
||||
int i, val, res;
|
||||
WCHAR *ret;
|
||||
char buf[4];
|
||||
WCHAR out;
|
||||
HRESULT hres;
|
||||
|
@ -839,11 +844,11 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
hres = to_string(ctx, argv[0], &str);
|
||||
hres = to_flat_string(ctx, argv[0], &str, &uri);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
for(ptr = str->str; *ptr; ptr++) {
|
||||
for(ptr = uri; *ptr; ptr++) {
|
||||
if(*ptr != '%') {
|
||||
len++;
|
||||
}else {
|
||||
|
@ -875,7 +880,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
for(ptr = str->str; *ptr; ptr++) {
|
||||
for(ptr = uri; *ptr; ptr++) {
|
||||
if(*ptr != '%') {
|
||||
*ret++ = *ptr;
|
||||
}else {
|
||||
|
@ -910,7 +915,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
|
|||
{
|
||||
jsstr_t *str, *ret_str;
|
||||
char buf[4];
|
||||
const WCHAR *ptr;
|
||||
const WCHAR *ptr, *uri;
|
||||
DWORD len = 0, size, i;
|
||||
WCHAR *ret;
|
||||
HRESULT hres;
|
||||
|
@ -923,11 +928,11 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
hres = to_string(ctx, argv[0], &str);
|
||||
hres = to_flat_string(ctx, argv[0], &str, &uri);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
for(ptr = str->str; *ptr; ptr++) {
|
||||
for(ptr = uri; *ptr; ptr++) {
|
||||
if(is_uri_unescaped(*ptr))
|
||||
len++;
|
||||
else {
|
||||
|
@ -946,7 +951,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
for(ptr = str->str; *ptr; ptr++) {
|
||||
for(ptr = uri; *ptr; ptr++) {
|
||||
if(is_uri_unescaped(*ptr)) {
|
||||
*ret++ = *ptr;
|
||||
}else {
|
||||
|
@ -972,8 +977,8 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
|
|||
static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
const WCHAR *ptr, *uri;
|
||||
jsstr_t *str, *ret;
|
||||
const WCHAR *ptr;
|
||||
WCHAR *out_ptr;
|
||||
DWORD len = 0;
|
||||
HRESULT hres;
|
||||
|
@ -986,11 +991,11 @@ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
hres = to_string(ctx, argv[0], &str);
|
||||
hres = to_flat_string(ctx, argv[0], &str, &uri);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
ptr = str->str;
|
||||
ptr = uri;
|
||||
while(*ptr) {
|
||||
if(*ptr == '%') {
|
||||
char octets[4];
|
||||
|
@ -1046,7 +1051,7 @@ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
ptr = str->str;
|
||||
ptr = uri;
|
||||
while(*ptr) {
|
||||
if(*ptr == '%') {
|
||||
char octets[4];
|
||||
|
|
Loading…
Reference in a new issue