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
39da0520
Commit
39da0520
authored
Mar 15, 2023
by
Rémi Bernon
Committed by
Alexandre Julliard
Mar 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widl: Introduce new (open|close)_input_file helpers.
parent
a6ab03dc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
41 deletions
+40
-41
parser.h
tools/widl/parser.h
+2
-1
parser.l
tools/widl/parser.l
+11
-40
widl.c
tools/widl/widl.c
+27
-0
No files found.
tools/widl/parser.h
View file @
39da0520
...
...
@@ -37,6 +37,7 @@ int is_type(const char *name);
int
do_warning
(
const
char
*
toggle
,
warning_list_t
*
wnum
);
int
is_warning_enabled
(
int
warning
);
extern
char
*
temp_name
;
extern
char
*
find_input_file
(
const
char
*
name
,
const
char
*
parent
);
extern
FILE
*
open_input_file
(
const
char
*
path
);
#endif
tools/widl/parser.l
View file @
39da0520
...
...
@@ -524,6 +524,7 @@ void pop_import(void)
if (yyin) fclose( yyin );
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer( state->buffer );
free( input_name );
input_name = state->input_name;
line_number = state->line_number;
free( state );
...
...
@@ -532,10 +533,8 @@ void pop_import(void)
void push_import( char *import_name )
{
struct import_state *state;
FILE *f;
char *path, *name;
struct import *import;
int ret
;
FILE *file
;
state = xmalloc( sizeof(struct import_state ));
list_add_head( &import_stack, &state->entry );
...
...
@@ -556,55 +555,27 @@ void push_import( char *import_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( 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 );
input_name = path;
input_name = find_input_file( import_name, input_name );
file = open_input_file( input_name );
line_number = 1;
name = make_temp_file( "widl-pp", NULL );
if (!(f = fopen(name, "wt")))
error("Could not open fd %s for writing\n", name);
ret = wpp_parse( path, f );
fclose( f );
if (ret) exit(1);
if((f = fopen(name, "r")) == NULL)
error_loc("Unable to open %s\n", name);
yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
yy_switch_to_buffer( yy_create_buffer( file, YY_BUF_SIZE ) );
}
static void switch_to_acf(void)
{
char *name;
int ret;
FILE *f;
FILE *file;
if (yyin) fclose( yyin );
yy_delete_buffer( YY_CURRENT_BUFFER );
free( input_name );
input_name =
acf_name
;
acf_name = NULL
;
input_name =
xstrdup( acf_name )
;
file = open_input_file( input_name )
;
line_number = 1;
acf_name = NULL;
name = make_temp_file( "widl-acf", NULL );
if (!(f = fopen(name, "wt")))
error("Could not open fd %s for writing\n", name);
ret = wpp_parse(input_name, f);
fclose(f);
if (ret) exit(1);
if((f = fopen(name, "r")) == NULL)
error_loc("Unable to open %s\n", name);
yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
yy_switch_to_buffer( yy_create_buffer( file, YY_BUF_SIZE ) );
}
static void warning_disable(int warning)
...
...
tools/widl/widl.c
View file @
39da0520
...
...
@@ -893,3 +893,30 @@ static void rm_tempfile(void)
unlink
(
typelib_name
);
remove_temp_files
();
}
char
*
find_input_file
(
const
char
*
name
,
const
char
*
parent
)
{
char
*
path
;
/* don't search for a file name with a path in the include directories, for compatibility with MIDL */
if
(
strchr
(
name
,
'/'
)
||
strchr
(
name
,
'\\'
))
path
=
xstrdup
(
name
);
else
if
(
!
(
path
=
wpp_find_include
(
name
,
parent
)))
error_loc
(
"Unable to open include file %s
\n
"
,
name
);
return
path
;
}
FILE
*
open_input_file
(
const
char
*
path
)
{
FILE
*
file
;
char
*
name
;
int
ret
;
name
=
make_temp_file
(
"widl"
,
NULL
);
if
(
!
(
file
=
fopen
(
name
,
"wt"
)))
error_loc
(
"Could not open %s for writing
\n
"
,
name
);
ret
=
wpp_parse
(
path
,
file
);
fclose
(
file
);
if
(
ret
)
exit
(
1
);
if
(
!
(
file
=
fopen
(
name
,
"r"
)))
error_loc
(
"Unable to open %s
\n
"
,
name
);
return
file
;
}
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