diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2018-12-14 00:17:13 -0800 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2018-12-14 00:17:13 -0800 |
commit | 374312cde4d44f8849d602cc5c9ea634798b9c50 (patch) | |
tree | 613d618b52059c61b6dcbaa9f8863ecd0086c0d8 /nasmlib | |
parent | c5593142f750bc440b2d6a0952deaeb769bc6c57 (diff) | |
download | nasm-374312cde4d44f8849d602cc5c9ea634798b9c50.tar.gz |
strlist, warnings: improve strlist, buffer warnings until error
Make strlist_free() take a pointer to a pointer, so we can set it to
NULL.
Buffer warnings on a strlist until we either get an error or we are in
pass 2. Hopefully this should let us get rid of a lot of the ERR_PASS*
bullshit, which far too often causes messages to get lost.
asm/labels.c contains one example of a warning that cannot be made
correct with a specific pass number.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Diffstat (limited to 'nasmlib')
-rw-r--r-- | nasmlib/strlist.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/nasmlib/strlist.c b/nasmlib/strlist.c index 93a6787f..506ad50e 100644 --- a/nasmlib/strlist.c +++ b/nasmlib/strlist.c @@ -136,21 +136,24 @@ strlist_printf(struct strlist *list, const char *fmt, ...) } /* - * Free a string list + * Free a string list. Sets the pointed to pointer to NULL. */ -void strlist_free(struct strlist *list) +void strlist_free(struct strlist **listp) { - if (list) { - struct strlist_entry *e, *tmp; + struct strlist *list = *listp; + struct strlist_entry *e, *tmp; - if (list->uniq) - hash_free(&list->hash); + if (!list) + return; - list_for_each_safe(e, tmp, list->head) - nasm_free(e); + if (list->uniq) + hash_free(&list->hash); - nasm_free(list); - } + list_for_each_safe(e, tmp, list->head) + nasm_free(e); + + nasm_free(list); + *listp = NULL; } /* @@ -187,3 +190,17 @@ void *strlist_linearize(const struct strlist *list, char sep) return buf; } + +/* + * Output a string list to a file. The separator can be any string. + */ +void strlist_write(const struct strlist *list, const char *sep, FILE *f) +{ + const struct strlist_entry *sl; + size_t seplen = strlen(sep); + + strlist_for_each(sl, list) { + fwrite(sl->str, 1, sl->size - 1, f); + fwrite(sep, 1, seplen, f); + } +} |