use dynwind_begin and dynwind_end
authorBT Templeton <bt@hcoop.net>
Mon, 16 Sep 2013 21:02:53 +0000 (17:02 -0400)
committerRobin Templeton <robin@terpri.org>
Sat, 18 Apr 2015 22:49:11 +0000 (18:49 -0400)
This patch was generated using Coccinelle.

42 files changed:
src/buffer.c
src/callint.c
src/callproc.c
src/charset.c
src/coding.c
src/composite.c
src/cygw32.c
src/dbusbind.c
src/decompress.c
src/dired.c
src/dispnew.c
src/doc.c
src/editfns.c
src/emacs.c
src/eval.c
src/fileio.c
src/fns.c
src/frame.c
src/gtkutil.c
src/image.c
src/indent.c
src/insdel.c
src/keyboard.c
src/keymap.c
src/lread.c
src/macros.c
src/menu.c
src/minibuf.c
src/process.c
src/sound.c
src/sysdep.c
src/textprop.c
src/undo.c
src/w32fns.c
src/w32menu.c
src/window.c
src/xdisp.c
src/xfaces.c
src/xfns.c
src/xmenu.c
src/xselect.c
src/xterm.c

index 7b735ae..7f0f2cc 100644 (file)
@@ -1721,7 +1721,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
 
   /* Run hooks with the buffer to be killed the current buffer.  */
   {
-    ptrdiff_t count = SPECPDL_INDEX ();
+    dynwind_begin ();
     Lisp_Object arglist[1];
 
     record_unwind_protect (save_excursion_restore, save_excursion_save ());
@@ -1731,8 +1731,11 @@ cleaning up all windows currently displaying the buffer to be killed. */)
        don't kill the buffer.  */
     arglist[0] = Qkill_buffer_query_functions;
     tem = Frun_hook_with_args_until_failure (1, arglist);
-    if (NILP (tem))
-      return unbind_to (count, Qnil);
+    if (NILP (tem)){
+      
+        dynwind_end ();
+        return Qnil;
+      }
 
     /* Query if the buffer is still modified.  */
     if (INTERACTIVE && !NILP (BVAR (b, filename))
@@ -1742,17 +1745,23 @@ cleaning up all windows currently displaying the buffer to be killed. */)
         tem = do_yes_or_no_p (format2 ("Buffer %s modified; kill anyway? ",
                                       BVAR (b, name), make_number (0)));
        UNGCPRO;
-       if (NILP (tem))
-         return unbind_to (count, Qnil);
+       if (NILP (tem)){
+         
+           dynwind_end ();
+         return Qnil;
+         }
       }
 
     /* If the hooks have killed the buffer, exit now.  */
-    if (!BUFFER_LIVE_P (b))
-      return unbind_to (count, Qt);
+    if (!BUFFER_LIVE_P (b)){
+      
+        dynwind_end ();
+        return Qt;
+      }
 
     /* Then run the hooks.  */
     Frun_hooks (1, &Qkill_buffer_hook);
-    unbind_to (count, Qnil);
+    dynwind_end ();
   }
 
   /* If the hooks have killed the buffer, exit now.  */
@@ -2075,7 +2084,7 @@ the current buffer's major mode.  */)
   if (NILP (function) || EQ (function, Qfundamental_mode))
     return Qnil;
 
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   /* To select a nonfundamental mode,
      select the buffer temporarily and then call the mode function.  */
@@ -2085,7 +2094,8 @@ the current buffer's major mode.  */)
   Fset_buffer (buffer);
   call0 (function);
 
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 
 DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0,
@@ -3980,7 +3990,7 @@ buffer.  */)
 {
   struct buffer *b, *ob = 0;
   Lisp_Object obuffer;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   ptrdiff_t n_beg, n_end, o_beg IF_LINT (= 0), o_end IF_LINT (= 0);
 
   CHECK_OVERLAY (overlay);
@@ -4052,8 +4062,12 @@ buffer.  */)
 
   /* Delete the overlay if it is empty after clipping and has the
      evaporate property.  */
-  if (n_beg == n_end && !NILP (Foverlay_get (overlay, Qevaporate)))
-    return unbind_to (count, Fdelete_overlay (overlay));
+  if (n_beg == n_end && !NILP (Foverlay_get (overlay, Qevaporate))){
+    
+      Lisp_Object tem0 = Fdelete_overlay (overlay);
+      dynwind_end ();
+      return tem0;
+    }
 
   /* Put the overlay into the new buffer's overlay lists, first on the
      wrong list.  */
@@ -4071,7 +4085,8 @@ buffer.  */)
   /* This puts it in the right list, and in the right order.  */
   recenter_overlay_lists (b, b->overlay_center);
 
-  return unbind_to (count, overlay);
+  dynwind_end ();
+  return overlay;
 }
 
 DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0,
@@ -4080,13 +4095,15 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0,
 {
   Lisp_Object buffer;
   struct buffer *b;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   CHECK_OVERLAY (overlay);
 
   buffer = Fmarker_buffer (OVERLAY_START (overlay));
-  if (NILP (buffer))
+  if (NILP (buffer)) {
+    dynwind_end ();
     return Qnil;
+  }
 
   b = XBUFFER (buffer);
   specbind (Qinhibit_quit, Qt);
@@ -4103,7 +4120,8 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0,
          || !NILP (Foverlay_get (overlay, Qafter_string))))
     b->prevent_redisplay_optimizations_p = 1;
 
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 
 DEFUN ("delete-all-overlays", Fdelete_all_overlays, Sdelete_all_overlays, 0, 1, 0,
index d46ab23..a036f44 100644 (file)
@@ -297,7 +297,7 @@ invoke it.  If KEYS is omitted or nil, the return value of
   Lisp_Object teml;
   Lisp_Object up_event;
   Lisp_Object enable;
-  ptrdiff_t speccount = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   /* The index of the next element of this_command_keys to examine for
      the 'e' interactive code.  */
@@ -412,11 +412,13 @@ invoke it.  If KEYS is omitted or nil, the return value of
       kset_last_command (current_kboard, save_last_command);
 
       {
-       Lisp_Object args[3];
+       Lisp_Object tem0, args[3];
        args[0] = Qfuncall_interactively;
        args[1] = function;
        args[2] = specs;
-       return unbind_to (speccount, Fapply (3, args));
+       tem0 = Fapply (3, args);
+        dynwind_end ();
+        return tem0;
       }
     }
 
@@ -617,7 +619,7 @@ invoke it.  If KEYS is omitted or nil, the return value of
 
        case 'k':               /* Key sequence.  */
          {
-           ptrdiff_t speccount1 = SPECPDL_INDEX ();
+           dynwind_begin ();
            specbind (Qcursor_in_echo_area, Qt);
            /* Prompt in `minibuffer-prompt' face.  */
            Fput_text_property (make_number (0),
@@ -625,7 +627,7 @@ invoke it.  If KEYS is omitted or nil, the return value of
                                Qface, Qminibuffer_prompt, callint_message);
            args[i] = Fread_key_sequence (callint_message,
                                          Qnil, Qnil, Qnil, Qnil);
-           unbind_to (speccount1, Qnil);
+           dynwind_end ();
            teml = args[i];
            visargs[i] = Fkey_description (teml, Qnil);
 
@@ -649,7 +651,7 @@ invoke it.  If KEYS is omitted or nil, the return value of
 
        case 'K':               /* Key sequence to be defined.  */
          {
-           ptrdiff_t speccount1 = SPECPDL_INDEX ();
+           dynwind_begin ();
            specbind (Qcursor_in_echo_area, Qt);
            /* Prompt in `minibuffer-prompt' face.  */
            Fput_text_property (make_number (0),
@@ -659,7 +661,7 @@ invoke it.  If KEYS is omitted or nil, the return value of
                                                 Qnil, Qt, Qnil, Qnil);
            teml = args[i];
            visargs[i] = Fkey_description (teml, Qnil);
-           unbind_to (speccount1, Qnil);
+           dynwind_end ();
 
            /* If the key sequence ends with a down-event,
               discard the following up-event.  */
@@ -824,7 +826,7 @@ invoke it.  If KEYS is omitted or nil, the return value of
       if (tem) tem++;
       else tem = "";
     }
-  unbind_to (speccount, Qnil);
+  dynwind_end ();
 
   QUIT;
 
@@ -871,7 +873,8 @@ invoke it.  If KEYS is omitted or nil, the return value of
   {
     Lisp_Object val = Ffuncall (nargs, args);
     UNGCPRO;
-    return unbind_to (speccount, val);
+    dynwind_end ();
+    return val;
   }
 }
 
index 2f6030f..56bdc7d 100644 (file)
@@ -128,7 +128,7 @@ encode_current_directory (void)
     report_file_error ("Setting current directory",
                       BVAR (current_buffer, directory));
 
-  RETURN_UNGCPRO (dir);
+  return dir;
 }
 
 /* If P is reapable, record it as a deleted process and kill it.
@@ -245,7 +245,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS)  *
   Lisp_Object infile, encoded_infile;
   int filefd;
   struct gcpro gcpro1;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   if (nargs >= 2 && ! NILP (args[1]))
     {
@@ -263,7 +263,9 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS)  *
     report_file_error ("Opening process input file", infile);
   record_unwind_protect_ptr (close_file_ptr_unwind, &filefd);
   UNGCPRO;
-  return unbind_to (count, call_process (nargs, args, &filefd, NULL));
+  Lisp_Object tem0 = call_process (nargs, args, &filefd, NULL);
+  dynwind_end ();
+  return tem0;
 }
 
 /* Like Fcall_process (NARGS, ARGS), except use FILEFD as the input file.
@@ -1007,7 +1009,7 @@ create_temp_file (ptrdiff_t nargs, Lisp_Object *args,
   val = complement_process_encoding_system (val);
 
   {
-    ptrdiff_t count1 = SPECPDL_INDEX ();
+    dynwind_begin ();
 
     specbind (intern ("coding-system-for-write"), val);
     /* POSIX lets mk[s]temp use "."; don't invoke jka-compr if we
@@ -1015,7 +1017,7 @@ create_temp_file (ptrdiff_t nargs, Lisp_Object *args,
     specbind (intern ("file-name-handler-alist"), Qnil);
     write_region (start, end, filename_string, Qnil, Qlambda, Qnil, Qnil, fd);
 
-    unbind_to (count1, Qnil);
+    dynwind_end ();
   }
 
   if (lseek (fd, 0, SEEK_SET) < 0)
@@ -1056,7 +1058,7 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
 {
   struct gcpro gcpro1;
   Lisp_Object infile, val;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object start = args[0];
   Lisp_Object end = args[1];
   bool empty_input;
@@ -1103,7 +1105,8 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
   args[1] = infile;
 
   val = call_process (nargs, args, &fd, &infile);
-  RETURN_UNGCPRO (unbind_to (count, val));
+  dynwind_end ();
+  return val;
 }
 \f
 #ifndef WINDOWSNT
index e51ca5a..97d6346 100644 (file)
@@ -492,10 +492,10 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile,
 
   suffixes = list2 (build_string (".map"), build_string (".TXT"));
 
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
   record_unwind_protect_ptr (fclose_ptr_unwind, &fp);
   {
-    ptrdiff_t count1 = SPECPDL_INDEX ();
+    dynwind_begin ();
     specbind (Qfile_name_handler_alist, Qnil);
     fd = openp (Vcharset_map_path, mapfile, suffixes, NULL, Qnil, false);
     fp = fd < 0 ? 0 : fdopen (fd, "r");
@@ -505,7 +505,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile,
         emacs_close (fd);
         report_file_errno ("Loading charset map", mapfile, open_errno);
       }
-    unbind_to (count1, Qnil);
+    dynwind_end ();
   }
 
   /* Use record, as `charset_map_entries' is large (larger than
@@ -556,7 +556,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile,
   fp = NULL;
 
   load_charset_map (charset, head, n_entries, control_flag);
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 static void
index 55e2145..fc21795 100644 (file)
@@ -7879,7 +7879,7 @@ void
 decode_coding_gap (struct coding_system *coding,
                   ptrdiff_t chars, ptrdiff_t bytes)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object attrs;
 
   coding->src_object = Fcurrent_buffer ();
@@ -7973,6 +7973,7 @@ decode_coding_gap (struct coding_system *coding,
          coding->produced = bytes;
          coding->produced_char = chars;
          insert_from_gap (chars, bytes, 1);
+         dynwind_end ();
          return;
        }
     }
@@ -7996,7 +7997,7 @@ decode_coding_gap (struct coding_system *coding,
       coding->produced += Z_BYTE - prev_Z_BYTE;
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 
@@ -8036,7 +8037,7 @@ decode_coding_object (struct coding_system *coding,
                      ptrdiff_t to, ptrdiff_t to_byte,
                      Lisp_Object dst_object)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   unsigned char *destination IF_LINT (= NULL);
   ptrdiff_t dst_bytes IF_LINT (= 0);
   ptrdiff_t chars = to - from;
@@ -8209,7 +8210,7 @@ decode_coding_object (struct coding_system *coding,
     }
 
   Vdeactivate_mark = old_deactivate_mark;
-  unbind_to (count, coding->dst_object);
+  dynwind_end ();
 }
 
 
@@ -8220,7 +8221,7 @@ encode_coding_object (struct coding_system *coding,
                      ptrdiff_t to, ptrdiff_t to_byte,
                      Lisp_Object dst_object)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   ptrdiff_t chars = to - from;
   ptrdiff_t bytes = to_byte - from_byte;
   Lisp_Object attrs;
@@ -8418,7 +8419,7 @@ encode_coding_object (struct coding_system *coding,
     Fkill_buffer (coding->src_object);
 
   Vdeactivate_mark = old_deactivate_mark;
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 
@@ -8516,7 +8517,7 @@ are lower-case).  */)
   (Lisp_Object prompt, Lisp_Object default_coding_system)
 {
   Lisp_Object val;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   if (SYMBOLP (default_coding_system))
     default_coding_system = SYMBOL_NAME (default_coding_system);
@@ -8524,7 +8525,7 @@ are lower-case).  */)
   val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
                          Qt, Qnil, Qcoding_system_history,
                          default_coding_system, Qnil);
