Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
f34cecba
Commit
f34cecba
authored
Nov 08, 2019
by
Jacek Caban
Committed by
Alexandre Julliard
Nov 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Treat only ASCII digits as digits.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
8b7e38c5
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
40 additions
and
32 deletions
+40
-32
array.c
dlls/jscript/array.c
+2
-2
dispex.c
dlls/jscript/dispex.c
+1
-1
global.c
dlls/jscript/global.c
+10
-8
jscript.h
dlls/jscript/jscript.h
+5
-0
json.c
dlls/jscript/json.c
+1
-1
jsutils.c
dlls/jscript/jsutils.c
+3
-3
lex.c
dlls/jscript/lex.c
+15
-15
string.c
dlls/jscript/string.c
+2
-2
api.js
dlls/jscript/tests/api.js
+1
-0
No files found.
dlls/jscript/array.c
View file @
f34cecba
...
...
@@ -1191,10 +1191,10 @@ static void Array_on_put(jsdisp_t *dispex, const WCHAR *name)
const
WCHAR
*
ptr
=
name
;
DWORD
id
=
0
;
if
(
!
is
w
digit
(
*
ptr
))
if
(
!
is
_
digit
(
*
ptr
))
return
;
while
(
*
ptr
&&
is
w
digit
(
*
ptr
))
{
while
(
*
ptr
&&
is
_
digit
(
*
ptr
))
{
id
=
id
*
10
+
(
*
ptr
-
'0'
);
ptr
++
;
}
...
...
dlls/jscript/dispex.c
View file @
f34cecba
...
...
@@ -239,7 +239,7 @@ static HRESULT find_prop_name(jsdisp_t *This, unsigned hash, const WCHAR *name,
const
WCHAR
*
ptr
;
unsigned
idx
=
0
;
for
(
ptr
=
name
;
is
w
digit
(
*
ptr
)
&&
idx
<
0x10000
;
ptr
++
)
for
(
ptr
=
name
;
is
_
digit
(
*
ptr
)
&&
idx
<
0x10000
;
ptr
++
)
idx
=
idx
*
10
+
(
*
ptr
-
'0'
);
if
(
!*
ptr
&&
idx
<
This
->
builtin_info
->
idx_length
(
This
))
{
prop
=
alloc_prop
(
This
,
name
,
PROP_IDX
,
This
->
builtin_info
->
idx_put
?
PROPF_WRITABLE
:
0
);
...
...
dlls/jscript/global.c
View file @
f34cecba
...
...
@@ -376,6 +376,8 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
return
S_OK
;
}
TRACE
(
"%s
\n
"
,
debugstr_jsval
(
argv
[
0
]));
hres
=
to_flat_string
(
ctx
,
argv
[
0
],
&
val_str
,
&
str
);
if
(
FAILED
(
hres
))
return
hres
;
...
...
@@ -389,10 +391,10 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
str
++
;
}
if
(
is
w
digit
(
*
str
))
if
(
is
_
digit
(
*
str
))
ret_nan
=
FALSE
;
while
(
is
w
digit
(
*
str
))
{
while
(
is
_
digit
(
*
str
))
{
hlp
=
d
*
10
+
*
(
str
++
)
-
'0'
;
if
(
d
>
MAXLONGLONG
/
10
||
hlp
<
0
)
{
exp
++
;
...
...
@@ -401,17 +403,17 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
else
d
=
hlp
;
}
while
(
is
w
digit
(
*
str
))
{
while
(
is
_
digit
(
*
str
))
{
exp
++
;
str
++
;
}
if
(
*
str
==
'.'
)
str
++
;
if
(
is
w
digit
(
*
str
))
if
(
is
_
digit
(
*
str
))
ret_nan
=
FALSE
;
while
(
is
w
digit
(
*
str
))
{
while
(
is
_
digit
(
*
str
))
{
hlp
=
d
*
10
+
*
(
str
++
)
-
'0'
;
if
(
d
>
MAXLONGLONG
/
10
||
hlp
<
0
)
break
;
...
...
@@ -419,7 +421,7 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
d
=
hlp
;
exp
--
;
}
while
(
is
w
digit
(
*
str
))
while
(
is
_
digit
(
*
str
))
str
++
;
if
(
*
str
&&
!
ret_nan
&&
(
*
str
==
'e'
||
*
str
==
'E'
))
{
...
...
@@ -433,7 +435,7 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
str
++
;
}
while
(
is
w
digit
(
*
str
))
{
while
(
is
_
digit
(
*
str
))
{
if
(
e
>
INT_MAX
/
10
||
(
e
=
e
*
10
+
*
str
++
-
'0'
)
<
0
)
e
=
INT_MAX
;
}
...
...
@@ -461,7 +463,7 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
static
inline
int
hex_to_int
(
const
WCHAR
wch
)
{
if
(
towupper
(
wch
)
>=
'A'
&&
towupper
(
wch
)
<=
'F'
)
return
towupper
(
wch
)
-
'A'
+
10
;
if
(
is
w
digit
(
wch
))
return
wch
-
'0'
;
if
(
is
_
digit
(
wch
))
return
wch
-
'0'
;
return
-
1
;
}
...
...
dlls/jscript/jscript.h
View file @
f34cecba
...
...
@@ -354,6 +354,11 @@ HRESULT decode_source(WCHAR*) DECLSPEC_HIDDEN;
HRESULT
double_to_string
(
double
,
jsstr_t
**
)
DECLSPEC_HIDDEN
;
BOOL
is_finite
(
double
)
DECLSPEC_HIDDEN
;
static
inline
BOOL
is_digit
(
WCHAR
c
)
{
return
'0'
<=
c
&&
c
<=
'9'
;
}
typedef
struct
named_item_t
{
IDispatch
*
disp
;
DWORD
flags
;
...
...
dlls/jscript/json.c
View file @
f34cecba
...
...
@@ -260,7 +260,7 @@ static HRESULT parse_json_value(json_parse_ctx_t *ctx, jsval_t *r)
skip_spaces
(
ctx
);
}
if
(
*
ctx
->
ptr
==
'0'
&&
ctx
->
ptr
+
1
<
ctx
->
end
&&
is
w
digit
(
ctx
->
ptr
[
1
]))
if
(
*
ctx
->
ptr
==
'0'
&&
ctx
->
ptr
+
1
<
ctx
->
end
&&
is
_
digit
(
ctx
->
ptr
[
1
]))
break
;
hres
=
parse_decimal
(
&
ctx
->
ptr
,
ctx
->
end
,
&
n
);
...
...
dlls/jscript/jsutils.c
View file @
f34cecba
...
...
@@ -555,7 +555,7 @@ static HRESULT str_to_number(jsstr_t *str, double *ret)
return
S_OK
;
}
while
(
is
w
digit
(
*
ptr
))
while
(
is
_
digit
(
*
ptr
))
d
=
d
*
10
+
(
*
ptr
++
-
'0'
);
if
(
*
ptr
==
'e'
||
*
ptr
==
'E'
)
{
...
...
@@ -570,7 +570,7 @@ static HRESULT str_to_number(jsstr_t *str, double *ret)
ptr
++
;
}
while
(
is
w
digit
(
*
ptr
))
while
(
is
_
digit
(
*
ptr
))
l
=
l
*
10
+
(
*
ptr
++
-
'0'
);
if
(
eneg
)
l
=
-
l
;
...
...
@@ -580,7 +580,7 @@ static HRESULT str_to_number(jsstr_t *str, double *ret)
DOUBLE
dec
=
0
.
1
;
ptr
++
;
while
(
is
w
digit
(
*
ptr
))
{
while
(
is
_
digit
(
*
ptr
))
{
d
+=
dec
*
(
*
ptr
++
-
'0'
);
dec
*=
0
.
1
;
}
...
...
dlls/jscript/lex.c
View file @
f34cecba
...
...
@@ -297,11 +297,11 @@ BOOL unescape(WCHAR *str, size_t *len)
c
+=
i
;
break
;
default:
if
(
is
w
digit
(
*
p
))
{
if
(
is
_
digit
(
*
p
))
{
c
=
*
p
++
-
'0'
;
if
(
p
<
end
&&
is
w
digit
(
*
p
))
{
if
(
p
<
end
&&
is
_
digit
(
*
p
))
{
c
=
c
*
8
+
(
*
p
++
-
'0'
);
if
(
p
<
end
&&
is
w
digit
(
*
p
))
if
(
p
<
end
&&
is
_
digit
(
*
p
))
c
=
c
*
8
+
(
*
p
++
-
'0'
);
}
p
--
;
...
...
@@ -400,7 +400,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret)
LONGLONG
d
=
0
,
hlp
;
int
exp
=
0
;
while
(
ptr
<
end
&&
is
w
digit
(
*
ptr
))
{
while
(
ptr
<
end
&&
is
_
digit
(
*
ptr
))
{
hlp
=
d
*
10
+
*
(
ptr
++
)
-
'0'
;
if
(
d
>
MAXLONGLONG
/
10
||
hlp
<
0
)
{
exp
++
;
...
...
@@ -409,7 +409,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret)
else
d
=
hlp
;
}
while
(
ptr
<
end
&&
is
w
digit
(
*
ptr
))
{
while
(
ptr
<
end
&&
is
_
digit
(
*
ptr
))
{
exp
++
;
ptr
++
;
}
...
...
@@ -417,7 +417,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret)
if
(
*
ptr
==
'.'
)
{
ptr
++
;
while
(
ptr
<
end
&&
is
w
digit
(
*
ptr
))
{
while
(
ptr
<
end
&&
is
_
digit
(
*
ptr
))
{
hlp
=
d
*
10
+
*
(
ptr
++
)
-
'0'
;
if
(
d
>
MAXLONGLONG
/
10
||
hlp
<
0
)
break
;
...
...
@@ -425,7 +425,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret)
d
=
hlp
;
exp
--
;
}
while
(
ptr
<
end
&&
is
w
digit
(
*
ptr
))
while
(
ptr
<
end
&&
is
_
digit
(
*
ptr
))
ptr
++
;
}
...
...
@@ -438,7 +438,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret)
}
else
if
(
*
ptr
==
'-'
)
{
sign
=
-
1
;
ptr
++
;
}
else
if
(
!
is
w
digit
(
*
ptr
))
{
}
else
if
(
!
is
_
digit
(
*
ptr
))
{
WARN
(
"Expected exponent part
\n
"
);
return
E_FAIL
;
}
...
...
@@ -449,7 +449,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret)
return
E_FAIL
;
}
while
(
ptr
<
end
&&
is
w
digit
(
*
ptr
))
{
while
(
ptr
<
end
&&
is
_
digit
(
*
ptr
))
{
if
(
e
>
INT_MAX
/
10
||
(
e
=
e
*
10
+
*
ptr
++
-
'0'
)
<
0
)
e
=
INT_MAX
;
}
...
...
@@ -500,12 +500,12 @@ static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
return
TRUE
;
}
if
(
is
w
digit
(
*
ctx
->
ptr
))
{
if
(
is
_
digit
(
*
ctx
->
ptr
))
{
unsigned
base
=
8
;
const
WCHAR
*
ptr
;
double
val
=
0
;
for
(
ptr
=
ctx
->
ptr
;
ptr
<
ctx
->
end
&&
is
w
digit
(
*
ptr
);
ptr
++
)
{
for
(
ptr
=
ctx
->
ptr
;
ptr
<
ctx
->
end
&&
is
_
digit
(
*
ptr
);
ptr
++
)
{
if
(
*
ptr
>
'7'
)
{
base
=
10
;
break
;
...
...
@@ -514,7 +514,7 @@ static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
do
{
val
=
val
*
base
+
*
ctx
->
ptr
-
'0'
;
}
while
(
++
ctx
->
ptr
<
ctx
->
end
&&
is
w
digit
(
*
ctx
->
ptr
));
}
while
(
++
ctx
->
ptr
<
ctx
->
end
&&
is
_
digit
(
*
ctx
->
ptr
));
/* FIXME: Do we need it here? */
if
(
ctx
->
ptr
<
ctx
->
end
&&
(
is_identifier_char
(
*
ctx
->
ptr
)
||
*
ctx
->
ptr
==
'.'
))
{
...
...
@@ -564,7 +564,7 @@ static int next_token(parser_ctx_t *ctx, void *lval)
return
parse_identifier
(
ctx
,
lval
);
}
if
(
is
w
digit
(
*
ctx
->
ptr
))
{
if
(
is
_
digit
(
*
ctx
->
ptr
))
{
double
n
;
if
(
!
parse_numeric_literal
(
ctx
,
&
n
))
...
...
@@ -591,7 +591,7 @@ static int next_token(parser_ctx_t *ctx, void *lval)
return
'}'
;
case
'.'
:
if
(
ctx
->
ptr
+
1
<
ctx
->
end
&&
is
w
digit
(
ctx
->
ptr
[
1
]))
{
if
(
ctx
->
ptr
+
1
<
ctx
->
end
&&
is
_
digit
(
ctx
->
ptr
[
1
]))
{
double
n
;
HRESULT
hres
;
hres
=
parse_decimal
(
&
ctx
->
ptr
,
ctx
->
end
,
&
n
);
...
...
@@ -909,7 +909,7 @@ int try_parse_ccval(parser_ctx_t *ctx, ccval_t *r)
if
(
!
skip_spaces
(
ctx
))
return
-
1
;
if
(
is
w
digit
(
*
ctx
->
ptr
))
{
if
(
is
_
digit
(
*
ctx
->
ptr
))
{
double
n
;
if
(
!
parse_numeric_literal
(
ctx
,
&
n
))
...
...
dlls/jscript/string.c
View file @
f34cecba
...
...
@@ -904,14 +904,14 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
default:
{
DWORD
idx
;
if
(
!
is
w
digit
(
ptr2
[
1
]))
{
if
(
!
is
_
digit
(
ptr2
[
1
]))
{
hres
=
strbuf_append
(
&
ret
,
ptr2
,
1
);
ptr
=
ptr2
+
1
;
break
;
}
idx
=
ptr2
[
1
]
-
'0'
;
if
(
is
w
digit
(
ptr2
[
2
])
&&
idx
*
10
+
(
ptr2
[
2
]
-
'0'
)
<=
match
->
paren_count
)
{
if
(
is
_
digit
(
ptr2
[
2
])
&&
idx
*
10
+
(
ptr2
[
2
]
-
'0'
)
<=
match
->
paren_count
)
{
idx
=
idx
*
10
+
(
ptr
[
2
]
-
'0'
);
ptr
=
ptr2
+
3
;
}
else
if
(
idx
&&
idx
<=
match
->
paren_count
)
{
...
...
dlls/jscript/tests/api.js
View file @
f34cecba
...
...
@@ -1442,6 +1442,7 @@ 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'
));
ok
(
isNaN
(
parseFloat
(
'
\
uff16'
)),
"parseFloat('
\\
uD835') is not NaN"
);
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