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
15dfae71
Commit
15dfae71
authored
Jul 21, 2014
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 21, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vbscript: Use VariantChangeType in to_int.
parent
0eed829f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
41 deletions
+16
-41
global.c
dlls/vbscript/global.c
+13
-41
api.vbs
dlls/vbscript/tests/api.vbs
+3
-0
No files found.
dlls/vbscript/global.c
View file @
15dfae71
...
...
@@ -142,41 +142,15 @@ static inline HRESULT return_date(VARIANT *res, double date)
HRESULT
to_int
(
VARIANT
*
v
,
int
*
ret
)
{
if
(
V_VT
(
v
)
==
(
VT_BYREF
|
VT_VARIANT
))
v
=
V_VARIANTREF
(
v
);
switch
(
V_VT
(
v
))
{
case
VT_I2
:
*
ret
=
V_I2
(
v
);
break
;
case
VT_I4
:
*
ret
=
V_I4
(
v
);
break
;
case
VT_R8
:
{
double
n
=
floor
(
V_R8
(
v
)
+
0
.
5
);
INT32
i
;
if
(
!
is_int32
(
n
))
{
FIXME
(
"%lf is out of int range
\n
"
,
n
);
return
E_FAIL
;
}
/* Round half to even */
i
=
n
;
if
(
i
%
2
&&
n
-
V_R8
(
v
)
==
0
.
5
)
i
--
;
VARIANT
r
;
HRESULT
hres
;
*
ret
=
i
;
break
;
}
case
VT_BOOL
:
*
ret
=
V_BOOL
(
v
)
?
-
1
:
0
;
break
;
default:
FIXME
(
"not supported %s
\n
"
,
debugstr_variant
(
v
));
return
E_NOTIMPL
;
}
V_VT
(
&
r
)
=
VT_EMPTY
;
hres
=
VariantChangeType
(
&
r
,
v
,
0
,
VT_I4
);
if
(
FAILED
(
hres
))
return
hres
;
*
ret
=
V_I4
(
&
r
);
return
S_OK
;
}
...
...
@@ -400,24 +374,22 @@ static HRESULT Global_CInt(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
static
HRESULT
Global_CLng
(
vbdisp_t
*
This
,
VARIANT
*
arg
,
unsigned
args_cnt
,
VARIANT
*
res
)
{
VARIANT
v
;
int
i
;
HRESULT
hres
;
TRACE
(
"%s
\n
"
,
debugstr_variant
(
arg
));
assert
(
args_cnt
==
1
);
V_VT
(
&
v
)
=
VT_EMPTY
;
hres
=
VariantChangeType
(
&
v
,
arg
,
0
,
VT_I4
);
hres
=
to_int
(
arg
,
&
i
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
!
res
)
return
DISP_E_BADVARTYPE
;
else
{
*
res
=
v
;
return
S_OK
;
}
V_VT
(
res
)
=
VT_I4
;
V_I4
(
res
)
=
i
;
return
S_OK
;
}
static
HRESULT
Global_CBool
(
vbdisp_t
*
This
,
VARIANT
*
arg
,
unsigned
args_cnt
,
VARIANT
*
res
)
...
...
dlls/vbscript/tests/api.vbs
View file @
15dfae71
...
...
@@ -136,6 +136,7 @@ Call ok(Chr(120) = "x", "Chr(120) = " & Chr(120))
Call
ok
(
Chr
(
0
)
<>
""
,
"Chr(0) =
""""
"
)
Call
ok
(
Chr
(
120.5
)
=
"x"
,
"Chr(120.5) = "
&
Chr
(
120.5
))
Call
ok
(
Chr
(
119.5
)
=
"x"
,
"Chr(119.5) = "
&
Chr
(
119.5
))
Call
ok
(
Chr
(
"120"
)
=
"x"
,
"Chr(
""
120
""
) = "
&
Chr
(
"120"
))
sub
testChrError
on
error
resume
next
...
...
@@ -321,6 +322,7 @@ Call ok(Space(5.5) = " ", "Space(5.5) = " & Space(5.5) & """")
Call
ok
(
Space
(
4.5
)
=
" "
,
"Space(4.5) = "
&
Space
(
4.5
)
&
"
""
"
)
Call
ok
(
Space
(
0.5
)
=
""
,
"Space(0.5) = "
&
Space
(
0.5
)
&
"
""
"
)
Call
ok
(
Space
(
1.5
)
=
" "
,
"Space(1.5) = "
&
Space
(
1.5
)
&
"
""
"
)
Call
ok
(
Space
(
"1"
)
=
" "
,
"Space(
""
1
""
) = "
&
Space
(
"1"
)
&
"
""
"
)
Sub
TestStrReverse
(
str
,
ex
)
Call
ok
(
StrReverse
(
str
)
=
ex
,
"StrReverse("
&
str
&
") = "
&
StrReverse
(
str
))
...
...
@@ -341,6 +343,7 @@ TestLeft "test", 0, ""
TestLeft
123
,
2
,
"12"
TestLeft
"123456"
,
1.5
,
"12"
TestLeft
"123456"
,
2.5
,
"12"
TestLeft
"test"
,
"2"
,
"te"
if
isEnglishLang
then
TestLeft
true
,
2
,
"Tr"
Sub
TestRight
(
str
,
len
,
ex
)
...
...
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