Module: wine Branch: master Commit: 3b7398b403347e9a127e08afb79b03394aaa5b12 URL: https://gitlab.winehq.org/wine/wine/-/commit/3b7398b403347e9a127e08afb79b033...
Author: Rémi Bernon rbernon@codeweavers.com Date: Fri Aug 18 09:35:41 2023 +0200
widl: Guard against re-import of the main input file.
---
tools/widl/parser.l | 1 + tools/widl/parser.y | 2 +- tools/widl/widl.c | 9 ++++++--- tools/widl/widl.h | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 951998de381..61266efb9e3 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -520,6 +520,7 @@ void push_import( const char *import_name, struct location *where )
LIST_FOR_EACH_ENTRY( import, &imports, struct import, entry ) if (!strcmp( import->name, import_name )) return; /* already imported */ + if (!strcmp( idl_name, import_name )) return; /* already imported */
import = xmalloc( sizeof(struct import) ); import->name = xstrdup( import_name ); diff --git a/tools/widl/parser.y b/tools/widl/parser.y index f66dc62492f..bfd41aa9807 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -2270,7 +2270,7 @@ char *gen_name(void)
if (! file_id) { - char *dst = replace_extension( get_basename(input_idl_name), ".idl", "" ); + char *dst = replace_extension( idl_name, ".idl", "" ); file_id = dst;
for (; *dst; ++dst) diff --git a/tools/widl/widl.c b/tools/widl/widl.c index 5bbaeb970fb..e37160e3869 100644 --- a/tools/widl/widl.c +++ b/tools/widl/widl.c @@ -114,7 +114,7 @@ static int stdinc = 1; static enum stub_mode stub_mode = MODE_Os;
char *input_name; -char *input_idl_name; +char *idl_name; char *acf_name; char *header_name; char *local_stubs_name; @@ -435,7 +435,7 @@ void write_id_data(const statement_list_t *stmts) }
fprintf(idfile, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION); - fprintf(idfile, "from %s - Do not edit ***/\n\n", input_idl_name); + fprintf(idfile, "from %s - Do not edit ***/\n\n", idl_name); fprintf(idfile, "#include <rpc.h>\n"); fprintf(idfile, "#include <rpcndr.h>\n\n");
@@ -782,7 +782,10 @@ int main(int argc,char *argv[]) return 1; } else - input_idl_name = input_name = xstrdup(files.str[0]); + { + input_name = xstrdup( files.str[0] ); + idl_name = get_basename( input_name ); + } } else { fprintf(stderr, "%s", usage); diff --git a/tools/widl/widl.h b/tools/widl/widl.h index 518ae613f83..7595cfe7311 100644 --- a/tools/widl/widl.h +++ b/tools/widl/widl.h @@ -52,7 +52,7 @@ extern int winrt_mode; extern int use_abi_namespace;
extern char *input_name; -extern char *input_idl_name; +extern char *idl_name; extern char *acf_name; extern char *header_name; extern char *header_token;