Mercurial > hg > index.cgi
diff lwasm/input.c @ 224:3864d96ee8c7
Make unicorns notice referenced files better
Fix bug related to includebin and also make unicorns notice all files opened
through the input subsystem when generating the resource list.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 15 Jul 2012 20:50:18 -0600 |
parents | afd50d6b4113 |
children | 4b36eaaf80c3 |
line wrap: on
line diff
--- a/lwasm/input.c Sun Jul 15 20:14:51 2012 -0600 +++ b/lwasm/input.c Sun Jul 15 20:50:18 2012 -0600 @@ -80,6 +80,28 @@ #define IS ((struct input_stack *)(as -> input_data)) +struct ifl *ifl_head = NULL; + +/* this adds real filenames that were opened to a list */ +void input_add_to_resource_list(asmstate_t *as, const char *s) +{ + struct ifl *ifl; + + /* first see if the file is already referenced */ + for (ifl = ifl_head; ifl; ifl = ifl -> next) + { + if (strcmp(s, ifl -> fn) == 0) + break; + } + if (!ifl) + { + ifl = lw_alloc(sizeof(struct ifl)); + ifl -> next = ifl_head; + ifl_head = ifl; + ifl -> fn = lw_strdup(s); + } +} + void input_init(asmstate_t *as) { struct input_stack *t; @@ -200,6 +222,7 @@ as -> fileerr = 1; } input_pushpath(as, s); + input_add_to_resource_list(as, s); return; } @@ -211,6 +234,7 @@ if (IS -> data) { input_pushpath(as, p2); + input_add_to_resource_list(as, p2); lw_free(p2); return; } @@ -227,6 +251,7 @@ if (IS -> data) { input_pushpath(as, p2); + input_add_to_resource_list(as, p2); lw_free(p2); return; } @@ -252,18 +277,20 @@ lw_error("Cannot open file '%s': %s\n", s, strerror(errno)); } input_pushpath(as, s); + input_add_to_resource_list(as, s); return; } lw_error("Cannot figure out how to open '%s'.\n", t -> filespec); } -FILE *input_open_standalone(asmstate_t *as, char *s) +FILE *input_open_standalone(asmstate_t *as, char *s, char **rfn) { // char *s2; FILE *fp; char *p, *p2; + debug_message(as, 2, "Open file (st) %s", s); /* first check for absolute path and if so, skip path */ if (*s == '/') { @@ -276,6 +303,9 @@ { return NULL; } + if (rfn) + *rfn = lw_strdup(s); + input_add_to_resource_list(as, s); return fp; } @@ -288,6 +318,9 @@ { if (as -> flags & FLAG_DEPEND) printf("%s\n", p2); + input_add_to_resource_list(as, p2); + if (rfn) + *rfn = lw_strdup(p2); lw_free(p2); return fp; } @@ -304,6 +337,9 @@ { if (as -> flags & FLAG_DEPEND) printf("%s\n", p2); + input_add_to_resource_list(as, p2); + if (rfn) + *rfn = lw_strdup(p2); lw_free(p2); return fp; }