-  unbind_to (count, Qnil);
+  dynwind_end ();
   return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil));
 }
 
index 1c14a05..b75ac99 100644 (file)
@@ -582,7 +582,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask)
     }
   if (min_pos < max_pos)
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
 
       specbind (Qinhibit_read_only, Qt);
       specbind (Qinhibit_modification_hooks, Qt);
@@ -590,7 +590,7 @@ update_compositions (ptrdiff_t from, ptrdiff_t to, int check_mask)
       Fremove_list_of_text_properties (make_number (min_pos),
                                       make_number (max_pos),
                                       list1 (Qauto_composed), Qnil);
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 }
 
@@ -869,7 +869,7 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
               ptrdiff_t limit, struct window *win, struct face *face,
               Lisp_Object string)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct frame *f = XFRAME (win->frame);
   Lisp_Object pos = make_number (charpos);
   ptrdiff_t to;
@@ -881,8 +881,11 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
   re = AREF (rule, 0);
   if (NILP (re))
     len = 1;
-  else if (! STRINGP (re))
-    return unbind_to (count, Qnil);
+  else if (! STRINGP (re)){
+    
+      dynwind_end ();
+      return Qnil;
+    }
   else if ((len = fast_looking_at (re, charpos, bytepos, limit, -1, string))
           > 0)
     {
@@ -891,8 +894,11 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
       else
        len = string_byte_to_char (string, bytepos + len) - charpos;
     }
-  if (len <= 0)
-    return unbind_to (count, Qnil);
+  if (len <= 0){
+    
+      dynwind_end ();
+      return Qnil;
+    }
   to = limit = charpos + len;
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (f))
@@ -901,8 +907,11 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
       if (! FONT_OBJECT_P (font_object)
          || (! NILP (re)
              && to < limit
-             && (fast_looking_at (re, charpos, bytepos, to, -1, string) <= 0)))
-       return unbind_to (count, Qnil);
+             && (fast_looking_at (re, charpos, bytepos, to, -1, string) <= 0))){
+       
+         dynwind_end ();
+       return Qnil;
+       }
     }
   else
 #endif /* not HAVE_WINDOW_SYSTEM */
@@ -918,7 +927,8 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
       lgstring = safe_call (6, Vauto_composition_function, AREF (rule, 2),
                            pos, make_number (to), font_object, string);
     }
-  return unbind_to (count, lgstring);
+  dynwind_end ();
+  return lgstring;
 }
 
 /* 1 iff the character C is composable.  Characters of general
index 59844c4..9808cc6 100644 (file)
@@ -56,7 +56,7 @@ conv_filename_to_w32_unicode (Lisp_Object in, int absolute_p)
   ssize_t converted_len;
   Lisp_Object converted;
   unsigned flags;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   chdir_to_default_directory ();
 
@@ -76,7 +76,8 @@ conv_filename_to_w32_unicode (Lisp_Object in, int absolute_p)
                         SDATA (converted), converted_len))
     error ("cygwin_conv_path: %s", strerror (errno));
 
-  return unbind_to (count, converted);
+  dynwind_end ();
+  return converted;
 }
 
 static Lisp_Object
@@ -85,7 +86,7 @@ conv_filename_from_w32_unicode (const wchar_t* in, int absolute_p)
   ssize_t converted_len;
   Lisp_Object converted;
   unsigned flags;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   chdir_to_default_directory ();
 
@@ -102,7 +103,9 @@ conv_filename_from_w32_unicode (const wchar_t* in, int absolute_p)
   if (cygwin_conv_path (flags, in, SDATA (converted), converted_len))
     error ("cygwin_conv_path: %s", strerror (errno));
 
-  return unbind_to (count, DECODE_FILE (converted));
+  Lisp_Object tem0 = DECODE_FILE (converted);
+  dynwind_end ();
+  return tem0;
 }
 
 DEFUN ("cygwin-convert-file-name-to-windows",
index 58513e1..e8b0771 100644 (file)
@@ -946,7 +946,7 @@ xd_retrieve_arg (int dtype, DBusMessageIter *iter)
            dbus_message_iter_next (&subiter);
          }
        XD_DEBUG_MESSAGE ("%c %s", dtype, XD_OBJECT_TO_STRING (result));
-       RETURN_UNGCPRO (Fnreverse (result));
+       return Fnreverse (result);
       }
 
     default:
@@ -1534,7 +1534,7 @@ usage: (dbus-message-internal &rest REST)  */)
   dbus_message_unref (dmessage);
 
   /* Return the result.  */
-  RETURN_UNGCPRO (result);
+  return result;
 }
 
 /* Read one queued incoming message of the D-Bus BUS.
index 540c39d..9dfec88 100644 (file)
@@ -139,7 +139,7 @@ This function can be called only in unibyte buffers.  */)
   z_stream stream;
   int inflate_status;
   struct decompress_unwind_data unwind_data;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   validate_region (&start, &end);
 
@@ -149,8 +149,10 @@ This function can be called only in unibyte buffers.  */)
 #ifdef WINDOWSNT
   if (!zlib_initialized)
     zlib_initialized = init_zlib_functions ();
-  if (!zlib_initialized)
+  if (!zlib_initialized) {
+    dynwind_end ();
     return Qnil;
+  }
 #endif
 
   /* This is a unibyte buffer, so character positions and bytes are
@@ -167,8 +169,10 @@ This function can be called only in unibyte buffers.  */)
 
   /* The magic number 32 apparently means "autodetect both the gzip and
      zlib formats" according to zlib.h.  */
-  if (fn_inflateInit2 (&stream, MAX_WBITS + 32) != Z_OK)
+  if (fn_inflateInit2 (&stream, MAX_WBITS + 32) != Z_OK) {
+    dynwind_end ();
     return Qnil;
+  }
 
   unwind_data.start = iend;
   unwind_data.stream = &stream;
@@ -206,15 +210,19 @@ This function can be called only in unibyte buffers.  */)
     }
   while (inflate_status == Z_OK);
 
-  if (inflate_status != Z_STREAM_END)
-    return unbind_to (count, Qnil);
+  if (inflate_status != Z_STREAM_END){
+    
+      dynwind_end ();
+      return Qnil;
+    }
 
   unwind_data.start = 0;
 
   /* Delete the compressed data.  */
   del_range (istart, iend);
 
-  return unbind_to (count, Qt);
+  dynwind_end ();
+  return Qt;
 }
 
 \f
index b3f880b..6bec249 100644 (file)
@@ -143,7 +143,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
   Lisp_Object list, dirfilename, encoded_directory;
   struct re_pattern_buffer *bufp = NULL;
   bool needsep = 0;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
   struct dirent *dp;
 
@@ -306,13 +306,13 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
       UNGCPRO;
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   if (NILP (nosort))
     list = Fsort (Fnreverse (list),
                  attrs ? Qfile_attributes_lessp : Qstring_lessp);
 
-  RETURN_UNGCPRO (list);
+  return list;
 }
 
 
@@ -452,7 +452,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
      well as "." and "..".  Until shown otherwise, assume we can't exclude
      anything.  */
   bool includeall = 1;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
 
   elt = Qnil;
@@ -743,7 +743,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
 
   UNGCPRO;
   /* This closes the directory.  */
-  unbind_to (count, bestmatch);
+  dynwind_end ();
 
   if (all_flag || NILP (bestmatch))
     return bestmatch;
index d9ef017..5c6a43c 100644 (file)
@@ -5477,7 +5477,7 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
   int new_text_width, new_text_height, new_root_width;
   int old_root_width = WINDOW_PIXEL_WIDTH (XWINDOW (FRAME_ROOT_WINDOW (f)));
   int new_cols, new_lines;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   /* If we can't deal with the change now, queue it for later.  */
   if (delay || (redisplaying_p && !safe))
@@ -5486,6 +5486,7 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
       f->new_height = new_height;
       f->new_pixelwise = pixelwise;
       delayed_size_change = 1;
+      dynwind_end ();
       return;
     }
 
@@ -5532,7 +5533,10 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
          FRAME_TEXT_TO_PIXEL_HEIGHT (f, new_text_height))
       && (FRAME_PIXEL_WIDTH (f) ==
          FRAME_TEXT_TO_PIXEL_WIDTH (f, new_text_width)))
-    return;
+    {
+      dynwind_end ();
+      return;
+    }
 
   block_input ();
 
@@ -5602,7 +5606,7 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
 
   run_window_configuration_change_hook (f);
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 \f
 /***********************************************************************
@@ -5839,11 +5843,11 @@ immediately by pending input.  */)
       || !NILP (Vexecuting_kbd_macro))
     return Qnil;
 
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
   if (!NILP (force) && !redisplay_dont_pause)
     specbind (Qredisplay_dont_pause, Qt);
   redisplay_preserve_echo_area (2);
-  unbind_to (count, Qnil);
+  dynwind_end ();
   return Qt;
 }
 
index 9f10f57..2eaaffa 100644 (file)
--- a/src/doc.c
+++ b/src/doc.c
@@ -951,7 +951,7 @@ Otherwise, return a new string.  */)
   else
     tem = string;
   xfree (buf);
-  RETURN_UNGCPRO (tem);
+  return tem;
 }
 \f
 void
