From 7ce155510c818610fc9945ade82329e1f65750d7 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 30 Jul 2020 17:46:55 +0000 Subject: 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. --- usr.bin/awk/lib.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'usr.bin/awk/lib.c') 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 */ -- cgit v1.2.3