Source-Changes-HG archive

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

[src/netbsd-2-0]: src/usr.bin/vi/cl Pull up revision 1.7 (requested by aymeri...



details:   https://anonhg.NetBSD.org/src/rev/5da9e7d91f3b
branches:  netbsd-2-0
changeset: 561379:5da9e7d91f3b
user:      tron <tron%NetBSD.org@localhost>
date:      Mon Jun 14 20:23:10 2004 +0000

description:
Pull up revision 1.7 (requested by aymeric in ticket #496):
. don't call newterm() more than once; use setterm() and resizeterm() instead
  on subsequent calls. Newterm() would fail after a few calls, leading to vi
  exiting with a "ex/vi: error initializing terminal" message
. if tcsetattr() fails due to EINTR, ignore it
Fixes PR #25849

diffstat:

 usr.bin/vi/cl/cl_screen.c |  26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diffs (77 lines):

diff -r 8167c6754a08 -r 5da9e7d91f3b usr.bin/vi/cl/cl_screen.c
--- a/usr.bin/vi/cl/cl_screen.c Mon Jun 14 20:19:44 2004 +0000
+++ b/usr.bin/vi/cl/cl_screen.c Mon Jun 14 20:23:10 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cl_screen.c,v 1.6 2002/04/09 01:47:30 thorpej Exp $    */
+/*     $NetBSD: cl_screen.c,v 1.6.4.1 2004/06/14 20:23:10 tron Exp $   */
 
 /*-
  * Copyright (c) 1993, 1994
@@ -16,7 +16,7 @@
 #if 0
 static const char sccsid[] = "@(#)cl_screen.c  10.49 (Berkeley) 9/24/96";
 #else
-__RCSID("$NetBSD: cl_screen.c,v 1.6 2002/04/09 01:47:30 thorpej Exp $");
+__RCSID("$NetBSD: cl_screen.c,v 1.6.4.1 2004/06/14 20:23:10 tron Exp $");
 #endif
 #endif /* not lint */
 
@@ -188,6 +188,7 @@
 cl_vi_init(sp)
        SCR *sp;
 {
+       static int newterm_done = 0;
        CL_PRIVATE *clp;
        GS *gp;
        char *o_cols, *o_lines, *o_term, *ttype;
@@ -250,7 +251,7 @@
         * have to specify the terminal type.
         */
        errno = 0;
-       if (newterm(ttype, stdout, stdin) == NULL) {
+       if (!newterm_done && newterm(ttype, stdout, stdin) == NULL) {
                if (errno)
                        if (strcmp(ttype, "unknown") == 0)
                                msgq(sp, M_ERR, "terminal type unknown");
@@ -260,8 +261,13 @@
                else
                        msgq(sp, M_ERR, "%s: unknown terminal type", ttype);
                return (1);
+       } else if (newterm_done) {
+               setterm(ttype);
+               resizeterm(O_VAL(sp, O_LINES), O_VAL(sp, O_COLUMNS));
        }
 
+       newterm_done = 1;
+
        if (o_term == NULL)
                unsetenv("TERM");
        if (o_lines == NULL)
@@ -379,9 +385,11 @@
 
 fast:  /* Set the terminal modes. */
        if (tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &clp->vi_enter)) {
-               msgq(sp, M_SYSERR, "tcsetattr");
-err:           (void)cl_vi_end(sp->gp);
-               return (1);
+               if (errno != EINTR) {
+                       msgq(sp, M_SYSERR, "tcsetattr");
+err:                   (void)cl_vi_end(sp->gp);
+                       return (1);
+               }
        }
        return (0);
 }
@@ -497,8 +505,10 @@
 #endif
 
 fast:  if (tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->ex_enter)) {
-               msgq(sp, M_SYSERR, "tcsetattr");
-               return (1);
+               if (errno != EINTR) {
+                       msgq(sp, M_SYSERR, "tcsetattr");
+                       return (1);
+               }
        }
        return (0);
 }



Home | Main Index | Thread Index | Old Index