Fix corruption with multiple emacsclient -t instances.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 11 Sep 2013 08:24:05 +0000 (01:24 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 11 Sep 2013 08:24:05 +0000 (01:24 -0700)
This bug was introduced by my 2013-08-26 patch, which incorrectly
assumed that the terminfo implementation doesn't use termcap buffers.
* term.c (init_tty) [TERMINFO]: Remove optimization, as
these buffers apparently are used after all.
* termchar.h (TERMCAP_BUFFER_SIZE) [TERMINFO]: Define here too.
(struct tty_display_info): Define members termcap_term_buffer and
termcap_strings_buffer even if TERMINFO.

Fixes: debbugs:15222

src/ChangeLog
src/term.c
src/termchar.h

index f51e6a1..21cb47e 100644 (file)
@@ -1,3 +1,14 @@
+2013-09-11  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Fix corruption with multiple emacsclient -t instances (Bug#15222).
+       This bug was introduced by my 2013-08-26 patch, which incorrectly
+       assumed that the terminfo implementation doesn't use termcap buffers.
+       * term.c (init_tty) [TERMINFO]: Remove optimization, as
+       these buffers apparently are used after all.
+       * termchar.h (TERMCAP_BUFFER_SIZE) [TERMINFO]: Define here too.
+       (struct tty_display_info): Define members termcap_term_buffer and
+       termcap_strings_buffer even if TERMINFO.
+
 2013-09-11  Dmitry Antipov  <dmantipov@yandex.ru>
 
        Fix last change.
index 0270c1e..fd5ea5a 100644 (file)
@@ -2917,12 +2917,8 @@ dissociate_if_controlling_tty (int fd)
 struct terminal *
 init_tty (const char *name, const char *terminal_type, bool must_succeed)
 {
-#ifdef TERMINFO
-  char **address = 0;
-#else
   char *area;
   char **address = &area;
-#endif
   int status;
   struct tty_display_info *tty = NULL;
   struct terminal *terminal = NULL;
@@ -3013,13 +3009,9 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed)
   /* On some systems, tgetent tries to access the controlling
      terminal.  */
   block_tty_out_signal ();
-#ifdef TERMINFO
-  status = tgetent (0, terminal_type);
-#else
   status = tgetent (tty->termcap_term_buffer, terminal_type);
   if (tty->termcap_term_buffer[TERMCAP_BUFFER_SIZE - 1])
     emacs_abort ();
-#endif
   unblock_tty_out_signal ();
 
   if (status < 0)
@@ -3050,9 +3042,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
                    terminal_type);
     }
 
-#ifndef TERMINFO
   area = tty->termcap_strings_buffer;
-#endif
   tty->TS_ins_line = tgetstr ("al", address);
   tty->TS_ins_multi_lines = tgetstr ("AL", address);
   tty->TS_bell = tgetstr ("bl", address);
index 687f7fb..11cea34 100644 (file)
@@ -30,9 +30,7 @@ struct tty_output
   /* There is nothing else here at the moment... */
 };
 
-#ifndef TERMINFO
 enum { TERMCAP_BUFFER_SIZE = 4096 };
-#endif
 
 /* Parameters that are shared between frames on the same tty device. */
 
@@ -78,7 +76,6 @@ struct tty_display_info
      mouse-face.  */
   Mouse_HLInfo mouse_highlight;
 
-#ifndef TERMINFO
   /* Buffer used internally by termcap (see tgetent in the Termcap
      manual).  Only init_tty should use this.  */
   char termcap_term_buffer[TERMCAP_BUFFER_SIZE];
@@ -86,7 +83,6 @@ struct tty_display_info
   /* Buffer storing terminal description strings (see tgetstr in the
      Termcap manual).  Only init_tty should use this.  */
   char termcap_strings_buffer[TERMCAP_BUFFER_SIZE];
-#endif
 
   /* Strings, numbers and flags taken from the termcap entry.  */