From e33fa75597994805119c4aafecc5d6ef5e9d2939 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 1 Sep 2011 12:08:51 +0100 Subject: [PATCH] mtimeout.c: Fettle the signal-table Lisp code. This is a slightly better version taken from another program (hitting this repository soon). --- mtimeout.c | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/mtimeout.c b/mtimeout.c index dbdc83e..1bb4848 100644 --- a/mtimeout.c +++ b/mtimeout.c @@ -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]), -- 2.11.0