use dynwind_begin and dynwind_end
[bpt/emacs.git] / src / callproc.c
index 3647a1a..2f6030f 100644 (file)
@@ -283,7 +283,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int *filefd, Lisp_Object *temp
   int callproc_fd[CALLPROC_FDS];
   int status;
   ptrdiff_t i;
-  ptrdiff_t count = SPECPDL_INDEX ();
   USE_SAFE_ALLOCA;
 
   char **new_argv;
@@ -306,6 +305,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int *filefd, Lisp_Object *temp
   Lisp_Object coding_systems;
   bool discard_output;
 
+  dynwind_begin ();
+
   if (synch_process_pid)
     error ("call-process invoked recursively");
 
@@ -571,7 +572,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int *filefd, Lisp_Object *temp
   if (pid < 0)
     {
       child_errno = errno;
-      unbind_to (count, Qnil);
+      dynwind_end ();
       synchronize_system_messages_locale ();
       return
        code_convert_string_norecord (build_string (strerror (child_errno)),
@@ -626,7 +627,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int *filefd, Lisp_Object *temp
     bool volatile display_p_volatile = display_p;
     int volatile fd_error_volatile = fd_error;
     int *volatile filefd_volatile = filefd;
-    ptrdiff_t volatile count_volatile = count;
     char **volatile new_argv_volatile = new_argv;
     int volatile callproc_fd_volatile[CALLPROC_FDS];
     for (i = 0; i < CALLPROC_FDS; i++)
@@ -640,7 +640,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int *filefd, Lisp_Object *temp
     display_p = display_p_volatile;
     fd_error = fd_error_volatile;
     filefd = filefd_volatile;
-    count = count_volatile;
     new_argv = new_argv_volatile;
 
     for (i = 0; i < CALLPROC_FDS; i++)
@@ -707,7 +706,10 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int *filefd, Lisp_Object *temp
 #endif /* not MSDOS */
 
   if (INTEGERP (buffer))
-    return unbind_to (count, Qnil);
+    {
+      dynwind_end ();
+      return Qnil;
+    }
 
   if (BUFFERP (buffer))
     Fset_buffer (buffer);
@@ -806,8 +808,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int *filefd, Lisp_Object *temp
          else
            {                   /* We have to decode the input.  */
              Lisp_Object curbuf;
-             ptrdiff_t count1 = SPECPDL_INDEX ();
 
+              dynwind_begin ();
              XSETBUFFER (curbuf, current_buffer);
              /* FIXME: Call signal_after_change!  */
              prepare_to_modify_buffer (PT, PT, NULL);
@@ -819,7 +821,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int *filefd, Lisp_Object *temp
              specbind (Qinhibit_modification_hooks, Qt);
              decode_coding_c_string (&process_coding,
                                      (unsigned char *) buf, nread, curbuf);
-             unbind_to (count1, Qnil);
+              dynwind_end ();
              if (display_on_the_fly
                  && CODING_REQUIRE_DETECTION (&saved_coding)
                  && ! CODING_REQUIRE_DETECTION (&process_coding))
@@ -894,7 +896,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int *filefd, Lisp_Object *temp
   synch_process_pid = 0;
 
   SAFE_FREE ();
-  unbind_to (count, Qnil);
+  dynwind_end ();
 
   if (WIFSIGNALED (status))
     {