summaryrefslogtreecommitdiff
path: root/devel/libedit/files/patch-netbsd-pr-50863
blob: 72383f9c2b1290bea4d581c848f2c1c44d532bea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=50863

--- src/tty.c.orig	2014-06-18 19:07:45 UTC
+++ src/tty.c
@@ -499,6 +499,9 @@ tty_setup(EditLine *el)
 	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__,
@@ -558,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;
 }
 
@@ -567,6 +571,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);
@@ -580,6 +585,9 @@ protected void
 /*ARGSUSED*/
 tty_end(EditLine *el)
 {
+	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,
--- src/tty.h.orig	2014-06-18 16:05:56 UTC
+++ src/tty.h
@@ -474,8 +474,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;