Line 0
Link Here
|
|
|
1 |
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=50863 |
2 |
|
3 |
--- src/tty.c.orig 2014-06-18 19:07:45 UTC |
4 |
+++ src/tty.c |
5 |
@@ -499,6 +499,9 @@ tty_setup(EditLine *el) |
6 |
if (el->el_flags & EDIT_DISABLED) |
7 |
return 0; |
8 |
|
9 |
+ if (el->el_tty.t_initialized) |
10 |
+ return -1; |
11 |
+ |
12 |
if (!isatty(el->el_outfd)) { |
13 |
#ifdef DEBUG_TTY |
14 |
(void) fprintf(el->el_errfile, "%s: isatty: %s\n", __func__, |
15 |
@@ -558,6 +561,7 @@ tty_setup(EditLine *el) |
16 |
|
17 |
tty__setchar(&el->el_tty.t_ed, el->el_tty.t_c[ED_IO]); |
18 |
tty_bind_char(el, 1); |
19 |
+ el->el_tty.t_initialized = 1; |
20 |
return 0; |
21 |
} |
22 |
|
23 |
@@ -567,6 +571,7 @@ tty_init(EditLine *el) |
24 |
|
25 |
el->el_tty.t_mode = EX_IO; |
26 |
el->el_tty.t_vdisable = _POSIX_VDISABLE; |
27 |
+ el->el_tty.t_initialized = 0; |
28 |
(void) memcpy(el->el_tty.t_t, ttyperm, sizeof(ttyperm_t)); |
29 |
(void) memcpy(el->el_tty.t_c, ttychar, sizeof(ttychar_t)); |
30 |
return tty_setup(el); |
31 |
@@ -580,6 +585,9 @@ protected void |
32 |
/*ARGSUSED*/ |
33 |
tty_end(EditLine *el) |
34 |
{ |
35 |
+ if (!el->el_tty.t_initialized) |
36 |
+ return; |
37 |
+ |
38 |
if (tty_setty(el, TCSAFLUSH, &el->el_tty.t_or) == -1) { |
39 |
#ifdef DEBUG_TTY |
40 |
(void) fprintf(el->el_errfile, |
41 |
--- src/tty.h.orig 2014-06-18 16:05:56 UTC |
42 |
+++ src/tty.h |
43 |
@@ -474,8 +474,9 @@ typedef struct { |
44 |
int t_tabs; |
45 |
int t_eight; |
46 |
speed_t t_speed; |
47 |
- int t_mode; |
48 |
+ unsigned char t_mode; |
49 |
unsigned char t_vdisable; |
50 |
+ unsigned char t_initialized; |
51 |
} el_tty_t; |
52 |
|
53 |
|