Module Name:    src
Committed By:   christos
Date:           Sun Nov 29 17:09:33 UTC 2015

Modified Files:
        src/external/bsd/nvi: Makefile.inc
        src/external/bsd/nvi/dist/ex: ex_script.c

Log Message:
Fix > 1024 char lines in script. (Rin Okuyama)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/Makefile.inc
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/ex/ex_script.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/nvi/Makefile.inc
diff -u src/external/bsd/nvi/Makefile.inc:1.3 src/external/bsd/nvi/Makefile.inc:1.4
--- src/external/bsd/nvi/Makefile.inc:1.3	Sat Nov 28 08:20:02 2015
+++ src/external/bsd/nvi/Makefile.inc	Sun Nov 29 12:09:33 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.3 2015/11/28 13:20:02 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.4 2015/11/29 17:09:33 christos Exp $
 
 .include <bsd.own.mk>
 
@@ -7,4 +7,4 @@ DIST= ${NETBSDSRCDIR}/external/bsd/nvi/d
 BINDIR=/usr/bin
 
 CWARNFLAGS.clang+=	-Wno-error=unused-const-variable
-VERSION=1.81.6-2013-11-20nb2
+VERSION=1.81.6-2013-11-20nb3

Index: src/external/bsd/nvi/dist/ex/ex_script.c
diff -u src/external/bsd/nvi/dist/ex/ex_script.c:1.5 src/external/bsd/nvi/dist/ex/ex_script.c:1.6
--- src/external/bsd/nvi/dist/ex/ex_script.c:1.5	Sat Nov 28 08:20:03 2015
+++ src/external/bsd/nvi/dist/ex/ex_script.c	Sun Nov 29 12:09:33 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_script.c,v 1.5 2015/11/28 13:20:03 christos Exp $ */
+/*	$NetBSD: ex_script.c,v 1.6 2015/11/29 17:09:33 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -19,7 +19,7 @@
 static const char sccsid[] = "Id: ex_script.c,v 10.38 2001/06/25 15:19:19 skimo Exp  (Berkeley) Date: 2001/06/25 15:19:19 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex_script.c,v 1.5 2015/11/28 13:20:03 christos Exp $");
+__RCSID("$NetBSD: ex_script.c,v 1.6 2015/11/29 17:09:33 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -294,7 +294,7 @@ sscr_exec(SCR *sp, db_recno_t lno)
 	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 @@ more:	switch (nr = read(sc->sh_master, e
 
 	/* 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 @@ more:	switch (nr = read(sc->sh_master, e
 			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));
 }
 

Reply via email to