From owner-freebsd-current Wed Jul 17 00:56:58 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id AAA07150 for current-outgoing; Wed, 17 Jul 1996 00:56:58 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id AAA07145 for ; Wed, 17 Jul 1996 00:56:54 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.12/8.6.9) id RAA00019; Wed, 17 Jul 1996 17:54:01 +1000 Date: Wed, 17 Jul 1996 17:54:01 +1000 From: Bruce Evans Message-Id: <199607170754.RAA00019@godzilla.zeta.org.au> To: bde@zeta.org.au, davidg@root.com Subject: Re: sed broken Cc: bostic@bsdi.com, current@FreeBSD.org, mark@linus.demon.co.uk Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk >>Making init_sysent.c in /sys/kern no longer works. sed looped and grew to >>50MB before I killed it. I backed out to rounds of attempted fixes to >>sed/compile.c (to rev.1.4) and the make worked again. > Try Keith Bostic's final version (you'll have to dig it out of PR#1350) and >see if it works. Our PR's seem to be tangled up: some followups to #1350 are in #1353, #1354 and #1356 with Keith's final version in #1356. I fixed it independently before locating all the PR's. My version is the same as Keith's except it loses more gracefully for lines not terminated by a newline. Bruce Index: compile.c =================================================================== RCS file: /a/ncvs/src/usr.bin/sed/compile.c,v retrieving revision 1.4 diff -c -2 -r1.4 compile.c *** compile.c 1995/08/16 05:56:42 1.4 --- compile.c 1996/07/17 07:08:56 *************** *** 616,620 **** compile_text() { ! int asize, size; char *text, *p, *op, *s; char lbuf[_POSIX2_LINE_MAX + 1]; --- 616,620 ---- compile_text() { ! int asize, esc_nl, size; char *text, *p, *op, *s; char lbuf[_POSIX2_LINE_MAX + 1]; *************** *** 627,637 **** p = lbuf; EATSPACE(); ! for (; *p; p++) { ! if (*p == '\\') ! p++; *s++ = *p; } size += s - op; ! if (p[-2] != '\\') { *s = '\0'; break; --- 627,637 ---- p = lbuf; EATSPACE(); ! for (esc_nl = 0; *p != '\0'; p++) { ! if (*p == '\\' && p[1] != '\0' && *++p == '\n') ! esc_nl = 1; *s++ = *p; } size += s - op; ! if (!esc_nl) { *s = '\0'; break;