From root@gits.dyndns.org  Tue Jul 30 19:00:43 2002
Return-Path: <root@gits.dyndns.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D912137B401
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Jul 2002 19:00:43 -0700 (PDT)
Received: from smtp.noos.fr (camus.noos.net [212.198.2.70])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B058943E31
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Jul 2002 19:00:42 -0700 (PDT)
	(envelope-from root@gits.dyndns.org)
Received: (qmail 49160778 invoked by uid 0); 31 Jul 2002 02:00:26 -0000
Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.229.153]) (envelope-sender <root@gits.dyndns.org>)
          by 212.198.2.70 (qmail-ldap-1.03) with SMTP
          for <FreeBSD-gnats-submit@freebsd.org>; 31 Jul 2002 02:00:26 -0000
Received: from gits.gits.dyndns.org (sh9g6w5ad0ctwn63@localhost [127.0.0.1])
	by gits.gits.dyndns.org (8.12.5/8.12.5) with ESMTP id g6V20EJD004789;
	Wed, 31 Jul 2002 04:00:15 +0200 (CEST)
	(envelope-from root@gits.dyndns.org)
Received: (from root@localhost)
	by gits.gits.dyndns.org (8.12.5/8.12.5/Submit) id g6V20Dbb004787;
	Wed, 31 Jul 2002 04:00:13 +0200 (CEST)
	(envelope-from root)
Message-Id: <200207310200.g6V20Dbb004787@gits.gits.dyndns.org>
Date: Wed, 31 Jul 2002 04:00:13 +0200 (CEST)
From: Cyrille Lefevre <cyrille.lefevre@laposte.net>
Reply-To: Cyrille Lefevre <cyrille.lefevre@laposte.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc: "Tim J. Robbins" <tjr@freebsd.org>
Subject: in sed, report the { linenum instead of EOF linenum on pending }
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         41190
>Category:       bin
>Synopsis:       [patch] sed(1) 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:  Mon Apr  8 23:00:00 UTC 2013
>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:

From: "Simon 'corecode' Schubert" <corecode@corecode.ath.cx>
To: Cyrille Lefevre <cyrille.lefevre@laposte.net>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG, tjr@FreeBSD.ORG
Subject: Re: bin/41190: in sed, report the { linenum instead of EOF linenum on pending }
Date: Wed, 31 Jul 2002 16:52:50 +0200

 --=.njZdDoSOH3BiKf
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 
 On Wed, 31 Jul 2002 04:00:13 +0200 (CEST) Cyrille Lefevre wrote:
 
 > >Description:
 > 	actually, sed reports the EOF linenum on pending }. this patch
 > 	makes sed to report the { linenum instead.
 
 i think that's counter-intuitive as all programs i know of report the
 line containing the error (pending }) and don't guess about where it
 could have originated:
 
 % echo 'foo() {' > foo.c && cc foo.c
 foo.c: In function `foo':
 foo.c:2: syntax error at end of input
 
 cheers
   simon
 
 -- 
 /"\   http://corecode.ath.cx/#donate
 \ /
  \     ASCII Ribbon Campaign
 / \  Against HTML Mail and News
 
 --=.njZdDoSOH3BiKf
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.7 (FreeBSD)
 
 iD8DBQE9R/nGr5S+dk6z85oRArPKAKCDPeJXGOKSh65LSjgwJb9xTxVpSQCgwA3y
 PyDf7NEht7KwyEhTmRWLtCE=
 =nOYh
 -----END PGP SIGNATURE-----
 
 --=.njZdDoSOH3BiKf--
 

From: Cyrille Lefevre <cyrille.lefevre-lists@laposte.net>
To: bug-followup@FreeBSD.org, cyrille.lefevre@laposte.net
Cc:  
Subject: Re: bin/41190: [patch] sed(1) report the { linenum instead of EOF
 linenum on pending }
Date: Tue, 09 Apr 2013 00:45:06 +0200

 ping more than 10 years after... !
 
>Unformatted:
