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
84ef7ece
Commit
84ef7ece
authored
Apr 09, 2009
by
Piotr Caban
Committed by
Alexandre Julliard
Apr 10, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added html comments handling.
parent
754b5cf2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
10 deletions
+38
-10
engine.h
dlls/jscript/engine.h
+2
-1
global.c
dlls/jscript/global.c
+1
-1
jscript.c
dlls/jscript/jscript.c
+2
-2
lex.c
dlls/jscript/lex.c
+21
-3
parser.y
dlls/jscript/parser.y
+12
-3
No files found.
dlls/jscript/engine.h
View file @
84ef7ece
...
...
@@ -55,6 +55,7 @@ typedef struct _parser_ctx_t {
script_ctx_t
*
script
;
source_elements_t
*
source
;
BOOL
nl
;
BOOL
is_html
;
HRESULT
hres
;
jsheap_t
heap
;
...
...
@@ -65,7 +66,7 @@ typedef struct _parser_ctx_t {
struct
_parser_ctx_t
*
next
;
}
parser_ctx_t
;
HRESULT
script_parse
(
script_ctx_t
*
,
const
WCHAR
*
,
parser_ctx_t
**
);
HRESULT
script_parse
(
script_ctx_t
*
,
const
WCHAR
*
,
const
WCHAR
*
,
parser_ctx_t
**
);
void
parser_release
(
parser_ctx_t
*
);
int
parser_lex
(
void
*
,
parser_ctx_t
*
);
...
...
dlls/jscript/global.c
View file @
84ef7ece
...
...
@@ -264,7 +264,7 @@ static HRESULT JSGlobal_eval(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
}
TRACE
(
"parsing %s
\n
"
,
debugstr_w
(
V_BSTR
(
arg
)));
hres
=
script_parse
(
dispex
->
ctx
,
V_BSTR
(
arg
),
&
parser_ctx
);
hres
=
script_parse
(
dispex
->
ctx
,
V_BSTR
(
arg
),
NULL
,
&
parser_ctx
);
if
(
FAILED
(
hres
))
{
WARN
(
"parse (%s) failed: %08x
\n
"
,
debugstr_w
(
V_BSTR
(
arg
)),
hres
);
return
hres
;
...
...
dlls/jscript/jscript.c
View file @
84ef7ece
...
...
@@ -596,7 +596,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
if
(
This
->
thread_id
!=
GetCurrentThreadId
()
||
This
->
ctx
->
state
==
SCRIPTSTATE_CLOSED
)
return
E_UNEXPECTED
;
hres
=
script_parse
(
This
->
ctx
,
pstrCode
,
&
parser_ctx
);
hres
=
script_parse
(
This
->
ctx
,
pstrCode
,
pstrDelimiter
,
&
parser_ctx
);
if
(
FAILED
(
hres
))
return
hres
;
...
...
@@ -662,7 +662,7 @@ static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptPars
if
(
This
->
thread_id
!=
GetCurrentThreadId
()
||
This
->
ctx
->
state
==
SCRIPTSTATE_CLOSED
)
return
E_UNEXPECTED
;
hres
=
script_parse
(
This
->
ctx
,
pstrCode
,
&
parser_ctx
);
hres
=
script_parse
(
This
->
ctx
,
pstrCode
,
pstrDelimiter
,
&
parser_ctx
);
if
(
FAILED
(
hres
))
{
WARN
(
"Parse failed %08x
\n
"
,
hres
);
return
hres
;
...
...
dlls/jscript/lex.c
View file @
84ef7ece
...
...
@@ -174,6 +174,20 @@ static void skip_spaces(parser_ctx_t *ctx)
}
}
static
BOOL
skip_html_comment
(
parser_ctx_t
*
ctx
)
{
const
WCHAR
html_commentW
[]
=
{
'<'
,
'!'
,
'-'
,
'-'
,
0
};
if
(
!
ctx
->
is_html
||
ctx
->
ptr
+
3
>=
ctx
->
end
||
memcmp
(
ctx
->
ptr
,
html_commentW
,
sizeof
(
WCHAR
)
*
4
))
return
FALSE
;
ctx
->
nl
=
TRUE
;
while
(
ctx
->
ptr
<
ctx
->
end
&&
!
is_endline
(
*
ctx
->
ptr
++
));
return
TRUE
;
}
static
BOOL
skip_comment
(
parser_ctx_t
*
ctx
)
{
if
(
ctx
->
ptr
+
1
>=
ctx
->
end
||
*
ctx
->
ptr
!=
'/'
)
...
...
@@ -466,13 +480,13 @@ int parser_lex(void *lval, parser_ctx_t *ctx)
{
int
ret
;
ctx
->
nl
=
FALSE
;
ctx
->
nl
=
ctx
->
ptr
==
ctx
->
begin
;
do
{
skip_spaces
(
ctx
);
if
(
ctx
->
ptr
==
ctx
->
end
)
return
0
;
}
while
(
skip_comment
(
ctx
));
}
while
(
skip_comment
(
ctx
)
||
skip_html_comment
(
ctx
)
);
if
(
isalphaW
(
*
ctx
->
ptr
))
{
ret
=
check_keywords
(
ctx
,
lval
);
...
...
@@ -585,8 +599,12 @@ int parser_lex(void *lval, parser_ctx_t *ctx)
ctx
->
ptr
++
;
if
(
ctx
->
ptr
<
ctx
->
end
)
{
switch
(
*
ctx
->
ptr
)
{
case
'-'
:
/* -- */
case
'-'
:
/* --
or -->
*/
ctx
->
ptr
++
;
if
(
ctx
->
is_html
&&
ctx
->
nl
&&
ctx
->
ptr
<
ctx
->
end
&&
*
ctx
->
ptr
==
'>'
)
{
ctx
->
ptr
++
;
return
tHTMLCOMMENT
;
}
return
tDEC
;
case
'='
:
/* -= */
ctx
->
ptr
++
;
...
...
dlls/jscript/parser.y
View file @
84ef7ece
...
...
@@ -170,7 +170,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
/* keywords */
%token kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kIF kFINALLY kFOR kIN
%token kINSTANCEOF kNEW kNULL kUNDEFINED kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH
%token tANDAND tOROR tINC tDEC
%token tANDAND tOROR tINC tDEC
tHTMLCOMMENT
%token <srcptr> kFUNCTION '}'
...
...
@@ -251,7 +251,12 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
/* ECMA-262 3rd Edition 14 */
Program
: SourceElements { program_parsed(ctx, $1); }
: SourceElements HtmlComment
{ program_parsed(ctx, $1); }
HtmlComment
: tHTMLCOMMENT {}
| /* empty */ {}
/* ECMA-262 3rd Edition 14 */
SourceElements
...
...
@@ -1549,18 +1554,22 @@ void parser_release(parser_ctx_t *ctx)
heap_free(ctx);
}
HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, parser_ctx_t **ret)
HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimiter,
parser_ctx_t **ret)
{
parser_ctx_t *parser_ctx;
jsheap_t *mark;
HRESULT hres;
const WCHAR html_tagW[] = {'<','/','s','c','r','i','p','t','>',0};
parser_ctx = heap_alloc_zero(sizeof(parser_ctx_t));
if(!parser_ctx)
return E_OUTOFMEMORY;
parser_ctx->ref = 1;
parser_ctx->hres = E_FAIL;
parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW);
parser_ctx->begin = parser_ctx->ptr = code;
parser_ctx->end = code + strlenW(code);
...
...
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