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
5deda2de
Commit
5deda2de
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: Simplify handling of already parsed imports.
parent
9d1f1a3f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
28 deletions
+25
-28
parser.h
tools/widl/parser.h
+1
-1
parser.l
tools/widl/parser.l
+20
-16
parser.y
tools/widl/parser.y
+4
-11
No files found.
tools/widl/parser.h
View file @
5deda2de
...
...
@@ -29,7 +29,7 @@ extern int parser_debug;
extern
int
yy_flex_debug
;
extern
int
import_stack_ptr
;
int
do_import
(
char
*
fname
);
void
push_import
(
char
*
import_name
);
void
pop_import
(
void
);
#define parse_only import_stack_ptr
...
...
tools/widl/parser.l
View file @
5deda2de
...
...
@@ -512,7 +512,7 @@ void pop_import(void)
{
int ptr = import_stack_ptr-1;
fclose(yyin
);
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;
...
...
@@ -520,7 +520,7 @@ void pop_import(void)
import_stack_ptr--;
}
int do_import(char *fname
)
void push_import( char *import_name
)
{
FILE *f;
char *path, *name;
...
...
@@ -528,26 +528,32 @@ int do_import(char *fname)
int ptr = import_stack_ptr;
int ret;
if (import_stack_ptr == MAX_IMPORT_DEPTH)
error_loc("Exceeded max import depth\n");
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;
/* reset buffer for <<EOF>>, in case import fails or already imported */
yy_scan_string( "" );
LIST_FOR_EACH_ENTRY( import, &imports, struct import, entry )
if (!strcmp( import->name,
fname )) return 0
; /* already imported */
if (!strcmp( import->name,
import_name )) return
; /* already imported */
import = xmalloc( sizeof(struct import) );
import->name = xstrdup(
f
name );
import->name = xstrdup(
import_
name );
list_add_tail( &imports, &import->entry );
/* don't search for a file name with a path in the include directories,
* for compatibility with MIDL */
if (strchr(
fname, '/' ) || strchr( f
name, '\\' ))
path = xstrdup(
f
name );
else if (!(path = wpp_find_include(
f
name, input_name )))
error_loc(
"Unable to open include file %s\n", fname
);
if (strchr(
import_name, '/' ) || strchr( import_
name, '\\' ))
path = xstrdup(
import_
name );
else if (!(path = wpp_find_include(
import_
name, input_name )))
error_loc(
"Unable to open include file %s\n", import_name
);
if (import_stack_ptr == MAX_IMPORT_DEPTH)
error_loc("Exceeded max import depth\n");
import_stack[ptr].input_name = input_name;
import_stack[ptr].line_number = line_number;
import_stack_ptr++;
input_name = path;
line_number = 1;
...
...
@@ -562,9 +568,7 @@ int do_import(char *fname)
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));
return 1;
}
static void switch_to_acf(void)
...
...
tools/widl/parser.y
View file @
5deda2de
...
...
@@ -331,7 +331,7 @@ int parser_lex( PARSER_STYPE *yylval );
%type <str> libraryhdr callconv cppquote importlib import
%type <str> typename m_typename
%type <uuid> uuid_string
%type <
import
> import_start
%type <
str
> import_start
%type <typelib> library_start librarydef
%type <statement> statement typedef pragma_warning
%type <stmt_list> gbl_statements imp_statements int_statements
...
...
@@ -504,17 +504,10 @@ typedecl:
cppquote: tCPPQUOTE '(' aSTRING ')' { $$ = $3; }
;
import_start: tIMPORT aSTRING ';' { $$ = xmalloc(sizeof(struct _import_t));
$$->name = $2;
$$->import_performed = do_import($2);
if (!$$->import_performed) yychar = aEOF;
}
;
import: import_start imp_statements aEOF { $$ = $1->name;
if ($1->import_performed) pop_import();
free($1);
}
import_start: tIMPORT aSTRING ';' { $$ = $2; push_import($2); }
;
import: import_start imp_statements aEOF { pop_import(); }
;
importlib: tIMPORTLIB '(' aSTRING ')'
...
...
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