mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-02-17 17:19:35 +08:00
listing: add support for multiple errors and dropping the current line
Right now it appears we lose more than one error message from the listing file; this is not OK. Add support for dropping the current listed line (leaving only possible error messages.) This will be used in the upcoming %note patch. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
94acb7b5d0
commit
4431b268ae
@ -49,6 +49,7 @@
|
|||||||
#include "listing.h"
|
#include "listing.h"
|
||||||
|
|
||||||
#define LIST_MAX_LEN 216 /* something sensible */
|
#define LIST_MAX_LEN 216 /* something sensible */
|
||||||
|
#define LIST_MAX_ERRORS 256 /* errors on a single line */
|
||||||
#define LIST_INDENT 40
|
#define LIST_INDENT 40
|
||||||
#define LIST_HEXBIT 18
|
#define LIST_HEXBIT 18
|
||||||
|
|
||||||
@ -60,14 +61,16 @@ static struct MacroInhibit {
|
|||||||
int inhibiting;
|
int inhibiting;
|
||||||
} *mistack;
|
} *mistack;
|
||||||
|
|
||||||
static char xdigit[] = "0123456789ABCDEF";
|
static const char xdigit[16] = "0123456789ABCDEF";
|
||||||
|
|
||||||
#define HEX(a,b) (*(a)=xdigit[((b)>>4)&15],(a)[1]=xdigit[(b)&15]);
|
#define HEX(a,b) (*(a)=xdigit[((b)>>4)&15],(a)[1]=xdigit[(b)&15]);
|
||||||
|
|
||||||
static char listline[LIST_MAX_LEN];
|
static char listline[LIST_MAX_LEN];
|
||||||
static bool listlinep;
|
static bool listlinep;
|
||||||
|
|
||||||
static char listerror[LIST_MAX_LEN];
|
static char *listerror[LIST_MAX_ERRORS];
|
||||||
|
static int listerrors;
|
||||||
|
static char err_hex[LIST_HEXBIT+1];
|
||||||
|
|
||||||
static char listdata[2 * LIST_INDENT]; /* we need less than that actually */
|
static char listdata[2 * LIST_INDENT]; /* we need less than that actually */
|
||||||
static int32_t listoffset;
|
static int32_t listoffset;
|
||||||
@ -86,44 +89,41 @@ static void list_emit(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!listlinep && !listdata[0])
|
if (listlinep || listdata[0]) {
|
||||||
return;
|
fprintf(listfp, "%6"PRId32" ", listlineno);
|
||||||
|
|
||||||
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])
|
if (listlevel_e)
|
||||||
fprintf(listfp, "%08"PRIX32" %-*s", listoffset, LIST_HEXBIT + 1,
|
fprintf(listfp, "%s<%d>", (listlevel < 10 ? " " : ""),
|
||||||
listdata);
|
listlevel_e);
|
||||||
else
|
else if (listlinep)
|
||||||
fprintf(listfp, "%*s", LIST_HEXBIT + 10, "");
|
fprintf(listfp, " ");
|
||||||
|
|
||||||
if (listlevel_e)
|
if (listlinep)
|
||||||
fprintf(listfp, "%s<%d>", (listlevel < 10 ? " " : ""),
|
fprintf(listfp, " %s", listline);
|
||||||
listlevel_e);
|
|
||||||
else if (listlinep)
|
|
||||||
fprintf(listfp, " ");
|
|
||||||
|
|
||||||
if (listlinep)
|
putc('\n', listfp);
|
||||||
fprintf(listfp, " %s", listline);
|
listlinep = false;
|
||||||
|
listdata[0] = '\0';
|
||||||
putc('\n', listfp);
|
}
|
||||||
listlinep = false;
|
|
||||||
listdata[0] = '\0';
|
|
||||||
|
|
||||||
if (listerror[0]) {
|
|
||||||
fprintf(listfp, "%6"PRId32" ", listlineno);
|
|
||||||
for (i = 0; i < LIST_HEXBIT; i++)
|
|
||||||
putc('*', listfp);
|
|
||||||
|
|
||||||
|
for (i = 0; i < listerrors; i++) {
|
||||||
|
fprintf(listfp, "%6"PRId32" %s", listlineno, err_hex);
|
||||||
if (listlevel_e)
|
if (listlevel_e)
|
||||||
fprintf(listfp, " %s<%d>", (listlevel < 10 ? " " : ""),
|
fprintf(listfp, " %s<%d>", (listlevel < 10 ? " " : ""),
|
||||||
listlevel_e);
|
listlevel_e);
|
||||||
else
|
else
|
||||||
fprintf(listfp, " ");
|
fprintf(listfp, " ");
|
||||||
|
|
||||||
fprintf(listfp, " %s\n", listerror);
|
fprintf(listfp, " %s\n", listerror[i]);
|
||||||
listerror[0] = '\0';
|
nasm_free(listerror[i]);
|
||||||
}
|
}
|
||||||
|
listerrors = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void list_init(const char *fname)
|
static void list_init(const char *fname)
|
||||||
@ -142,7 +142,7 @@ static void list_init(const char *fname)
|
|||||||
|
|
||||||
*listline = '\0';
|
*listline = '\0';
|
||||||
listlineno = 0;
|
listlineno = 0;
|
||||||
*listerror = '\0';
|
listerrors = 0;
|
||||||
listp = true;
|
listp = true;
|
||||||
listlevel = 0;
|
listlevel = 0;
|
||||||
suppress = 0;
|
suppress = 0;
|
||||||
@ -150,6 +150,7 @@ static void list_init(const char *fname)
|
|||||||
mistack->next = NULL;
|
mistack->next = NULL;
|
||||||
mistack->level = 0;
|
mistack->level = 0;
|
||||||
mistack->inhibiting = true;
|
mistack->inhibiting = true;
|
||||||
|
memset(err_hex, '*', sizeof(err_hex) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void list_cleanup(void)
|
static void list_cleanup(void)
|
||||||
@ -280,6 +281,12 @@ static void list_line(int type, char *line)
|
|||||||
listlevel_e = listlevel;
|
listlevel_e = listlevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void list_drop(void)
|
||||||
|
{
|
||||||
|
listlinep = false;
|
||||||
|
list_emit();
|
||||||
|
}
|
||||||
|
|
||||||
static void list_uplevel(int type)
|
static void list_uplevel(int type)
|
||||||
{
|
{
|
||||||
if (!listp)
|
if (!listp)
|
||||||
@ -330,7 +337,10 @@ static void list_error(int severity, const char *pfx, const char *msg)
|
|||||||
if (!listfp)
|
if (!listfp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
snprintf(listerror, sizeof listerror, "%s%s", pfx, msg);
|
if (listerrors >= LIST_MAX_ERRORS)
|
||||||
|
return; /* We have *HOW* many errors on this line? */
|
||||||
|
|
||||||
|
listerror[listerrors++] = nasm_strcat(pfx, msg);
|
||||||
|
|
||||||
if ((severity & ERR_MASK) >= ERR_FATAL)
|
if ((severity & ERR_MASK) >= ERR_FATAL)
|
||||||
list_emit();
|
list_emit();
|
||||||
@ -346,6 +356,7 @@ static const struct lfmt nasm_list = {
|
|||||||
list_cleanup,
|
list_cleanup,
|
||||||
list_output,
|
list_output,
|
||||||
list_line,
|
list_line,
|
||||||
|
list_drop,
|
||||||
list_uplevel,
|
list_uplevel,
|
||||||
list_downlevel,
|
list_downlevel,
|
||||||
list_error,
|
list_error,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ----------------------------------------------------------------------- *
|
/* ----------------------------------------------------------------------- *
|
||||||
*
|
*
|
||||||
* Copyright 1996-2016 The NASM Authors - All Rights Reserved
|
* Copyright 1996-2016 The NASM Authors - All Rights Reserved
|
||||||
* See the file AUTHORS included with the NASM distribution for
|
* See the file AUTHORS included with the NASM distribution for
|
||||||
* the specific copyright holders.
|
* the specific copyright holders.
|
||||||
@ -14,7 +14,7 @@
|
|||||||
* copyright notice, this list of conditions and the following
|
* copyright notice, this list of conditions and the following
|
||||||
* disclaimer in the documentation and/or other materials provided
|
* disclaimer in the documentation and/or other materials provided
|
||||||
* with the distribution.
|
* with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
@ -31,7 +31,7 @@
|
|||||||
*
|
*
|
||||||
* ----------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* listing.h header file for listing.c
|
* listing.h header file for listing.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -73,6 +73,11 @@ struct lfmt {
|
|||||||
*/
|
*/
|
||||||
void (*line)(int type, char *line);
|
void (*line)(int type, char *line);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call to suppress the printing of the current line.
|
||||||
|
*/
|
||||||
|
void (*drop)(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called to change one of the various levelled mechanisms in
|
* Called to change one of the various levelled mechanisms in
|
||||||
* the listing generator. LIST_INCLUDE and LIST_MACRO can be
|
* the listing generator. LIST_INCLUDE and LIST_MACRO can be
|
||||||
|
Loading…
Reference in New Issue
Block a user