index dbeb1d0..747f59e 100644 (file)
@@ -759,7 +759,7 @@ This function does not move point.  */)
   (Lisp_Object n)
 {
   ptrdiff_t orig, orig_byte, end;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   specbind (Qinhibit_point_motion_hooks, Qt);
 
   if (NILP (n))
@@ -774,7 +774,7 @@ This function does not move point.  */)
 
   SET_PT_BOTH (orig, orig_byte);
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   /* Return END constrained to the current input field.  */
   return Fconstrain_to_field (make_number (end), make_number (orig),
@@ -934,12 +934,13 @@ usage: (save-excursion &rest BODY)  */)
   (Lisp_Object args)
 {
   register Lisp_Object val;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   record_unwind_protect (save_excursion_restore, save_excursion_save ());
 
   val = Fprogn (args);
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 
 DEFUN ("save-current-buffer", Fsave_current_buffer, Ssave_current_buffer, 0, UNEVALLED, 0,
@@ -948,10 +949,12 @@ BODY is executed just like `progn'.
 usage: (save-current-buffer &rest BODY)  */)
   (Lisp_Object args)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   record_unwind_current_buffer ();
-  return unbind_to (count, Fprogn (args));
+  Lisp_Object tem0 = Fprogn (args);
+  dynwind_end ();
+  return tem0;
 }
 \f
 DEFUN ("buffer-size", Fbuffer_size, Sbuffer_size, 0, 1, 0,
@@ -2828,7 +2831,7 @@ Both characters must have the same length of multi-byte form.  */)
   ptrdiff_t changed = 0;
   unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH];
   unsigned char *p;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 #define COMBINING_NO    0
 #define COMBINING_BEFORE 1
 #define COMBINING_AFTER  2
@@ -2993,7 +2996,7 @@ Both characters must have the same length of multi-byte form.  */)
       update_compositions (changed, last_changed, CHECK_ALL);
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
   return Qnil;
 }
 
@@ -3405,11 +3408,12 @@ usage: (save-restriction &rest BODY)  */)
   (Lisp_Object body)
 {
   register Lisp_Object val;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   record_unwind_protect (save_restriction_restore, save_restriction_save ());
   val = Fprogn (body);
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 \f
 DEFUN ("message", Fmessage, Smessage, 1, MANY, 0,
@@ -3539,7 +3543,7 @@ usage: (propertize STRING &rest PROPERTIES)  */)
   Fadd_text_properties (make_number (0),
                        make_number (SCHARS (string)),
                        properties, string);
-  RETURN_UNGCPRO (string);
+  return string;
 }
 
 DEFUN ("format", Fformat, Sformat, 1, MANY, 0,
index 93b4598..bef3266 100644 (file)
@@ -390,7 +390,7 @@ init_cmdargs (int argc, char **argv, int skip_args, char *original_pwd)
 {
   register int i;
   Lisp_Object name, dir, handler;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object raw_name;
 
   initial_argv = argv;
@@ -549,7 +549,7 @@ init_cmdargs (int argc, char **argv, int skip_args, char *original_pwd)
          = Fcons (build_unibyte_string (argv[i]), Vcommand_line_args);
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0,
@@ -2071,7 +2071,7 @@ You must run Emacs in batch mode in order to dump it.  */)
 {
   Lisp_Object tem;
   Lisp_Object symbol;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   check_pure_size ();
 
@@ -2161,7 +2161,8 @@ You must run Emacs in batch mode in order to dump it.  */)
 
   Vpurify_flag = tem;
 
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 
 #endif /* not CANNOT_DUMP */
index d6c0e87..d9434a9 100644 (file)
@@ -276,7 +276,7 @@ Lisp_Object
 call_debugger (Lisp_Object arg)
 {
   bool debug_while_redisplaying;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object val;
   EMACS_INT old_depth = max_lisp_eval_depth;
   /* Do not allow max_specpdl_size less than actual depth (Bug#16603).  */
@@ -332,7 +332,8 @@ call_debugger (Lisp_Object arg)
   if (debug_while_redisplaying)
     Ftop_level ();
 
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 
 static void
@@ -850,7 +851,7 @@ usage: (let* VARLIST BODY...)  */)
   (Lisp_Object args)
 {
   Lisp_Object varlist, var, val, elt, lexenv;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3;
 
   GCPRO3 (args, elt, varlist);
@@ -899,7 +900,8 @@ usage: (let* VARLIST BODY...)  */)
     }
   UNGCPRO;
   val = Fprogn (XCDR (args));
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 
 DEFUN ("let", Flet, Slet, 1, UNEVALLED, 0,
@@ -913,7 +915,7 @@ usage: (let VARLIST BODY...)  */)
 {
   Lisp_Object *temps, tem, lexenv;
   register Lisp_Object elt, varlist;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   ptrdiff_t argnum;
   struct gcpro gcpro1, gcpro2;
   USE_SAFE_ALLOCA;
@@ -970,7 +972,8 @@ usage: (let VARLIST BODY...)  */)
 
   elt = Fprogn (XCDR (args));
   SAFE_FREE ();
-  return unbind_to (count, elt);
+  dynwind_end ();
+  return elt;
 }
 
 DEFUN ("while", Fwhile, Swhile, 1, UNEVALLED, 0,
@@ -1205,11 +1208,12 @@ usage: (unwind-protect BODYFORM UNWINDFORMS...)  */)
   (Lisp_Object args)
 {
   Lisp_Object val;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   record_unwind_protect (unwind_body, XCDR (args));
   val = eval_sub (XCAR (args));
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 \f
 DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0,
@@ -1919,17 +1923,21 @@ If equal to `macro', MACRO-ONLY specifies that FUNDEF should only be loaded if
 it is defines a macro.  */)
   (Lisp_Object fundef, Lisp_Object funname, Lisp_Object macro_only)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3;
 
-  if (!CONSP (fundef) || !EQ (Qautoload, XCAR (fundef)))
+  if (!CONSP (fundef) || !EQ (Qautoload, XCAR (fundef))) {
+    dynwind_end ();
     return fundef;
+  }
 
   if (EQ (macro_only, Qmacro))
     {
       Lisp_Object kind = Fnth (make_number (4), fundef);
-      if (! (EQ (kind, Qt) || EQ (kind, Qmacro)))
-       return fundef;
+      if (! (EQ (kind, Qt) || EQ (kind, Qmacro))) {
+        dynwind_end ();
+        return fundef;
+      }
     }
 
   /* This is to make sure that loadup.el gives a clear picture
@@ -1960,7 +1968,7 @@ it is defines a macro.  */)
 
   /* Once loading finishes, don't undo it.  */
   Vautoload_queue = Qt;
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   UNGCPRO;
 
@@ -1986,10 +1994,12 @@ LEXICAL can also be an actual lexical environment, in the form of an
 alist mapping symbols to their value.  */)
   (Lisp_Object form, Lisp_Object lexical)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   specbind (Qinternal_interpreter_environment,
            CONSP (lexical) || NILP (lexical) ? lexical : list1 (Qt));
-  return unbind_to (count, eval_sub (form));
+  Lisp_Object tem0 = eval_sub (form);
+  dynwind_end ();
+  return tem0;
 }
 
 /* Grow the specpdl stack by one entry.
@@ -2231,7 +2241,7 @@ eval_sub (Lisp_Object form)
        }
       if (EQ (funcar, Qmacro))
        {
-         ptrdiff_t count = SPECPDL_INDEX ();
+         dynwind_begin ();
          Lisp_Object exp;
          /* Bind lexical-binding during expansion of the macro, so the
             macro can know reliably if the code it outputs will be
@@ -2239,7 +2249,7 @@ eval_sub (Lisp_Object form)
          specbind (Qlexical_binding,
                    NILP (Vinternal_interpreter_environment) ? Qnil : Qt);
          exp = apply1 (Fcdr (fun), original_args);
-         unbind_to (count, Qnil);
+         dynwind_end ();
          val = eval_sub (exp);
        }
       else if (EQ (funcar, Qlambda)
@@ -2564,14 +2574,14 @@ apply1 (Lisp_Object fn, Lisp_Object arg)
 
   GCPRO1 (fn);
   if (NILP (arg))
-    RETURN_UNGCPRO (Ffuncall (1, &fn));
+    return Ffuncall (1, &fn);
   gcpro1.nvars = 2;
   {
     Lisp_Object args[2];
     args[0] = fn;
     args[1] = arg;
     gcpro1.var = args;
-    RETURN_UNGCPRO (Fapply (2, args));
+    return Fapply (2, args);
   }
 }
 
@@ -2582,7 +2592,7 @@ call0 (Lisp_Object fn)
   struct gcpro gcpro1;
 
   GCPRO1 (fn);
-  RETURN_UNGCPRO (Ffuncall (1, &fn));
+  return Ffuncall (1, &fn);
 }
 
 /* Call function fn with 1 argument arg1.  */
@@ -2597,7 +2607,7 @@ call1 (Lisp_Object fn, Lisp_Object arg1)
   args[1] = arg1;
   GCPRO1 (args[0]);
   gcpro1.nvars = 2;
-  RETURN_UNGCPRO (Ffuncall (2, args));
+  return Ffuncall (2, args);
 }
 
 /* Call function fn with 2 arguments arg1, arg2.  */
@@ -2612,7 +2622,7 @@ call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2)
   args[2] = arg2;
   GCPRO1 (args[0]);
   gcpro1.nvars = 3;
-  RETURN_UNGCPRO (Ffuncall (3, args));
+  return Ffuncall (3, args);
 }
 
 /* Call function fn with 3 arguments arg1, arg2, arg3.  */
@@ -2628,7 +2638,7 @@ call3 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
   args[3] = arg3;
   GCPRO1 (args[0]);
   gcpro1.nvars = 4;
-  RETURN_UNGCPRO (Ffuncall (4, args));
+  return Ffuncall (4, args);
 }
 
 /* Call function fn with 4 arguments arg1, arg2, arg3, arg4.  */
@@ -2646,7 +2656,7 @@ call4 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
   args[4] = arg4;
   GCPRO1 (args[0]);
   gcpro1.nvars = 5;
-  RETURN_UNGCPRO (Ffuncall (5, args));
+  return Ffuncall (5, args);
 }
 
 /* Call function fn with 5 arguments arg1, arg2, arg3, arg4, arg5.  */
@@ -2665,7 +2675,7 @@ call5 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
   args[5] = arg5;
   GCPRO1 (args[0]);
   gcpro1.nvars = 6;
-  RETURN_UNGCPRO (Ffuncall (6, args));
+  return Ffuncall (6, args);
 }
 
 /* Call function fn with 6 arguments arg1, arg2, arg3, arg4, arg5, arg6.  */
@@ -2685,7 +2695,7 @@ call6 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
   args[6] = arg6;
   GCPRO1 (args[0]);
   gcpro1.nvars = 7;
-  RETURN_UNGCPRO (Ffuncall (7, args));
+  return Ffuncall (7, args);
 }
 
 /* Call function fn with 7 arguments arg1, arg2, arg3, arg4, arg5, arg6, arg7.  */
@@ -2706,7 +2716,7 @@ call7 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
   args[7] = arg7;
   GCPRO1 (args[0]);
   gcpro1.nvars = 8;
-  RETURN_UNGCPRO (Ffuncall (8, args));
+  return Ffuncall (8, args);
 }
 
 /* The caller should GCPRO all the elements of ARGS.  */
@@ -2925,7 +2935,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
                register Lisp_Object *arg_vector)
 {
   Lisp_Object val, syms_left, next, lexenv;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   ptrdiff_t i;
   bool optional, rest;
 
@@ -2962,6 +2972,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
             and constants vector yet, fetch them from the file.  */
          if (CONSP (AREF (fun, COMPILED_BYTECODE)))
            Ffetch_bytecode (fun);
+         dynwind_end ();
          return exec_byte_code (AREF (fun, COMPILED_BYTECODE),
                                 AREF (fun, COMPILED_CONSTANTS),
                                 AREF (fun, COMPILED_STACK_DEPTH),
@@ -3034,7 +3045,8 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
                            Qnil, 0, 0);
     }
 
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 
 DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode,
@@ -3575,7 +3587,7 @@ NFRAMES and BASE specify the activation frame to use, as in `backtrace-frame'.
      (Lisp_Object exp, Lisp_Object nframes, Lisp_Object base)
 {
   union specbinding *pdl = get_backtrace_frame (nframes, base);
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   ptrdiff_t distance = specpdl_ptr - pdl;
   eassert (distance >= 0);
 
@@ -3588,7 +3600,9 @@ NFRAMES and BASE specify the activation frame to use, as in `backtrace-frame'.
   /* Use eval_sub rather than Feval since the main motivation behind
      backtrace-eval is to be able to get/set the value of lexical variables
      from the debugger.  */
-  return unbind_to (count, eval_sub (exp));
+  Lisp_Object tem1 = eval_sub (exp);
+  dynwind_end ();
+  return tem1;
 }
 
 DEFUN ("backtrace--locals", Fbacktrace__locals, Sbacktrace__locals, 1, 2, NULL,
index 34b2497..e000890 100644 (file)
@@ -1959,7 +1959,7 @@ permissions.  */)
 {
   Lisp_Object handler;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object encoded_file, encoded_newname;
 #if HAVE_LIBSELINUX
   security_context_t con;
@@ -1994,10 +1994,10 @@ permissions.  */)
   /* Likewise for output file name.  */
   if (NILP (handler))
     handler = Ffind_file_name_handler (newname, Qcopy_file);
-  if (!NILP (handler))
-    RETURN_UNGCPRO (call7 (handler, Qcopy_file, file, newname,
-                          ok_if_already_exists, keep_time, preserve_uid_gid,
-                          preserve_permissions));
+  if (!NILP (handler)) {
+    dynwind_end ();
+    return call7 (handler, Qcopy_file, file, newname, ok_if_already_exists, keep_time, preserve_uid_gid, preserve_permissions);
+  }
 
   encoded_file = ENCODE_FILE (file);
   encoded_newname = ENCODE_FILE (newname);
@@ -2176,7 +2176,7 @@ permissions.  */)
 #endif /* MSDOS */
 #endif /* not WINDOWSNT */
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   UNGCPRO;
   return Qnil;
@@ -2333,8 +2333,7 @@ This is what happens in interactive use with M-x.  */)
   if (NILP (handler))
     handler = Ffind_file_name_handler (newname, Qrename_file);
   if (!NILP (handler))
-    RETURN_UNGCPRO (call4 (handler, Qrename_file,
-                          file, newname, ok_if_already_exists));
+    return call4 (handler, Qrename_file, file, newname, ok_if_already_exists);
 
   encoded_file = ENCODE_FILE (file);
   encoded_newname = ENCODE_FILE (newname);
@@ -2368,14 +2367,14 @@ This is what happens in interactive use with M-x.  */)
                        NILP (ok_if_already_exists) ? Qnil : Qt,
                        Qt, Qt, Qt);
 
-         count = SPECPDL_INDEX ();
+         dynwind_begin ();
          specbind (Qdelete_by_moving_to_trash, Qnil);
 
          if (!NILP (Ffile_directory_p (file)) && NILP (symlink_target))
            call2 (Qdelete_directory, file, Qt);
          else
            Fdelete_file (file, Qnil);
-         unbind_to (count, Qnil);
+         dynwind_end ();
        }
       else
        report_file_errno ("Renaming", list2 (file, newname), rename_errno);
@@ -2412,15 +2411,13 @@ This is what happens in interactive use with M-x.  */)
      call the corresponding file handler.  */
   handler = Ffind_file_name_handler (file, Qadd_name_to_file);
   if (!NILP (handler))
-    RETURN_UNGCPRO (call4 (handler, Qadd_name_to_file, file,
-                          newname, ok_if_already_exists));
+    return call4 (handler, Qadd_name_to_file, file, newname, ok_if_already_exists);
 
   /* If the new name has special constructs in it,
      call the corresponding file handler.  */
   handler = Ffind_file_name_handler (newname, Qadd_name_to_file);
   if (!NILP (handler))
-    RETURN_UNGCPRO (call4 (handler, Qadd_name_to_file, file,
-                          newname, ok_if_already_exists));
+    return call4 (handler, Qadd_name_to_file, file, newname, ok_if_already_exists);
 
   encoded_file = ENCODE_FILE (file);
   encoded_newname = ENCODE_FILE (newname);
