Don't print extra newlines on error before awk starts parsing. (#97)

If awk prints an error message while when compile_time is still set
to ERROR_PRINTING, don't try to print the context since there is
none.  This can happen due to a problem with, e.g., unknown command
line options.
This commit is contained in:
Todd C. Miller 2020-12-03 10:30:36 -07:00 committed by GitHub
parent a2a41a8e35
commit feb247a852
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

9
lib.c
View File

@ -669,12 +669,11 @@ void error()
fprintf(stderr, " source line number %d", curnode->lineno);
else if (lineno)
fprintf(stderr, " source line number %d", lineno);
if (compile_time == COMPILING && cursource() != NULL)
fprintf(stderr, " source file %s", cursource());
fprintf(stderr, "\n");
eprint();
}
if (compile_time == COMPILING && cursource() != NULL)
fprintf(stderr, " source file %s", cursource());
fprintf(stderr, "\n");
eprint();
}
void eprint(void) /* try to print context around error */