From 91431e4cf644e8d6bbc4fe98467c459c4cf79a5a Mon Sep 17 00:00:00 2001 From: tg Date: Tue, 5 Jun 2007 21:47:49 +0000 Subject: [PATCH] with this, we don't need the special list of pre-known signal names any more either, and can make use of code sharing between detection of sys_siglist and sys_signame (and the underscored variants); nuke the now-useless signames.c file too (merge struct into histrap.c) --- Build.sh | 60 +++++++++++++++++------------------------------------- Makefile | 23 ++++++++++----------- histrap.c | 17 +++++++++------- signames.c | 19 ----------------- 4 files changed, 40 insertions(+), 79 deletions(-) delete mode 100644 signames.c diff --git a/Build.sh b/Build.sh index 72280f1..7a7aaf2 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $MirOS: src/bin/mksh/Build.sh,v 1.202 2007/06/05 21:17:05 tg Exp $ +# $MirOS: src/bin/mksh/Build.sh,v 1.203 2007/06/05 21:47:48 tg Exp $ #- # Environment used: CC CFLAGS CPP CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS # CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NEED_MKNOD MKSH_NOPWNAM @@ -536,44 +536,22 @@ CPPFLAGS="$CPPFLAGS -DHAVE_SIG_T=$HAVE_SIG_T" # test x"NetBSD" = x"$TARGET_OS" && $e Ignore the compatibility warning. -ac_test mksh_signame '' 'our own list of signal names' <<-'EOF' - #include /* for NULL */ - #define MKSH_SIGNAMES_CHECK - #include "signames.c" - int main(void) { return (mksh_sigpairs[0].nr); } -EOF - -ac_test sys_signame '!' mksh_signame 0 'the sys_signame[] array' <<-'EOF' - extern const char *const sys_signame[]; - int main(void) { return (sys_signame[0][0]); } -EOF - -ac_test _sys_signame '!' sys_signame 0 'the _sys_signame[] array' <<-'EOF' - extern const char *const _sys_signame[]; - int main(void) { return (_sys_signame[0][0]); } -EOF - -if test 000 = $HAVE_SYS_SIGNAME$HAVE__SYS_SIGNAME$HAVE_MKSH_SIGNAME; then - NEED_MKSH_SIGNAME=1 -else - NEED_MKSH_SIGNAME=0 -fi - -# only testn: added later below -ac_testn sys_siglist '' 'the sys_siglist[] array' <<-'EOF' - extern const char *const sys_siglist[]; - int main(void) { return (sys_siglist[0][0]); } -EOF - -ac_testn _sys_siglist '!' sys_siglist 0 'the _sys_siglist[] array' <<-'EOF' - extern const char *const _sys_siglist[]; - int main(void) { return (_sys_siglist[0][0]); } -EOF -if test 1 = $HAVE__SYS_SIGLIST; then - CPPFLAGS="$CPPFLAGS -Dsys_siglist=_sys_siglist" - HAVE_SYS_SIGLIST=1 -fi -CPPFLAGS="$CPPFLAGS -DHAVE_SYS_SIGLIST=$HAVE_SYS_SIGLIST" +for what in name list; do + uwhat=`upper $what` + ac_testn sys_sig$what '' "the sys_sig${what}[] array" <<-EOF + extern const char *const sys_sig${what}[]; + int main(void) { return (sys_sig${what}[0][0]); } + EOF + ac_testn _sys_sig$what '!' sys_sig$what 0 "the _sys_sig${what}[] array" <<-EOF + extern const char *const _sys_sig${what}[]; + int main(void) { return (_sys_sig${what}[0][0]); } + EOF + if eval "test 1 = \$HAVE__SYS_SIG$uwhat"; then + CPPFLAGS="$CPPFLAGS -Dsys_sig$what=_sys_sig$what" + eval "HAVE_SYS_SIG$uwhat=1" + fi + eval CPPFLAGS=\"\$CPPFLAGS -DHAVE_SYS_SIG$uwhat=\$HAVE_SYS_SIG$uwhat\" +done ac_test strsignal '!' sys_siglist 0 <<-'EOF' #include @@ -707,7 +685,7 @@ test 1 = $HAVE_PERSISTENT_HISTORY || \ # Compiler: Praeprocessor (only if needed) # HAVE_CPP_DD=yes -if test 1 = $NEED_MKSH_SIGNAME; then +if test 0 = $HAVE_SYS_SIGNAME; then $e ... checking how to run the C Preprocessor save_CPP=$CPP for i in "$save_CPP" "$CC -E -" "cpp" "/usr/libexec/cpp" "/lib/cpp"; do @@ -745,7 +723,7 @@ ed x /dev/null | grep 3 >/dev/null 2>&1 && \ check_categories=$check_categories,oldish-ed rm -f x -if test 1 = $NEED_MKSH_SIGNAME; then +if test 0 = $HAVE_SYS_SIGNAME; then if test $HAVE_CPP_DD = yes; then $e Generating list of signal names... else diff --git a/Makefile b/Makefile index 5aeebe1..350dc4d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/Makefile,v 1.42 2007/06/05 19:48:45 tg Exp $ +# $MirOS: src/bin/mksh/Makefile,v 1.43 2007/06/05 21:47:48 tg Exp $ #- # use CPPFLAGS=-DDEBUG __CRAZY=Yes to check for certain more stuff @@ -10,20 +10,19 @@ SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \ .if !make(test-build) CPPFLAGS+= -DMKSH_ASSUME_UTF8 \ -DHAVE_ATTRIBUTE=1 -DHAVE_ATTRIBUTE_BOUNDED=1 \ - -DHAVE_ATTRIBUTE_USED=1 -DHAVE_EXPSTMT=1 \ - -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 \ + -DHAVE_ATTRIBUTE_USED=1 -DHAVE_EXPSTMT=1 -DHAVE_SYS_PARAM_H=1 \ + -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 \ -DHAVE_SYS_SYSMACROS_H=0 -DHAVE_LIBGEN_H=1 -DHAVE_PATHS_H=1 \ -DHAVE_STDBOOL_H=1 -DHAVE_STDINT_H=1 -DHAVE_GRP_H=1 \ -DHAVE_ULIMIT_H=0 -DHAVE_VALUES_H=0 -DHAVE_RLIM_T=1 \ - -DHAVE_SIG_T=1 -DHAVE_MKSH_SIGNAME=0 -DHAVE_SYS_SIGNAME=1 \ - -DHAVE__SYS_SIGNAME=0 -DHAVE_SYS_SIGLIST=1 -DHAVE_STRSIGNAL=0 \ - -DHAVE_ARC4RANDOM=1 -DHAVE_ARC4RANDOM_PUSH=1 \ - -DHAVE_FLOCK_EX=1 -DHAVE_SETLOCALE_CTYPE=0 \ - -DHAVE_LANGINFO_CODESET=0 -DHAVE_REVOKE=1 -DHAVE_SETMODE=1 \ - -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRCASESTR=1 \ - -DHAVE_STRLCPY=1 -DHAVE_ARC4RANDOM_DECL=1 \ - -DHAVE_ARC4RANDOM_PUSH_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \ - -DHAVE_PERSISTENT_HISTORY=1 + -DHAVE_SIG_T=1 -DHAVE_SYS_SIGNAME=1 -DHAVE_SYS_SIGLIST=1 \ + -DHAVE_STRSIGNAL=0 -DHAVE_ARC4RANDOM=1 \ + -DHAVE_ARC4RANDOM_PUSH=1 -DHAVE_FLOCK_EX=1 \ + -DHAVE_SETLOCALE_CTYPE=0 -DHAVE_LANGINFO_CODESET=0 \ + -DHAVE_REVOKE=1 -DHAVE_SETMODE=1 -DHAVE_SETRESUGID=1 \ + -DHAVE_SETGROUPS=1 -DHAVE_STRCASESTR=1 -DHAVE_STRLCPY=1 \ + -DHAVE_ARC4RANDOM_DECL=1 -DHAVE_ARC4RANDOM_PUSH_DECL=1 \ + -DHAVE_SYS_SIGLIST_DECL=1 -DHAVE_PERSISTENT_HISTORY=1 COPTS+= -std=gnu99 -Wall .endif diff --git a/histrap.c b/histrap.c index e00aee9..05f7721 100644 --- a/histrap.c +++ b/histrap.c @@ -3,7 +3,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.47 2007/06/04 21:33:28 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.48 2007/06/05 21:47:48 tg Exp $"); Trap sigtraps[NSIG + 1]; static struct sigaction Sigact_ign, Sigact_trap; @@ -949,11 +949,14 @@ sprinkle(int fd) } #endif -#if HAVE_SYS_SIGNAME -#elif HAVE__SYS_SIGNAME -#define sys_signame _sys_signame -#else -#include "signames.c" +#if !HAVE_SYS_SIGNAME +static const struct mksh_sigpair { + int nr; + const char *const name; +} mksh_sigpairs[] = { +#include "signames.inc" + { 0, NULL } +}; #endif void @@ -969,7 +972,7 @@ inittraps(void) sigtraps[i].name = "ERR"; sigtraps[i].mess = "Error handler"; } else { -#if HAVE_SYS_SIGNAME || HAVE__SYS_SIGNAME +#if HAVE_SYS_SIGNAME cs = sys_signame[i]; #else const struct mksh_sigpair *pair = mksh_sigpairs; diff --git a/signames.c b/signames.c deleted file mode 100644 index b55b1c2..0000000 --- a/signames.c +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef MKSH_SIGNAMES_CHECK -__RCSID("$MirOS: src/bin/mksh/signames.c,v 1.2 2007/03/04 03:04:28 tg Exp $"); -#endif - -static const struct mksh_sigpair { - int nr; - const char *const name; -} mksh_sigpairs[] = { -#ifdef __Plan9__ -... -#elif defined(__minix) && !defined(__GNUC__) -... -#elif defined(MKSH_SIGNAMES_CHECK) -#error no, must be OS supplied -#elif !defined(__IN_MKDEP) -#include "signames.inc" -#endif - { 0, NULL } -};