Module Name:    src
Committed By:   christos
Date:           Sat Feb 27 18:13:21 UTC 2016

Modified Files:
        src/lib/libedit: tty.c tty.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/lib/libedit/tty.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libedit/tty.h

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

Modified files:

Index: src/lib/libedit/tty.c
diff -u src/lib/libedit/tty.c:1.57 src/lib/libedit/tty.c:1.58
--- src/lib/libedit/tty.c:1.57	Wed Feb 17 14:47:49 2016
+++ src/lib/libedit/tty.c	Sat Feb 27 13:13:21 2016
@@ -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 @@ tty_setup(EditLine *el)
 {
 	int rst = 1;
 
+	el->el_tty.t_initialized = 0;
 	if (el->el_flags & EDIT_DISABLED)
 		return 0;
 
@@ -560,6 +561,7 @@ tty_setup(EditLine *el)
 
 	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 @@ tty_end(EditLine *el)
 	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,

Index: src/lib/libedit/tty.h
diff -u src/lib/libedit/tty.h:1.18 src/lib/libedit/tty.h:1.19
--- src/lib/libedit/tty.h:1.18	Tue Feb 16 10:53:48 2016
+++ src/lib/libedit/tty.h	Sat Feb 27 13:13:21 2016
@@ -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 @@ typedef struct {
     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;
 
 

Reply via email to