Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit PR/50863: John Hein: libedit el_end() messes up ...



details:   https://anonhg.NetBSD.org/src/rev/da494651c463
branches:  trunk
changeset: 813948:da494651c463
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Feb 27 18:13:21 2016 +0000

description:
PR/50863: John Hein: libedit el_end() messes up term settings if piped
Keep track if we initialized the tty, and only reset it if we did.

diffstat:

 lib/libedit/tty.c |  9 +++++++--
 lib/libedit/tty.h |  5 +++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diffs (64 lines):

diff -r e86c4c51fc0e -r da494651c463 lib/libedit/tty.c
--- a/lib/libedit/tty.c Sat Feb 27 16:40:22 2016 +0000
+++ b/lib/libedit/tty.c Sat Feb 27 18:13:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.57 2016/02/17 19:47:49 christos Exp $        */
+/*     $NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 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.57 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -498,6 +498,7 @@
 {
        int rst = 1;
 
+       el->el_tty.t_initialized = 0;
        if (el->el_flags & EDIT_DISABLED)
                return 0;
 
@@ -560,6 +561,7 @@
 
        tty__setchar(&el->el_tty.t_ed, el->el_tty.t_c[ED_IO]);
        tty_bind_char(el, 1);
+       el->el_tty.t_initialized = 1;
        return 0;
 }
 
@@ -585,6 +587,9 @@
        if (el->el_flags & EDIT_DISABLED)
                return;
 
+       if (el->el_tty.t_initialized)
+               return;
+
        if (tty_setty(el, TCSAFLUSH, &el->el_tty.t_or) == -1) {
 #ifdef DEBUG_TTY
                (void) fprintf(el->el_errfile,
diff -r e86c4c51fc0e -r da494651c463 lib/libedit/tty.h
--- a/lib/libedit/tty.h Sat Feb 27 16:40:22 2016 +0000
+++ b/lib/libedit/tty.h Sat Feb 27 18:13:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.h,v 1.18 2016/02/16 15:53:48 christos Exp $        */
+/*     $NetBSD: tty.h,v 1.19 2016/02/27 18:13:21 christos Exp $        */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -472,8 +472,9 @@
     int t_tabs;
     int t_eight;
     speed_t t_speed;
-    int t_mode;
+    unsigned char t_mode;
     unsigned char t_vdisable;
+    unsigned char t_initialized;
 } el_tty_t;
 
 



Home | Main Index | Thread Index | Old Index