aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <Todd.Miller@sudo.ws>2020-12-03 10:30:36 -0700
committerGitHub <noreply@github.com>2020-12-03 19:30:36 +0200
commitfeb247a852c0a068dc8c23e0e683a5af075fff60 (patch)
treed9be608e7cd5acea29062bb8d2c739424dace360
parenta2a41a8e359dca5295c43dc2c2408094b96c3e0c (diff)
downloadone-true-awk-feb247a852c0a068dc8c23e0e683a5af075fff60.tar.gz
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.
-rw-r--r--lib.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib.c b/lib.c
index f55e897..db065db 100644
--- a/lib.c
+++ b/lib.c
@@ -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 */