]> diplodocus.org Git - nmh/commitdiff
Switch from our horrible awk script that parses the signal header file
authorKen Hornstein <kenh@pobox.com>
Mon, 5 Sep 2016 02:20:40 +0000 (22:20 -0400)
committerKen Hornstein <kenh@pobox.com>
Mon, 5 Sep 2016 02:20:40 +0000 (22:20 -0400)
to the POSIX function strsignal().

.gitignore
Makefile.am
configure.ac
sbr/pidstatus.c
sbr/sigmsg.awk [deleted file]

index b93c65d4867d5806ecb1d5ac2294af19277eba1d..0452577e28799853efe4440bdac69745d9b3c1d7 100644 (file)
@@ -60,7 +60,6 @@ a.out.dSYM/
 /mts/libmts.a
 /sbr/*.a
 /sbr/ctype-checked.*
-/sbr/sigmsg.h
 /sbr/addrparse.tab.c
 /sbr/addrparse.tab.h
 /sbr/addrparse.output
index 41607874db99eddf691a5d814bb16e60f207bf9e..aaa0e5579843b2a08a4971180ff57c936c18bd65 100644 (file)
@@ -146,7 +146,7 @@ superclean: maintainer-clean
 ##
 ## Files that need to be built before everything else
 ##
-BUILT_SOURCES = sbr/sigmsg.h sbr/ctype-checked.c
+BUILT_SOURCES = sbr/ctype-checked.c
 
 ##
 ## This is a list of all programs that get installed in the "bin" directory
@@ -282,7 +282,7 @@ man_SRCS = man/ali.man man/anno.man man/ap.man man/burst.man man/comp.man \
 ## Files we need to include in the distribution which aren't found by
 ## Automake using the automatic rules
 ##
-EXTRA_DIST = autogen.sh config/version.sh sbr/sigmsg.awk sbr/icalparse.h \
+EXTRA_DIST = autogen.sh config/version.sh sbr/icalparse.h \
             etc/mts.conf.in etc/mhn.defaults.sh etc/sendfiles \
             $(MHNSEARCHPROG) DATE MACHINES \
             docs/ChangeLog_MH-3_to_MH-6.6 \
@@ -505,9 +505,6 @@ etc_gen_ctype_checked_LDADD = $(POSTLINK)
 config/version.c: Makefile $(srcdir)/config/version.sh
        env srcdir="$(srcdir)" sh $(srcdir)/config/version.sh $(VERSION) > ./config/version.c
 
-sbr/sigmsg.h: $(srcdir)/sbr/sigmsg.awk $(SIGNAL_H)
-       $(AWK) -f $(srcdir)/sbr/sigmsg.awk $(SIGNAL_H) > $@
-
 sbr/ctype-checked.h: etc/gen-ctype-checked
        etc/gen-ctype-checked
 
index b41f58a2ac39dc63bab35f1fcebc43cee73f1118..ecba13952840c0eda834020f6f9b73ddbe14944b 100644 (file)
@@ -512,25 +512,6 @@ AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
 
 AC_STRUCT_DIRENT_D_TYPE
 
-dnl Where is <signal.h> located?  Needed as input for signames.awk
-AC_CACHE_CHECK(where signal.h is located, nmh_cv_path_signal_h,
-[for SIGNAL_H in /usr/include/bsd/sys/signal.h  dnl Next
-                 /usr/include/asm/signal.h      dnl Linux 1.3.0 and above
-                 /usr/include/asm/signum.h      dnl some versions of Linux/Alpha
-                 /usr/include/linux/signal.h    dnl Linux up to 1.2.11
-                 /usr/include/sys/signal.h      dnl Almost everybody else
-                /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/signal.h   dnl Newer version of MacOS X
-                 /dev/null;                     dnl Just in case we fall through
-do
-  test -f $SIGNAL_H && \
-  grep '#[     ]*define[       ][      ]*SIG[0-9A-Z]*[         ]*[0-9][0-9]*' $SIGNAL_H > /dev/null && \
-  break
-done
-nmh_cv_path_signal_h=$SIGNAL_H
-])
-SIGNAL_H=$nmh_cv_path_signal_h
-AC_SUBST(SIGNAL_H)dnl
-
 dnl
 dnl Sigh, this is required because under the new world order autoconf has
 dnl nothing to create in a few of the build directories when doing an object
index 1c1f734896455c19efe4f827a5a2d3b16e72001d..82f2d1194159853bc57fc19e9d8e88472129b8eb 100644 (file)
@@ -9,11 +9,6 @@
 
 #include <h/mh.h>
 
-/*
- * auto-generated header
- */
-#include <sigmsg.h>
-
 #ifndef WTERMSIG
 # define WTERMSIG(s) ((int)((s) & 0x7F))
 #endif
