Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit Fix reversed condition in tty_end() (Ingo Schwarze)



details:   https://anonhg.NetBSD.org/src/rev/03419794d34e
branches:  trunk
changeset: 814453:03419794d34e
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Mar 22 01:34:32 2016 +0000

description:
Fix reversed condition in tty_end() (Ingo Schwarze)
Also don't succeed if calling setup twice.

diffstat:

 lib/libedit/tty.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (49 lines):

diff -r 1459676972ac -r 03419794d34e lib/libedit/tty.c
--- a/lib/libedit/tty.c Mon Mar 21 22:42:56 2016 +0000
+++ b/lib/libedit/tty.c Tue Mar 22 01:34:32 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $        */
+/*     $NetBSD: tty.c,v 1.59 2016/03/22 01:34:32 christos Exp $        */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)tty.c      8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $");
+__RCSID("$NetBSD: tty.c,v 1.59 2016/03/22 01:34:32 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -498,10 +498,12 @@
 {
        int rst = 1;
 
-       el->el_tty.t_initialized = 0;
        if (el->el_flags & EDIT_DISABLED)
                return 0;
 
+       if (el->el_tty.t_initialized)
+               return -1;
+
        if (!isatty(el->el_outfd)) {
 #ifdef DEBUG_TTY
                (void) fprintf(el->el_errfile, "%s: isatty: %s\n", __func__,
@@ -571,6 +573,7 @@
 
        el->el_tty.t_mode = EX_IO;
        el->el_tty.t_vdisable = _POSIX_VDISABLE;
+       el->el_tty.t_initialized = 0;
        (void) memcpy(el->el_tty.t_t, ttyperm, sizeof(ttyperm_t));
        (void) memcpy(el->el_tty.t_c, ttychar, sizeof(ttychar_t));
        return tty_setup(el);
@@ -587,7 +590,7 @@
        if (el->el_flags & EDIT_DISABLED)
                return;
 
-       if (el->el_tty.t_initialized)
+       if (!el->el_tty.t_initialized)
                return;
 
        if (tty_setty(el, TCSAFLUSH, &el->el_tty.t_or) == -1) {



Home | Main Index | Thread Index | Old Index