@@ -2474,15 +2471,13 @@ This happens for interactive use with M-x.  */)
      call the corresponding file handler.  */
   handler = Ffind_file_name_handler (filename, Qmake_symbolic_link);
   if (!NILP (handler))
-    RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename,
-                          linkname, ok_if_already_exists));
+    return call4 (handler, Qmake_symbolic_link, filename, linkname, ok_if_already_exists);
 
   /* If the new link name has special constructs in it,
      call the corresponding file handler.  */
   handler = Ffind_file_name_handler (linkname, Qmake_symbolic_link);
   if (!NILP (handler))
-    RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename,
-                          linkname, ok_if_already_exists));
+    return call4 (handler, Qmake_symbolic_link, filename, linkname, ok_if_already_exists);
 
   encoded_filename = ENCODE_FILE (filename);
   encoded_linkname = ENCODE_FILE (linkname);
@@ -5532,7 +5527,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
   int do_handled_files;
   Lisp_Object oquit;
   FILE *stream = NULL;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   bool orig_minibuffer_auto_raise = minibuffer_auto_raise;
   bool old_message_p = 0;
   struct auto_save_unwind auto_save_unwind;
@@ -5715,7 +5710,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
   Vquit_flag = oquit;
 
   /* This restores the message-stack status.  */
-  unbind_to (count, Qnil);
+  dynwind_end ();
   return Qnil;
 }
 
index e275df7..015fc8c 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -2618,7 +2618,7 @@ The normal messages at start and end of loading FILENAME are suppressed.  */)
 
   if (NILP (tem))
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       int nesting = 0;
 
       /* This is to make sure that loadup.el gives a clear picture
@@ -2656,8 +2656,11 @@ The normal messages at start and end of loading FILENAME are suppressed.  */)
       UNGCPRO;
 
       /* If load failed entirely, return nil.  */
-      if (NILP (tem))
-       return unbind_to (count, Qnil);
+      if (NILP (tem)){
+       
+         dynwind_end ();
+       return Qnil;
+       }
 
       tem = Fmemq (feature, Vfeatures);
       if (NILP (tem))
@@ -2666,7 +2669,7 @@ The normal messages at start and end of loading FILENAME are suppressed.  */)
 
       /* Once loading finishes, don't undo it.  */
       Vautoload_queue = Qt;
-      unbind_to (count, feature);
+      dynwind_end ();
     }
 
   return feature;
@@ -4280,7 +4283,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start,
     }
   else
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
 
       record_unwind_current_buffer ();
 
@@ -4374,7 +4377,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start,
        }
 
       object = make_buffer_string (b, e, 0);
-      unbind_to (count, Qnil);
+      dynwind_end ();
 
       if (STRING_MULTIBYTE (object))
        object = code_convert_string (object, coding_system, Qnil, 1, 0, 0);
index d0bbc62..9ab18ad 100644 (file)
@@ -1560,7 +1560,7 @@ and returns whatever that function returns.  */)
   GCPRO1 (retval);
   if (!NILP (Vmouse_position_function))
     retval = call1 (Vmouse_position_function, retval);
-  RETURN_UNGCPRO (retval);
+  return retval;
 }
 
 DEFUN ("mouse-pixel-position", Fmouse_pixel_position,
index 558b727..fcb4224 100644 (file)
@@ -1637,7 +1637,7 @@ xg_maybe_add_timer (gpointer data)
 static int
 xg_dialog_run (struct frame *f, GtkWidget *w)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct xg_dialog_data dd;
 
   xg_set_screen (w, f);
@@ -1665,7 +1665,7 @@ xg_dialog_run (struct frame *f, GtkWidget *w)
   g_main_loop_run (dd.loop);
 
   dd.w = 0;
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   return dd.response;
 }
index a741815..7fa2884 100644 (file)
@@ -2263,7 +2263,7 @@ slurp_file (char *file, ptrdiff_t *size)
 
   if (fp)
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       record_unwind_protect_ptr (fclose_unwind, fp);
 
       if (fstat (fileno (fp), &st) == 0
@@ -2282,7 +2282,7 @@ slurp_file (char *file, ptrdiff_t *size)
            }
        }
 
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 
   return buf;
index 85ec401..5b95bcf 100644 (file)
@@ -2150,7 +2150,7 @@ whether or not it is currently displayed in some window.  */)
                       old_charpos, old_bytepos);
     }
 
-  RETURN_UNGCPRO (make_number (it.vpos));
+  return make_number (it.vpos);
 }
 
 
index f515ed4..c6d89da 100644 (file)
@@ -1951,7 +1951,7 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int,
   Lisp_Object start_marker, end_marker;
   Lisp_Object preserve_marker;
   struct gcpro gcpro1, gcpro2, gcpro3;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct rvoe_arg rvoe_arg;
 
   start = make_number (start_int);
@@ -2006,7 +2006,7 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int,
   RESTORE_VALUE;
   UNGCPRO;
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 /* Signal a change immediately after it happens.
@@ -2019,11 +2019,13 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int,
 void
 signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct rvoe_arg rvoe_arg;
 
-  if (inhibit_modification_hooks)
+  if (inhibit_modification_hooks) {
+    dynwind_end ();
     return;
+  }
 
   /* If we are deferring calls to the after-change functions
      and there are no before-change functions,
@@ -2044,6 +2046,7 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins)
        = Fcons (elt, combine_after_change_list);
       combine_after_change_buffer = Fcurrent_buffer ();
 
+      dynwind_end ();
       return;
     }
 
@@ -2086,7 +2089,7 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins)
     report_interval_modification (make_number (charpos),
                                  make_number (charpos + lenins));
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 static void
@@ -2100,13 +2103,15 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
        doc: /* This function is for use internally in the function `combine-after-change-calls'.  */)
   (void)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   ptrdiff_t beg, end, change;
   ptrdiff_t begpos, endpos;
   Lisp_Object tail;
 
-  if (NILP (combine_after_change_list))
+  if (NILP (combine_after_change_list)) {
+    dynwind_end ();
     return Qnil;
+  }
 
   /* It is rare for combine_after_change_buffer to be invalid, but
      possible.  It can happen when combine-after-change-calls is
@@ -2116,6 +2121,7 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
       || !BUFFER_LIVE_P (XBUFFER (combine_after_change_buffer)))
     {
       combine_after_change_list = Qnil;
+      dynwind_end ();
       return Qnil;
     }
 
@@ -2177,7 +2183,8 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
   signal_after_change (begpos, endpos - begpos - change, endpos - begpos);
   update_compositions (begpos, endpos, CHECK_ALL);
 
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 \f
 void
index 72ec1b4..20498d0 100644 (file)
@@ -740,7 +740,7 @@ add_command_key (Lisp_Object key)
 Lisp_Object
 recursive_edit_1 (void)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object val;
 
   if (command_loop_level > 0)
@@ -777,7 +777,8 @@ recursive_edit_1 (void)
   if (STRINGP (val))
     xsignal1 (Qerror, val);
 
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 
 /* When an auto-save happens, record the "time", and don't do again soon.  */
@@ -812,13 +813,15 @@ one level up.
 This function is called by the editor initialization to begin editing.  */)
   (void)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object buffer;
 
   /* If we enter while input is blocked, don't lock up here.
      This may happen through the debugger during redisplay.  */
-  if (input_blocked_p ())
+  if (input_blocked_p ()) {
+    dynwind_end ();
     return Qnil;
+  }
 
   if (command_loop_level >= 0
       && current_buffer != XBUFFER (XWINDOW (selected_window)->contents))
@@ -841,7 +844,8 @@ This function is called by the editor initialization to begin editing.  */)
     temporarily_switch_to_single_kboard (SELECTED_FRAME ());
 
   recursive_edit_1 ();
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 
 void
@@ -1269,7 +1273,7 @@ Normally, mouse motion is ignored.
 usage: (track-mouse BODY...)  */)
   (Lisp_Object args)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object val;
 
   record_unwind_protect (tracking_off, do_mouse_tracking);
@@ -1277,7 +1281,8 @@ usage: (track-mouse BODY...)  */)
   do_mouse_tracking = Qt;
 
   val = Fprogn (args);
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 
 /* If mouse has moved on some frame, return one of those frames.
@@ -1929,12 +1934,12 @@ safe_run_hooks (Lisp_Object hook)
   /* FIXME: our `internal_condition_case' does not provide any way to pass data
      to its body or to its handlers other than via globals such as
      dynamically-bound variables ;-)  */
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   specbind (Qinhibit_quit, hook);
 
   run_hook_with_args (1, &hook, safe_run_hook_funcall);
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 \f
@@ -4552,7 +4557,7 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers)
        {
          if (NILP (AREF (chosen_timer, 0)))
            {
-             ptrdiff_t count = SPECPDL_INDEX ();
+             dynwind_begin ();
              Lisp_Object old_deactivate_mark = Vdeactivate_mark;
 
              /* Mark the timer as triggered to prevent problems if the lisp
@@ -4564,7 +4569,7 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers)
              call1 (Qtimer_event_handler, chosen_timer);
              Vdeactivate_mark = old_deactivate_mark;
              timers_run++;
-             unbind_to (count, Qnil);
+             dynwind_end ();
 
              /* Since we have handled the event,
                 we don't need to tell the caller to wake up and do it.  */
@@ -7651,12 +7656,13 @@ eval_dyn (Lisp_Object form)
 Lisp_Object
 menu_item_eval_property (Lisp_Object sexpr)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object val;
   specbind (Qinhibit_redisplay, Qt);
   val = internal_condition_case_1 (eval_dyn, sexpr, Qerror,
                                   menu_item_eval_property_1);
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 
 /* This function parses a menu item and leaves the result in the
@@ -9805,7 +9811,7 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
   Lisp_Object keybuf[30];
   register int i;
   struct gcpro gcpro1;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   if (!NILP (prompt))
     CHECK_STRING (prompt);
@@ -9851,9 +9857,9 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
       QUIT;
     }
   UNGCPRO;
-  return unbind_to (count,
-                   ((allow_string ? make_event_array : Fvector)
-                    (i, keybuf)));
+  Lisp_Object tem0 = ((allow_string ? make_event_array : Fvector) (i, keybuf));
+  dynwind_end ();
+  return tem0;
 }
 
 DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 5, 0,
@@ -10200,7 +10206,7 @@ Some operating systems cannot stop the Emacs process and resume it later.
 On such systems, Emacs starts a subshell instead of suspending.  */)
   (Lisp_Object stuffstring)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   int old_height, old_width;
   int width, height;
   struct gcpro gcpro1;
@@ -10227,7 +10233,7 @@ On such systems, Emacs starts a subshell instead of suspending.  */)
     sys_subshell ();
   else
     sys_suspend ();
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   /* Check if terminal/window size has changed.
      Note that this is not useful when we are running directly
index 85a272b..5b0b874 100644 (file)
@@ -356,7 +356,7 @@ Return PARENT.  PARENT should be nil or another keymap.  */)
        {
          CHECK_IMPURE (prev);
          XSETCDR (prev, parent);
-         RETURN_UNGCPRO (parent);
+         return parent;
        }
       prev = list;
     }
@@ -1131,7 +1131,7 @@ binding KEY to DEF is added at the front of KEYMAP.  */)
 
   length = XFASTINT (Flength (key));
   if (length == 0)
-    RETURN_UNGCPRO (Qnil);
+    return Qnil;
 
   if (SYMBOLP (def) && !EQ (Vdefine_key_rebound_commands, Qt))
     Vdefine_key_rebound_commands = Fcons (def, Vdefine_key_rebound_commands);
@@ -1194,7 +1194,7 @@ binding KEY to DEF is added at the front of KEYMAP.  */)
        message_with_string ("Key sequence contains invalid event %s", c, 1);
 
       if (idx == length)
-       RETURN_UNGCPRO (store_in_keymap (keymap, c, def));
+       return store_in_keymap (keymap, c, def);
 
       cmd = access_keymap (keymap, c, 0, 1, 1);
 
@@ -1287,7 +1287,7 @@ recognize the default bindings, just as `read-key-sequence' does.  */)
 
   length = XFASTINT (Flength (key));
   if (length == 0)
-    RETURN_UNGCPRO (keymap);
+    return keymap;
 
   idx = 0;
   while (1)
@@ -1308,11 +1308,11 @@ recognize the default bindings, just as `read-key-sequence' does.  */)
 
       cmd = access_keymap (keymap, c, t_ok, 0, 1);
       if (idx == length)
-       RETURN_UNGCPRO (cmd);
+       return cmd;
 
       keymap = get_keymap (cmd, 0, 1);
       if (!CONSP (keymap))
-       RETURN_UNGCPRO (make_number (idx));
+       return make_number (idx);
 
       QUIT;
     }
@@ -1544,7 +1544,7 @@ OLP if non-nil indicates that we should obey `overriding-local-map' and
 like in the respective argument of `key-binding'.  */)
   (Lisp_Object olp, Lisp_Object position)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   Lisp_Object keymaps = list1 (current_global_map);
 
@@ -1662,7 +1662,7 @@ like in the respective argument of `key-binding'.  */)
        keymaps = Fcons (otlp, keymaps);
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   return keymaps;
 }
@@ -1806,7 +1806,7 @@ bindings; see the description of `lookup-key' for more details about this.  */)
        if (KEYMAPP (binding))
          maps[j++] = Fcons (modes[i], binding);
        else if (j == 0)
