NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: PR/50484 CVS commit: src/external/bsd/nvi



The following reply was made to PR bin/50484; it has been noted by GNATS.

From: Rin Okuyama <okuyama%flex.phys.tohoku.ac.jp@localhost>
To: gnats-bugs%NetBSD.org@localhost, christos%netbsd.org@localhost
Cc: 
Subject: Re: PR/50484 CVS commit: src/external/bsd/nvi
Date: Mon, 30 Nov 2015 01:30:31 +0900

 Thank you for your commit.
 
 I'm sorry, however, the previous version still has a problem when
 output is long; although segmentation faults are safely avoided,
 every 1024th characters are replaced by line breaks.
 
   https://twitter.com/LabDrunker/status/670999814516121600
 
 Here, I attached the revised version. I'm sorry for taking your
 time, but please apply the patch below.
 
 Thanks,
 Rin
 
 --- src/external/bsd/nvi/Makefile.inc.orig	2015-11-29 00:34:51.000000000 +0900
 +++ src/external/bsd/nvi/Makefile.inc	2015-11-29 00:34:57.000000000 +0900
 @@ -7,4 +7,4 @@
  BINDIR=/usr/bin
  
  CWARNFLAGS.clang+=	-Wno-error=unused-const-variable
 -VERSION=1.81.6-2013-11-20nb2
 +VERSION=1.81.6-2013-11-20nb3
 --- src/external/bsd/nvi/dist/ex/ex_script.c.orig	2015-11-29 00:03:55.000000000 +0900
 +++ src/external/bsd/nvi/dist/ex/ex_script.c	2015-11-29 05:17:24.000000000 +0900
 @@ -294,7 +294,7 @@
  	INT2CHAR(sp, ip, ilen, p, len);
  
  	/* Delete any prompt. */
 -	if (sc->sh_prompt != NULL && strnstr(p, sc->sh_prompt, len) == p) {
 +	if (strnstr(p, sc->sh_prompt, len) == p) {
  		len -= sc->sh_prompt_len;
  		if (len == 0) {
  empty:			msgq(sp, M_BERR, "151|No command to execute");
 @@ -456,7 +456,7 @@
  
  	/* Append the lines into the file. */
  	for (p = t = bp; p < endp; ++p) {
 -		if (p == bp + sizeof(bp) - 1 || *p == '\r' || *p == '\n') {
 +		if (*p == '\r' || *p == '\n') {
  			len = p - t;
  			if (CHAR2INT(sp, t, len, ip, ilen) ||
  			    db_append(sp, 1, lno++, ip, ilen))
 @@ -464,37 +464,45 @@
  			t = p + 1;
  		}
  	}
 -	if (p > t) {
 -		len = p - t;
 -		/*
 -		 * If the last thing from the shell isn't another prompt, wait
 -		 * up to 1/10 of a second for more stuff to show up, so that
 -		 * we don't break the output into two separate lines.  Don't
 -		 * want to hang indefinitely because some program is hanging,
 -		 * confused the shell, or whatever.
 -		 */
 -		if (len != sc->sh_prompt_len ||
 -		    strnstr(t, sc->sh_prompt, len) == NULL) {
 -			tv.tv_sec = 0;
 -			tv.tv_usec = 100000;
 -			FD_ZERO(&rdfd);
 -			FD_SET(sc->sh_master, &rdfd);
 -			if (select(sc->sh_master + 1,
 -			    &rdfd, NULL, NULL, &tv) == 1) {
 +	/*
 +	 * If the last thing from the shell isn't another prompt, wait up to
 +	 * 1/10 of a second for more stuff to show up, so that we don't break
 +	 * the output into two separate lines.  Don't want to hang indefinitely
 +	 * because some program is hanging, confused the shell, or whatever.
 +	 * Note that sc->sh_prompt can be NULL here.
 +	 */
 +	len = p - t;
 +	if (sc->sh_prompt == NULL || len != sc->sh_prompt_len ||
 +	    strnstr(p, sc->sh_prompt, len) == NULL) {
 +		tv.tv_sec = 0;
 +		tv.tv_usec = 100000;
 +		FD_ZERO(&rdfd);
 +		FD_SET(sc->sh_master, &rdfd);
 +		if (select(sc->sh_master + 1, &rdfd, NULL, NULL, &tv) == 1) {
 +			if (len == sizeof(bp)) {
 +				if (CHAR2INT(sp, t, len, ip, ilen) ||
 +				    db_append(sp, 1, lno++, ip, ilen))
 +					return (1);
 +				endp = bp;
 +			} else {
  				memmove(bp, t, len);
  				endp = bp + len;
 -				goto more;
  			}
 +			goto more;
  		}
 -		if (sscr_setprompt(sp, t, len) ||
 -		    CHAR2INT(sp, t, len, ip, ilen) ||
 -		    db_append(sp, 1, lno++, ip, ilen))
 +		if (sscr_setprompt(sp, t, len))
  			return (1);
  	}
  
 -	/* The cursor moves to EOF. */
 +	/* Append the remains into the file, and the cursor moves to EOF. */
 +	if (len > 0) {
 +		if (CHAR2INT(sp, t, len, ip, ilen) ||
 +		    db_append(sp, 1, lno++, ip, ilen))
 +			return (1);
 +		sp->cno = ilen - 1;
 +	} else
 +		sp->cno = 0;
  	sp->lno = lno;
 -	sp->cno = ilen ? ilen - 1 : 0;
  	return (vs_refresh(sp, 1));
  }
  
 


Home | Main Index | Thread Index | Old Index