Clean up the signal mess, saves 172 Bytes:
* 'sigseen' in Build.sh goes away * Signal name existence is checked in this order: have our own¹ -> sys_signame[] -> _sys_signame[] -> build our own² * Signal description existence is checked in this order: sys_siglist[] -> _sys_siglist[] -> strsignal() -> NULL³ ¹ Predefined list of items, for operating systems where we cannot build² them, i.e. Plan 9 and Minix 3 (e.g. no $CPP -dD) ² The usual cpp(1) stuff ³ Changed later, see below * Make $CPP test dependent on $NEED_MKSH_SIGNAME (others can be added here, this is not absolute) * Make signal name list generation² dependent on $NEED_MKSH_SIGNAME * Fix check if the generation worked * Guarantee that sigtraps[*].name and sigtraps[*].mess are valid C strings; this makes the code shorter *and* removes a few pos- sible nil pointer dereferences * Embed autoconf'd usages of sys_sig* / strsignal / mksh_sigpairs into inittraps() * Check for each signal 0<=i<=NSIG that name is not NULL or "" -> replace with ("%d", i) mess is not NULL or "" -> replace with ("Signal %d", i) name does not start (case-insensitive) with "SIG" -> name += 3 * In gettrap(), fix check if signal name starts, case-sensitive or case-insensitive, depending on need, with "SIG" (bug from millert@) Other changes: * Build.sh: ac_test[n]() are documented * Build.sh: ac_test[n]() can have negative prereqs as well now * Build.sh: use <<-'EOF' consistently * bump patchlevel to today
This commit is contained in:
24
funcs.c
24
funcs.c
@ -5,7 +5,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.40 2007/01/11 00:32:31 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.41 2007/01/12 00:25:39 tg Exp $");
|
||||
|
||||
int
|
||||
c_cd(char **wp)
|
||||
@ -1085,16 +1085,10 @@ kill_fmt_entry(const void *arg, int i, char *buf, int buflen)
|
||||
const struct kill_info *ki = (const struct kill_info *)arg;
|
||||
|
||||
i++;
|
||||
if (sigtraps[i].name)
|
||||
shf_snprintf(buf, buflen, "%*d %*s %s",
|
||||
ki->num_width, i,
|
||||
ki->name_width, sigtraps[i].name,
|
||||
sigtraps[i].mess);
|
||||
else
|
||||
shf_snprintf(buf, buflen, "%*d %*d %s",
|
||||
ki->num_width, i,
|
||||
ki->name_width, sigtraps[i].signal,
|
||||
sigtraps[i].mess);
|
||||
shf_snprintf(buf, buflen, "%*d %*s %s",
|
||||
ki->num_width, i,
|
||||
ki->name_width, sigtraps[i].name,
|
||||
sigtraps[i].mess);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -1152,7 +1146,7 @@ c_kill(char **wp)
|
||||
return 1;
|
||||
if (n > 128 && n < 128 + NSIG)
|
||||
n -= 128;
|
||||
if (n > 0 && n < NSIG && sigtraps[n].name)
|
||||
if (n > 0 && n < NSIG)
|
||||
shprintf("%s\n", sigtraps[n].name);
|
||||
else
|
||||
shprintf("%d\n", n);
|
||||
@ -1166,9 +1160,7 @@ c_kill(char **wp)
|
||||
ki.num_width++;
|
||||
ki.name_width = mess_width = 0;
|
||||
for (j = 0; j < NSIG; j++) {
|
||||
w = sigtraps[j].name ?
|
||||
(int)strlen(sigtraps[j].name) :
|
||||
ki.num_width;
|
||||
w = strlen(sigtraps[j].name);
|
||||
if (w > ki.name_width)
|
||||
ki.name_width = w;
|
||||
w = strlen(sigtraps[j].mess);
|
||||
@ -1177,7 +1169,7 @@ c_kill(char **wp)
|
||||
}
|
||||
|
||||
print_columns(shl_stdout, NSIG - 1,
|
||||
kill_fmt_entry, (void *) &ki,
|
||||
kill_fmt_entry, (void *)&ki,
|
||||
ki.num_width + ki.name_width + mess_width + 3, 1);
|
||||
}
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user