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
3edf1ba2
Commit
3edf1ba2
authored
Aug 05, 2009
by
Piotr Caban
Committed by
Alexandre Julliard
Aug 06, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added JSGlobal_parseFloat implementation.
parent
9d23f8a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
2 deletions
+110
-2
global.c
dlls/jscript/global.c
+100
-2
api.js
dlls/jscript/tests/api.js
+10
-0
No files found.
dlls/jscript/global.c
View file @
3edf1ba2
...
...
@@ -20,6 +20,7 @@
#include "wine/port.h"
#include <math.h>
#include <limits.h>
#include "jscript.h"
#include "engine.h"
...
...
@@ -28,6 +29,8 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
jscript
);
#define LONGLONG_MAX (((LONGLONG)0x7fffffff<<32)|0xffffffff)
static
const
WCHAR
NaNW
[]
=
{
'N'
,
'a'
,
'N'
,
0
};
static
const
WCHAR
InfinityW
[]
=
{
'I'
,
'n'
,
'f'
,
'i'
,
'n'
,
'i'
,
't'
,
'y'
,
0
};
static
const
WCHAR
ArrayW
[]
=
{
'A'
,
'r'
,
'r'
,
'a'
,
'y'
,
0
};
...
...
@@ -474,8 +477,103 @@ static HRESULT JSGlobal_parseInt(DispatchEx *dispex, LCID lcid, WORD flags, DISP
static
HRESULT
JSGlobal_parseFloat
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
FIXME
(
"
\n
"
);
return
E_NOTIMPL
;
LONGLONG
d
=
0
,
hlp
;
int
exp
=
0
,
length
;
VARIANT
*
arg
;
WCHAR
*
str
;
BSTR
val_str
=
NULL
;
BOOL
ret_nan
=
TRUE
,
positive
=
TRUE
;
HRESULT
hres
;
if
(
!
arg_cnt
(
dp
))
{
if
(
retv
)
num_set_nan
(
retv
);
return
S_OK
;
}
arg
=
get_arg
(
dp
,
0
);
hres
=
to_string
(
dispex
->
ctx
,
arg
,
ei
,
&
val_str
);
if
(
FAILED
(
hres
))
return
hres
;
str
=
val_str
;
length
=
SysStringLen
(
val_str
);
while
(
isspaceW
(
*
str
))
str
++
;
if
(
*
str
==
'+'
)
str
++
;
else
if
(
*
str
==
'-'
)
{
positive
=
FALSE
;
str
++
;
}
if
(
isdigitW
(
*
str
))
ret_nan
=
FALSE
;
while
(
isdigitW
(
*
str
))
{
hlp
=
d
*
10
+
*
(
str
++
)
-
'0'
;
if
(
d
>
LONGLONG_MAX
/
10
||
hlp
<
0
)
{
exp
++
;
break
;
}
else
d
=
hlp
;
}
while
(
isdigitW
(
*
str
))
{
exp
++
;
str
++
;
}
if
(
*
str
==
'.'
)
str
++
;
if
(
isdigitW
(
*
str
))
ret_nan
=
FALSE
;
while
(
isdigitW
(
*
str
))
{
hlp
=
d
*
10
+
*
(
str
++
)
-
'0'
;
if
(
d
>
LONGLONG_MAX
/
10
||
hlp
<
0
)
break
;
d
=
hlp
;
exp
--
;
}
while
(
isdigitW
(
*
str
))
str
++
;
if
(
*
str
&&
!
ret_nan
&&
(
*
str
==
'e'
||
*
str
==
'E'
))
{
int
sign
=
1
,
e
=
0
;
str
++
;
if
(
*
str
==
'+'
)
str
++
;
else
if
(
*
str
==
'-'
)
{
sign
=
-
1
;
str
++
;
}
while
(
isdigitW
(
*
str
))
{
if
(
e
>
INT_MAX
/
10
||
(
e
=
e
*
10
+
*
str
++
-
'0'
)
<
0
)
e
=
INT_MAX
;
}
e
*=
sign
;
if
(
exp
<
0
&&
e
<
0
&&
exp
+
e
>
0
)
exp
=
INT_MIN
;
else
if
(
exp
>
0
&&
e
>
0
&&
exp
+
e
<
0
)
exp
=
INT_MAX
;
else
exp
+=
e
;
}
SysFreeString
(
val_str
);
if
(
ret_nan
)
{
if
(
retv
)
num_set_nan
(
retv
);
return
S_OK
;
}
V_VT
(
retv
)
=
VT_R8
;
V_R8
(
retv
)
=
(
double
)(
positive
?
d
:-
d
)
*
pow
(
10
,
exp
);
return
S_OK
;
}
static
HRESULT
JSGlobal_unescape
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
...
...
dlls/jscript/tests/api.js
View file @
3edf1ba2
...
...
@@ -627,6 +627,16 @@ for(i=2; i<10; i++) {
ok
((
0
).
toString
(
i
)
===
"0"
,
"(0).toString("
+
i
+
") = "
+
(
0
).
toString
(
i
));
}
ok
(
parseFloat
(
'123'
)
===
123
,
"parseFloat('123') = "
+
parseFloat
(
'123'
));
ok
(
parseFloat
(
'-13.7'
)
===
-
13.7
,
"parseFloat('-13.7') = "
+
parseFloat
(
'-13.7'
));
ok
(
parseFloat
(
'-0.01e-2'
)
===
-
0.01
e
-
2
,
"parseFloat('-0.01e-2') = "
+
parseFloat
(
'-0.01e-2'
));
ok
(
parseFloat
(
'-12e+5'
)
===
-
12
e
+
5
,
"parseFloat('-12e+5') = "
+
parseFloat
(
'-12e+5'
));
ok
(
parseFloat
(
'1E5 not parsed'
)
===
1
E5
,
"parseFloat('1E5 not parsed') = "
+
parseFloat
(
'1E5 not parsed'
));
ok
(
isNaN
(
parseFloat
(
'not a number'
)),
"parseFloat('not a number') is not NaN"
);
ok
(
parseFloat
(
'+13.2e-3'
)
===
13.2
e
-
3
,
"parseFloat('+13.2e-3') = "
+
parseFloat
(
'+13.2e-3'
));
ok
(
parseFloat
(
'.12'
)
===
0.12
,
"parseFloat('.12') = "
+
parseFloat
(
'.12'
));
ok
(
parseFloat
(
'1e'
)
===
1
,
"parseFloat('1e') = "
+
parseFloat
(
'1e'
));
tmp
=
Math
.
min
(
1
);
ok
(
tmp
===
1
,
"Math.min(1) = "
+
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