Always list lines that have an error

This commit is contained in:
Paul Koning 2022-06-14 13:26:23 -04:00
parent c42c5732b3
commit aa8d5fdfef
2 changed files with 20 additions and 6 deletions

View File

@ -30,16 +30,26 @@ FILE *lstfile = NULL;
int list_pass_0 = 0;/* Also list what happens during the first pass */
static int errline = 0; /* Set if current line has an error */
/* maybe_list returns TRUE if listing may happen for this line. */
static int can_list(
void)
{
int ok = lstfile != NULL &&
(pass > 0 || list_pass_0);
return ok;
}
/* do_list returns TRUE if listing is enabled. */
static int dolist(
void)
{
int ok = lstfile != NULL &&
(pass > 0 || list_pass_0) &&
list_level > 0;
int ok = can_list () &&
(list_level > 0 || errline);
return ok;
}
@ -50,9 +60,11 @@ void list_source(
STREAM *str,
char *cp)
{
if (dolist()) {
if (can_list()) {
int len = strcspn(cp, "\n");
/* Not an error yet */
errline = 0;
/* Save the line text away for later... */
if (listline)
free(listline);
@ -165,6 +177,8 @@ void report(
if (!pass && list_pass_0 < 2)
return; /* Don't report now. */
errline = 1;
if (str) {
name = str->name;
line = str->line;

View File

@ -4,13 +4,13 @@
4 ;
5
6 ; This should get listed (list_level 1)
7 .nlist
9 .list
10 ; This should get listed (list_level 1)
11 .list
12 ; This should get listed (list_level 2)
13 .nlist
14 ; This should get listed (list_level 1)
15 .nlist
21 .list
22 ; This should get listed (list_level 1)
22