Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/nvi Fix > 1024 char lines in script. (Rin Okuyama)



details:   https://anonhg.NetBSD.org/src/rev/a67c336d41f3
branches:  trunk
changeset: 341929:a67c336d41f3
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Nov 29 17:09:33 2015 +0000

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

diffstat:

 external/bsd/nvi/Makefile.inc        |   4 +-
 external/bsd/nvi/dist/ex/ex_script.c |  62 ++++++++++++++++++++---------------
 2 files changed, 37 insertions(+), 29 deletions(-)

diffs (120 lines):

diff -r 5740c34b0a46 -r a67c336d41f3 external/bsd/nvi/Makefile.inc
--- a/external/bsd/nvi/Makefile.inc     Sun Nov 29 16:52:00 2015 +0000
+++ b/external/bsd/nvi/Makefile.inc     Sun Nov 29 17:09:33 2015 +0000
@@ -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 @@
 BINDIR=/usr/bin
 
 CWARNFLAGS.clang+=     -Wno-error=unused-const-variable
-VERSION=1.81.6-2013-11-20nb2
+VERSION=1.81.6-2013-11-20nb3
diff -r 5740c34b0a46 -r a67c336d41f3 external/bsd/nvi/dist/ex/ex_script.c
--- a/external/bsd/nvi/dist/ex/ex_script.c      Sun Nov 29 16:52:00 2015 +0000
+++ b/external/bsd/nvi/dist/ex/ex_script.c      Sun Nov 29 17:09:33 2015 +0000
@@ -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 @@
        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