1996-09-22 03:35:13 +04:00
|
|
|
#!/bin/sh
|
2016-03-17 16:59:02 +03:00
|
|
|
# $NetBSD: siglist.sh,v 1.12 2016/03/17 13:59:02 christos Exp $
|
1996-09-22 03:35:13 +04:00
|
|
|
#
|
|
|
|
# Script to generate a sorted, complete list of signals, suitable
|
|
|
|
# for inclusion in trap.c as array initializer.
|
|
|
|
#
|
|
|
|
|
2016-03-17 16:54:31 +03:00
|
|
|
set -e
|
|
|
|
|
|
|
|
: ${AWK:=awk}
|
2008-10-26 02:18:15 +04:00
|
|
|
: ${SED:=sed}
|
2008-10-20 02:10:04 +04:00
|
|
|
|
2016-03-17 16:54:31 +03:00
|
|
|
in=tmpi$$.c
|
|
|
|
out=tmpo$$.c
|
|
|
|
ecode=1
|
|
|
|
trapsigs='0 1 2 13 15'
|
|
|
|
trap 'rm -f $in $out; trap 0; exit $ecode' $trapsigs
|
2016-03-17 02:01:33 +03:00
|
|
|
|
2016-03-17 16:54:31 +03:00
|
|
|
CPP="${1-cc -E}"
|
|
|
|
|
|
|
|
# The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap
|
|
|
|
(trap $trapsigs;
|
|
|
|
echo '#include "sh.h"';
|
|
|
|
echo ' { QwErTy SIGNALS , "DUMMY" , "hook for number of signals" },';
|
|
|
|
${SED} -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\
|
|
|
|
{ QwErTy .signal = SIG\1 , .name = "\1", .mess = "\2" },\
|
|
|
|
#endif/') > $in
|
|
|
|
# work around for gcc 5
|
2016-03-17 16:59:02 +03:00
|
|
|
$CPP $in | grep -v '^#' | tr -d '\n' | ${SED} 's/},/},\
|
2016-03-17 16:54:31 +03:00
|
|
|
/g' > $out
|
|
|
|
${SED} -n 's/{ QwErTy/{/p' < $out | ${AWK} '{print NR, $0}' | sort -k 5n -k 1n |
|
|
|
|
${SED} 's/^[0-9]* //' |
|
|
|
|
${AWK} 'BEGIN { last=0; nsigs=0; }
|
|
|
|
{
|
|
|
|
if ($4 ~ /^[0-9][0-9]*$/ && $5 == ",") {
|
|
|
|
n = $4;
|
|
|
|
if (n > 0 && n != last) {
|
|
|
|
while (++last < n) {
|
|
|
|
printf "\t{ .signal = %d , .name = NULL, .mess = `Signal %d` } ,\n", last, last;
|
|
|
|
}
|
|
|
|
print;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}' |
|
|
|
|
tr '`' '"' | grep -v '"DUMMY"'
|
|
|
|
ecode=0
|