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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
29 deletions
+33
-29
parser.h
tools/widl/parser.h
+1
-3
parser.l
tools/widl/parser.l
+32
-24
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;
extern
int
parser_debug
;
extern
int
yy_flex_debug
;
extern
int
import_stack_ptr
;
extern
int
parse_only
;
void
push_import
(
char
*
import_name
);
void
pop_import
(
void
);
#define parse_only import_stack_ptr
int
is_type
(
const
char
*
name
);
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);
static warning_list_t *disabled_warnings = NULL;
#define MAX_IMPORT_DEPTH 20
struct
{
YY_BUFFER_STATE state
;
struct import_state
{
YY_BUFFER_STATE buffer
;
char *input_name;
int line_number;
} import_stack[MAX_IMPORT_DEPTH];
int import_stack_ptr = 0;
struct list entry;
};
static struct list import_stack = LIST_INIT( import_stack );
int parse_only = 0;
struct import
{
...
...
@@ -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>winrt[^\n]* {
if(import_stack_ptr) {
if (!list_empty( &import_stack ))
{
if(!winrt_mode)
error_loc("winrt IDL file imported in non-winrt mode\n");
}else {
...
...
@@ -234,7 +237,7 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
<INITIAL,ATTR>\.\.\. return ELLIPSIS;
<INITIAL,ATTR>. return yytext[0];
<<EOF>> {
if (
import_stack_ptr
)
if (
!list_empty( &import_stack )
)
return aEOF;
if (acf_name)
{
...
...
@@ -510,32 +513,38 @@ static char *get_buffered_cstring(void)
void pop_import(void)
{
int ptr = import_stack_ptr-1;
struct list *entry = list_head( &import_stack );
struct import_state *state;
assert( entry );
state = LIST_ENTRY( entry, struct import_state, entry );
list_remove( &state->entry );
parse_only = !list_empty( &import_stack );
if (yyin) fclose( yyin );
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer( import_stack[ptr].state
);
input_name = import_stack[ptr].
input_name;
line_number = import_stack[ptr].
line_number;
import_stack_ptr--
;
yy_switch_to_buffer( state->buffer
);
input_name = state->
input_name;
line_number = state->
line_number;
free( state )
;
}
void push_import( char *import_name )
{
struct import_state *state;
FILE *f;
char *path, *name;
struct import *import;
int ptr = import_stack_ptr;
int ret;
if (import_stack_ptr == MAX_IMPORT_DEPTH)
error_loc("Exceeded max import depth\n");
state = xmalloc( sizeof(struct import_state ));
list_add_head( &import_stack, &state->entry );
parse_only = !list_empty( &import_stack );
import_stack[ptr].state = YY_CURRENT_BUFFER;
import_stack[ptr].input_name = input_name;
import_stack[ptr].line_number = line_number;
import_stack_ptr++;
yyin = NULL;
state->buffer = YY_CURRENT_BUFFER;
state->input_name = input_name;
state->line_number = line_number;
input_name = NULL;
/* reset buffer for <<EOF>>, in case import fails or already imported */
yy_scan_string( "" );
...
...
@@ -573,12 +582,12 @@ void push_import( char *import_name )
static void switch_to_acf(void)
{
int ptr = import_stack_ptr;
int ret;
char *name;
int ret;
FILE *f;
assert(import_stack_ptr == 0);
if (yyin) fclose( yyin );
yy_delete_buffer( YY_CURRENT_BUFFER );
input_name = acf_name;
acf_name = NULL;
...
...
@@ -595,7 +604,6 @@ static void switch_to_acf(void)
if((f = fopen(name, "r")) == NULL)
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));
}
...
...
tools/widl/widl.c
View file @
9d537999
...
...
@@ -871,8 +871,6 @@ int main(int argc,char *argv[])
init_types
();
ret
=
parser_parse
();
fclose
(
parser_in
);
if
(
ret
)
{
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