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
04e9b16c
Commit
04e9b16c
authored
Feb 28, 2011
by
Jacek Caban
Committed by
Alexandre Julliard
Feb 28, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Fixed corner cases in parseInt implementation.
parent
90da8b74
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
17 deletions
+70
-17
global.c
dlls/jscript/global.c
+28
-17
api.js
dlls/jscript/tests/api.js
+42
-0
No files found.
dlls/jscript/global.c
View file @
04e9b16c
...
@@ -450,10 +450,10 @@ static INT char_to_int(WCHAR c)
...
@@ -450,10 +450,10 @@ static INT char_to_int(WCHAR c)
static
HRESULT
JSGlobal_parseInt
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
DISPPARAMS
*
dp
,
static
HRESULT
JSGlobal_parseInt
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
{
BOOL
neg
=
FALSE
,
empty
=
TRUE
;
DOUBLE
ret
=
0
.
0
;
DOUBLE
ret
=
0
.
0
;
INT
radix
=
1
0
,
i
;
INT
radix
=
0
,
i
;
WCHAR
*
ptr
;
WCHAR
*
ptr
;
BOOL
neg
=
FALSE
;
BSTR
str
;
BSTR
str
;
HRESULT
hres
;
HRESULT
hres
;
...
@@ -467,11 +467,11 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
...
@@ -467,11 +467,11 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
if
(
FAILED
(
hres
))
if
(
FAILED
(
hres
))
return
hres
;
return
hres
;
if
(
!
radix
)
{
if
(
radix
&&
(
radix
<
2
||
radix
>
36
))
{
radix
=
10
;
}
else
if
(
radix
<
2
||
radix
>
36
)
{
WARN
(
"radix %d out of range
\n
"
,
radix
);
WARN
(
"radix %d out of range
\n
"
,
radix
);
return
E_FAIL
;
if
(
retv
)
num_set_nan
(
retv
);
return
S_OK
;
}
}
}
}
...
@@ -489,20 +489,31 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
...
@@ -489,20 +489,31 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
neg
=
TRUE
;
neg
=
TRUE
;
ptr
++
;
ptr
++
;
break
;
break
;
case
'0'
:
ptr
++
;
if
(
*
ptr
==
'x'
||
*
ptr
==
'X'
)
{
radix
=
16
;
ptr
++
;
}
}
}
while
(
*
ptr
)
{
if
(
!
radix
)
{
i
=
char_to_int
(
*
ptr
++
);
if
(
*
ptr
==
'0'
)
{
if
(
i
>
radix
)
if
(
ptr
[
1
]
==
'x'
||
ptr
[
1
]
==
'X'
)
{
break
;
radix
=
16
;
ptr
+=
2
;
}
else
{
radix
=
8
;
ptr
++
;
empty
=
FALSE
;
}
}
else
{
radix
=
10
;
}
}
ret
=
ret
*
radix
+
i
;
i
=
char_to_int
(
*
ptr
++
);
if
(
i
<
radix
)
{
do
{
ret
=
ret
*
radix
+
i
;
i
=
char_to_int
(
*
ptr
++
);
}
while
(
i
<
radix
);
}
else
if
(
empty
)
{
ret
=
ret_nan
();
}
}
SysFreeString
(
str
);
SysFreeString
(
str
);
...
...
dlls/jscript/tests/api.js
View file @
04e9b16c
...
@@ -42,6 +42,48 @@ i = parseInt("123", 10, "test");
...
@@ -42,6 +42,48 @@ i = parseInt("123", 10, "test");
ok
(
i
===
123
,
"parseInt('123', 10, 'test') = "
+
i
);
ok
(
i
===
123
,
"parseInt('123', 10, 'test') = "
+
i
);
i
=
parseInt
(
"11"
,
"8"
);
i
=
parseInt
(
"11"
,
"8"
);
ok
(
i
===
9
,
"parseInt('11', '8') = "
+
i
);
ok
(
i
===
9
,
"parseInt('11', '8') = "
+
i
);
i
=
parseInt
(
"010"
);
ok
(
i
===
8
,
"parseInt('010') = "
+
i
);
i
=
parseInt
(
""
);
ok
(
isNaN
(
i
),
"parseInt('') = "
+
i
);
i
=
parseInt
(
"0x"
);
ok
(
isNaN
(
i
),
"parseInt('0x') = "
+
i
);
i
=
parseInt
(
"+"
);
ok
(
isNaN
(
i
),
"parseInt('+') = "
+
i
);
i
=
parseInt
(
"-"
);
ok
(
isNaN
(
i
),
"parseInt('-') = "
+
i
);
i
=
parseInt
(
"0x10"
,
11
);
ok
(
i
===
0
,
"parseInt('0x10', 11) = "
+
i
);
i
=
parseInt
(
"010"
,
7
);
ok
(
i
===
7
,
"parseInt('010', 7) = "
+
i
);
i
=
parseInt
(
"123abc"
);
ok
(
i
===
123
,
"parseInt('123abc') = "
+
i
);
i
=
parseInt
(
"
\
t123abc"
);
ok
(
i
===
123
,
"parseInt('
\\
t123abc') = "
+
i
);
i
=
parseInt
(
"abc"
);
ok
(
isNaN
(
i
),
"parseInt('123abc') = "
+
i
);
i
=
parseInt
(
"-12"
,
11
);
ok
(
i
===
-
13
,
"parseInt('-12') = "
+
i
);
i
=
parseInt
(
"-0x10"
);
ok
(
i
===
-
16
,
"parseInt('-0x10') = "
+
i
);
i
=
parseInt
(
"-010"
);
ok
(
i
===
-
8
,
"parseInt('-010') = "
+
i
);
i
=
parseInt
(
"123"
,
0
);
ok
(
i
===
123
,
"parseInt('123', 0) = "
+
i
);
i
=
parseInt
(
"0x10"
,
0
);
ok
(
i
===
16
,
"parseInt('123', 0) = "
+
i
);
i
=
parseInt
(
"0x10"
,
10
);
ok
(
i
===
0
,
"parseInt('0x10', 10) = "
+
i
);
i
=
parseInt
(
"0xz"
);
ok
(
isNaN
(
i
),
"parseInt('0xz') = "
+
i
);
i
=
parseInt
(
"1"
,
1
);
ok
(
isNaN
(
i
),
"parseInt('1', 1) = "
+
i
);
i
=
parseInt
(
"1"
,
-
1
);
ok
(
isNaN
(
i
),
"parseInt('1', -1) = "
+
i
);
i
=
parseInt
(
"1"
,
37
);
ok
(
isNaN
(
i
),
"parseInt('1', 37) = "
+
i
);
i
=
parseInt
(
"1"
,
36
);
ok
(
i
===
1
,
"parseInt('1', 36) = "
+
i
);
tmp
=
encodeURI
(
"abc"
);
tmp
=
encodeURI
(
"abc"
);
ok
(
tmp
===
"abc"
,
"encodeURI('abc') = "
+
tmp
);
ok
(
tmp
===
"abc"
,
"encodeURI('abc') = "
+
tmp
);
...
...
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