Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jul 2002 04:00:13 +0200 (CEST)
From:      Cyrille Lefevre <cyrille.lefevre@laposte.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        "Tim J. Robbins" <tjr@FreeBSD.org>
Subject:   bin/41190: in sed, report the { linenum instead of EOF linenum on pending }
Message-ID:  <200207310200.g6V20Dbb004787@gits.gits.dyndns.org>

next in thread | raw e-mail | index | archive | help

>Number:         41190
>Category:       bin
>Synopsis:       in sed, report the { linenum instead of EOF linenum on pending }
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 30 19:10:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Cyrille Lefevre
>Release:        FreeBSD 4.6-STABLE i386
>Organization:
ACME
>Environment:
System: FreeBSD gits 4.6-STABLE FreeBSD 4.6-STABLE #21: Sun Jul 28 09:42:24 CEST 2002 root@gits:/disk2/freebsd/stable/src/sys/compile/CUSTOM i386
>Description:
	actually, sed reports the EOF linenum on pending }. this patch
	makes sed to report the { linenum instead.
>How-To-Repeat:
	fetch http://queen.rett.polimi.it/~paolob/seders/scripts/sokoban.sed
	sed -f sokoban.sed
	sed: 2266: /root/sokoban.sed: unexpected EOF (pending }'s)

	patched version says :
	sed: 2063: /root/sokoban.sed: unexpected EOF (pending }'s)
	which is more accurate, IMHO.
>Fix:
Index: compile.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/sed/compile.c,v
retrieving revision 1.21
diff -u -r1.21 compile.c
--- compile.c	1 Jun 2002 13:25:47 -0000	1.21
+++ compile.c	31 Jul 2002 01:53:02 -0000
@@ -165,9 +165,12 @@
 	stack = 0;
 	for (;;) {
 		if ((p = cu_fgets(lbuf, sizeof(lbuf), NULL)) == NULL) {
-			if (stack != 0)
+			if (stack != 0) {
+				for (cmd = stack; cmd->next; cmd = cmd->next)
+					/* nothing */ ;
 				errx(1, "%lu: %s: unexpected EOF (pending }'s)",
-							linenum, fname);
+							cmd->linenum, fname);
+			}
 			return (link);
 		}
 
@@ -226,6 +229,7 @@
 			p++;
 			EATSPACE();
 			cmd->next = stack;
+			cmd->linenum = linenum;
 			stack = cmd;
 			link = &cmd->u.c;
 			if (*p)
Index: defs.h
===================================================================
RCS file: /home/ncvs/src/usr.bin/sed/defs.h,v
retrieving revision 1.3
diff -u -r1.3 defs.h
--- defs.h	11 Aug 1997 07:21:00 -0000	1.3
+++ defs.h	31 Jul 2002 01:51:04 -0000
@@ -88,6 +88,7 @@
 		int fd;				/* File descriptor for w */
 	} u;
 	char code;				/* Command code */
+	u_long linenum;				/* Line number. */
 	u_int nonsel:1;				/* True if ! */
 	u_int inrange:1;			/* True if in range */
 };
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207310200.g6V20Dbb004787>