aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2018-12-12 16:47:04 -0800
committerH. Peter Anvin (Intel) <hpa@zytor.com>2018-12-12 16:47:04 -0800
commit46016cb3688bf8582f47967e09b06b69ea271e75 (patch)
treec58e9a40b68c2f380b3f10c8e81e7c3e3a7a149c
parentbdf017c89c7fc66db78ab49729136423d4ce04fe (diff)
downloadnasm-46016cb3688bf8582f47967e09b06b69ea271e75.tar.gz
nasm-46016cb3688bf8582f47967e09b06b69ea271e75.tar.xz
nasm-46016cb3688bf8582f47967e09b06b69ea271e75.zip
listing.c: handle multiple error messages on a single line
We may produce an arbitrary number of error messages on a single line; include all of them in the list file. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--asm/listing.c75
1 files changed, 49 insertions, 26 deletions
diff --git a/asm/listing.c b/asm/listing.c
index 6c459e13..fe7c5e92 100644
--- a/asm/listing.c
+++ b/asm/listing.c
@@ -48,7 +48,7 @@
#include "error.h"
#include "listing.h"
-#define LIST_MAX_LEN 216 /* something sensible */
+#define LIST_MAX_LEN 256 /* something sensible */
#define LIST_INDENT 40
#define LIST_HEXBIT 18
@@ -67,7 +67,11 @@ static char xdigit[] = "0123456789ABCDEF";
static char listline[LIST_MAX_LEN];
static bool listlinep;
-static char listerror[LIST_MAX_LEN];
+struct list_error {
+ struct list_error *next;
+ char str[1];
+};
+struct list_error *listerr_head, **listerr_tail;
static char listdata[2 * LIST_INDENT]; /* we need less than that actually */
static int32_t listoffset;
@@ -85,32 +89,32 @@ static FILE *listfp;
static void list_emit(void)
{
int i;
+ struct list_error *le, *tmp;
- if (!listlinep && !listdata[0])
- return;
-
- fprintf(listfp, "%6"PRId32" ", listlineno);
+ if (listlinep || *listdata) {
+ fprintf(listfp, "%6"PRId32" ", listlineno);
- if (listdata[0])
- fprintf(listfp, "%08"PRIX32" %-*s", listoffset, LIST_HEXBIT + 1,
- listdata);
- else
- fprintf(listfp, "%*s", LIST_HEXBIT + 10, "");
+ if (listdata[0])
+ fprintf(listfp, "%08"PRIX32" %-*s", listoffset, LIST_HEXBIT + 1,
+ listdata);
+ else
+ fprintf(listfp, "%*s", LIST_HEXBIT + 10, "");
- if (listlevel_e)
- fprintf(listfp, "%s<%d>", (listlevel < 10 ? " " : ""),
- listlevel_e);
- else if (listlinep)
- fprintf(listfp, " ");
+ if (listlevel_e)
+ fprintf(listfp, "%s<%d>", (listlevel < 10 ? " " : ""),
+ listlevel_e);
+ else if (listlinep)
+ fprintf(listfp, " ");
- if (listlinep)
- fprintf(listfp, " %s", listline);
+ if (listlinep)
+ fprintf(listfp, " %s", listline);
- putc('\n', listfp);
- listlinep = false;
- listdata[0] = '\0';
+ putc('\n', listfp);
+ listlinep = false;
+ listdata[0] = '\0';
+ }
- if (listerror[0]) {
+ list_for_each_safe(le, tmp, listerr_head) {
fprintf(listfp, "%6"PRId32" ", listlineno);
for (i = 0; i < LIST_HEXBIT; i++)
putc('*', listfp);
@@ -121,9 +125,10 @@ static void list_emit(void)
else
fprintf(listfp, " ");
- fprintf(listfp, " %s\n", listerror);
- listerror[0] = '\0';
+ fprintf(listfp, " %s\n", le->str);
+ nasm_free(le);
}
+ listerr_tail = &listerr_head;
}
static void list_init(const char *fname)
@@ -142,7 +147,8 @@ static void list_init(const char *fname)
*listline = '\0';
listlineno = 0;
- *listerror = '\0';
+ listerr_head = NULL;
+ listerr_tail = &listerr_head;
listp = true;
listlevel = 0;
suppress = 0;
@@ -327,10 +333,27 @@ static void list_downlevel(int type)
static void list_error(int severity, const char *pfx, const char *msg)
{
+ size_t l1, l2;
+ struct list_error *le;
+ char *p;
+
if (!listfp)
return;
- snprintf(listerror, sizeof listerror, "%s%s", pfx, msg);
+ l1 = strlen(pfx);
+ l2 = strlen(msg);
+
+ /* sizeof(*le) already accounts for the final NULL */
+ le = nasm_malloc(sizeof(*le) + l1 + l2);
+
+ le->next = NULL;
+ p = le->str;
+ p = mempcpy(p, pfx, l1);
+ p = mempcpy(p, msg, l2);
+ *p = '\0';
+
+ *listerr_tail = le;
+ listerr_tail = &le->next;
if ((severity & ERR_MASK) >= ERR_FATAL)
list_emit();