emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113887: * lisp.h (FOR_EACH_ALIST_VALUE): New macro


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r113887: * lisp.h (FOR_EACH_ALIST_VALUE): New macro
Date: Thu, 15 Aug 2013 14:53:54 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113887
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Thu 2013-08-15 18:52:53 +0400
message:
  * lisp.h (FOR_EACH_ALIST_VALUE): New macro
  to do `for' loops over alist values.
  * buffer.h (FOR_EACH_BUFFER):
  * process.c (FOR_EACH_PROCESS): Use it.
  (handle_child_signal, status_notify, Fget_buffer_process)
  (kill_buffer_processes): Use FOR_EACH_PROCESS.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/buffer.h                   buffer.h-20091113204419-o5vbwnq5f7feedwu-196
  src/lisp.h                     lisp.h-20091113204419-o5vbwnq5f7feedwu-253
  src/process.c                  process.c-20091113204419-o5vbwnq5f7feedwu-462
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-08-15 05:23:40 +0000
+++ b/src/ChangeLog     2013-08-15 14:52:53 +0000
@@ -1,5 +1,14 @@
 2013-08-15  Dmitry Antipov  <address@hidden>
 
+       * lisp.h (FOR_EACH_ALIST_VALUE): New macro
+       to do `for' loops over alist values.
+       * buffer.h (FOR_EACH_BUFFER):
+       * process.c (FOR_EACH_PROCESS): Use it.
+       (handle_child_signal, status_notify, Fget_buffer_process)
+       (kill_buffer_processes): Use FOR_EACH_PROCESS.
+
+2013-08-15  Dmitry Antipov  <address@hidden>
+
        * term.c (get_named_tty, create_tty_output, tty_free_frame_resources)
        (tty_free_frame_resources, delete_tty): Prefer eassert to emacs_abort.
        * image.c (make_image_cache): For struct image_cache, prefer xmalloc

=== modified file 'src/buffer.h'
--- a/src/buffer.h      2013-08-06 06:53:09 +0000
+++ b/src/buffer.h      2013-08-15 14:52:53 +0000
@@ -1132,10 +1132,8 @@
 /* FOR_EACH_LIVE_BUFFER (LIST_VAR, BUF_VAR) followed by a statement is
    a `for' loop which iterates over the buffers from Vbuffer_alist.  */
 
-#define FOR_EACH_LIVE_BUFFER(list_var, buf_var)                                
\
-  for (list_var = Vbuffer_alist;                                       \
-       (CONSP (list_var) && (buf_var = XCDR (XCAR (list_var)), 1));    \
-       list_var = XCDR (list_var))
+#define FOR_EACH_LIVE_BUFFER(list_var, buf_var)                        \
+  FOR_EACH_ALIST_VALUE (Vbuffer_alist, list_var, buf_var)
 
 /* Get text properties of B.  */
 

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2013-08-14 16:36:16 +0000
+++ b/src/lisp.h        2013-08-15 14:52:53 +0000
@@ -4342,6 +4342,12 @@
       memory_full (SIZE_MAX);                                 \
   } while (0)
 
+/* Do a `for' loop over alist values.  */
+
+#define FOR_EACH_ALIST_VALUE(head_var, list_var, value_var)            \
+  for (list_var = head_var;                                            \
+       (CONSP (list_var) && (value_var = XCDR (XCAR (list_var)), 1));  \
+       list_var = XCDR (list_var))
 
 /* Check whether it's time for GC, and run it if so.  */
 

=== modified file 'src/process.c'
--- a/src/process.c     2013-08-12 20:17:32 +0000
+++ b/src/process.c     2013-08-15 14:52:53 +0000
@@ -361,6 +361,12 @@
 #define DATAGRAM_CONN_P(proc)  (0)
 #endif
 
+/* FOR_EACH_PROCESS (LIST_VAR, PROC_VAR) followed by a statement is
+   a `for' loop which iterates over processes from Vprocess_alist.  */
+
+#define FOR_EACH_PROCESS(list_var, proc_var)                   \
+  FOR_EACH_ALIST_VALUE (Vprocess_alist, list_var, proc_var)
+
 /* These setters are used only in this file, so they can be private.  */
 static void
 pset_buffer (struct Lisp_Process *p, Lisp_Object val)
@@ -6135,7 +6141,7 @@
 static void
 handle_child_signal (int sig)
 {
-  Lisp_Object tail;
+  Lisp_Object tail, proc;
 
   /* Find the process that signaled us, and record its status.  */
 
@@ -6165,9 +6171,8 @@
     }
 
   /* Otherwise, if it is asynchronous, it is in Vprocess_alist.  */
-  for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
+  FOR_EACH_PROCESS (tail, proc)
     {
-      Lisp_Object proc = XCDR (XCAR (tail));
       struct Lisp_Process *p = XPROCESS (proc);
       int status;
 
@@ -6322,13 +6327,10 @@
      that we run, we get called again to handle their status changes.  */
   update_tick = process_tick;
 
-  for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
+  FOR_EACH_PROCESS (tail, proc)
     {
       Lisp_Object symbol;
-      register struct Lisp_Process *p;
-
-      proc = Fcdr (XCAR (tail));
-      p = XPROCESS (proc);
+      register struct Lisp_Process *p = XPROCESS (proc);
 
       if (p->tick != p->update_tick)
        {
@@ -6851,12 +6853,9 @@
   buf = Fget_buffer (buffer);
   if (NILP (buf)) return Qnil;
 
-  for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
-    {
-      proc = Fcdr (XCAR (tail));
-      if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf))
-       return proc;
-    }
+  FOR_EACH_PROCESS (tail, proc)
+    if (EQ (XPROCESS (proc)->buffer, buf))
+      return proc;
 #endif /* subprocesses */
   return Qnil;
 }
@@ -6889,18 +6888,14 @@
 #ifdef subprocesses
   Lisp_Object tail, proc;
 
-  for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
-    {
-      proc = XCDR (XCAR (tail));
-      if (PROCESSP (proc)
-         && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer)))
-       {
-         if (NETCONN_P (proc) || SERIALCONN_P (proc))
-           Fdelete_process (proc);
-         else if (XPROCESS (proc)->infd >= 0)
-           process_send_signal (proc, SIGHUP, Qnil, 1);
-       }
-    }
+  FOR_EACH_PROCESS (tail, proc)
+    if (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))
+      {
+       if (NETCONN_P (proc) || SERIALCONN_P (proc))
+         Fdelete_process (proc);
+       else if (XPROCESS (proc)->infd >= 0)
+         process_send_signal (proc, SIGHUP, Qnil, 1);
+      }
 #else  /* subprocesses */
   /* Since we have no subprocesses, this does nothing.  */
 #endif /* subprocesses */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]