From 8c8950af645ca4860c3faade9701a8177cec14ba Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 9 Sep 2008 21:47:34 +0000 Subject: [PATCH] PR/39501: David Holland: Don't print the remainder of the line in the error context because it can confuse input parsing in warnings. A full explanation is in the code. --- dist/nawk/lib.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/dist/nawk/lib.c b/dist/nawk/lib.c index 548a2b5a6105..212fd2ca8b01 100644 --- a/dist/nawk/lib.c +++ b/dist/nawk/lib.c @@ -615,7 +615,6 @@ void error() void eprint(void) /* try to print context around error */ { char *p, *q; - int c; static int been_here = 0; extern char ebuf[], *ep; @@ -639,11 +638,25 @@ void eprint(void) /* try to print context around error */ if (*p) putc(*p, stderr); fprintf(stderr, " <<< "); - if (*ep) +#if 0 + /* + * The following code was used to print the rest of the line of + * error context. It naively counts brackets, parens and braces in + * order to minimize the parsing effect of dropping the rest of the + * line but it does not work in all the cases. It is too much work + * to save the current program input point and restore it in all the + * cases just for the benefit of error printing so for now this + * code is disabled. In particular this code is confused if the + * [ { ( ) } ] is inside a quoted string or a pattern. + */ + if (*ep) { + int c; while ((c = input()) != '\n' && c != '\0' && c != EOF) { putc(c, stderr); bclass(c); } + } +#endif putc('\n', stderr); ep = ebuf; }