* alloc.c: Do not define struct catchtag.
[bpt/emacs.git] / src / term.c
index 5b71ce4..d860a93 100644 (file)
@@ -1,6 +1,6 @@
 /* Terminal control module for terminals described by TERMCAP
    Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1998, 2000, 2001,
-                 2002, 2003, 2004, 2005, 2006, 2007, 2008
+                 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
                  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -37,6 +37,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <signal.h>
 #include <stdarg.h>
+#include <setjmp.h>
 
 #include "lisp.h"
 #include "termchar.h"
@@ -581,10 +582,10 @@ encode_terminal_code (src, src_len, coding)
   required = MAX_MULTIBYTE_LENGTH * src_len;
   if (encode_terminal_src_size < required)
     {
-      if (encode_terminal_src_size == 0)
-       encode_terminal_src = xmalloc (required);
-      else
+      if (encode_terminal_src)
        encode_terminal_src = xrealloc (encode_terminal_src, required);
+      else
+       encode_terminal_src = xmalloc (required);
       encode_terminal_src_size = required;
     }
 
@@ -604,7 +605,7 @@ encode_terminal_code (src, src_len, coding)
          if (src->u.cmp.automatic)
            {
              gstring = composition_gstring_from_id (src->u.cmp.id);
-             required = src->u.cmp.to - src->u.cmp.from;
+             required = src->u.cmp.to + 1 - src->u.cmp.from;
            }
          else
            {
@@ -621,13 +622,13 @@ encode_terminal_code (src, src_len, coding)
            }
 
          if (src->u.cmp.automatic)
-           for (i = src->u.cmp.from; i < src->u.cmp.to; i++)
+           for (i = src->u.cmp.from; i <= src->u.cmp.to; i++)
              {
                Lisp_Object g = LGSTRING_GLYPH (gstring, i);
                int c = LGLYPH_CHAR (g);
 
                if (! char_charset (c, charset_list, NULL))
-                 break;
+                 c = '?';
                buf += CHAR_STRING (c, buf);
                nchars++;
              }
@@ -636,17 +637,23 @@ encode_terminal_code (src, src_len, coding)
              {
                int c = COMPOSITION_GLYPH (cmp, i);
 
-               if (! char_charset (c, charset_list, NULL))
-                 break;
+               if (c == '\t')
+                 continue;
+               if (char_charset (c, charset_list, NULL))
+                 {
+                   if (CHAR_WIDTH (c) == 0
+                       && i > 0 && COMPOSITION_GLYPH (cmp, i - 1) == '\t')
+                     /* Should be left-padded */
+                     {
+                       buf += CHAR_STRING (' ', buf);
+                       nchars++;
+                     }
+                 }
+               else
+                 c = '?';
                buf += CHAR_STRING (c, buf);
                nchars++;
              }
-         if (i == 0)
-           {
-             /* The first character of the composition is not encodable.  */
-             *buf++ = '?';
-             nchars++;
-           }
        }
       /* We must skip glyphs to be padded for a wide character.  */
       else if (! CHAR_GLYPH_PADDING_P (*src))
@@ -740,7 +747,11 @@ encode_terminal_code (src, src_len, coding)
   if (encode_terminal_dst_size == 0)
     {
       encode_terminal_dst_size = encode_terminal_src_size;
-      encode_terminal_dst = xmalloc (encode_terminal_dst_size);
+      if (encode_terminal_dst)
+       encode_terminal_dst = xrealloc (encode_terminal_dst,
+                                       encode_terminal_dst_size);
+      else
+       encode_terminal_dst = xmalloc (encode_terminal_dst_size);
     }
   coding->destination = encode_terminal_dst;
   coding->dst_bytes = encode_terminal_dst_size;
