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
b1197a15
Commit
b1197a15
authored
Jan 27, 2016
by
Jacek Caban
Committed by
Alexandre Julliard
Jan 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Make parse_decimal a more generic helper.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
bb29a9bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
37 deletions
+47
-37
lex.c
dlls/jscript/lex.c
+47
-37
No files found.
dlls/jscript/lex.c
View file @
b1197a15
...
...
@@ -406,14 +406,14 @@ literal_t *new_boolean_literal(parser_ctx_t *ctx, BOOL bval)
return
ret
;
}
static
BOOL
parse_double_literal
(
parser_ctx_t
*
ctx
,
LONG
int_part
,
double
*
ret
)
static
HRESULT
parse_decimal
(
const
WCHAR
**
iter
,
const
WCHAR
*
end
,
double
*
ret
)
{
LONGLONG
d
,
hlp
;
const
WCHAR
*
ptr
=
*
iter
;
LONGLONG
d
=
0
,
hlp
;
int
exp
=
0
;
d
=
int_part
;
while
(
ctx
->
ptr
<
ctx
->
end
&&
isdigitW
(
*
ctx
->
ptr
))
{
hlp
=
d
*
10
+
*
(
ctx
->
ptr
++
)
-
'0'
;
while
(
ptr
<
end
&&
isdigitW
(
*
ptr
))
{
hlp
=
d
*
10
+
*
(
ptr
++
)
-
'0'
;
if
(
d
>
MAXLONGLONG
/
10
||
hlp
<
0
)
{
exp
++
;
break
;
...
...
@@ -421,51 +421,48 @@ static BOOL parse_double_literal(parser_ctx_t *ctx, LONG int_part, double *ret)
else
d
=
hlp
;
}
while
(
ctx
->
ptr
<
ctx
->
end
&&
isdigitW
(
*
ctx
->
ptr
))
{
while
(
ptr
<
end
&&
isdigitW
(
*
ptr
))
{
exp
++
;
ctx
->
ptr
++
;
ptr
++
;
}
if
(
*
ctx
->
ptr
==
'.'
)
{
ctx
->
ptr
++
;
if
(
*
ptr
==
'.'
)
{
ptr
++
;
while
(
ctx
->
ptr
<
ctx
->
end
&&
isdigitW
(
*
ctx
->
ptr
))
{
hlp
=
d
*
10
+
*
(
ctx
->
ptr
++
)
-
'0'
;
while
(
ptr
<
end
&&
isdigitW
(
*
ptr
))
{
hlp
=
d
*
10
+
*
(
ptr
++
)
-
'0'
;
if
(
d
>
MAXLONGLONG
/
10
||
hlp
<
0
)
break
;
d
=
hlp
;
exp
--
;
}
while
(
ctx
->
ptr
<
ctx
->
end
&&
isdigitW
(
*
ctx
->
ptr
))
ctx
->
ptr
++
;
while
(
ptr
<
end
&&
isdigitW
(
*
ptr
))
ptr
++
;
}
if
(
ctx
->
ptr
<
ctx
->
end
&&
(
*
ctx
->
ptr
==
'e'
||
*
ctx
->
ptr
==
'E'
))
{
if
(
ptr
<
end
&&
(
*
ptr
==
'e'
||
*
ptr
==
'E'
))
{
int
sign
=
1
,
e
=
0
;
ctx
->
ptr
++
;
if
(
ctx
->
ptr
<
ctx
->
end
)
{
if
(
*
ctx
->
ptr
==
'+'
)
{
ctx
->
ptr
++
;
}
else
if
(
*
ctx
->
ptr
==
'-'
)
{
if
(
++
ptr
<
end
)
{
if
(
*
ptr
==
'+'
)
{
ptr
++
;
}
else
if
(
*
ptr
==
'-'
)
{
sign
=
-
1
;
ctx
->
ptr
++
;
}
else
if
(
!
isdigitW
(
*
ctx
->
ptr
))
{
ptr
++
;
}
else
if
(
!
isdigitW
(
*
ptr
))
{
WARN
(
"Expected exponent part
\n
"
);
lex_error
(
ctx
,
E_FAIL
);
return
FALSE
;
return
E_FAIL
;
}
}
if
(
ctx
->
ptr
==
ctx
->
end
)
{
if
(
ptr
==
end
)
{
WARN
(
"unexpected end of file
\n
"
);
lex_error
(
ctx
,
E_FAIL
);
return
FALSE
;
return
E_FAIL
;
}
while
(
ctx
->
ptr
<
ctx
->
end
&&
isdigitW
(
*
ctx
->
ptr
))
{
if
(
e
>
INT_MAX
/
10
||
(
e
=
e
*
10
+
*
ctx
->
ptr
++
-
'0'
)
<
0
)
while
(
ptr
<
end
&&
isdigitW
(
*
ptr
))
{
if
(
e
>
INT_MAX
/
10
||
(
e
=
e
*
10
+
*
ptr
++
-
'0'
)
<
0
)
e
=
INT_MAX
;
}
e
*=
sign
;
...
...
@@ -475,22 +472,25 @@ static BOOL parse_double_literal(parser_ctx_t *ctx, LONG int_part, double *ret)
else
exp
+=
e
;
}
if
(
is_identifier_char
(
*
ctx
->
ptr
))
{
if
(
is_identifier_char
(
*
ptr
))
{
WARN
(
"wrong char after zero
\n
"
);
lex_error
(
ctx
,
JS_E_MISSING_SEMICOLON
);
return
FALSE
;
return
JS_E_MISSING_SEMICOLON
;
}
*
ret
=
exp
>=
0
?
d
*
pow
(
10
,
exp
)
:
d
/
pow
(
10
,
-
exp
);
return
TRUE
;
*
iter
=
ptr
;
return
S_OK
;
}
static
BOOL
parse_numeric_literal
(
parser_ctx_t
*
ctx
,
double
*
ret
)
{
LONG
l
,
d
;
HRESULT
hres
;
if
(
*
ctx
->
ptr
==
'0'
)
{
LONG
d
,
l
=
0
;
ctx
->
ptr
++
;
l
=
*
ctx
->
ptr
++
-
'0'
;
if
(
!
l
)
{
if
(
*
ctx
->
ptr
==
'x'
||
*
ctx
->
ptr
==
'X'
)
{
if
(
++
ctx
->
ptr
==
ctx
->
end
)
{
ERR
(
"unexpected end of file
\n
"
);
...
...
@@ -546,7 +546,13 @@ static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
}
}
return
parse_double_literal
(
ctx
,
l
,
ret
);
hres
=
parse_decimal
(
&
ctx
->
ptr
,
ctx
->
end
,
ret
);
if
(
FAILED
(
hres
))
{
lex_error
(
ctx
,
hres
);
return
FALSE
;
}
return
TRUE
;
}
static
int
next_token
(
parser_ctx_t
*
ctx
,
void
*
lval
)
...
...
@@ -599,8 +605,12 @@ static int next_token(parser_ctx_t *ctx, void *lval)
case
'.'
:
if
(
++
ctx
->
ptr
<
ctx
->
end
&&
isdigitW
(
*
ctx
->
ptr
))
{
double
n
;
if
(
!
parse_double_literal
(
ctx
,
0
,
&
n
))
HRESULT
hres
;
hres
=
parse_decimal
(
&
ctx
->
ptr
,
ctx
->
end
,
&
n
);
if
(
FAILED
(
hres
))
{
lex_error
(
ctx
,
hres
);
return
-
1
;
}
*
(
literal_t
**
)
lval
=
new_double_literal
(
ctx
,
n
);
return
tNumericLiteral
;
}
...
...
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