-         RETURN_UNGCPRO (list1 (Fcons (modes[i], binding)));
+         return list1 (Fcons (modes[i], binding));
       }
 
   UNGCPRO;
@@ -2647,11 +2647,11 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
       /* We have a list of advertised bindings.  */
       while (CONSP (tem))
        if (EQ (shadow_lookup (keymaps, XCAR (tem), Qnil, 0), definition))
-         RETURN_UNGCPRO (XCAR (tem));
+         return XCAR (tem);
        else
          tem = XCDR (tem);
       if (EQ (shadow_lookup (keymaps, tem, Qnil, 0), definition))
-       RETURN_UNGCPRO (tem);
+       return tem;
     }
 
   sequences = Freverse (where_is_internal (definition, keymaps,
@@ -2720,10 +2720,10 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
         nil, then we should return the first ascii-only binding
         we find.  */
       if (EQ (firstonly, Qnon_ascii))
-       RETURN_UNGCPRO (sequence);
+       return sequence;
       else if (!NILP (firstonly)
               && 2 == preferred_sequence_p (sequence))
-       RETURN_UNGCPRO (sequence);
+       return sequence;
     }
 
   UNGCPRO;
@@ -3407,7 +3407,7 @@ This is text showing the elements of vector matched against indices.
 DESCRIBER is the output function used; nil means use `princ'.  */)
   (Lisp_Object vector, Lisp_Object describer)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   if (NILP (describer))
     describer = intern ("princ");
   specbind (Qstandard_output, Fcurrent_buffer ());
@@ -3415,7 +3415,8 @@ DESCRIBER is the output function used; nil means use `princ'.  */)
   describe_vector (vector, Qnil, describer, describe_vector_princ, 0,
                   Qnil, Qnil, 0, 0);
 
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 
 /* Insert in the current buffer a description of the contents of VECTOR.
index 033fa72..e02a91f 100644 (file)
@@ -1048,7 +1048,7 @@ Return t if the file exists and loads successfully.  */)
 {
   FILE *stream = NULL;
   int fd;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3;
   Lisp_Object found, efound, hist_file_name;
   /* True means we printed the ".el is newer" message.  */
@@ -1084,8 +1084,10 @@ Return t if the file exists and loads successfully.  */)
     {
       file = internal_condition_case_1 (Fsubstitute_in_file_name, file,
                                        Qt, load_error_handler);
-      if (NILP (file))
-       return Qnil;
+      if (NILP (file)) {
+        dynwind_end ();
+        return Qnil;
+      }
     }
   else
     file = Fsubstitute_in_file_name (file);
@@ -1141,6 +1143,7 @@ Return t if the file exists and loads successfully.  */)
     {
       if (NILP (noerror))
        report_file_error ("Cannot open load file", file);
+      dynwind_end ();
       return Qnil;
     }
 
@@ -1158,8 +1161,10 @@ Return t if the file exists and loads successfully.  */)
        handler = Ffind_file_name_handler (found, Qt);
       else
        handler = Ffind_file_name_handler (found, Qload);
-      if (! NILP (handler))
-       return call5 (handler, Qload, found, noerror, nomessage, Qt);
+      if (! NILP (handler)) {
+        dynwind_end ();
+        return call5 (handler, Qload, found, noerror, nomessage, Qt);
+      }
 #ifdef DOS_NT
       /* Tramp has to deal with semi-broken packages that prepend
         drive letters to remote files.  For that reason, Tramp
@@ -1299,7 +1304,8 @@ Return t if the file exists and loads successfully.  */)
          val = call4 (Vload_source_file_function, found, hist_file_name,
                       NILP (noerror) ? Qnil : Qt,
                       (NILP (nomessage) || force_load_messages) ? Qnil : Qt);
-         return unbind_to (count, val);
+         dynwind_end ();
+         return val;
        }
     }
 
@@ -1363,7 +1369,7 @@ Return t if the file exists and loads successfully.  */)
       readevalloop (Qget_emacs_mule_file_char, stream, hist_file_name,
                    0, Qnil, Qnil, Qnil, Qnil);
     }
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   /* Run any eval-after-load forms for this file.  */
   if (!NILP (Ffboundp (Qdo_after_load_evaluation)))
