use dynwind_begin and dynwind_end
[bpt/emacs.git] / src / editfns.c
index e8d4478..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;
 }
 
@@ -3363,10 +3366,6 @@ save_restriction_restore (Lisp_Object data)
 
          buf->clip_changed = 1; /* Remember that the narrowing changed. */
        }
-      /* These aren't needed anymore, so don't wait for GC.  */
-      free_marker (XCAR (data));
-      free_marker (XCDR (data));
-      free_cons (XCONS (data));
     }
   else
     /* A buffer, which means that there was no old restriction.  */
@@ -3409,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,
@@ -3543,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,
@@ -3606,7 +3606,6 @@ usage: (format STRING &rest OBJECTS)  */)
   ptrdiff_t bufsize = sizeof initial_buffer;
   ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1;
   char *p;
-  ptrdiff_t buf_save_value_index IF_LINT (= 0);
   char *format, *end, *format_start;
   ptrdiff_t formatlen, nchars;
   /* True if the format is multibyte.  */
@@ -4213,16 +4212,12 @@ usage: (format STRING &rest OBJECTS)  */)
 
        if (buf == initial_buffer)
          {
-           buf = xmalloc (bufsize);
-           sa_must_free = true;
-           buf_save_value_index = SPECPDL_INDEX ();
-           record_unwind_protect_ptr (xfree, buf);
+           buf = xmalloc_atomic (bufsize);
            memcpy (buf, initial_buffer, used);
          }
        else
          {
            buf = xrealloc (buf, bufsize);
-           set_unwind_protect_ptr (buf_save_value_index, xfree, buf);
          }
 
        p = buf + used;
@@ -4782,6 +4777,8 @@ Transposing beyond buffer boundaries is an error.  */)
 void
 syms_of_editfns (void)
 {
+#include "editfns.x"
+
   DEFSYM (Qbuffer_access_fontify_functions, "buffer-access-fontify-functions");
 
   DEFVAR_LISP ("inhibit-field-text-motion", Vinhibit_field_text_motion,
@@ -4828,95 +4825,6 @@ functions if all the text being accessed has this property.  */);
   DEFVAR_LISP ("operating-system-release", Voperating_system_release,
               doc: /* The release of the operating system Emacs is running on.  */);
 
-  defsubr (&Spropertize);
-  defsubr (&Schar_equal);
-  defsubr (&Sgoto_char);
-  defsubr (&Sstring_to_char);
-  defsubr (&Schar_to_string);
-  defsubr (&Sbyte_to_string);
-  defsubr (&Sbuffer_substring);
-  defsubr (&Sbuffer_substring_no_properties);
-  defsubr (&Sbuffer_string);
-  defsubr (&Sget_pos_property);
-
-  defsubr (&Spoint_marker);
-  defsubr (&Smark_marker);
-  defsubr (&Spoint);
-  defsubr (&Sregion_beginning);
-  defsubr (&Sregion_end);
-
   DEFSYM (Qfield, "field");
   DEFSYM (Qboundary, "boundary");
-  defsubr (&Sfield_beginning);
-  defsubr (&Sfield_end);
-  defsubr (&Sfield_string);
-  defsubr (&Sfield_string_no_properties);
-  defsubr (&Sdelete_field);
-  defsubr (&Sconstrain_to_field);
-
-  defsubr (&Sline_beginning_position);
-  defsubr (&Sline_end_position);
-
-  defsubr (&Ssave_excursion);
-  defsubr (&Ssave_current_buffer);
-
-  defsubr (&Sbuffer_size);
-  defsubr (&Spoint_max);
-  defsubr (&Spoint_min);
-  defsubr (&Spoint_min_marker);
-  defsubr (&Spoint_max_marker);
-  defsubr (&Sgap_position);
-  defsubr (&Sgap_size);
-  defsubr (&Sposition_bytes);
-  defsubr (&Sbyte_to_position);
-
-  defsubr (&Sbobp);
-  defsubr (&Seobp);
-  defsubr (&Sbolp);
-  defsubr (&Seolp);
-  defsubr (&Sfollowing_char);
-  defsubr (&Sprevious_char);
-  defsubr (&Schar_after);
-  defsubr (&Schar_before);
-  defsubr (&Sinsert);
-  defsubr (&Sinsert_before_markers);
-  defsubr (&Sinsert_and_inherit);
-  defsubr (&Sinsert_and_inherit_before_markers);
-  defsubr (&Sinsert_char);
-  defsubr (&Sinsert_byte);
-
-  defsubr (&Suser_login_name);
-  defsubr (&Suser_real_login_name);
-  defsubr (&Suser_uid);
-  defsubr (&Suser_real_uid);
-  defsubr (&Sgroup_gid);
-  defsubr (&Sgroup_real_gid);
-  defsubr (&Suser_full_name);
-  defsubr (&Semacs_pid);
-  defsubr (&Scurrent_time);
-  defsubr (&Sget_internal_run_time);
-  defsubr (&Sformat_time_string);
-  defsubr (&Sfloat_time);
-  defsubr (&Sdecode_time);
-  defsubr (&Sencode_time);
-  defsubr (&Scurrent_time_string);
-  defsubr (&Scurrent_time_zone);
-  defsubr (&Sset_time_zone_rule);
-  defsubr (&Ssystem_name);
-  defsubr (&Smessage);
-  defsubr (&Smessage_box);
-  defsubr (&Smessage_or_box);
-  defsubr (&Scurrent_message);
-  defsubr (&Sformat);
-
-  defsubr (&Sinsert_buffer_substring);
-  defsubr (&Scompare_buffer_substrings);
-  defsubr (&Ssubst_char_in_region);
-  defsubr (&Stranslate_region_internal);
-  defsubr (&Sdelete_region);
-  defsubr (&Sdelete_and_extract_region);
-  defsubr (&Swiden);
-  defsubr (&Snarrow_to_region);
-  defsubr (&Ssave_restriction);
-  defsubr (&Stranspose_regions);
 }