summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2020-07-30 17:46:55 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2020-07-30 17:46:55 +0000
commit7ce155510c818610fc9945ade82329e1f65750d7 (patch)
tree8809e6619ef8ba0f741dd639eed9979357d1d299
parentc8a944f12f7ae6fc2ca46c773045caf38d134ca5 (diff)
Don't print extra newlines on error before awk starts parsing.
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--usr.bin/awk/lib.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/usr.bin/awk/lib.c b/usr.bin/awk/lib.c
index d491f1a8dd8..173317a85ba 100644
--- a/usr.bin/awk/lib.c
+++ b/usr.bin/awk/lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib.c,v 1.40 2020/07/30 17:45:44 millert Exp $ */
+/* $OpenBSD: lib.c,v 1.41 2020/07/30 17:46:54 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -673,12 +673,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 */