From: Ken Hornstein Date: Mon, 5 Sep 2016 02:20:40 +0000 (-0400) Subject: Switch from our horrible awk script that parses the signal header file X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/5776f9b783afe8e6bdbe430adb5d5b9435d25b19?ds=inline;hp=--cc Switch from our horrible awk script that parses the signal header file to the POSIX function strsignal(). --- 5776f9b783afe8e6bdbe430adb5d5b9435d25b19 diff --git a/.gitignore b/.gitignore index b93c65d4..0452577e 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Makefile.am b/Makefile.am index 41607874..aaa0e557 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index b41f58a2..ecba1395 100644 --- a/configure.ac +++ b/configure.ac @@ -512,25 +512,6 @@ AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include ]) AC_STRUCT_DIRENT_D_TYPE -dnl Where is 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 diff --git a/sbr/pidstatus.c b/sbr/pidstatus.c index 1c1f7348..82f2d119 100644 --- a/sbr/pidstatus.c +++ b/sbr/pidstatus.c @@ -9,11 +9,6 @@ #include -/* - * auto-generated header - */ -#include - #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 index 88beac1e..00000000 --- a/sbr/sigmsg.awk +++ /dev/null @@ -1,85 +0,0 @@ -# -# sigmsg.awk -- awk/nawk/gawk script to generate sigmsg.h -# -# provided by Geoff Wing -# -# 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 "};" -}