@@ -1640,7 +1651,7 @@ produce_glyphs (it)
       if (unibyte_display_via_language_environment
          && (it->c >= 0240))
        {
-         it->char_to_display = unibyte_char_to_multibyte (it->c);
+         it->char_to_display = BYTE8_TO_CHAR (it->c);
          it->pixel_width = CHAR_WIDTH (it->char_to_display);
          it->nglyphs = it->pixel_width;
          if (it->glyph_row)
@@ -1730,6 +1741,10 @@ produce_stretch_glyph (it)
   if (width <= 0 && (width < 0 || !zero_width_ok_p))
     width = 1;
 
+  if (width > 0 && it->line_wrap != TRUNCATE
+      && it->current_x + width > it->last_visible_x)
+    width = it->last_visible_x - it->current_x - 1;
+
   if (width > 0 && it->glyph_row)
     {
       Lisp_Object o_object = it->object;
@@ -1778,7 +1793,7 @@ append_composite_glyph (it)
          glyph->u.cmp.automatic = 1;
          glyph->u.cmp.id = it->cmp_it.id;
          glyph->u.cmp.from = it->cmp_it.from;
-         glyph->u.cmp.to = it->cmp_it.to;
+         glyph->u.cmp.to = it->cmp_it.to - 1;
        }
 
       glyph->face_id = it->face_id;
@@ -1794,8 +1809,8 @@ append_composite_glyph (it)
 
 /* Produce a composite glyph for iterator IT.  IT->cmp_id is the ID of
    the composition.  We simply produces components of the composition
-   assuming that that the terminal has a capability to layout/render
-   it correctly.  */
+   assuming that the terminal has a capability to layout/render it
+   correctly.  */
 
 static void
 produce_composite_glyph (it)
@@ -1807,8 +1822,7 @@ produce_composite_glyph (it)
     {
       struct composition *cmp = composition_table[it->cmp_it.id];
 
-      c = COMPOSITION_GLYPH (cmp, 0);
-      it->pixel_width = CHAR_WIDTH (it->c);
+      it->pixel_width = cmp->width;
     }
   else
     {
@@ -1956,14 +1970,11 @@ turn_on_face (f, face_id)
        }
     }
 
