listing: change the line numbers to match the source code

Instead of completely useless sequential line numbers, emit line
numbers corresponding to the line numbers in the source code.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2016-02-17 15:35:06 -08:00
parent 777b7b1d25
commit d2ea49b326
2 changed files with 11 additions and 7 deletions

View file

@ -32,6 +32,9 @@ since 2007.
relocations are zero-extended from 32-bits with a warning
(suppressible via \c{}); signed 64-bit relocations are an arror.
\b Line numbers in list files now correspond to the lines in the source
files, instead of simply being sequential.
\S{cl-2.11.09} Version 2.11.09
\b Fix potential stack overwrite in \c{macho32} backend.

View file

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 1996-2009 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
* the specific copyright holders.
*
@ -73,6 +73,7 @@ static char listdata[2 * LIST_INDENT]; /* we need less than that actually */
static int32_t listoffset;
static int32_t listlineno;
static const char *listfn;
static int32_t listp;
@ -89,7 +90,7 @@ static void list_emit(void)
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,
@ -111,7 +112,7 @@ static void list_emit(void)
listdata[0] = '\0';
if (listerror[0]) {
fprintf(listfp, "%6"PRId32" ", ++listlineno);
fprintf(listfp, "%6"PRId32" ", listlineno);
for (i = 0; i < LIST_HEXBIT; i++)
putc('*', listfp);
@ -243,10 +244,9 @@ static void list_line(int type, char *line)
{
if (!listp)
return;
if (user_nolist) { /* fbk - 9/2/00 */
listlineno++;
return;
}
if (user_nolist)
return;
if (mistack && mistack->inhibiting) {
if (type == LIST_MACRO)
@ -258,6 +258,7 @@ static void list_line(int type, char *line)
}
}
list_emit();
listlineno = src_get_linnum();
listlinep = true;
strncpy(listline, line, LIST_MAX_LEN - 1);
listline[LIST_MAX_LEN - 1] = '\0';