forked from aniani/nasm
listing: when listing lines in macros and rep blocks, show the actual line
When printing lines coming from %rep blocks and macros, show the line number corresponding to the line actually being printed. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/* ----------------------------------------------------------------------- *
|
/* ----------------------------------------------------------------------- *
|
||||||
*
|
*
|
||||||
* Copyright 1996-2018 The NASM Authors - All Rights Reserved
|
* Copyright 1996-2019 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.
|
||||||
*
|
*
|
||||||
@@ -258,7 +258,7 @@ static void list_output(const struct out_data *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void list_line(int type, char *line)
|
static void list_line(int type, int32_t lineno, const char *line)
|
||||||
{
|
{
|
||||||
if (!listp)
|
if (!listp)
|
||||||
return;
|
return;
|
||||||
@@ -276,7 +276,8 @@ static void list_line(int type, char *line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
list_emit();
|
list_emit();
|
||||||
listlineno = src_get_linnum();
|
if (lineno >= 0)
|
||||||
|
listlineno = lineno;
|
||||||
listlinep = true;
|
listlinep = true;
|
||||||
strlcpy(listline, line, LIST_MAX_LEN-3);
|
strlcpy(listline, line, LIST_MAX_LEN-3);
|
||||||
memcpy(listline + LIST_MAX_LEN-4, "...", 4);
|
memcpy(listline + LIST_MAX_LEN-4, "...", 4);
|
||||||
|
@@ -70,8 +70,11 @@ struct lfmt {
|
|||||||
* `int' parameter is LIST_READ or LIST_MACRO depending on
|
* `int' parameter is LIST_READ or LIST_MACRO depending on
|
||||||
* whether the line came directly from an input file or is the
|
* whether the line came directly from an input file or is the
|
||||||
* result of a multi-line macro expansion.
|
* result of a multi-line macro expansion.
|
||||||
|
*
|
||||||
|
* If a line number is provided, print it; if the line number is
|
||||||
|
* -1 then use the same line number as the previous call.
|
||||||
*/
|
*/
|
||||||
void (*line)(int type, char *line);
|
void (*line)(int type, int32_t lineno, const char *line);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called to change one of the various levelled mechanisms in the
|
* Called to change one of the various levelled mechanisms in the
|
||||||
|
@@ -128,7 +128,7 @@ static char *nop_getline(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
lfmt->line(LIST_READ, buffer);
|
lfmt->line(LIST_READ, src_get_linnum(), buffer);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@@ -859,6 +859,7 @@ static char *read_line(void)
|
|||||||
unsigned int nr_cont = 0;
|
unsigned int nr_cont = 0;
|
||||||
bool cont = false;
|
bool cont = false;
|
||||||
char *buffer, *p;
|
char *buffer, *p;
|
||||||
|
int32_t lineno;
|
||||||
|
|
||||||
/* Standart macros set (predefined) goes first */
|
/* Standart macros set (predefined) goes first */
|
||||||
p = line_from_stdmac();
|
p = line_from_stdmac();
|
||||||
@@ -923,9 +924,10 @@ static char *read_line(void)
|
|||||||
*p++ = c;
|
*p++ = c;
|
||||||
} while (c);
|
} while (c);
|
||||||
|
|
||||||
src_set_linnum(src_get_linnum() + istk->lineinc +
|
lineno = src_get_linnum() + istk->lineinc +
|
||||||
(nr_cont * istk->lineinc));
|
(nr_cont * istk->lineinc);
|
||||||
lfmt->line(LIST_READ, buffer);
|
src_set_linnum(lineno);
|
||||||
|
lfmt->line(LIST_READ, lineno, buffer);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@@ -3194,20 +3196,12 @@ issue_error:
|
|||||||
free_tlist(origline);
|
free_tlist(origline);
|
||||||
|
|
||||||
tmp_defining = defining;
|
tmp_defining = defining;
|
||||||
defining = nasm_malloc(sizeof(MMacro));
|
nasm_new(defining);
|
||||||
defining->prev = NULL;
|
|
||||||
defining->name = NULL; /* flags this macro as a %rep block */
|
|
||||||
defining->casesense = false;
|
|
||||||
defining->plus = false;
|
|
||||||
defining->nolist = nolist;
|
defining->nolist = nolist;
|
||||||
defining->in_progress = count;
|
defining->in_progress = count;
|
||||||
defining->max_depth = 0;
|
|
||||||
defining->nparam_min = defining->nparam_max = 0;
|
|
||||||
defining->defaults = NULL;
|
|
||||||
defining->dlist = NULL;
|
|
||||||
defining->expansion = NULL;
|
|
||||||
defining->next_active = istk->mstk;
|
defining->next_active = istk->mstk;
|
||||||
defining->rep_nest = tmp_defining;
|
defining->rep_nest = tmp_defining;
|
||||||
|
src_get(&defining->xline, &defining->fname);
|
||||||
return DIRECTIVE_FOUND;
|
return DIRECTIVE_FOUND;
|
||||||
|
|
||||||
case PP_ENDREP:
|
case PP_ENDREP:
|
||||||
@@ -5484,13 +5478,19 @@ static Token *pp_tokline(void)
|
|||||||
|
|
||||||
if (istk->expansion) { /* from a macro expansion */
|
if (istk->expansion) { /* from a macro expansion */
|
||||||
Line *l = istk->expansion;
|
Line *l = istk->expansion;
|
||||||
|
int32_t lineno;
|
||||||
|
|
||||||
if (istk->mstk)
|
if (istk->mstk)
|
||||||
istk->mstk->lineno++;
|
lineno = ++istk->mstk->lineno + istk->mstk->xline;
|
||||||
|
else
|
||||||
|
lineno = src_get_linnum();
|
||||||
|
|
||||||
tline = l->first;
|
tline = l->first;
|
||||||
istk->expansion = l->next;
|
istk->expansion = l->next;
|
||||||
nasm_free(l);
|
nasm_free(l);
|
||||||
|
|
||||||
line = detoken(tline, false);
|
line = detoken(tline, false);
|
||||||
lfmt->line(LIST_MACRO, line);
|
lfmt->line(LIST_MACRO, lineno, line);
|
||||||
nasm_free(line);
|
nasm_free(line);
|
||||||
} else if ((line = read_line())) {
|
} else if ((line = read_line())) {
|
||||||
line = prepreproc(line);
|
line = prepreproc(line);
|
||||||
@@ -5602,7 +5602,7 @@ static char *pp_getline(void)
|
|||||||
|
|
||||||
if (list_option('e') && line && line[0]) {
|
if (list_option('e') && line && line[0]) {
|
||||||
char *buf = nasm_strcat(" ;;; ", line);
|
char *buf = nasm_strcat(" ;;; ", line);
|
||||||
lfmt->line(LIST_MACRO, buf);
|
lfmt->line(LIST_MACRO, -1, buf);
|
||||||
nasm_free(buf);
|
nasm_free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user