@@ -34,6 +29,7 @@ int
 pidstatus (int status, FILE *fp, char *cp)
 {
     int signum;
+    char *signame;
 
 /*
  * I have no idea what this is for (rc)
@@ -58,9 +54,12 @@ pidstatus (int status, FILE *fp, char *cp)
            if (cp)
                fprintf (fp, "%s: ", cp);
            fprintf (fp, "signal %d", signum);
-           if (signum >= 0 && signum < (int) sizeof(sigmsg) &&
-                  sigmsg[signum] != NULL)
-               fprintf (fp, " (%s%s)\n", sigmsg[signum],
+           errno = 0;
+           signame = strsignal(signum);
+           if (errno)
+               signame = NULL;
+           if (signame)
+               fprintf (fp, " (%s%s)\n", signame,
                         WCOREDUMP(status) ? ", core dumped" : "");
            else
                fprintf (fp, "%s\n", WCOREDUMP(status) ? " (core dumped)" : "");
diff --git a/sbr/sigmsg.awk b/sbr/sigmsg.awk
deleted file mode 100755 (executable)
index 88beac1..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-# 
-# sigmsg.awk -- awk/nawk/gawk script to generate sigmsg.h
-#
-# provided by Geoff Wing <mason@werple.apana.org.au>
-#
-# On SunOS 4.1.3 - user-functions don't work properly, also \" problems
-# Without 0 + hacks some nawks compare numbers as strings
-#
-/^[\t ]*#[\t ]*define[\t _]*SIG[A-Z][A-Z0-9]*[\t ]*[1-9][0-9]*/ { 
-    sigindex = index($0, "SIG")
-    sigtail = substr($0, sigindex, 80)
-    split(sigtail, tmp)
-    signam = substr(tmp[1], 4, 20)
-    signum = tmp[2]
-    if (sig[signum] == "") {
-       sig[signum] = signam
-       if (0 + max < 0 + signum && signum < 60)
-           max = signum
-       if (signam == "ABRT")   { msg[signum] = "abort" }
-       if (signam == "ALRM")   { msg[signum] = "alarm" }
-       if (signam == "BUS")    { msg[signum] = "bus error" }
-       if (signam == "CHLD")   { msg[signum] = "death of child" }
-       if (signam == "CLD")    { msg[signum] = "death of child" }
-       if (signam == "CONT")   { msg[signum] = "continued" }
-       if (signam == "EMT")    { msg[signum] = "EMT instruction" }
-       if (signam == "FPE")    { msg[signum] = "floating point exception" }
-       if (signam == "HUP")    { msg[signum] = "hangup" }
-       if (signam == "ILL")    { msg[signum] = "illegal hardware instruction" }
-       if (signam == "INFO")   { msg[signum] = "status request from keyboard" }
-       if (signam == "INT")    { msg[signum] = "interrupt" }
-       if (signam == "IO")     { msg[signum] = "i/o ready" }
-       if (signam == "IOT")    { msg[signum] = "IOT instruction" }
-       if (signam == "KILL")   { msg[signum] = "killed" }
-       if (signam == "LOST")   { msg[signum] = "resource lost" }
-       if (signam == "PIPE")   { msg[signum] = "broken pipe" }
-       if (signam == "POLL")   { msg[signum] = "pollable event occurred" }
-       if (signam == "PROF")   { msg[signum] = "profile signal" }
-       if (signam == "PWR")    { msg[signum] = "power fail" }
-       if (signam == "QUIT")   { msg[signum] = "quit" }
-       if (signam == "SEGV")   { msg[signum] = "segmentation fault" }
-       if (signam == "SYS")    { msg[signum] = "invalid system call" }
-       if (signam == "TERM")   { msg[signum] = "terminated" }
-       if (signam == "TRAP")   { msg[signum] = "trace trap" }
-       if (signam == "URG")    { msg[signum] = "urgent condition" }
-       if (signam == "USR1")   { msg[signum] = "user-defined signal 1" }
-       if (signam == "USR2")   { msg[signum] = "user-defined signal 2" }
-       if (signam == "VTALRM") { msg[signum] = "virtual time alarm" }
-       if (signam == "WINCH")  { msg[signum] = "window size changed" }
-       if (signam == "XCPU")   { msg[signum] = "cpu limit exceeded" }
-       if (signam == "XFSZ")   { msg[signum] = "file size limit exceeded" }
-    }
-}
-
-END {
-    ps = "%s"
-    ifdstr = sprintf("\t%cstopped%s%c,\n", 34, ps, 34)
-
-    print "\n/*"
-    print " * sigmsg.h -- architecture-customized signal messages for nmh"
-    print " *"
-    print " * automatically generated by sigmsg.awk"
-    print " */\n"
-    printf("%s  %d\n\n", "#define SIGCOUNT", max)
-    print "char *sigmsg[SIGCOUNT+2] = {"
-    print "\tNULL,"
-
-    for (i = 1; i <= 0 + max; i++)
-       if (msg[i] == "") {
-           if (sig[i] == "")
-               printf("\tNULL,\n")
-           else if (sig[i] == "STOP")
-               printf ifdstr, " (signal)", " (signal)"
-           else if (sig[i] == "TSTP")
-               printf ifdstr, "", ""
-           else if (sig[i] == "TTIN")
-               printf ifdstr, " (tty input)", " (tty input)"
-           else if (sig[i] == "TTOU")
-               printf ifdstr, " (tty output)", " (tty output)"
-           else
-               printf("\t%cSIG%s%c,\n", 34, sig[i], 34)
-       } else
-           printf("\t%c%s%c,\n", 34, msg[i], 34)
-    print "\tNULL"
-    print "};"
-}