@@ -1796,7 +1802,7 @@ readevalloop (Lisp_Object readcharfun,
 {
   register int c;
   register Lisp_Object val;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   struct buffer *b = 0;
   bool continue_reading_p;
@@ -1858,7 +1864,7 @@ readevalloop (Lisp_Object readcharfun,
   continue_reading_p = 1;
   while (continue_reading_p)
     {
-      ptrdiff_t count1 = SPECPDL_INDEX ();
+      dynwind_begin ();
 
       if (b != 0 && !BUFFER_LIVE_P (b))
        error ("Reading from killed buffer");
@@ -1901,7 +1907,7 @@ readevalloop (Lisp_Object readcharfun,
        }
       if (c < 0)
        {
-         unbind_to (count1, Qnil);
+         dynwind_end ();
          break;
        }
 
@@ -1942,7 +1948,7 @@ readevalloop (Lisp_Object readcharfun,
        start = Fpoint_marker ();
 
       /* Restore saved point and BEGV.  */
-      unbind_to (count1, Qnil);
+      dynwind_end ();
 
       /* Now eval what we just read.  */
       if (!NILP (macroexpand))
@@ -1967,7 +1973,7 @@ readevalloop (Lisp_Object readcharfun,
 
   UNGCPRO;
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 5, "",
@@ -1986,7 +1992,7 @@ DO-ALLOW-PRINT, if non-nil, specifies that `print' and related
 This function preserves the position of point.  */)
   (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename, Lisp_Object unibyte, Lisp_Object do_allow_print)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object tem, buf;
 
   if (NILP (buffer))
@@ -2011,7 +2017,7 @@ This function preserves the position of point.  */)
   specbind (Qlexical_binding, lisp_file_lexically_bound_p (buf) ? Qt : Qnil);
   readevalloop (buf, 0, filename,
                !NILP (printflag), unibyte, Qnil, Qnil, Qnil);
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   return Qnil;
 }
@@ -2031,7 +2037,7 @@ This function does not move point.  */)
   (Lisp_Object start, Lisp_Object end, Lisp_Object printflag, Lisp_Object read_function)
 {
   /* FIXME: Do the eval-sexp-add-defvars dance!  */
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object tem, cbuf;
 
   cbuf = Fcurrent_buffer ();
@@ -2048,7 +2054,8 @@ This function does not move point.  */)
                !NILP (printflag), Qnil, read_function,
                start, end);
 
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 
 \f
index 768cb54..d82ec8b 100644 (file)
@@ -300,7 +300,7 @@ each iteration of the macro.  Iteration stops if LOOPFUNC returns nil.  */)
 {
   Lisp_Object final;
   Lisp_Object tem;
-  ptrdiff_t pdlcount = SPECPDL_INDEX ();
+  dynwind_begin ();
   EMACS_INT repeat = 1;
   struct gcpro gcpro1, gcpro2;
   EMACS_INT success_count = 0;
@@ -353,7 +353,8 @@ each iteration of the macro.  Iteration stops if LOOPFUNC returns nil.  */)
   Vreal_this_command = Vexecuting_kbd_macro;
 
   UNGCPRO;
-  return unbind_to (pdlcount, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 \f
 void
index a6a9b55..240f873 100644 (file)
@@ -1159,14 +1159,17 @@ no quit occurs and `x-popup-menu' returns nil.  */)
   struct frame *f = NULL;
   Lisp_Object x, y, window;
   int menuflags = 0;
-  ptrdiff_t specpdl_count = SPECPDL_INDEX ();
+  dynwind_begin ();
   ptrdiff_t specpdl_count2;
   struct gcpro gcpro1;
 
   if (NILP (position))
     /* This is an obsolete call, which wants us to precompute the
        keybinding equivalents, but we don't do that any more anyway.  */
-    return Qnil;
+    {
+      dynwind_end ();
+      return Qnil;
+    }
 
   {
     bool get_current_pos_p = 0;
@@ -1384,7 +1387,7 @@ no quit occurs and `x-popup-menu' returns nil.  */)
       menuflags &= ~MENU_KEYMAPS;
     }
 
-  unbind_to (specpdl_count, Qnil);
+  dynwind_end ();
 
 #ifdef HAVE_WINDOW_SYSTEM
   /* Hide a previous tip, if any.  */
@@ -1407,7 +1410,7 @@ no quit occurs and `x-popup-menu' returns nil.  */)
     }
 #endif
 
-  specpdl_count2 = SPECPDL_INDEX ();
+  dynwind_begin ();
 
 #ifdef HAVE_NS                 /* FIXME: ns-specific, why? --Stef  */
   record_unwind_protect_void (discard_menu_items);
@@ -1424,7 +1427,7 @@ no quit occurs and `x-popup-menu' returns nil.  */)
   discard_menu_items ();
 #endif
 
-  unbind_to (specpdl_count2, Qnil);
+  dynwind_end ();
 
 #ifdef HAVE_NTGUI     /* FIXME: Is it really w32-specific?  --Stef  */
   if (FRAME_W32_P (f))
index c53f91a..e257ac2 100644 (file)
@@ -205,7 +205,7 @@ string_to_object (Lisp_Object val, Lisp_Object defalt)
     }
 
   val = Fcar (expr_and_pos);
-  RETURN_UNGCPRO (val);
+  return val;
 }
 
 
@@ -377,7 +377,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
              bool allow_props, bool inherit_input_method)
 {
   Lisp_Object val;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object mini_frame, ambient_dir, minibuffer, input_method;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
   Lisp_Object enable_multibyte;
@@ -462,7 +462,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
                                         expflag, histvar, histpos, defalt,
                                         allow_props, inherit_input_method);
       UNGCPRO;
-      return unbind_to (count, val);
+      dynwind_end ();
+      return val;
     }
 
   /* Choose the minibuffer window and frame, and take action on them.  */
@@ -625,7 +626,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
 
   /* Erase the buffer.  */
   {
-    ptrdiff_t count1 = SPECPDL_INDEX ();
+    dynwind_begin ();
     specbind (Qinhibit_read_only, Qt);
     specbind (Qinhibit_modification_hooks, Qt);
     Ferase_buffer ();
@@ -647,7 +648,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
        Fadd_text_properties (make_number (BEG), make_number (PT),
                              Vminibuffer_prompt_properties, Qnil);
       }
-    unbind_to (count1, Qnil);
+    dynwind_end ();
   }
 
   minibuf_prompt_width = current_column ();
@@ -753,7 +754,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
   /* The appropriate frame will get selected
      in set-window-configuration.  */
   UNGCPRO;
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 
 /* Return a buffer to be used as the minibuffer at depth `depth'.
@@ -787,7 +789,7 @@ get_minibuffer (EMACS_INT depth)
     }
   else
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       /* We have to empty both overlay lists.  Otherwise we end
         up with overlays that think they belong to this buffer
         while the buffer doesn't know about them any more.  */
@@ -799,7 +801,7 @@ get_minibuffer (EMACS_INT depth)
        call0 (intern ("minibuffer-inactive-mode"));
       else
         Fkill_all_local_variables ();
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 
   return buf;
@@ -853,14 +855,14 @@ read_minibuf_unwind (void)
 
   /* Erase the minibuffer we were using at this level.  */
   {
-    ptrdiff_t count = SPECPDL_INDEX ();
+    dynwind_begin ();
     /* Prevent error in erase-buffer.  */
     specbind (Qinhibit_read_only, Qt);
     specbind (Qinhibit_modification_hooks, Qt);
     old_deactivate_mark = Vdeactivate_mark;
     Ferase_buffer ();
     Vdeactivate_mark = old_deactivate_mark;
-    unbind_to (count, Qnil);
+    dynwind_end ();
   }
 
   /* When we get to the outmost level, make sure we resize the
@@ -983,7 +985,7 @@ Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
   (Lisp_Object prompt, Lisp_Object initial_input, Lisp_Object history, Lisp_Object default_value, Lisp_Object inherit_input_method)
 {
   Lisp_Object val;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   /* Just in case we're in a recursive minibuffer, make it clear that the
      previous minibuffer's completion table does not apply to the new
@@ -996,7 +998,8 @@ Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
                               inherit_input_method);
   if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (default_value))
     val = CONSP (default_value) ? XCAR (default_value) : default_value;
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 
 DEFUN ("read-no-blanks-input", Fread_no_blanks_input, Sread_no_blanks_input, 1, 3, 0,
@@ -1093,7 +1096,7 @@ function, instead of the usual behavior.  */)
   Lisp_Object args[4], result;
   char *s;
   ptrdiff_t len;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   if (BUFFERP (def))
     def = BVAR (XBUFFER (def), name);
@@ -1142,7 +1145,8 @@ function, instead of the usual behavior.  */)
       args[3] = require_match;
       result = Ffuncall (4, args);
     }
-  return unbind_to (count, result);
+  dynwind_end ();
+  return result;
 }
 \f
 static Lisp_Object
@@ -1746,17 +1750,20 @@ the values STRING, PREDICATE and `lambda'.  */)
   /* Reject this element if it fails to match all the regexps.  */
   if (CONSP (Vcompletion_regexp_list))
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
       for (regexps = Vcompletion_regexp_list; CONSP (regexps);
           regexps = XCDR (regexps))
        {
          if (NILP (Fstring_match (XCAR (regexps),
                                   SYMBOLP (tem) ? string : tem,
-                                  Qnil)))
-           return unbind_to (count, Qnil);
+                                  Qnil))){
+           
+             dynwind_end ();
+           return Qnil;
+           }
        }
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 
   /* Finally, check the predicate.  */
index 8182b28..3f5ad06 100644 (file)
@@ -1388,7 +1388,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS)  */)
   Lisp_Object buffer, name, program, proc, current_dir, tem;
   register unsigned char **new_argv;
   ptrdiff_t i;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   buffer = args[1];
   if (!NILP (buffer))
@@ -1592,7 +1592,8 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS)  */)
   else
     create_pty (proc);
 
-  return unbind_to (count, proc);
+  dynwind_end ();
+  return proc;
 }
 
 /* This function is the unwind_protect form for Fstart_process.  If
@@ -2564,7 +2565,7 @@ usage:  (make-serial-process &rest ARGS)  */)
     name = port;
   CHECK_STRING (name);
   proc = make_process (name);
-  specpdl_count = SPECPDL_INDEX ();
+  dynwind_begin ();
   record_unwind_protect_1 (remove_process, proc, false);
   p = XPROCESS (proc);
 
@@ -2648,7 +2649,7 @@ usage:  (make-serial-process &rest ARGS)  */)
 
   Fserial_process_configure (nargs, args);
 
-  unbind_to (specpdl_count, Qnil);
+  dynwind_end ();
 
   UNGCPRO;
   return proc;
@@ -3536,7 +3537,7 @@ network_interface_list (void)
   s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
   if (s < 0)
     return Qnil;
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
   record_unwind_protect_int (close_file_unwind, s);
 
   do
@@ -3548,12 +3549,13 @@ network_interface_list (void)
        {
          emacs_close (s);
          xfree (buf);
+         dynwind_end ();
          return Qnil;
        }
     }
   while (ifconf.ifc_len == buf_size);
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
   ifreq = ifconf.ifc_req;
   while ((char *) ifreq < (char *) ifconf.ifc_req + ifconf.ifc_len)
     {
@@ -3688,7 +3690,7 @@ network_interface_info (Lisp_Object ifname)
   s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
   if (s < 0)
     return Qnil;
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
   record_unwind_protect_int (close_file_unwind, s);
 
   elt = Qnil;
@@ -3808,7 +3810,9 @@ network_interface_info (Lisp_Object ifname)
 #endif
   res = Fcons (elt, res);
 
-  return unbind_to (count, any ? res : Qnil);
+  Lisp_Object tem0 = any ? res : Qnil;
+  dynwind_end ();
+  return tem0;
 }
 #endif /* !SIOCGIFADDR && !SIOCGIFHWADDR && !SIOCGIFFLAGS */
 #endif /* defined (HAVE_NET_IF_H) */
@@ -4045,7 +4049,7 @@ server_accept_connection (Lisp_Object server, int channel)
       return;
     }
 
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
   record_unwind_protect_int_1 (close_file_unwind, s, false);
 
   connect_counter++;
@@ -4165,7 +4169,7 @@ server_accept_connection (Lisp_Object server, int channel)
   pset_command (p, Qnil);
   p->pid = 0;
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   p->open_fd[SUBPROCESS_STDIN] = s;
   p->infd  = s;
@@ -4286,7 +4290,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
   Lisp_Object proc;
   struct timespec timeout, end_time;
   int got_some_input = -1;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   FD_ZERO (&Available);
   FD_ZERO (&Writeok);
@@ -4924,7 +4928,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
        }                       /* End for each file descriptor.  */
     }                          /* End while exit conditions not met.  */
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   /* If calling from keyboard input, do not quit
      since we want to return C-g as an input character.
@@ -4982,7 +4986,7 @@ read_process_output (Lisp_Object proc, register int channel)
   struct coding_system *coding = proc_decode_coding_system[channel];
   int carryover = p->decoding_carryover;
   int readmax = 4096;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object odeactivate;
 
   chars = alloca (carryover + readmax);
@@ -5052,8 +5056,10 @@ read_process_output (Lisp_Object proc, register int channel)
      (including the one in proc_buffered_char[channel]).  */
   if (nbytes <= 0)
     {
-      if (nbytes < 0 || coding->mode & CODING_MODE_LAST_BLOCK)
-       return nbytes;
+      if (nbytes < 0 || coding->mode & CODING_MODE_LAST_BLOCK) {
+        dynwind_end ();
+        return nbytes;
+      }
       coding->mode |= CODING_MODE_LAST_BLOCK;
     }
 
@@ -5071,7 +5077,7 @@ read_process_output (Lisp_Object proc, register int channel)
   /* Handling the process output should not deactivate the mark.  */
   Vdeactivate_mark = odeactivate;
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
   return nbytes;
 }
 
@@ -6258,12 +6264,14 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason)
 {
   Lisp_Object sentinel, odeactivate;
   struct Lisp_Process *p = XPROCESS (proc);
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   bool outer_running_asynch_code = running_asynch_code;
   int waiting = waiting_for_user_input_p;
 
-  if (inhibit_sentinels)
+  if (inhibit_sentinels) {
+    dynwind_end ();
     return;
+  }
 
   /* No need to gcpro these, because all we do with them later
      is test them for EQness, and none of them should be a string.  */
@@ -6326,7 +6334,7 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason)
     if (waiting_for_user_input_p == -1)
       record_asynch_buffer_change ();
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 /* Report all recent events of a change in process status
index ee43a92..ad51c73 100644 (file)
@@ -1302,7 +1302,7 @@ Internal use only, use `play-sound' instead.  */)
   (Lisp_Object sound)
 {
   Lisp_Object attrs[SOUND_ATTR_SENTINEL];
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
 #ifndef WINDOWSNT
   Lisp_Object file;
@@ -1412,7 +1412,7 @@ Internal use only, use `play-sound' instead.  */)
 
 #endif /* WINDOWSNT */
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
   return Qnil;
 }
 \f
index acbd904..e8b0057 100644 (file)
@@ -2950,7 +2950,7 @@ system_process_attributes (Lisp_Object pid)
   if (gr)
     attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
 
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
   strcpy (fn, procfn);
   procfn_end = fn + strlen (fn);
   strcpy (procfn_end, "/stat");
@@ -3061,7 +3061,7 @@ system_process_attributes (Lisp_Object pid)
          attrs = Fcons (Fcons (Qpmem, make_float (pmem)), attrs);
        }
     }
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   /* args */
   strcpy (procfn_end, "/cmdline");
@@ -3186,7 +3186,7 @@ system_process_attributes (Lisp_Object pid)
   if (gr)
     attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
 
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
   strcpy (fn, procfn);
   procfn_end = fn + strlen (fn);
   strcpy (procfn_end, "/psinfo");
@@ -3260,7 +3260,7 @@ system_process_attributes (Lisp_Object pid)
                      Vlocale_coding_system, 0));
       attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs);
     }
-  unbind_to (count, Qnil);
+  dynwind_end ();
   UNGCPRO;
   return attrs;
 }
index 0334a98..d7b58c9 100644 (file)
@@ -812,7 +812,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
   else
     {
       Lisp_Object initial_value, value;
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
 
       if (! NILP (object))
        CHECK_BUFFER (object);
@@ -853,7 +853,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
              break;
          }
 
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 
   return position;
@@ -895,7 +895,7 @@ position LIMIT; return LIMIT if nothing is found before reaching LIMIT.  */)
     }
   else
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
 
       if (! NILP (object))
        CHECK_BUFFER (object);
@@ -946,7 +946,7 @@ position LIMIT; return LIMIT if nothing is found before reaching LIMIT.  */)
            }
        }
 
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 
   return position;
@@ -1202,7 +1202,7 @@ add_text_properties_1 (Lisp_Object start, Lisp_Object end,
       do
        {
          if (got >= len)
-           RETURN_UNGCPRO (Qnil);
+           return Qnil;
          len -= got;
          i = next_interval (i);
          got = LENGTH (i);
index 6af5b4d..66b038e 100644 (file)
@@ -328,7 +328,7 @@ truncate_undo_list (struct buffer *b)
   Lisp_Object list;
   Lisp_Object prev, next, last_boundary;
   EMACS_INT size_so_far = 0;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   static const size_t sizeof_cons = sizeof (scm_t_cell);
 
   /* Make the buffer current to get its local values of variables such
@@ -395,7 +395,7 @@ truncate_undo_list (struct buffer *b)
        {
          /* The function is responsible for making
             any desired changes in buffer-undo-list.  */
-         unbind_to (count, Qnil);
+         dynwind_end ();
          return;
        }
       /* That function probably used the minibuffer, and if so, that
@@ -451,7 +451,7 @@ truncate_undo_list (struct buffer *b)
   else
     bset_undo_list (b, Qnil);
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 \f
index facc6b0..a848b23 100644 (file)
@@ -4344,7 +4344,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
   int minibuffer_only = 0;
   long window_prompting = 0;
   int width, height;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   Lisp_Object display;
   struct w32_display_info *dpyinfo = NULL;
@@ -4667,7 +4667,8 @@ This function is an internal primitive--use `make-frame' instead.  */)
      and similar functions.  */
   Vwindow_list = Qnil;
 
-  return unbind_to (count, frame);
+  dynwind_end ();
+  return frame;
 }
 
 /* FRAME is used only to get a handle on the X display.  We don't pass the
@@ -5646,7 +5647,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
   Lisp_Object name;
   long window_prompting = 0;
   int width, height;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3;
   struct kboard *kb;
   int face_change_count_before = face_change_count;
@@ -5866,7 +5867,8 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
   face_change_count = face_change_count_before;
 
   /* Discard the unwind_protect.  */
-  return unbind_to (count, frame);
+  dynwind_end ();
+  return frame;
 }
 
 
@@ -5993,7 +5995,7 @@ Text larger than the specified size is clipped.  */)
   int i, width, height, seen_reversed_p;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   int old_windows_or_buffers_changed = windows_or_buffers_changed;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   specbind (Qinhibit_redisplay, Qt);
 
@@ -6280,7 +6282,8 @@ Text larger than the specified size is clipped.  */)
                     intern ("x-hide-tip"));
 
   UNGCPRO;
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 
 
@@ -6302,7 +6305,7 @@ Value is t if tooltip was open, nil otherwise.  */)
   GCPRO2 (frame, timer);
   tip_frame = tip_timer = deleted = Qnil;
 
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
   specbind (Qinhibit_redisplay, Qt);
   specbind (Qinhibit_quit, Qt);
 
@@ -6316,7 +6319,8 @@ Value is t if tooltip was open, nil otherwise.  */)
     }
 
   UNGCPRO;
-  return unbind_to (count, deleted);
+  dynwind_end ();
+  return deleted;
 }
 \f
 /***********************************************************************
@@ -6656,7 +6660,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
 #endif /* !NTGUI_UNICODE */
 
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       /* Prevent redisplay.  */
       specbind (Qinhibit_redisplay, Qt);
       block_input ();
@@ -6675,7 +6679,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
        }
 #endif /* !NTGUI_UNICODE */
       unblock_input ();
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 
     if (file_opened)
@@ -6727,7 +6731,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
   if (NILP (filename))
     Fsignal (Qquit, Qnil);
 
-  RETURN_UNGCPRO (filename);
+  return filename;
 }
 
 \f
index 65bd8e0..19eac13 100644 (file)
@@ -299,7 +299,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
 
       struct buffer *prev = current_buffer;
       Lisp_Object buffer;
-      ptrdiff_t specpdl_count = SPECPDL_INDEX ();
+      dynwind_begin ();
       int previous_menu_items_used = f->menu_bar_items_used;
       Lisp_Object *previous_items
        = (Lisp_Object *) alloca (previous_menu_items_used
@@ -408,7 +408,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
        {
          free_menubar_widget_value_tree (first_wv);
          discard_menu_items ();
-          unbind_to (specpdl_count, Qnil);
+          dynwind_end ();
          return;
        }
 
@@ -416,7 +416,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
       f->menu_bar_items_used = menu_items_used;
 
       /* This undoes save_menu_items.  */
-      unbind_to (specpdl_count, Qnil);
+      dynwind_end ();
 
       /* Now GC cannot happen during the lifetime of the widget_value,
         so it's safe to store data from a Lisp_String, as long as
index 259ffcd..2fa89e8 100644 (file)
@@ -2803,7 +2803,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
              {
                if (EQ (window, selected_window))
                  /* Preferably return the selected window.  */
-                 RETURN_UNGCPRO (window);
+                 return window;
                else if (EQ (XWINDOW (window)->frame, selected_frame)
                         && !frame_best_window_flag)
                  /* Prefer windows on the current frame (but don't
@@ -3315,13 +3315,15 @@ select_frame_norecord (Lisp_Object frame)
 void
 run_window_configuration_change_hook (struct frame *f)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object frame, global_wcch
     = Fdefault_value (Qwindow_configuration_change_hook);
   XSETFRAME (frame, f);
 
-  if (NILP (Vrun_hooks) || !NILP (inhibit_lisp_code))
+  if (NILP (Vrun_hooks) || !NILP (inhibit_lisp_code)) {
+    dynwind_end ();
     return;
+  }
 
   /* Use the right buffer.  Matters when running the local hooks.  */
   if (current_buffer != XBUFFER (Fwindow_buffer (Qnil)))
@@ -3346,18 +3348,18 @@ run_window_configuration_change_hook (struct frame *f)
        if (!NILP (Flocal_variable_p (Qwindow_configuration_change_hook,
                                      buffer)))
          {
-           ptrdiff_t inner_count = SPECPDL_INDEX ();
+           dynwind_begin ();
            record_unwind_protect (select_window_norecord, selected_window);
            select_window_norecord (window);
            run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook,
                                           buffer));
