Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Jul 1996 17:54:01 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, davidg@root.com
Cc:        bostic@bsdi.com, current@FreeBSD.org, mark@linus.demon.co.uk
Subject:   Re: sed broken
Message-ID:  <199607170754.RAA00019@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>>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;



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