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
9d537999
Commit
9d537999
authored
Jan 25, 2023
by
Rémi Bernon
Committed by
Alexandre Julliard
Mar 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widl: Use a struct list for the import stack.
parent
5deda2de
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
34 deletions
+38
-34
parser.h
tools/widl/parser.h
+1
-3
parser.l
tools/widl/parser.l
+37
-29
widl.c
tools/widl/widl.c
+0
-2
No files found.
tools/widl/parser.h
View file @
9d537999
...
@@ -28,12 +28,10 @@ extern char *parser_text;
...
@@ -28,12 +28,10 @@ extern char *parser_text;
extern
int
parser_debug
;
extern
int
parser_debug
;
extern
int
yy_flex_debug
;
extern
int
yy_flex_debug
;
extern
int
import_stack_ptr
;
extern
int
parse_only
;
void
push_import
(
char
*
import_name
);
void
push_import
(
char
*
import_name
);
void
pop_import
(
void
);
void
pop_import
(
void
);
#define parse_only import_stack_ptr
int
is_type
(
const
char
*
name
);
int
is_type
(
const
char
*
name
);
int
do_warning
(
const
char
*
toggle
,
warning_list_t
*
wnum
);
int
do_warning
(
const
char
*
toggle
,
warning_list_t
*
wnum
);
...
...
tools/widl/parser.l
View file @
9d537999
...
@@ -81,13 +81,15 @@ static void switch_to_acf(void);
...
@@ -81,13 +81,15 @@ static void switch_to_acf(void);
static warning_list_t *disabled_warnings = NULL;
static warning_list_t *disabled_warnings = NULL;
#define MAX_IMPORT_DEPTH 20
struct import_state
struct {
{
YY_BUFFER_STATE state;
YY_BUFFER_STATE buffer;
char *input_name;
char *input_name;
int line_number;
int line_number;
} import_stack[MAX_IMPORT_DEPTH];
struct list entry;
int import_stack_ptr = 0;
};
static struct list import_stack = LIST_INIT( import_stack );
int parse_only = 0;
struct import
struct import
{
{
...
@@ -159,7 +161,8 @@ struct uuid *parse_uuid(const char *u)
...
@@ -159,7 +161,8 @@ struct uuid *parse_uuid(const char *u)
}
}
<PP_PRAGMA>midl_echo[^\n]* yyless(9); yy_pop_state(); return tCPPQUOTE;
<PP_PRAGMA>midl_echo[^\n]* yyless(9); yy_pop_state(); return tCPPQUOTE;
<PP_PRAGMA>winrt[^\n]* {
<PP_PRAGMA>winrt[^\n]* {
if(import_stack_ptr) {
if (!list_empty( &import_stack ))
{
if(!winrt_mode)
if(!winrt_mode)
error_loc("winrt IDL file imported in non-winrt mode\n");
error_loc("winrt IDL file imported in non-winrt mode\n");
}else {
}else {
...
@@ -234,7 +237,7 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
...
@@ -234,7 +237,7 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
<INITIAL,ATTR>\.\.\. return ELLIPSIS;
<INITIAL,ATTR>\.\.\. return ELLIPSIS;
<INITIAL,ATTR>. return yytext[0];
<INITIAL,ATTR>. return yytext[0];
<<EOF>> {
<<EOF>> {
if (
import_stack_ptr
)
if (
!list_empty( &import_stack )
)
return aEOF;
return aEOF;
if (acf_name)
if (acf_name)
{
{
...
@@ -510,32 +513,38 @@ static char *get_buffered_cstring(void)
...
@@ -510,32 +513,38 @@ static char *get_buffered_cstring(void)
void pop_import(void)
void pop_import(void)
{
{
int ptr = import_stack_ptr-1;
struct list *entry = list_head( &import_stack );
struct import_state *state;
if (yyin) fclose( yyin );
assert( entry );
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer( import_stack[ptr].state );
state = LIST_ENTRY( entry, struct import_state, entry );
input_name = import_stack[ptr].input_name;
list_remove( &state->entry );
line_number = import_stack[ptr].line_number;
parse_only = !list_empty( &import_stack );
import_stack_ptr--;
if (yyin) fclose( yyin );
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer( state->buffer );
input_name = state->input_name;
line_number = state->line_number;
free( state );
}
}
void push_import( char *import_name )
void push_import( char *import_name )
{
{
struct import_state *state;
FILE *f;
FILE *f;
char *path, *name;
char *path, *name;
struct import *import;
struct import *import;
int ptr = import_stack_ptr;
int ret;
int ret;
if (import_stack_ptr == MAX_IMPORT_DEPTH)
state = xmalloc( sizeof(struct import_state ));
error_loc("Exceeded max import depth\n");
list_add_head( &import_stack, &state->entry );
parse_only = !list_empty( &import_stack );
import_stack[ptr].state = YY_CURRENT_BUFFER;
state->buffer = YY_CURRENT_BUFFER;
import_stack[ptr].input_name = input_name;
state->input_name = input_name;
import_stack[ptr].line_number = line_number;
state->line_number = line_number;
import_stack_ptr++;
input_name = NULL;
yyin = NULL;
/* reset buffer for <<EOF>>, in case import fails or already imported */
/* reset buffer for <<EOF>>, in case import fails or already imported */
yy_scan_string( "" );
yy_scan_string( "" );
...
@@ -573,12 +582,12 @@ void push_import( char *import_name )
...
@@ -573,12 +582,12 @@ void push_import( char *import_name )
static void switch_to_acf(void)
static void switch_to_acf(void)
{
{
int ptr = import_stack_ptr;
int ret;
char *name;
char *name;
int ret;
FILE *f;
FILE *f;
assert(import_stack_ptr == 0);
if (yyin) fclose( yyin );
yy_delete_buffer( YY_CURRENT_BUFFER );
input_name = acf_name;
input_name = acf_name;
acf_name = NULL;
acf_name = NULL;
...
@@ -595,7 +604,6 @@ static void switch_to_acf(void)
...
@@ -595,7 +604,6 @@ static void switch_to_acf(void)
if((f = fopen(name, "r")) == NULL)
if((f = fopen(name, "r")) == NULL)
error_loc("Unable to open %s\n", name);
error_loc("Unable to open %s\n", name);
import_stack[ptr].state = YY_CURRENT_BUFFER;
yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
}
}
...
...
tools/widl/widl.c
View file @
9d537999
...
@@ -871,8 +871,6 @@ int main(int argc,char *argv[])
...
@@ -871,8 +871,6 @@ int main(int argc,char *argv[])
init_types
();
init_types
();
ret
=
parser_parse
();
ret
=
parser_parse
();
fclose
(
parser_in
);
if
(
ret
)
{
if
(
ret
)
{
exit
(
1
);
exit
(
1
);
}
}
...
...
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