-           unbind_to (inner_count, Qnil);
+           dynwind_end ();
          }
       }
   }
 
   run_funs (global_wcch);
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook,
@@ -3394,7 +3396,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
 {
   struct window *w = XWINDOW (window);
   struct buffer *b = XBUFFER (buffer);
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   bool samebuf = EQ (buffer, w->contents);
 
   wset_buffer (w, buffer);
@@ -3466,7 +3468,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
        run_window_configuration_change_hook (XFRAME (WINDOW_FRAME (w)));
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0,
@@ -3605,7 +3607,7 @@ temp_output_buffer_show (register Lisp_Object buf)
       /* Run temp-buffer-show-hook, with the chosen window selected
         and its buffer current.  */
       {
-        ptrdiff_t count = SPECPDL_INDEX ();
+        dynwind_begin ();
         Lisp_Object prev_window, prev_buffer;
         prev_window = selected_window;
         XSETBUFFER (prev_buffer, old);
@@ -3619,7 +3621,7 @@ temp_output_buffer_show (register Lisp_Object buf)
         Fselect_window (window, Qt);
         Fset_buffer (w->contents);
         Frun_hooks (1, &Qtemp_buffer_show_hook);
-        unbind_to (count, Qnil);
+        dynwind_end ();
       }
     }
 }
@@ -5368,7 +5370,7 @@ window_scroll_line_based (Lisp_Object window, int n, bool whole, int noerror)
 static void
 scroll_command (Lisp_Object n, int direction)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   eassert (eabs (direction) == 1);
 
@@ -5390,7 +5392,7 @@ scroll_command (Lisp_Object n, int direction)
       window_scroll (selected_window, XINT (n) * direction, 0, 0);
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 DEFUN ("scroll-up", Fscroll_up, Sscroll_up, 0, 1, "^P",
@@ -5482,7 +5484,7 @@ specifies the window to scroll.  This takes precedence over
 {
   Lisp_Object window;
   struct window *w;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   window = Fother_window_for_scrolling ();
   w = XWINDOW (window);
@@ -5506,7 +5508,7 @@ specifies the window to scroll.  This takes precedence over
     }
 
   set_marker_both (w->pointm, Qnil, PT, PT_BYTE);
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   return Qnil;
 }
index 3230e85..5fe2780 100644 (file)
@@ -2616,7 +2616,7 @@ safe__call (bool inhibit_quit, ptrdiff_t nargs, Lisp_Object func, va_list ap)
   else
     {
       ptrdiff_t i;
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       struct gcpro gcpro1;
       Lisp_Object *args = alloca (nargs * word_size);
 
@@ -2634,7 +2634,7 @@ safe__call (bool inhibit_quit, ptrdiff_t nargs, Lisp_Object func, va_list ap)
       val = internal_condition_case_n (Ffuncall, nargs, args, Qt,
                                       safe_eval_handler);
       UNGCPRO;
-      unbind_to (count, val);
+      dynwind_end ();
     }
 
   return val;
@@ -3811,7 +3811,7 @@ handle_fontified_prop (struct it *it)
             no amount of fontifying will be able to change it.  */
          NILP (prop) && IT_CHARPOS (*it) < Z))
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       Lisp_Object val;
       struct buffer *obuf = current_buffer;
       ptrdiff_t begv = BEGV, zv = ZV;
@@ -3859,7 +3859,7 @@ handle_fontified_prop (struct it *it)
          UNGCPRO;
        }
 
-      unbind_to (count, Qnil);
+      dynwind_end ();
 
       /* Fontification functions routinely call `save-restriction'.
         Normally, this tags clip_changed, which can confuse redisplay
@@ -4823,7 +4823,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
 
   if (!NILP (form) && !EQ (form, Qt))
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       struct gcpro gcpro1;
 
       /* Bind `object' to the object having the `display' property, a
@@ -4839,7 +4839,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
       GCPRO1 (form);
       form = safe_eval (form);
       UNGCPRO;
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 
   if (NILP (form))
@@ -4897,11 +4897,11 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
                {
                  /* Evaluate IT->font_height with `height' bound to the
                     current specified height to get the new height.  */
-                 ptrdiff_t count = SPECPDL_INDEX ();
+                 dynwind_begin ();
 
                  specbind (Qheight, face->lface[LFACE_HEIGHT_INDEX]);
                  value = safe_eval (it->font_height);
-                 unbind_to (count, Qnil);
+                 dynwind_end ();
 
                  if (NUMBERP (value))
                    new_height = XFLOATINT (value);
@@ -10425,7 +10425,7 @@ with_echo_area_buffer (struct window *w, int which,
 {
   Lisp_Object buffer;
   int this_one, the_other, clear_buffer_p, rc;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   /* If buffers aren't live, make new ones.  */
   ensure_echo_area_buffers ();
@@ -10499,7 +10499,7 @@ with_echo_area_buffer (struct window *w, int which,
   eassert (BEGV >= BEG);
   eassert (ZV <= Z && ZV >= BEGV);
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
   return rc;
 }
 
@@ -10604,11 +10604,11 @@ setup_echo_area_for_printing (int multibyte_p)
 
       if (Z > BEG)
        {
-         ptrdiff_t count = SPECPDL_INDEX ();
+         dynwind_begin ();
          specbind (Qinhibit_read_only, Qt);
          /* Note that undo recording is always disabled.  */
          del_range (BEG, Z);
-         unbind_to (count, Qnil);
+         dynwind_end ();
        }
       TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
 
@@ -11185,11 +11185,11 @@ echo_area_display (int update_frame_p)
              /* Must update other windows.  Likewise as in other
                 cases, don't let this update be interrupted by
                 pending input.  */
-             ptrdiff_t count = SPECPDL_INDEX ();
+             dynwind_begin ();
              specbind (Qredisplay_dont_pause, Qt);
              windows_or_buffers_changed = 44;
              redisplay_internal ();
-             unbind_to (count, Qnil);
+             dynwind_end ();
            }
          else if (FRAME_WINDOW_P (f) && n == 0)
            {
@@ -11481,7 +11481,7 @@ x_consider_frame_title (Lisp_Object frame)
       char *title;
       ptrdiff_t len;
       struct it it;
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
 
       FOR_EACH_FRAME (tail, other_frame)
        {
@@ -11517,7 +11517,7 @@ x_consider_frame_title (Lisp_Object frame)
       display_mode_element (&it, 0, -1, -1, fmt, Qnil, 0);
       len = MODE_LINE_NOPROP_LEN (title_start);
       title = mode_line_noprop_buf + title_start;
-      unbind_to (count, Qnil);
+      dynwind_end ();
 
       /* Set the title only if it's changed.  This avoids consing in
         the common case where it hasn't.  (If it turns out that we've
@@ -11625,7 +11625,7 @@ prepare_menu_bars (void)
   if (all_windows)
     {
       Lisp_Object tail, frame;
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       /* 1 means that update_menu_bar has run its hooks
         so any further calls to update_menu_bar shouldn't do so again.  */
       int menu_bar_hooks_run = 0;
@@ -11681,7 +11681,7 @@ prepare_menu_bars (void)
          UNGCPRO;
        }
 
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
   else
     {
@@ -11744,7 +11744,7 @@ update_menu_bar (struct frame *f, int save_match_data, int hooks_run)
          || window_buffer_changed (w))
        {
          struct buffer *prev = current_buffer;
-         ptrdiff_t count = SPECPDL_INDEX ();
+         dynwind_begin ();
 
          specbind (Qinhibit_menubar_update, Qt);
 
@@ -11797,7 +11797,7 @@ update_menu_bar (struct frame *f, int save_match_data, int hooks_run)
          w->update_mode_line = 1;
 #endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI || HAVE_NS || USE_GTK) */
 
-         unbind_to (count, Qnil);
+         dynwind_end ();
          set_buffer_internal_1 (prev);
        }
     }
@@ -11861,7 +11861,7 @@ update_tool_bar (struct frame *f, int save_match_data)
          || window_buffer_changed (w))
        {
          struct buffer *prev = current_buffer;
-         ptrdiff_t count = SPECPDL_INDEX ();
+         dynwind_begin ();
          Lisp_Object frame, new_tool_bar;
           int new_n_tool_bar;
          struct gcpro gcpro1;
@@ -11917,7 +11917,7 @@ update_tool_bar (struct frame *f, int save_match_data)
 
          UNGCPRO;
 
-         unbind_to (count, Qnil);
+         dynwind_end ();
          set_buffer_internal_1 (prev);
        }
     }
@@ -13381,7 +13381,7 @@ redisplay_internal (void)
 
   /* Record a function that clears redisplaying_p
      when we leave this function.  */
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
   record_unwind_protect_void (unwind_redisplay);
   redisplaying_p = 1;
   specbind (Qinhibit_free_realized_faces, Qnil);
@@ -14021,7 +14021,7 @@ redisplay_internal (void)
   if (interrupt_input && interrupts_deferred)
     request_sigio ();
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
   RESUME_POLLING;
 }
 
@@ -15810,7 +15810,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
      It indicates that the buffer contents and narrowing are unchanged.  */
   bool buffer_unchanged_p = false;
   int temp_scroll_step = 0;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   int rc;
   int centering_position = -1;
   int last_line_misfit = 0;
@@ -16749,7 +16749,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
   if (CHARPOS (lpoint) <= ZV)
     TEMP_SET_PT_BOTH (CHARPOS (lpoint), BYTEPOS (lpoint));
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 
@@ -21503,7 +21503,7 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format)
 {
   struct it it;
   struct face *face;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   init_iterator (&it, w, -1, -1, NULL, face_id);
   /* Don't extend on a previously drawn mode-line.
@@ -21531,7 +21531,7 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format)
   display_mode_element (&it, 0, 0, 0, format, Qnil, 0);
   pop_kboard ();
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   /* Fill up with spaces.  */
   display_string (" ", Qnil, Qnil, 0, 0, &it, 10000, -1, -1, 0);
@@ -22183,7 +22183,7 @@ are the selected window and the WINDOW's buffer).  */)
   struct buffer *old_buffer = NULL;
   int face_id;
   int no_props = INTEGERP (face);
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object str;
   int string_start = 0;
 
@@ -22196,8 +22196,10 @@ are the selected window and the WINDOW's buffer).  */)
 
   /* Make formatting the modeline a non-op when noninteractive, otherwise
      there will be problems later caused by a partially initialized frame.  */
-  if (NILP (format) || noninteractive)
+  if (NILP (format) || noninteractive) {
+    dynwind_end ();
     return empty_unibyte_string;
+  }
 
   if (no_props)
     face = Qnil;
@@ -22258,7 +22260,7 @@ are the selected window and the WINDOW's buffer).  */)
                        empty_unibyte_string);
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
   return str;
 }
 
index c0784c4..e32a1f5 100644 (file)
@@ -5201,7 +5201,7 @@ static bool
 realize_basic_faces (struct frame *f)
 {
   bool success_p = 0;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   /* Block input here so that we won't be surprised by an X expose
      event, for instance, without having the faces set up.  */
@@ -5240,7 +5240,7 @@ realize_basic_faces (struct frame *f)
       success_p = 1;
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
   unblock_input ();
   return success_p;
 }
index 24e2a5b..65edf6d 100644 (file)
@@ -2886,7 +2886,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
   int minibuffer_only = 0;
   long window_prompting = 0;
   int width, height;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   Lisp_Object display;
   struct x_display_info *dpyinfo = NULL;
@@ -3153,7 +3153,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
      could get an infloop in next_frame since the frame is not yet in
      Vframe_list.  */
   {
-    ptrdiff_t count2 = SPECPDL_INDEX ();
+    dynwind_begin ();
     record_unwind_protect (unwind_create_frame_1, inhibit_lisp_code);
     inhibit_lisp_code = Qt;
 
@@ -3166,7 +3166,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
                         ? make_number (0) : make_number (1),
                         NULL, NULL, RES_TYPE_NUMBER);
 
-    unbind_to (count2, Qnil);
+    dynwind_end ();
   }
 
   x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