-  if (face->tty_bold_p)
-    {
-      if (MAY_USE_WITH_COLORS_P (tty, NC_BOLD))
-       OUTPUT1_IF (tty, tty->TS_enter_bold_mode);
-    }
-  else if (face->tty_dim_p)
-    if (MAY_USE_WITH_COLORS_P (tty, NC_DIM))
-      OUTPUT1_IF (tty, tty->TS_enter_dim_mode);
+  if (face->tty_bold_p && MAY_USE_WITH_COLORS_P (tty, NC_BOLD))
+    OUTPUT1_IF (tty, tty->TS_enter_bold_mode);
+
+  if (face->tty_dim_p && MAY_USE_WITH_COLORS_P (tty, NC_DIM))
+    OUTPUT1_IF (tty, tty->TS_enter_dim_mode);
 
   /* Alternate charset and blinking not yet used.  */
   if (face->tty_alt_charset_p
@@ -2084,9 +2095,9 @@ DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p,
        0, 1, 0,
        doc: /* Return non-nil if the tty device TERMINAL can display colors.
 
-TERMINAL can be a terminal id, a frame or nil (meaning the selected
-frame's terminal).  This function always returns nil if TERMINAL
-is not on a tty device.  */)
+TERMINAL can be a terminal object, a frame, or nil (meaning the
+selected frame's terminal).  This function always returns nil if
+TERMINAL does not refer to a text-only terminal.  */)
      (terminal)
      Lisp_Object terminal;
 {
@@ -2102,9 +2113,9 @@ DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
        Stty_display_color_cells, 0, 1, 0,
        doc: /* Return the number of colors supported by the tty device TERMINAL.
 
-TERMINAL can be a terminal id, a frame or nil (meaning the selected
-frame's terminal).  This function always returns 0 if TERMINAL
-is not on a tty device.  */)
+TERMINAL can be a terminal object, a frame, or nil (meaning the
+selected frame's terminal).  This function always returns 0 if
+TERMINAL does not refer to a text-only terminal.  */)
      (terminal)
      Lisp_Object terminal;
 {
@@ -2290,8 +2301,8 @@ DEFUN ("tty-type", Ftty_type, Stty_type, 0, 1, 0,
        doc: /* Return the type of the tty device that TERMINAL uses.
 Returns nil if TERMINAL is not on a tty device.
 
-TERMINAL can be a terminal id, a frame or nil (meaning the selected
-frame's terminal).  */)
+TERMINAL can be a terminal object, a frame, or nil (meaning the
+selected frame's terminal).  */)
      (terminal)
      Lisp_Object terminal;
 {
@@ -2309,9 +2320,9 @@ frame's terminal).  */)
 DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0,
        doc: /* Return non-nil if TERMINAL is the controlling tty of the Emacs process.
 
-TERMINAL can be a terminal id, a frame or nil (meaning the selected
-frame's terminal).  This function always returns nil if TERMINAL
-is not on a tty device.  */)
+TERMINAL can be a terminal object, a frame, or nil (meaning the
+selected frame's terminal).  This function always returns nil if
+TERMINAL is not on a tty device.  */)
      (terminal)
      Lisp_Object terminal;
 {
@@ -2330,9 +2341,9 @@ This is used to override the terminfo data, for certain terminals that
 do not really do underlining, but say that they do.  This function has
 no effect if used on a non-tty terminal.
 
-TERMINAL can be a terminal id, a frame or nil (meaning the selected
-frame's terminal).  This function always returns nil if TERMINAL
-is not on a tty device.  */)
+TERMINAL can be a terminal object, a frame or nil (meaning the
+selected frame's terminal).  This function always returns nil if
+TERMINAL does not refer to a text-only terminal.  */)
   (terminal)
      Lisp_Object terminal;
 {
@@ -2353,8 +2364,8 @@ access to the tty device.  Frames that use the device are not deleted,
 but input is not read from them and if they change, their display is
 not updated.
 
-TTY may be a terminal id, a frame, or nil for the terminal device of
-the currently selected frame.
+TTY may be a terminal object, a frame, or nil for the terminal device
+of the currently selected frame.
 
 This function runs `suspend-tty-functions' after suspending the
 device.  The functions are run with one arg, the id of the suspended
@@ -2429,8 +2440,8 @@ device.
 `resume-tty' does nothing if it is called on a device that is not
 suspended.
 
-TTY may be a terminal id, a frame, or nil for the terminal device of
-the currently selected frame. */)
+TTY may be a terminal object, a frame, or nil (meaning the selected
+frame's terminal). */)
      (tty)
      Lisp_Object tty;
 {
@@ -2466,7 +2477,19 @@ the currently selected frame. */)
 #endif
 
       if (FRAMEP (t->display_info.tty->top_frame))
-        FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
+       {
+         struct frame *f = XFRAME (t->display_info.tty->top_frame);
+         int width, height;
+         int old_height = FRAME_COLS (f);
+         int old_width = FRAME_LINES (f);
+
+         /* Check if terminal/window size has changed while the frame
+            was suspended.  */
+         get_tty_size (fileno (t->display_info.tty->input), &width, &height);
+         if (width != old_width || height != old_height)
+           change_frame_size (f, height, width, 0, 0, 0);
+         FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
+       }
 
       init_sys_modes (t->display_info.tty);
 
@@ -2826,7 +2849,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
 
                mouse_face_face_id
                  = face_at_buffer_position (w, pos, 0, 0,
-                                            &ignore, pos + 1, 1);
+                                            &ignore, pos + 1, 1, -1);
 
                /* Display it as active.  */
                term_show_mouse_face (DRAW_MOUSE_FACE);
@@ -2861,7 +2884,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
 
                mouse_face_face_id
                  = face_at_buffer_position (w, pos, 0, 0,
-                                            &ignore, pos + 1, 1);
+                                            &ignore, pos + 1, 1, -1);
 
                /* Display it as active.  */
                term_show_mouse_face (DRAW_MOUSE_FACE);
@@ -3129,10 +3152,10 @@ Gpm-mouse can only be activated for one tty at a time.  */)
 }
 
 void
