Module: wine Branch: master Commit: 9d1f1a3fb1533f72243bfc9258f421d294fee5ad URL: https://gitlab.winehq.org/wine/wine/-/commit/9d1f1a3fb1533f72243bfc9258f421d...
Author: Rémi Bernon rbernon@codeweavers.com Date: Tue Jan 24 22:19:45 2023 +0100
widl: Use a struct list to keep imported files.
---
tools/widl/parser.l | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 85d33d6e86a..710b6e37636 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -89,6 +89,13 @@ struct { } import_stack[MAX_IMPORT_DEPTH]; int import_stack_ptr = 0;
+struct import +{ + const char *name; + struct list entry; +}; +static struct list imports = LIST_INIT( imports ); + /* converts an integer in string form to an unsigned long and prints an error * on overflow */ static unsigned int xstrtoul(const char *nptr, char **endptr, int base) @@ -513,28 +520,20 @@ void pop_import(void) import_stack_ptr--; }
-struct imports { - char *name; - struct imports *next; -} *first_import; - int do_import(char *fname) { FILE *f; char *path, *name; - struct imports *import; + struct import *import; int ptr = import_stack_ptr; int ret;
- import = first_import; - while (import && strcmp(import->name, fname)) - import = import->next; - if (import) return 0; /* already imported */ + LIST_FOR_EACH_ENTRY( import, &imports, struct import, entry ) + if (!strcmp( import->name, fname )) return 0; /* already imported */
- import = xmalloc(sizeof(struct imports)); - import->name = xstrdup(fname); - import->next = first_import; - first_import = import; + import = xmalloc( sizeof(struct import) ); + import->name = xstrdup( fname ); + list_add_tail( &imports, &import->entry );
/* don't search for a file name with a path in the include directories, * for compatibility with MIDL */