@@ -3314,7 +3314,8 @@ This function is an internal primitive--use `make-frame' instead.  */)
      and similar functions.  */
   Vwindow_list = Qnil;
 
-  return unbind_to (count, frame);
+  dynwind_end ();
+  return frame;
 }
 
 
@@ -4907,7 +4908,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
   Lisp_Object frame;
   Lisp_Object name;
   int width, height;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3;
   int face_change_count_before = face_change_count;
   Lisp_Object buffer;
@@ -5206,7 +5207,8 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
   face_change_count = face_change_count_before;
 
   /* Discard the unwind_protect.  */
-  return unbind_to (count, frame);
+  dynwind_end ();
+  return frame;
 }
 
 
@@ -5304,7 +5306,7 @@ Text larger than the specified size is clipped.  */)
   int i, width, height, seen_reversed_p;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   int old_windows_or_buffers_changed = windows_or_buffers_changed;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   specbind (Qinhibit_redisplay, Qt);
 
@@ -5565,7 +5567,8 @@ Text larger than the specified size is clipped.  */)
                     intern ("x-hide-tip"));
 
   UNGCPRO;
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 
 
@@ -5587,7 +5590,7 @@ Value is t if tooltip was open, nil otherwise.  */)
   GCPRO2 (frame, timer);
   tip_frame = tip_timer = deleted = Qnil;
 
-  count = SPECPDL_INDEX ();
+  dynwind_begin ();
   specbind (Qinhibit_redisplay, Qt);
   specbind (Qinhibit_quit, Qt);
 
@@ -5630,7 +5633,8 @@ Value is t if tooltip was open, nil otherwise.  */)
     }
 
   UNGCPRO;
-  return unbind_to (count, deleted);
+  dynwind_end ();
+  return deleted;
 }
 
 
@@ -5714,7 +5718,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
   Arg al[10];
   int ac = 0;
   XmString dir_xmstring, pattern_xmstring;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
 
   check_window_system (f);
@@ -5853,7 +5857,8 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
 
   decoded_file = DECODE_FILE (file);
 
-  return unbind_to (count, decoded_file);
+  dynwind_end ();
+  return decoded_file;
 }
 
 #endif /* USE_MOTIF */
@@ -5881,7 +5886,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
   char *fn;
   Lisp_Object file = Qnil;
   Lisp_Object decoded_file;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
   char *cdef_file;
 
@@ -5925,7 +5930,8 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
 
   decoded_file = DECODE_FILE (file);
 
-  return unbind_to (count, decoded_file);
+  dynwind_end ();
+  return decoded_file;
 }
 
 
@@ -5945,7 +5951,7 @@ nil, it defaults to the selected frame. */)
   Lisp_Object font_param;
   char *default_name = NULL;
   struct gcpro gcpro1, gcpro2;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   if (popup_activated ())
     error ("Trying to use a menu from within a menu-entry");
@@ -5977,7 +5983,8 @@ nil, it defaults to the selected frame. */)
   if (NILP (font))
     Fsignal (Qquit, Qnil);
 
-  return unbind_to (count, font);
+  dynwind_end ();
+  return font;
 }
 #endif /* HAVE_FREETYPE */
 
index 0f2e9f2..92f293b 100644 (file)
@@ -750,7 +750,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
 
       struct buffer *prev = current_buffer;
       Lisp_Object buffer;
-      ptrdiff_t specpdl_count = SPECPDL_INDEX ();
+      dynwind_begin ();
       int previous_menu_items_used = f->menu_bar_items_used;
       Lisp_Object *previous_items
        = alloca (previous_menu_items_used * sizeof *previous_items);
@@ -867,7 +867,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
             the menus in any form, since it would be a no-op.  */
          free_menubar_widget_value_tree (first_wv);
          discard_menu_items ();
-         unbind_to (specpdl_count, Qnil);
+         dynwind_end ();
          return;
        }
 
@@ -876,7 +876,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
       f->menu_bar_items_used = menu_items_used;
 
       /* This undoes save_menu_items.  */
-      unbind_to (specpdl_count, Qnil);
+      dynwind_end ();
 
       /* Now GC cannot happen during the lifetime of the widget_value,
         so it's safe to store data from a Lisp_String.  */
@@ -1201,7 +1201,7 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv,
   GtkWidget *menu;
   GtkMenuPositionFunc pos_func = 0;  /* Pop up at pointer.  */
   struct next_popup_x_y popup_x_y;
-  ptrdiff_t specpdl_count = SPECPDL_INDEX ();
+  dynwind_begin ();
   bool use_pos_func = ! for_click;
 
 #ifdef HAVE_GTK3
@@ -1261,7 +1261,7 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv,
       popup_widget_loop (1, menu);
     }
 
-  unbind_to (specpdl_count, Qnil);
+  dynwind_end ();
 
   /* Must reset this manually because the button release event is not passed
      to Emacs event loop. */
@@ -1363,7 +1363,7 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv,
 
   {
     int fact = 4 * sizeof (LWLIB_ID);
-    ptrdiff_t specpdl_count = SPECPDL_INDEX ();
+    dynwind_begin ();
     record_unwind_protect (pop_down_menu,
                            Fcons (make_number (menu_id >> (fact)),
                                   make_number (menu_id & ~(-1 << (fact)))));
@@ -1371,7 +1371,7 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv,
     /* Process events that apply to the menu.  */
     popup_get_selection (0, FRAME_DISPLAY_INFO (f), menu_id, 1);
 
-    unbind_to (specpdl_count, Qnil);
+    dynwind_end ();
   }
 }
 
@@ -1397,7 +1397,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
 
   int first_pane;
 
-  ptrdiff_t specpdl_count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   eassert (FRAME_X_P (f));
 
@@ -1406,6 +1406,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
   if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
     {
       *error_name = "Empty menu";
+      dynwind_end ();
       return Qnil;
     }
 
@@ -1579,7 +1580,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
   create_and_show_popup_menu (f, first_wv, x, y,
                              menuflags & MENU_FOR_CLICK);
 
-  unbind_to (specpdl_count, Qnil);
+  dynwind_end ();
 
   /* Find the selected item, and its pane, to return
      the proper value.  */
@@ -1676,7 +1677,7 @@ create_and_show_dialog (struct frame *f, widget_value *first_wv)
 
   if (menu)
     {
-      ptrdiff_t specpdl_count = SPECPDL_INDEX ();
+      dynwind_begin ();
       record_unwind_protect_ptr (pop_down_menu, menu);
 
       /* Display the menu.  */
@@ -1685,7 +1686,7 @@ create_and_show_dialog (struct frame *f, widget_value *first_wv)
       /* Process events that apply to the menu.  */
       popup_widget_loop (1, menu);
 
-      unbind_to (specpdl_count, Qnil);
+      dynwind_end ();
     }
 }
 
@@ -1731,7 +1732,7 @@ create_and_show_dialog (struct frame *f, widget_value *first_wv)
   /* Process events that apply to the dialog box.
      Also handle timers.  */
   {
-    ptrdiff_t count = SPECPDL_INDEX ();
+    dynwind_begin ();
     int fact = 4 * sizeof (LWLIB_ID);
 
     /* xdialog_show_unwind is responsible for popping the dialog box down.  */
@@ -1741,7 +1742,7 @@ create_and_show_dialog (struct frame *f, widget_value *first_wv)
 
     popup_get_selection (0, FRAME_DISPLAY_INFO (f), dialog_id, 1);
 
-    unbind_to (count, Qnil);
+    dynwind_end ();
   }
 }
 
@@ -1765,7 +1766,7 @@ x_dialog_show (struct frame *f, Lisp_Object title,
   /* 1 means we've seen the boundary between left-hand elts and right-hand.  */
   int boundary_seen = 0;
 
-  ptrdiff_t specpdl_count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   eassert (FRAME_X_P (f));
 
@@ -1774,6 +1775,7 @@ x_dialog_show (struct frame *f, Lisp_Object title,
   if (menu_items_n_panes > 1)
     {
       *error_name = "Multiple panes in dialog box";
+      dynwind_end ();
       return Qnil;
     }
 
@@ -1804,6 +1806,7 @@ x_dialog_show (struct frame *f, Lisp_Object title,
          {
            free_menubar_widget_value_tree (first_wv);
            *error_name = "Submenu in dialog items";
+           dynwind_end ();
            return Qnil;
          }
        if (EQ (item_name, Qquote))
@@ -1818,6 +1821,7 @@ x_dialog_show (struct frame *f, Lisp_Object title,
          {
            free_menubar_widget_value_tree (first_wv);
            *error_name = "Too many dialog items";
+           dynwind_end ();
            return Qnil;
          }
 
@@ -1875,7 +1879,7 @@ x_dialog_show (struct frame *f, Lisp_Object title,
   /* Actually create and show the dialog.  */
   create_and_show_dialog (f, first_wv);
 
-  unbind_to (specpdl_count, Qnil);
+  dynwind_end ();
 
   /* Find the selected item, and its pane, to return
      the proper value.  */
@@ -2030,17 +2034,20 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
   int maxwidth;
   int dummy_int;
   unsigned int dummy_uint;
-  ptrdiff_t specpdl_count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   eassert (FRAME_X_P (f) || FRAME_MSDOS_P (f));
 
   *error_name = 0;
-  if (menu_items_n_panes == 0)
+  if (menu_items_n_panes == 0) {
+    dynwind_end ();
     return Qnil;
+  }
 
   if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
     {
       *error_name = "Empty menu";
+      dynwind_end ();
       return Qnil;
     }
 
@@ -2057,6 +2064,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
     {
       *error_name = "Can't create menu";
       unblock_input ();
+      dynwind_end ();
       return Qnil;
     }
 
@@ -2096,6 +2104,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
              XMenuDestroy (FRAME_X_DISPLAY (f), menu);
              *error_name = "Can't create pane";
              unblock_input ();
+             dynwind_end ();
              return Qnil;
            }
          i += MENU_ITEMS_PANE_LENGTH;
@@ -2161,6 +2170,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
              XMenuDestroy (FRAME_X_DISPLAY (f), menu);
              *error_name = "Can't add selection to menu";
              unblock_input ();
+             dynwind_end ();
              return Qnil;
            }
          i += MENU_ITEMS_ITEM_LENGTH;
@@ -2295,7 +2305,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
     }
 
   unblock_input ();
-  unbind_to (specpdl_count, Qnil);
+  dynwind_end ();
 
   return entry;
 }
index faf8584..8ff783c 100644 (file)
@@ -390,7 +390,7 @@ x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
       /* Don't allow a quit within the converter.
         When the user types C-g, he would be surprised
         if by luck it came during a converter.  */
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       specbind (Qinhibit_quit, Qt);
 
       CHECK_SYMBOL (target_type);
@@ -404,7 +404,7 @@ x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
                       XCAR (XCDR (local_value)));
       else
        value = Qnil;
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 
   /* Make sure this value is of a type that we could transmit
@@ -570,7 +570,7 @@ x_reply_selection_request (struct input_event *event,
   Window window = SELECTION_EVENT_REQUESTOR (event);
   ptrdiff_t bytes_remaining;
   int max_bytes = selection_quantum (display);
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct selection_data *cs;
 
   reply->type = SelectionNotify;
@@ -737,7 +737,7 @@ x_reply_selection_request (struct input_event *event,
      and then BLOCK again because x_uncatch_errors requires it.  */
   block_input ();
   /* This calls x_uncatch_errors.  */
-  unbind_to (count, Qnil);
+  dynwind_end ();
   unblock_input ();
 }
 \f
@@ -759,7 +759,7 @@ x_handle_selection_request (struct input_event *event)
   Atom property = SELECTION_EVENT_PROPERTY (event);
   Lisp_Object local_selection_data;
   int success = 0;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   GCPRO2 (local_selection_data, target_symbol);
 
   if (!dpyinfo) goto DONE;
@@ -849,7 +849,7 @@ x_handle_selection_request (struct input_event *event)
       Frun_hook_with_args (4, args);
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
   UNGCPRO;
 }
 
@@ -1105,7 +1105,7 @@ wait_for_property_change_unwind (void *loc)
 static void
 wait_for_property_change (struct prop_location *location)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   if (property_change_reply_object)
     emacs_abort ();
@@ -1134,7 +1134,7 @@ wait_for_property_change (struct prop_location *location)
        }
     }
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 /* Called from XTread_socket in response to a PropertyNotify event.  */
@@ -2003,8 +2003,7 @@ On Nextstep, TIME-STAMP and TERMINAL are unused.  */)
     {
       Lisp_Object frame;
       XSETFRAME (frame, f);
-      RETURN_UNGCPRO (x_get_foreign_selection (selection_symbol, target_type,
-                                              time_stamp, frame));
+      return x_get_foreign_selection (selection_symbol, target_type, time_stamp, frame);
     }
 
   if (CONSP (val) && SYMBOLP (XCAR (val)))
@@ -2013,7 +2012,7 @@ On Nextstep, TIME-STAMP and TERMINAL are unused.  */)
       if (CONSP (val) && NILP (XCDR (val)))
        val = XCAR (val);
     }
-  RETURN_UNGCPRO (clean_local_selection_data (val));
+  return clean_local_selection_data (val);
 }
 
 DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal,
index eb33259..b64ca2d 100644 (file)
@@ -7584,7 +7584,7 @@ x_connection_closed (Display *dpy, const char *error_message)
 {
   struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
   Lisp_Object frame, tail;
-  ptrdiff_t idx = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   error_msg = alloca (strlen (error_message) + 1);
   strcpy (error_msg, error_message);
@@ -7673,7 +7673,7 @@ For details, see etc/PROBLEMS.\n",
 
   totally_unblock_input ();
 
-  unbind_to (idx, Qnil);
+  dynwind_end ();
   clear_waiting_for_input ();
 
   /* Tell GCC not to suggest attribute 'noreturn' for this function.  */