-close_gpm ()
+close_gpm (int fd)
 {
-  if (gpm_fd >= 0)
-    delete_gpm_wait_descriptor (gpm_fd);
+  if (fd >= 0)
+    delete_gpm_wait_descriptor (fd);
   while (Gpm_Close()); /* close all the stack */
   gpm_tty = NULL;
 }
@@ -3150,12 +3173,13 @@ DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop,
   if (!tty || gpm_tty != tty)
     return Qnil;       /* Not activated on this terminal, nothing to do.  */
 
-  close_gpm ();
+  close_gpm (gpm_fd);
   return Qnil;
 }
 #endif /* HAVE_GPM */
 
 \f
+#ifndef MSDOS
 /***********************************************************************
                            Initialization
  ***********************************************************************/
@@ -3179,17 +3203,34 @@ create_tty_output (struct frame *f)
   f->output_data.tty = t;
 }
 
-/* Delete the tty-dependent part of frame F. */
+/* Delete frame F's face cache, and its tty-dependent part. */
 
 static void
-delete_tty_output (struct frame *f)
+tty_free_frame_resources (struct frame *f)
 {
   if (! FRAME_TERMCAP_P (f))
     abort ();
 
+  if (FRAME_FACE_CACHE (f))
+    free_frame_faces (f);
+
   xfree (f->output_data.tty);
 }
 
+#else  /* MSDOS */
+
+/* Delete frame F's face cache. */
+
+static void
+tty_free_frame_resources (struct frame *f)
+{
+  if (! FRAME_TERMCAP_P (f) && ! FRAME_MSDOS_P (f))
+    abort ();
+
+  if (FRAME_FACE_CACHE (f))
+    free_frame_faces (f);
+}
+#endif /* MSDOS */
 \f
 /* Reset the hooks in TERMINAL.  */
 
@@ -3225,7 +3266,7 @@ clear_tty_hooks (struct terminal *terminal)
 
   /* Leave these two set, or suspended frames are not deleted
      correctly.  */
-  terminal->delete_frame_hook = &delete_tty_output;
+  terminal->delete_frame_hook = &tty_free_frame_resources;
   terminal->delete_terminal_hook = &delete_tty;
 }
 
@@ -3269,7 +3310,7 @@ set_tty_hooks (struct terminal *terminal)
   terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
   terminal->frame_up_to_date_hook = 0; /* Not needed. */
 
-  terminal->delete_frame_hook = &delete_tty_output;
+  terminal->delete_frame_hook = &tty_free_frame_resources;
   terminal->delete_terminal_hook = &delete_tty;
 }
 
@@ -3326,7 +3367,6 @@ init_tty (char *name, char *terminal_type, int must_succeed)
 {
   char *area = NULL;
   char **address = &area;
-  char *buffer = NULL;
   int buffer_size = 4096;
   register char *p = NULL;
   int status;
@@ -3335,7 +3375,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
   int ctty = 0;                 /* 1 if asked to open controlling tty. */
 
   if (!terminal_type)
-    maybe_fatal (must_succeed, 0, 0,
+    maybe_fatal (must_succeed, 0,
                  "Unknown terminal type",
                  "Unknown terminal type");
 
@@ -3356,7 +3396,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
   terminal = create_terminal ();
 #ifdef MSDOS
   if (been_here > 0)
-    maybe_fatal (1, 0, 0, "Attempt to create another terminal %s", "",
+    maybe_fatal (1, 0, "Attempt to create another terminal %s", "",
                 name, "");
   been_here = 1;
   tty = &the_only_display_info;
@@ -3396,15 +3436,18 @@ init_tty (char *name, char *terminal_type, int must_succeed)
       fd = emacs_open (name, O_RDWR | O_NOCTTY, 0);
 #endif /* O_IGNORE_CTTY */
 
+    tty->name = xstrdup (name);
+    terminal->name = xstrdup (name);
+
     if (fd < 0)
-      maybe_fatal (must_succeed, buffer, terminal,
+      maybe_fatal (must_succeed, terminal,
                    "Could not open file: %s",
                    "Could not open file: %s",
                    name);
     if (!isatty (fd))
       {
         close (fd);
-        maybe_fatal (must_succeed, buffer, terminal,
+        maybe_fatal (must_succeed, terminal,
                      "Not a tty device: %s",
                      "Not a tty device: %s",
                      name);
@@ -3416,17 +3459,13 @@ init_tty (char *name, char *terminal_type, int must_succeed)
 #endif
 
     file = fdopen (fd, "w+");
-    tty->name = xstrdup (name);
-    terminal->name = xstrdup (name);
     tty->input = file;
     tty->output = file;
   }
 
   tty->type = xstrdup (terminal_type);
 
-#ifdef subprocesses
   add_keyboard_wait_descriptor (fileno (tty->input));
-#endif
 
 #endif /* !DOS_NT */
 
@@ -3449,7 +3488,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
   tty->output = stdout;
   tty->input = stdin;
   /* The following two are inaccessible from w32console.c.  */
-  terminal->delete_frame_hook = &delete_tty_output;
+  terminal->delete_frame_hook = &tty_free_frame_resources;
   terminal->delete_terminal_hook = &delete_tty;
 
   tty->name = xstrdup (name);
@@ -3504,22 +3543,22 @@ init_tty (char *name, char *terminal_type, int must_succeed)
 
   Wcm_clear (tty);
 
-  buffer = (char *) xmalloc (buffer_size);
+  tty->termcap_term_buffer = (char *) xmalloc (buffer_size);
 
   /* On some systems, tgetent tries to access the controlling
      terminal. */
   sigblock (sigmask (SIGTTOU));
-  status = tgetent (buffer, terminal_type);
+  status = tgetent (tty->termcap_term_buffer, terminal_type);
   sigunblock (sigmask (SIGTTOU));
 
   if (status < 0)
     {
 #ifdef TERMINFO
-      maybe_fatal (must_succeed, buffer, terminal,
+      maybe_fatal (must_succeed, terminal,
                    "Cannot open terminfo database file",
                    "Cannot open terminfo database file");
 #else
-      maybe_fatal (must_succeed, buffer, terminal,
+      maybe_fatal (must_succeed, terminal,
                    "Cannot open termcap database file",
                    "Cannot open termcap database file");
 #endif
@@ -3527,7 +3566,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
   if (status == 0)
     {
 #ifdef TERMINFO
-      maybe_fatal (must_succeed, buffer, terminal,
+      maybe_fatal (must_succeed, terminal,
                    "Terminal type %s is not defined",
                    "Terminal type %s is not defined.\n\
 If that is not the actual type of terminal you have,\n\
@@ -3536,7 +3575,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
 to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
                    terminal_type);
 #else
-      maybe_fatal (must_succeed, buffer, terminal,
+      maybe_fatal (must_succeed, terminal,
                    "Terminal type %s is not defined",
                    "Terminal type %s is not defined.\n\
 If that is not the actual type of terminal you have,\n\
@@ -3548,12 +3587,11 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
     }
 
 #ifndef TERMINFO
-  if (strlen (buffer) >= buffer_size)
+  if (strlen (tty->termcap_term_buffer) >= buffer_size)
     abort ();
-  buffer_size = strlen (buffer);
+  buffer_size = strlen (tty->termcap_term_buffer);
 #endif
-  area = (char *) xmalloc (buffer_size);
-
+  tty->termcap_strings_buffer = area = (char *) xmalloc (buffer_size);
   tty->TS_ins_line = tgetstr ("al", address);
   tty->TS_ins_multi_lines = tgetstr ("AL", address);
   tty->TS_bell = tgetstr ("bl", address);
@@ -3690,15 +3728,11 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
     FrameRows (tty) = tgetnum ("li");
 
   if (FrameRows (tty) < 3 || FrameCols (tty) < 3)
-    maybe_fatal (must_succeed, NULL, terminal,
+    maybe_fatal (must_succeed, terminal,
                  "Screen size %dx%d is too small"
                  "Screen size %dx%d is too small",
                  FrameCols (tty), FrameRows (tty));
 
-#if 0  /* This is not used anywhere. */
-  tty->terminal->min_padding_speed = tgetnum ("pb");
-#endif
-
   TabWidth (tty) = tgetnum ("tw");
 
   if (!tty->TS_bell)
@@ -3814,7 +3848,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
 
   if (Wcm_init (tty) == -1)    /* can't do cursor motion */
     {
-      maybe_fatal (must_succeed, NULL, terminal,
+      maybe_fatal (must_succeed, terminal,
                    "Terminal type \"%s\" is not powerful enough to run Emacs",
 # ifdef TERMINFO
                    "Terminal type \"%s\" is not powerful enough to run Emacs.\n\
@@ -3835,7 +3869,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
     }
 
   if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0)
-    maybe_fatal (must_succeed, NULL, terminal,
+    maybe_fatal (must_succeed, terminal,
                  "Could not determine the frame size",
                  "Could not determine the frame size");
 
@@ -3868,9 +3902,6 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
 
   init_baud_rate (fileno (tty->input));
 
-  /* Don't do this.  I think termcap may still need the buffer. */
-  /* xfree (buffer); */
-
 #endif /* not DOS_NT */
 
   /* Init system terminal modes (RAW or CBREAK, etc.).  */
@@ -3880,18 +3911,15 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
 }
 
 /* Auxiliary error-handling function for init_tty.
-   Free BUFFER and delete TERMINAL, then call error or fatal
-   with str1 or str2, respectively, according to MUST_SUCCEED.  */
+   Delete TERMINAL, then call error or fatal with str1 or str2,
+   respectively, according to MUST_SUCCEED.  */
 
 static void
-maybe_fatal (must_succeed, buffer, terminal, str1, str2, arg1, arg2)
+maybe_fatal (must_succeed, terminal, str1, str2, arg1, arg2)
      int must_succeed;
-     char *buffer;
      struct terminal *terminal;
      char *str1, *str2, *arg1, *arg2;
 {
-  xfree (buffer);
-
   if (terminal)
     delete_tty (terminal);
 
@@ -3926,7 +3954,7 @@ delete_tty (struct terminal *terminal)
   Lisp_Object tail, frame;
   int last_terminal;
 
-  /* Protect against recursive calls.  Fdelete_frame in
+  /* Protect against recursive calls.  delete_frame in
      delete_terminal calls us back when it deletes our last frame.  */
   if (!terminal->name)
     return;
@@ -3989,6 +4017,8 @@ delete_tty (struct terminal *terminal)
 
   xfree (tty->old_tty);
   xfree (tty->Wcm);
+  xfree (tty->termcap_strings_buffer);
+  xfree (tty->termcap_term_buffer);
 
   bzero (tty, sizeof (struct tty_display_info));
   xfree (tty);
@@ -4024,14 +4054,14 @@ This variable can be used by terminal emulator packages.  */);
 
   DEFVAR_LISP ("suspend-tty-functions", &Vsuspend_tty_functions,
     doc: /* Functions to be run after suspending a tty.
-The functions are run with one argument, the terminal id to be suspended.
+The functions are run with one argument, the terminal object to be suspended.
 See `suspend-tty'.  */);
   Vsuspend_tty_functions = Qnil;
 
 
   DEFVAR_LISP ("resume-tty-functions", &Vresume_tty_functions,
     doc: /* Functions to be run after resuming a tty.
-The functions are run with one argument, the terminal id that was revived.
+The functions are run with one argument, the terminal object that was revived.
 See `resume-tty'.  */);
   Vresume_tty_functions = Qnil;
 
@@ -4061,6 +4091,9 @@ bigger, or it may make it blink, or it may do nothing at all.  */);
   default_set_foreground = NULL;
   default_set_background = NULL;
 #endif /* !DOS_NT */
+
+  encode_terminal_src = NULL;
+  encode_terminal_dst = NULL;
 }