Module Name:    src
Committed By:   christos
Date:           Tue Mar 22 01:34:32 UTC 2016

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

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


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

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.58 src/lib/libedit/tty.c:1.59
--- src/lib/libedit/tty.c:1.58	Sat Feb 27 13:13:21 2016
+++ src/lib/libedit/tty.c	Mon Mar 21 21:34:32 2016
@@ -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 @@ tty_setup(EditLine *el)
 {
 	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 @@ tty_init(EditLine *el)
 
 	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 @@ tty_end(EditLine *el)
 	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) {

Reply via email to