* xmenu.c (set_frame_menubar): Allocate smaller local vectors.
[bpt/emacs.git] / src / term.c
index e78e2e6..ea85654 100644 (file)
@@ -85,8 +85,10 @@ static void set_tty_hooks (struct terminal *terminal);
 static void dissociate_if_controlling_tty (int fd);
 static void delete_tty (struct terminal *);
 static void maybe_fatal (int must_succeed, struct terminal *terminal,
-                        const char *str1, const char *str2, ...) NO_RETURN;
-static void vfatal (const char *str, va_list ap) NO_RETURN;
+                        const char *str1, const char *str2, ...)
+  NO_RETURN ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5);
+static void vfatal (const char *str, va_list ap)
+  NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 0);
 
 
 #define OUTPUT(tty, a)                                          \
@@ -501,7 +503,7 @@ static int encode_terminal_dst_size;
    Set CODING->produced to the byte-length of the resulting byte
    sequence, and return a pointer to that byte sequence.  */
 
-static unsigned char *
+unsigned char *
 encode_terminal_code (struct glyph *src, int src_len, struct coding_system *coding)
 {
   struct glyph *src_end = src + src_len;
@@ -707,6 +709,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
 {
   unsigned char *conversion_buffer;
   struct coding_system *coding;
+  size_t n, stringlen;
 
   struct tty_display_info *tty = FRAME_TTY (f);
 
@@ -734,13 +737,12 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
      the tail.  */
   coding->mode &= ~CODING_MODE_LAST_BLOCK;
 
-  while (len > 0)
+  for (stringlen = len; stringlen != 0; stringlen -= n)
     {
       /* Identify a run of glyphs with the same face.  */
       int face_id = string->face_id;
-      int n;
 
-      for (n = 1; n < len; ++n)
+      for (n = 1; n < stringlen; ++n)
        if (string[n].face_id != face_id)
          break;
 
@@ -748,7 +750,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
       tty_highlight_if_desired (tty);
       turn_on_face (f, face_id);
 
-      if (n == len)
+      if (n == stringlen)
        /* This is the last run.  */
        coding->mode |= CODING_MODE_LAST_BLOCK;
       conversion_buffer = encode_terminal_code (string, n, coding);
@@ -762,7 +764,6 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
            fwrite (conversion_buffer, 1, coding->produced, tty->termscript);
          UNBLOCK_INPUT;
        }
-      len -= n;
       string += n;
 
       /* Turn appearance modes off.  */
@@ -1952,7 +1953,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
 
   it->pixel_width = len;
   it->nglyphs = len;
-  if (len > 0 && it->glyph_row)
+  if (it->glyph_row)
     append_glyphless_glyph (it, face_id, str);
 }
 
@@ -2500,13 +2501,10 @@ A suspended tty may be resumed by calling `resume-tty' on it.  */)
       /* First run `suspend-tty-functions' and then clean up the tty
         state because `suspend-tty-functions' might need to change
         the tty state.  */
-      if (!NILP (Vrun_hooks))
-        {
-          Lisp_Object args[2];
-          args[0] = intern ("suspend-tty-functions");
-          XSETTERMINAL (args[1], t);
-          Frun_hook_with_args (2, args);
-        }
+      Lisp_Object args[2];
+      args[0] = intern ("suspend-tty-functions");
+      XSETTERMINAL (args[1], t);
+      Frun_hook_with_args (2, args);
 
       reset_sys_modes (t->display_info.tty);
       delete_keyboard_wait_descriptor (fileno (f));
@@ -2596,14 +2594,13 @@ frame's terminal). */)
 
       init_sys_modes (t->display_info.tty);
 
-      /* Run `resume-tty-functions'.  */
-      if (!NILP (Vrun_hooks))
-        {
-          Lisp_Object args[2];
-          args[0] = intern ("resume-tty-functions");
-          XSETTERMINAL (args[1], t);
-          Frun_hook_with_args (2, args);
-        }
+      {
+        /* Run `resume-tty-functions'.  */
+        Lisp_Object args[2];
+        args[0] = intern ("resume-tty-functions");
+        XSETTERMINAL (args[1], t);
+        Frun_hook_with_args (2, args);
+      }
     }
 
   set_tty_hooks (t);
@@ -3158,13 +3155,12 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
          if we don't have one at the moment.  */
       fd = emacs_open (name, O_RDWR | O_IGNORE_CTTY | O_NOCTTY, 0);
     else
-#else
+#endif /* O_IGNORE_CTTY */
       /* Alas, O_IGNORE_CTTY is a GNU extension that seems to be only
          defined on Hurd.  On other systems, we need to explicitly
          dissociate ourselves from the controlling tty when we want to
          open a frame on the same terminal.  */
       fd = emacs_open (name, O_RDWR | O_NOCTTY, 0);
-#endif /* O_IGNORE_CTTY */
 
     tty->name = xstrdup (name);
     terminal->name = xstrdup (name);