Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
4ece40f8
Commit
4ece40f8
authored
Mar 25, 2013
by
Jacek Caban
Committed by
Alexandre Julliard
Mar 25, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Return buffer pointer separately from jsstr_t from jsstr_alloc_len.
parent
79632a22
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
141 additions
and
123 deletions
+141
-123
array.c
dlls/jscript/array.c
+17
-17
date.c
dlls/jscript/date.c
+40
-24
engine.c
dlls/jscript/engine.c
+2
-2
error.c
dlls/jscript/error.c
+10
-6
function.c
dlls/jscript/function.c
+6
-5
global.c
dlls/jscript/global.c
+27
-32
jsstr.c
dlls/jscript/jsstr.c
+12
-9
jsstr.h
dlls/jscript/jsstr.h
+1
-1
number.c
dlls/jscript/number.c
+2
-4
object.c
dlls/jscript/object.c
+4
-3
string.c
dlls/jscript/string.c
+20
-20
No files found.
dlls/jscript/array.c
View file @
4ece40f8
...
...
@@ -234,7 +234,7 @@ static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
static
HRESULT
array_join
(
script_ctx_t
*
ctx
,
jsdisp_t
*
array
,
DWORD
length
,
const
WCHAR
*
sep
,
jsval_t
*
r
)
{
jsstr_t
**
str_tab
,
*
ret
=
NULL
;
jsstr_t
**
str_tab
,
*
ret
;
jsval_t
val
;
DWORD
i
;
HRESULT
hres
=
E_FAIL
;
...
...
@@ -267,7 +267,6 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons
if
(
SUCCEEDED
(
hres
))
{
DWORD
seplen
=
0
,
len
=
0
;
WCHAR
*
ptr
;
seplen
=
strlenW
(
sep
);
...
...
@@ -283,25 +282,26 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons
}
}
if
(
SUCCEEDED
(
hres
))
ret
=
jsstr_alloc_buf
(
len
);
if
(
ret
)
{
ptr
=
ret
->
str
;
if
(
SUCCEEDED
(
hres
))
{
WCHAR
*
ptr
=
NULL
;
if
(
str_tab
[
0
])
ptr
+=
jsstr_flush
(
str_tab
[
0
],
ptr
);
ptr
=
jsstr_alloc_buf
(
len
,
&
ret
);
if
(
ptr
)
{
if
(
str_tab
[
0
])
ptr
+=
jsstr_flush
(
str_tab
[
0
],
ptr
);
for
(
i
=
1
;
i
<
length
;
i
++
)
{
if
(
seplen
)
{
memcpy
(
ptr
,
sep
,
seplen
*
sizeof
(
WCHAR
));
ptr
+=
seplen
;
}
for
(
i
=
1
;
i
<
length
;
i
++
)
{
if
(
seplen
)
{
memcpy
(
ptr
,
sep
,
seplen
*
sizeof
(
WCHAR
));
ptr
+=
seplen
;
}
if
(
str_tab
[
i
])
ptr
+=
jsstr_flush
(
str_tab
[
i
],
ptr
);
if
(
str_tab
[
i
])
ptr
+=
jsstr_flush
(
str_tab
[
i
],
ptr
);
}
}
else
{
hres
=
E_OUTOFMEMORY
;
}
}
else
{
hres
=
E_OUTOFMEMORY
;
}
}
...
...
dlls/jscript/date.c
View file @
4ece40f8
...
...
@@ -492,7 +492,7 @@ static inline HRESULT date_to_string(DOUBLE time, BOOL show_offset, int offset,
BOOL
formatAD
=
TRUE
;
WCHAR
week
[
64
],
month
[
64
];
jsstr_t
*
date_str
;
jsstr_t
*
date_
js
str
;
int
len
,
size
,
year
,
day
;
DWORD
lcid_en
;
WCHAR
sign
=
'-'
;
...
...
@@ -504,6 +504,8 @@ static inline HRESULT date_to_string(DOUBLE time, BOOL show_offset, int offset,
}
if
(
r
)
{
WCHAR
*
date_str
;
len
=
21
;
lcid_en
=
MAKELCID
(
MAKELANGID
(
LANG_ENGLISH
,
SUBLANG_ENGLISH_US
),
SORT_DEFAULT
);
...
...
@@ -544,25 +546,25 @@ static inline HRESULT date_to_string(DOUBLE time, BOOL show_offset, int offset,
offset
=
-
offset
;
}
date_str
=
jsstr_alloc_buf
(
len
);
date_str
=
jsstr_alloc_buf
(
len
,
&
date_jsstr
);
if
(
!
date_str
)
return
E_OUTOFMEMORY
;
if
(
!
show_offset
)
sprintfW
(
date_str
->
str
,
formatNoOffsetW
,
week
,
month
,
day
,
sprintfW
(
date_str
,
formatNoOffsetW
,
week
,
month
,
day
,
(
int
)
hour_from_time
(
time
),
(
int
)
min_from_time
(
time
),
(
int
)
sec_from_time
(
time
),
year
,
formatAD
?
ADW
:
BCW
);
else
if
(
offset
)
sprintfW
(
date_str
->
str
,
formatW
,
week
,
month
,
day
,
sprintfW
(
date_str
,
formatW
,
week
,
month
,
day
,
(
int
)
hour_from_time
(
time
),
(
int
)
min_from_time
(
time
),
(
int
)
sec_from_time
(
time
),
sign
,
offset
/
60
,
offset
%
60
,
year
,
formatAD
?
ADW
:
BCW
);
else
sprintfW
(
date_str
->
str
,
formatUTCW
,
week
,
month
,
day
,
sprintfW
(
date_str
,
formatUTCW
,
week
,
month
,
day
,
(
int
)
hour_from_time
(
time
),
(
int
)
min_from_time
(
time
),
(
int
)
sec_from_time
(
time
),
year
,
formatAD
?
ADW
:
BCW
);
*
r
=
jsval_string
(
date_str
);
*
r
=
jsval_string
(
date_
js
str
);
}
return
S_OK
;
}
...
...
@@ -618,14 +620,18 @@ static HRESULT Date_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
return
dateobj_to_string
(
date
,
r
);
if
(
r
)
{
WCHAR
*
ptr
;
date_len
=
GetDateFormatW
(
ctx
->
lcid
,
DATE_LONGDATE
,
&
st
,
NULL
,
NULL
,
0
);
time_len
=
GetTimeFormatW
(
ctx
->
lcid
,
0
,
&
st
,
NULL
,
NULL
,
0
);
date_str
=
jsstr_alloc_buf
(
date_len
+
time_len
-
1
);
ptr
=
jsstr_alloc_buf
(
date_len
+
time_len
-
1
,
&
date_str
);
if
(
!
date_str
)
return
E_OUTOFMEMORY
;
GetDateFormatW
(
ctx
->
lcid
,
DATE_LONGDATE
,
&
st
,
NULL
,
date_str
->
str
,
date_len
);
GetTimeFormatW
(
ctx
->
lcid
,
0
,
&
st
,
NULL
,
date_str
->
str
+
date_len
,
time_len
);
date_str
->
str
[
date_len
-
1
]
=
' '
;
GetDateFormatW
(
ctx
->
lcid
,
DATE_LONGDATE
,
&
st
,
NULL
,
ptr
,
date_len
);
GetTimeFormatW
(
ctx
->
lcid
,
0
,
&
st
,
NULL
,
ptr
+
date_len
,
time_len
);
ptr
[
date_len
-
1
]
=
' '
;
*
r
=
jsval_string
(
date_str
);
}
...
...
@@ -681,6 +687,8 @@ static inline HRESULT create_utc_string(script_ctx_t *ctx, vdisp_t *jsthis, jsva
}
if
(
r
)
{
WCHAR
*
ptr
;
len
=
17
;
lcid_en
=
MAKELCID
(
MAKELANGID
(
LANG_ENGLISH
,
SUBLANG_ENGLISH_US
),
SORT_DEFAULT
);
...
...
@@ -713,11 +721,11 @@ static inline HRESULT create_utc_string(script_ctx_t *ctx, vdisp_t *jsthis, jsva
}
while
(
day
);
day
=
date_from_time
(
date
->
time
);
date_str
=
jsstr_alloc_buf
(
len
);
ptr
=
jsstr_alloc_buf
(
len
,
&
date_str
);
if
(
!
date_str
)
return
E_OUTOFMEMORY
;
sprintfW
(
date_str
->
s
tr
,
formatAD
?
formatADW
:
formatBCW
,
week
,
day
,
month
,
year
,
sprintfW
(
p
tr
,
formatAD
?
formatADW
:
formatBCW
,
week
,
day
,
month
,
year
,
(
int
)
hour_from_time
(
date
->
time
),
(
int
)
min_from_time
(
date
->
time
),
(
int
)
sec_from_time
(
date
->
time
));
...
...
@@ -773,6 +781,8 @@ static HRESULT dateobj_to_date_string(DateInstance *date, jsval_t *r)
time
=
local_time
(
date
->
time
,
date
);
if
(
r
)
{
WCHAR
*
ptr
;
len
=
5
;
lcid_en
=
MAKELCID
(
MAKELANGID
(
LANG_ENGLISH
,
SUBLANG_ENGLISH_US
),
SORT_DEFAULT
);
...
...
@@ -807,10 +817,10 @@ static HRESULT dateobj_to_date_string(DateInstance *date, jsval_t *r)
}
while
(
day
);
day
=
date_from_time
(
time
);
date_str
=
jsstr_alloc_buf
(
len
);
if
(
!
date_s
tr
)
ptr
=
jsstr_alloc_buf
(
len
,
&
date_str
);
if
(
!
p
tr
)
return
E_OUTOFMEMORY
;
sprintfW
(
date_str
->
s
tr
,
formatAD
?
formatADW
:
formatBCW
,
week
,
month
,
day
,
year
);
sprintfW
(
p
tr
,
formatAD
?
formatADW
:
formatBCW
,
week
,
month
,
day
,
year
);
*
r
=
jsval_string
(
date_str
);
}
...
...
@@ -856,7 +866,9 @@ static HRESULT Date_toTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
time
=
local_time
(
date
->
time
,
date
);
if
(
r
)
{
date_str
=
jsstr_alloc_buf
(
17
);
WCHAR
*
ptr
;
ptr
=
jsstr_alloc_buf
(
17
,
&
date_str
);
if
(
!
date_str
)
return
E_OUTOFMEMORY
;
...
...
@@ -870,11 +882,11 @@ static HRESULT Date_toTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
else
sign
=
'-'
;
if
(
offset
)
sprintfW
(
date_str
->
s
tr
,
formatW
,
(
int
)
hour_from_time
(
time
),
sprintfW
(
p
tr
,
formatW
,
(
int
)
hour_from_time
(
time
),
(
int
)
min_from_time
(
time
),
(
int
)
sec_from_time
(
time
),
sign
,
offset
/
60
,
offset
%
60
);
else
sprintfW
(
date_str
->
s
tr
,
formatUTCW
,
(
int
)
hour_from_time
(
time
),
sprintfW
(
p
tr
,
formatUTCW
,
(
int
)
hour_from_time
(
time
),
(
int
)
min_from_time
(
time
),
(
int
)
sec_from_time
(
time
));
*
r
=
jsval_string
(
date_str
);
...
...
@@ -908,11 +920,13 @@ static HRESULT Date_toLocaleDateString(script_ctx_t *ctx, vdisp_t *jsthis, WORD
return
dateobj_to_date_string
(
date
,
r
);
if
(
r
)
{
WCHAR
*
ptr
;
len
=
GetDateFormatW
(
ctx
->
lcid
,
DATE_LONGDATE
,
&
st
,
NULL
,
NULL
,
0
);
date_str
=
jsstr_alloc_buf
(
len
);
if
(
!
date_s
tr
)
ptr
=
jsstr_alloc_buf
(
len
,
&
date_str
);
if
(
!
p
tr
)
return
E_OUTOFMEMORY
;
GetDateFormatW
(
ctx
->
lcid
,
DATE_LONGDATE
,
&
st
,
NULL
,
date_str
->
s
tr
,
len
);
GetDateFormatW
(
ctx
->
lcid
,
DATE_LONGDATE
,
&
st
,
NULL
,
p
tr
,
len
);
*
r
=
jsval_string
(
date_str
);
}
...
...
@@ -945,11 +959,13 @@ static HRESULT Date_toLocaleTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD
return
Date_toTimeString
(
ctx
,
jsthis
,
flags
,
argc
,
argv
,
r
);
if
(
r
)
{
WCHAR
*
ptr
;
len
=
GetTimeFormatW
(
ctx
->
lcid
,
0
,
&
st
,
NULL
,
NULL
,
0
);
date_str
=
jsstr_alloc_buf
(
len
);
if
(
!
date_s
tr
)
ptr
=
jsstr_alloc_buf
(
len
,
&
date_str
);
if
(
!
p
tr
)
return
E_OUTOFMEMORY
;
GetTimeFormatW
(
ctx
->
lcid
,
0
,
&
st
,
NULL
,
date_str
->
s
tr
,
len
);
GetTimeFormatW
(
ctx
->
lcid
,
0
,
&
st
,
NULL
,
p
tr
,
len
);
*
r
=
jsval_string
(
date_str
);
}
...
...
dlls/jscript/engine.c
View file @
4ece40f8
...
...
@@ -2001,11 +2001,11 @@ static HRESULT interp_eq2(exec_ctx_t *ctx)
BOOL
b
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
r
=
stack_pop
(
ctx
);
l
=
stack_pop
(
ctx
);
TRACE
(
"%s === %s
\n
"
,
debugstr_jsval
(
l
),
debugstr_jsval
(
r
));
hres
=
equal2_values
(
r
,
l
,
&
b
);
jsval_release
(
l
);
jsval_release
(
r
);
...
...
dlls/jscript/error.c
View file @
4ece40f8
...
...
@@ -83,12 +83,16 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
unsigned
msg_len
=
msg
?
jsstr_length
(
msg
)
:
0
;
if
(
name_len
&&
msg_len
)
{
ret
=
jsstr_alloc_buf
(
name_len
+
msg_len
+
2
);
if
(
ret
)
{
jsstr_flush
(
name
,
ret
->
str
);
ret
->
str
[
name_len
]
=
':'
;
ret
->
str
[
name_len
+
1
]
=
' '
;
jsstr_flush
(
msg
,
ret
->
str
+
name_len
+
2
);
WCHAR
*
ptr
;
ptr
=
jsstr_alloc_buf
(
name_len
+
msg_len
+
2
,
&
ret
);
if
(
ptr
)
{
jsstr_flush
(
name
,
ptr
);
ptr
[
name_len
]
=
':'
;
ptr
[
name_len
+
1
]
=
' '
;
jsstr_flush
(
msg
,
ptr
+
name_len
+
2
);
}
else
{
hres
=
E_OUTOFMEMORY
;
}
}
else
if
(
name_len
)
{
ret
=
name
;
...
...
dlls/jscript/function.c
View file @
4ece40f8
...
...
@@ -318,15 +318,16 @@ static HRESULT function_to_string(FunctionInstance *function, jsstr_t **ret)
if
(
function
->
value_proc
)
{
DWORD
name_len
;
WCHAR
*
ptr
;
name_len
=
strlenW
(
function
->
name
);
str
=
jsstr_alloc_buf
((
sizeof
(
native_prefixW
)
+
sizeof
(
native_suffixW
))
/
sizeof
(
WCHAR
)
+
name_len
);
if
(
!
s
tr
)
ptr
=
jsstr_alloc_buf
((
sizeof
(
native_prefixW
)
+
sizeof
(
native_suffixW
))
/
sizeof
(
WCHAR
)
+
name_len
,
&
str
);
if
(
!
p
tr
)
return
E_OUTOFMEMORY
;
memcpy
(
str
->
s
tr
,
native_prefixW
,
sizeof
(
native_prefixW
));
memcpy
(
str
->
str
+
sizeof
(
native_prefixW
)
/
sizeof
(
WCHAR
),
function
->
name
,
name_len
*
sizeof
(
WCHAR
));
memcpy
(
str
->
str
+
sizeof
(
native_prefixW
)
/
sizeof
(
WCHAR
)
+
name_len
,
native_suffixW
,
sizeof
(
native_suffixW
));
memcpy
(
p
tr
,
native_prefixW
,
sizeof
(
native_prefixW
));
memcpy
(
ptr
+=
sizeof
(
native_prefixW
)
/
sizeof
(
WCHAR
),
function
->
name
,
name_len
*
sizeof
(
WCHAR
));
memcpy
(
ptr
+
name_len
,
native_suffixW
,
sizeof
(
native_suffixW
));
}
else
{
str
=
jsstr_alloc_len
(
function
->
func_code
->
source
,
function
->
func_code
->
source_len
);
if
(
!
str
)
...
...
dlls/jscript/global.c
View file @
4ece40f8
...
...
@@ -304,14 +304,13 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
len
+=
3
;
}
ret
_str
=
jsstr_alloc_buf
(
len
);
if
(
!
ret
_str
)
{
ret
=
jsstr_alloc_buf
(
len
,
&
ret_str
);
if
(
!
ret
)
{
jsstr_release
(
str
);
return
E_OUTOFMEMORY
;
}
len
=
0
;
ret
=
ret_str
->
str
;
for
(
ptr
=
str
->
str
;
*
ptr
;
ptr
++
)
{
if
(
*
ptr
>
0xff
)
{
ret
[
len
++
]
=
'%'
;
...
...
@@ -655,13 +654,12 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
len
++
;
}
ret
_str
=
jsstr_alloc_buf
(
len
);
if
(
!
ret
_str
)
{
ret
=
jsstr_alloc_buf
(
len
,
&
ret_str
);
if
(
!
ret
)
{
jsstr_release
(
str
);
return
E_OUTOFMEMORY
;
}
ret
=
ret_str
->
str
;
len
=
0
;
for
(
ptr
=
str
->
str
;
*
ptr
;
ptr
++
)
{
if
(
*
ptr
==
'%'
)
{
...
...
@@ -793,12 +791,11 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
}
}
r
et
=
jsstr_alloc_buf
(
len
);
if
(
!
r
et
)
{
r
ptr
=
jsstr_alloc_buf
(
len
,
&
ret
);
if
(
!
r
ptr
)
{
jsstr_release
(
str
);
return
E_OUTOFMEMORY
;
}
rptr
=
ret
->
str
;
for
(
ptr
=
str
->
str
;
*
ptr
;
ptr
++
)
{
if
(
is_uri_unescaped
(
*
ptr
)
||
is_uri_reserved
(
*
ptr
)
||
*
ptr
==
'#'
)
{
...
...
@@ -826,9 +823,10 @@ 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
)
{
jsstr_t
*
str
,
*
ret
;
WCHAR
*
ptr
;
int
i
,
len
=
0
,
val
,
res
;
jsstr_t
*
str
,
*
ret_str
;
unsigned
len
=
0
;
WCHAR
*
ptr
,
*
ret
;
int
i
,
val
,
res
;
char
buf
[
4
];
WCHAR
out
;
HRESULT
hres
;
...
...
@@ -871,17 +869,15 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
}
}
ret
=
jsstr_alloc_buf
(
len
);
ret
=
jsstr_alloc_buf
(
len
,
&
ret_str
);
if
(
!
ret
)
{
jsstr_release
(
str
);
return
E_OUTOFMEMORY
;
}
len
=
0
;
for
(
ptr
=
str
->
str
;
*
ptr
;
ptr
++
)
{
if
(
*
ptr
!=
'%'
)
{
ret
->
str
[
len
]
=
*
ptr
;
len
++
;
*
ret
++
=
*
ptr
;
}
else
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
if
(
ptr
[
i
*
3
]
!=
'%'
||
hex_to_int
(
ptr
[
i
*
3
+
1
])
==-
1
||
(
val
=
hex_to_int
(
ptr
[
i
*
3
+
2
]))
==-
1
)
...
...
@@ -889,33 +885,34 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
val
+=
hex_to_int
(
ptr
[
i
*
3
+
1
])
<<
4
;
buf
[
i
]
=
val
;
res
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
buf
,
i
+
1
,
ret
->
str
+
len
,
1
);
res
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
buf
,
i
+
1
,
ret
,
1
);
if
(
res
)
break
;
}
ptr
+=
i
*
3
+
2
;
len
++
;
ret
++
;
}
}
TRACE
(
"%s -> %s
\n
"
,
debugstr_jsstr
(
str
),
debugstr_jsstr
(
ret
));
TRACE
(
"%s -> %s
\n
"
,
debugstr_jsstr
(
str
),
debugstr_jsstr
(
ret
_str
));
jsstr_release
(
str
);
if
(
r
)
*
r
=
jsval_string
(
ret
);
*
r
=
jsval_string
(
ret
_str
);
else
jsstr_release
(
ret
);
jsstr_release
(
ret
_str
);
return
S_OK
;
}
static
HRESULT
JSGlobal_encodeURIComponent
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
jsstr_t
*
str
,
*
ret
;
jsstr_t
*
str
,
*
ret
_str
;
char
buf
[
4
];
const
WCHAR
*
ptr
;
DWORD
len
=
0
,
size
,
i
;
WCHAR
*
ret
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
...
...
@@ -943,22 +940,21 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
}
}
ret
=
jsstr_alloc_buf
(
len
);
ret
=
jsstr_alloc_buf
(
len
,
&
ret_str
);
if
(
!
ret
)
{
jsstr_release
(
str
);
return
E_OUTOFMEMORY
;
}
len
=
0
;
for
(
ptr
=
str
->
str
;
*
ptr
;
ptr
++
)
{
if
(
is_uri_unescaped
(
*
ptr
))
{
ret
->
str
[
len
++
]
=
*
ptr
;
*
ret
++
=
*
ptr
;
}
else
{
size
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
ptr
,
1
,
buf
,
sizeof
(
buf
),
NULL
,
NULL
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
ret
->
str
[
len
++
]
=
'%'
;
ret
->
str
[
len
++
]
=
int_to_char
((
BYTE
)
buf
[
i
]
>>
4
);
ret
->
str
[
len
++
]
=
int_to_char
(
buf
[
i
]
&
0x0f
);
*
ret
++
=
'%'
;
*
ret
++
=
int_to_char
((
BYTE
)
buf
[
i
]
>>
4
);
*
ret
++
=
int_to_char
(
buf
[
i
]
&
0x0f
);
}
}
}
...
...
@@ -966,9 +962,9 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
jsstr_release
(
str
);
if
(
r
)
*
r
=
jsval_string
(
ret
);
*
r
=
jsval_string
(
ret
_str
);
else
jsstr_release
(
ret
);
jsstr_release
(
ret
_str
);
return
S_OK
;
}
...
...
@@ -1044,12 +1040,11 @@ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
}
}
ret
=
jsstr_alloc_buf
(
len
);
out_ptr
=
jsstr_alloc_buf
(
len
,
&
ret
);
if
(
!
ret
)
{
jsstr_release
(
str
);
return
E_OUTOFMEMORY
;
}
out_ptr
=
ret
->
str
;
ptr
=
str
->
str
;
while
(
*
ptr
)
{
...
...
dlls/jscript/jsstr.c
View file @
4ece40f8
...
...
@@ -25,7 +25,7 @@ const char *debugstr_jsstr(jsstr_t *str)
return
debugstr_wn
(
str
->
str
,
jsstr_length
(
str
));
}
jsstr_t
*
jsstr_alloc_buf
(
unsigned
len
)
WCHAR
*
jsstr_alloc_buf
(
unsigned
len
,
jsstr_t
**
r
)
{
jsstr_t
*
ret
;
...
...
@@ -39,16 +39,18 @@ jsstr_t *jsstr_alloc_buf(unsigned len)
ret
->
length_flags
=
len
<<
JSSTR_LENGTH_SHIFT
;
ret
->
ref
=
1
;
ret
->
str
[
len
]
=
0
;
return
ret
;
*
r
=
ret
;
return
ret
->
str
;
}
jsstr_t
*
jsstr_alloc_len
(
const
WCHAR
*
buf
,
unsigned
len
)
{
jsstr_t
*
ret
;
WCHAR
*
ptr
;
ret
=
jsstr_alloc_buf
(
len
);
if
(
ret
)
memcpy
(
ret
->
s
tr
,
buf
,
len
*
sizeof
(
WCHAR
));
ptr
=
jsstr_alloc_buf
(
len
,
&
ret
);
if
(
ptr
)
memcpy
(
p
tr
,
buf
,
len
*
sizeof
(
WCHAR
));
return
ret
;
}
...
...
@@ -70,6 +72,7 @@ jsstr_t *jsstr_concat(jsstr_t *str1, jsstr_t *str2)
{
unsigned
len1
,
len2
;
jsstr_t
*
ret
;
WCHAR
*
ptr
;
len1
=
jsstr_length
(
str1
);
if
(
!
len1
)
...
...
@@ -79,12 +82,12 @@ jsstr_t *jsstr_concat(jsstr_t *str1, jsstr_t *str2)
if
(
!
len2
)
return
jsstr_addref
(
str1
);
ret
=
jsstr_alloc_buf
(
len1
+
len2
);
ptr
=
jsstr_alloc_buf
(
len1
+
len2
,
&
ret
);
if
(
!
ret
)
return
NULL
;
jsstr_flush
(
str1
,
ret
->
s
tr
);
jsstr_flush
(
str2
,
ret
->
s
tr
+
len1
);
jsstr_flush
(
str1
,
p
tr
);
jsstr_flush
(
str2
,
p
tr
+
len1
);
return
ret
;
}
...
...
@@ -110,7 +113,7 @@ BOOL init_strings(void)
static
const
WCHAR
NaNW
[]
=
{
'N'
,
'a'
,
'N'
,
0
};
static
const
WCHAR
undefinedW
[]
=
{
'u'
,
'n'
,
'd'
,
'e'
,
'f'
,
'i'
,
'n'
,
'e'
,
'd'
,
0
};
if
(
!
(
empty_str
=
jsstr_alloc_buf
(
0
)
))
if
(
!
jsstr_alloc_buf
(
0
,
&
empty_str
))
return
FALSE
;
if
(
!
(
nan_str
=
jsstr_alloc
(
NaNW
)))
return
FALSE
;
...
...
dlls/jscript/jsstr.h
View file @
4ece40f8
...
...
@@ -34,7 +34,7 @@ static inline unsigned jsstr_length(jsstr_t *str)
}
jsstr_t
*
jsstr_alloc_len
(
const
WCHAR
*
,
unsigned
)
DECLSPEC_HIDDEN
;
jsstr_t
*
jsstr_alloc_buf
(
unsigned
)
DECLSPEC_HIDDEN
;
WCHAR
*
jsstr_alloc_buf
(
unsigned
,
jsstr_t
**
)
DECLSPEC_HIDDEN
;
static
inline
jsstr_t
*
jsstr_alloc
(
const
WCHAR
*
str
)
{
...
...
dlls/jscript/number.c
View file @
4ece40f8
...
...
@@ -125,11 +125,10 @@ static inline jsstr_t *number_to_fixed(double val, int prec)
if
(
prec
)
size
+=
prec
+
1
;
ret
=
jsstr_alloc_buf
(
size
);
str
=
jsstr_alloc_buf
(
size
,
&
ret
);
if
(
!
ret
)
return
NULL
;
str
=
ret
->
str
;
size
=
buf_pos
=
0
;
if
(
neg
)
str
[
size
++
]
=
'-'
;
...
...
@@ -193,11 +192,10 @@ static inline jsstr_t *number_to_exponential(double val, int prec)
if
(
neg
)
size
++
;
ret
=
jsstr_alloc_buf
(
size
);
str
=
jsstr_alloc_buf
(
size
,
&
ret
);
if
(
!
ret
)
return
NULL
;
str
=
ret
->
str
;
size
=
0
;
pbuf
=
buf
;
if
(
neg
)
...
...
dlls/jscript/object.c
View file @
4ece40f8
...
...
@@ -71,12 +71,13 @@ static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
if
(
r
)
{
jsstr_t
*
ret
;
WCHAR
*
ptr
;
ret
=
jsstr_alloc_buf
(
9
+
strlenW
(
str
)
);
if
(
!
ret
)
ptr
=
jsstr_alloc_buf
(
9
+
strlenW
(
str
),
&
ret
);
if
(
!
ptr
)
return
E_OUTOFMEMORY
;
sprintfW
(
ret
->
s
tr
,
formatW
,
str
);
sprintfW
(
p
tr
,
formatW
,
str
);
*
r
=
jsval_string
(
ret
);
}
...
...
dlls/jscript/string.c
View file @
4ece40f8
...
...
@@ -160,13 +160,12 @@ static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, j
tagname_len
=
strlenW
(
tagname
);
ret
=
jsstr_alloc_buf
(
jsstr_length
(
str
)
+
2
*
tagname_len
+
5
);
ptr
=
jsstr_alloc_buf
(
jsstr_length
(
str
)
+
2
*
tagname_len
+
5
,
&
ret
);
if
(
!
ret
)
{
jsstr_release
(
str
);
return
E_OUTOFMEMORY
;
}
ptr
=
ret
->
str
;
*
ptr
++
=
'<'
;
memcpy
(
ptr
,
tagname
,
tagname_len
*
sizeof
(
WCHAR
));
ptr
+=
tagname_len
;
...
...
@@ -209,11 +208,10 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
unsigned
attrname_len
=
strlenW
(
attrname
);
unsigned
tagname_len
=
strlenW
(
tagname
);
jsstr_t
*
ret
;
WCHAR
*
ptr
;
ret
=
jsstr_alloc_buf
(
2
*
tagname_len
+
attrname_len
+
jsstr_length
(
attr_value
)
+
jsstr_length
(
str
)
+
9
);
if
(
ret
)
{
WCHAR
*
ptr
=
ret
->
str
;
ptr
=
jsstr_alloc_buf
(
2
*
tagname_len
+
attrname_len
+
jsstr_length
(
attr_value
)
+
jsstr_length
(
str
)
+
9
,
&
ret
);
if
(
ptr
)
{
*
ptr
++
=
'<'
;
memcpy
(
ptr
,
tagname
,
tagname_len
*
sizeof
(
WCHAR
));
ptr
+=
tagname_len
;
...
...
@@ -390,9 +388,8 @@ static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
}
}
ret
=
jsstr_alloc_buf
(
len
);
if
(
ret
)
{
ptr
=
ret
->
str
;
ptr
=
jsstr_alloc_buf
(
len
,
&
ret
);
if
(
ptr
)
{
for
(
i
=
0
;
i
<
str_cnt
;
i
++
)
ptr
+=
jsstr_flush
(
strs
[
i
],
ptr
);
}
else
{
...
...
@@ -1337,15 +1334,16 @@ static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if
(
r
)
{
jsstr_t
*
ret
;
WCHAR
*
buf
;
ret
=
jsstr_alloc_buf
(
jsstr_length
(
str
)
);
if
(
!
ret
)
{
buf
=
jsstr_alloc_buf
(
jsstr_length
(
str
),
&
ret
);
if
(
!
buf
)
{
jsstr_release
(
str
);
return
E_OUTOFMEMORY
;
}
jsstr_flush
(
str
,
ret
->
str
);
strlwrW
(
ret
->
str
);
jsstr_flush
(
str
,
buf
);
strlwrW
(
buf
);
*
r
=
jsval_string
(
ret
);
}
jsstr_release
(
str
);
...
...
@@ -1366,15 +1364,16 @@ static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if
(
r
)
{
jsstr_t
*
ret
;
WCHAR
*
buf
;
ret
=
jsstr_alloc_buf
(
jsstr_length
(
str
)
);
if
(
!
ret
)
{
buf
=
jsstr_alloc_buf
(
jsstr_length
(
str
),
&
ret
);
if
(
!
buf
)
{
jsstr_release
(
str
);
return
E_OUTOFMEMORY
;
}
jsstr_flush
(
str
,
ret
->
str
);
struprW
(
ret
->
str
);
jsstr_flush
(
str
,
buf
);
struprW
(
buf
);
*
r
=
jsval_string
(
ret
);
}
jsstr_release
(
str
);
...
...
@@ -1525,14 +1524,15 @@ static const builtin_info_t StringInst_info = {
static
HRESULT
StringConstr_fromCharCode
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
WCHAR
*
ret_str
;
DWORD
i
,
code
;
jsstr_t
*
ret
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
ret
=
jsstr_alloc_buf
(
argc
);
if
(
!
ret
)
ret
_str
=
jsstr_alloc_buf
(
argc
,
&
ret
);
if
(
!
ret
_str
)
return
E_OUTOFMEMORY
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
...
...
@@ -1542,7 +1542,7 @@ static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WOR
return
hres
;
}
ret
->
str
[
i
]
=
code
;
ret
_
str
[
i
]
=
code
;
}
if
(
r
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment