chiark / gitweb /
mtimeout.c: Fettle the signal-table Lisp code.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 1 Sep 2011 11:08:51 +0000 (12:08 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 1 Sep 2011 11:08:51 +0000 (12:08 +0100)
This is a slightly better version taken from another program (hitting
this repository soon).

mtimeout.c

index dbdc83ef60584bd0e03f3c2b67a115fb2d631a76..1bb484800f99c99597b63e5cf07641b3b6267da1 100644 (file)
@@ -104,27 +104,31 @@ int cmp_namesig(const void *k, const void *v)
 static int namesig(const char *p)
 {
   const static struct namesig tab[] = {
-/*
-  ;;; The signal name table is very boring to type.  To make life less awful,
-  ;;; put the signal names in this list and evaluate the code to get Emacs to
-  ;;; regenerate it.  We use @bsearch@ on it, so it's important that it be
-  ;;; sorted: Emacs does this for us.
-  (let ((signals '(HUP INT QUIT ILL ABRT FPE KILL SEGV PIPE ALRM TERM
-                  USR1 USR2 CHLD CONT STOP TSTP TTIN TTOU BUS POLL
-                  PROF SYS TRAP URG VTALRM XCPU XFSZ IOT EMT STKFLT
-                  IO CLD PWR INFO LOST WINCH)))
-    (save-excursion
-      (goto-char (point-min))
-      (let ((start (search-forward (concat "/" "* SIGLIST *" "/\n")))
-           (end (search-forward (concat "/" "* END *" "/\n"))))
-       (delete-region start end))
-      (dolist (sig (sort (copy-list signals) #'string<))
-       (insert (format "#ifdef SIG%s\n    { \"%s\", SIG%s },\n#endif\n"
-                       sig sig sig)))
-      (insert (concat "/" "* END *" "/\n"))))
-*/
-
-/* SIGLIST */
+  /*
+     ;;; The signal name table is very boring to type.  To make life less
+     ;;; awful, put the signal names in this list and evaluate the code to
+     ;;; get Emacs to regenerate it.  We use @bsearch@ on it, so it's
+     ;;; important that it be sorted: Emacs does this for us.
+
+     (let ((signals '(HUP INT QUIT ILL ABRT FPE KILL SEGV PIPE ALRM TERM
+                     USR1 USR2 CHLD CONT STOP TSTP TTIN TTOU BUS POLL
+                     PROF SYS TRAP URG VTALRM XCPU XFSZ IOT EMT STKFLT
+                     IO CLD PWR INFO LOST WINCH)))
+       (save-excursion
+        (goto-char (point-min))
+        (search-forward (concat "***" "BEGIN siglist" "***"))
+        (beginning-of-line 2)
+        (delete-region (point)
+                       (progn
+                         (search-forward "***END***")
+                         (beginning-of-line)
+                         (point)))
+        (dolist (sig (sort (copy-list signals) #'string<))
+          (insert (format "#ifdef SIG%s\n    { \"%s\", SIG%s },\n#endif\n"
+                          sig sig sig)))))
+  */
+
+    /***BEGIN siglist***/
 #ifdef SIGABRT
     { "ABRT", SIGABRT },
 #endif
@@ -236,7 +240,7 @@ static int namesig(const char *p)
 #ifdef SIGXFSZ
     { "XFSZ", SIGXFSZ },
 #endif
-/* END */
+    /***END***/
   };
 
   const struct namesig *ns = bsearch(p, tab, N(tab), sizeof(tab[0]),