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
56bf46fd
Commit
56bf46fd
authored
May 03, 2012
by
Jacek Caban
Committed by
Alexandre Julliard
May 03, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Return double from to_integer.
parent
e26a3018
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
55 deletions
+26
-55
array.c
dlls/jscript/array.c
+3
-5
jscript.h
dlls/jscript/jscript.h
+1
-1
jsutils.c
dlls/jscript/jsutils.c
+6
-9
string.c
dlls/jscript/string.c
+16
-40
No files found.
dlls/jscript/array.c
View file @
56bf46fd
...
...
@@ -853,9 +853,9 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP
{
DWORD
length
,
start
=
0
,
delete_cnt
=
0
,
argc
,
i
,
add_args
=
0
;
jsdisp_t
*
ret_array
=
NULL
,
*
jsthis
;
VARIANT
v
;
double
d
;
int
n
;
VARIANT
v
;
HRESULT
hres
=
S_OK
;
TRACE
(
"
\n
"
);
...
...
@@ -866,10 +866,9 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP
argc
=
arg_cnt
(
dp
);
if
(
argc
>=
1
)
{
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
v
);
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
d
);
if
(
FAILED
(
hres
))
return
hres
;
d
=
num_val
(
&
v
);
if
(
is_int32
(
d
))
{
if
((
n
=
d
)
>=
0
)
...
...
@@ -882,10 +881,9 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP
}
if
(
argc
>=
2
)
{
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
v
);
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
d
);
if
(
FAILED
(
hres
))
return
hres
;
d
=
num_val
(
&
v
);
if
(
is_int32
(
d
))
{
if
((
n
=
d
)
>
0
)
...
...
dlls/jscript/jscript.h
View file @
56bf46fd
...
...
@@ -254,7 +254,7 @@ typedef enum {
HRESULT
to_primitive
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
VARIANT
*
,
hint_t
)
DECLSPEC_HIDDEN
;
HRESULT
to_boolean
(
VARIANT
*
,
VARIANT_BOOL
*
)
DECLSPEC_HIDDEN
;
HRESULT
to_number
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
double
*
)
DECLSPEC_HIDDEN
;
HRESULT
to_integer
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
VARIANT
*
)
DECLSPEC_HIDDEN
;
HRESULT
to_integer
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
double
*
)
DECLSPEC_HIDDEN
;
HRESULT
to_int32
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
INT
*
)
DECLSPEC_HIDDEN
;
HRESULT
to_uint32
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
DWORD
*
)
DECLSPEC_HIDDEN
;
HRESULT
to_string
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
BSTR
*
)
DECLSPEC_HIDDEN
;
...
...
dlls/jscript/jsutils.c
View file @
56bf46fd
...
...
@@ -457,13 +457,13 @@ HRESULT to_number(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, double *ret)
}
/* ECMA-262 3rd Edition 9.4 */
HRESULT
to_integer
(
script_ctx_t
*
ctx
,
VARIANT
*
v
,
jsexcept_t
*
ei
,
VARIANT
*
ret
)
HRESULT
to_integer
(
script_ctx_t
*
ctx
,
VARIANT
*
v
,
jsexcept_t
*
ei
,
double
*
ret
)
{
double
n
;
HRESULT
hres
;
if
(
V_VT
(
v
)
==
VT_I4
)
{
*
ret
=
*
v
;
*
ret
=
V_I4
(
v
)
;
return
S_OK
;
}
...
...
@@ -471,13 +471,10 @@ HRESULT to_integer(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret)
if
(
FAILED
(
hres
))
return
hres
;
if
(
isnan
(
n
))
{
V_VT
(
ret
)
=
VT_I4
;
V_I4
(
ret
)
=
0
;
}
else
{
num_set_val
(
ret
,
n
>=
0
.
0
?
floor
(
n
)
:
-
floor
(
-
n
));
}
if
(
isnan
(
n
))
*
ret
=
0
;
else
*
ret
=
n
>=
0
.
0
?
floor
(
n
)
:
-
floor
(
-
n
);
return
S_OK
;
}
...
...
dlls/jscript/string.c
View file @
56bf46fd
...
...
@@ -302,15 +302,13 @@ static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
return
hres
;
if
(
arg_cnt
(
dp
))
{
VARIANT
num
;
double
d
;
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
num
);
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
d
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
val_str
);
return
hres
;
}
d
=
num_val
(
&
num
);
pos
=
is_int32
(
d
)
?
d
:
-
1
;
}
...
...
@@ -349,17 +347,14 @@ static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return
hres
;
if
(
arg_cnt
(
dp
)
>
0
)
{
VARIANT
v
;
double
d
;
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
v
);
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
d
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
val_str
);
return
hres
;
}
d
=
num_val
(
&
v
);
if
(
!
is_int32
(
d
)
||
d
<
0
||
d
>=
length
)
{
SysFreeString
(
val_str
);
if
(
retv
)
...
...
@@ -493,15 +488,11 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
}
if
(
arg_cnt
(
dp
)
>=
2
)
{
VARIANT
ival
;
double
d
;
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
ival
);
if
(
SUCCEEDED
(
hres
))
{
d
=
num_val
(
&
ival
);
if
(
d
>
0
.
0
)
pos
=
is_int32
(
d
)
?
min
((
int
)
d
,
length
)
:
length
;
}
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
d
);
if
(
SUCCEEDED
(
hres
)
&&
d
>
0
.
0
)
pos
=
is_int32
(
d
)
?
min
(
length
,
d
)
:
length
;
}
if
(
SUCCEEDED
(
hres
))
{
...
...
@@ -567,15 +558,11 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
search_len
=
SysStringLen
(
search_str
);
if
(
arg_cnt
(
dp
)
>=
2
)
{
VARIANT
ival
;
double
d
;
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
ival
);
if
(
SUCCEEDED
(
hres
))
{
d
=
num_val
(
&
ival
);
if
(
d
>
0
)
pos
=
is_int32
(
d
)
?
min
((
int
)
d
,
length
)
:
length
;
}
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
d
);
if
(
SUCCEEDED
(
hres
)
&&
d
>
0
)
pos
=
is_int32
(
d
)
?
min
(
length
,
d
)
:
length
;
}
else
{
pos
=
length
;
}
...
...
@@ -1072,7 +1059,6 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
DWORD
length
;
INT
start
=
0
,
end
;
double
d
;
VARIANT
v
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
...
...
@@ -1082,14 +1068,12 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
return
hres
;
if
(
arg_cnt
(
dp
))
{
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
v
);
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
d
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
val_str
);
return
hres
;
}
d
=
num_val
(
&
v
);
if
(
is_int32
(
d
))
{
start
=
d
;
if
(
start
<
0
)
{
...
...
@@ -1105,14 +1089,12 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
}
if
(
arg_cnt
(
dp
)
>=
2
)
{
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
v
);
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
d
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
val_str
);
return
hres
;
}
d
=
num_val
(
&
v
);
if
(
is_int32
(
d
))
{
end
=
d
;
if
(
end
<
0
)
{
...
...
@@ -1301,7 +1283,6 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
BSTR
val_str
;
INT
start
=
0
,
end
;
DWORD
length
;
VARIANT
v
;
double
d
;
HRESULT
hres
;
...
...
@@ -1312,27 +1293,25 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return
hres
;
if
(
arg_cnt
(
dp
)
>=
1
)
{
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
v
);
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
d
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
val_str
);
return
hres
;
}
d
=
num_val
(
&
v
);
if
(
d
>=
0
)
start
=
is_int32
(
d
)
?
min
(
(
int
)
d
,
length
)
:
length
;
start
=
is_int32
(
d
)
?
min
(
length
,
d
)
:
length
;
}
if
(
arg_cnt
(
dp
)
>=
2
)
{
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
v
);
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
d
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
val_str
);
return
hres
;
}
d
=
num_val
(
&
v
);
if
(
d
>=
0
)
end
=
is_int32
(
d
)
?
min
(
(
int
)
d
,
length
)
:
length
;
end
=
is_int32
(
d
)
?
min
(
length
,
d
)
:
length
;
else
end
=
0
;
}
else
{
...
...
@@ -1365,7 +1344,6 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
const
WCHAR
*
str
;
INT
start
=
0
,
len
;
DWORD
length
;
VARIANT
v
;
double
d
;
HRESULT
hres
;
...
...
@@ -1376,25 +1354,23 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
return
hres
;
if
(
arg_cnt
(
dp
)
>=
1
)
{
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
v
);
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
d
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
val_str
);
return
hres
;
}
d
=
num_val
(
&
v
);
if
(
d
>=
0
)
start
=
is_int32
(
d
)
?
min
(
length
,
d
)
:
length
;
}
if
(
arg_cnt
(
dp
)
>=
2
)
{
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
v
);
hres
=
to_integer
(
ctx
,
get_arg
(
dp
,
1
),
ei
,
&
d
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
val_str
);
return
hres
;
}
d
=
num_val
(
&
v
);
if
(
d
>=
0
.
0
)
len
=
is_int32
(
d
)
?
min
(
length
-
start
,
d
)
:
length
-
start
;
else
...
...
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