| @@ -1,42 +1,42 @@ | | | @@ -1,42 +1,42 @@ |
1 | #!/bin/sh | | 1 | #!/bin/sh |
2 | # $NetBSD: siglist.sh,v 1.8 2008/10/25 22:18:15 apb Exp $ | | 2 | # $NetBSD: siglist.sh,v 1.9 2011/01/23 17:11:55 hauke Exp $ |
3 | # | | 3 | # |
4 | # Script to generate a sorted, complete list of signals, suitable | | 4 | # Script to generate a sorted, complete list of signals, suitable |
5 | # for inclusion in trap.c as array initializer. | | 5 | # for inclusion in trap.c as array initializer. |
6 | # | | 6 | # |
7 | | | 7 | |
8 | set -e | | 8 | set -e |
9 | | | 9 | |
10 | : ${AWK:=awk} | | 10 | : ${AWK:=awk} |
11 | : ${SED:=sed} | | 11 | : ${SED:=sed} |
12 | | | 12 | |
13 | in=tmpi$$.c | | 13 | in=tmpi$$.c |
14 | out=tmpo$$.c | | 14 | out=tmpo$$.c |
15 | ecode=1 | | 15 | ecode=1 |
16 | trapsigs='0 1 2 13 15' | | 16 | trapsigs='0 1 2 13 15' |
17 | trap 'rm -f $in $out; trap 0; exit $ecode' $trapsigs | | 17 | trap 'rm -f $in $out; trap 0; exit $ecode' $trapsigs |
18 | | | 18 | |
19 | CPP="${1-cc -E}" | | 19 | CPP="${1-cc -E}" |
20 | | | 20 | |
21 | # The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap | | 21 | # The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap |
22 | (trap $trapsigs; | | 22 | (trap $trapsigs; |
23 | echo '#include "sh.h"'; | | 23 | echo '#include "sh.h"'; |
24 | echo ' { QwErTy SIGNALS , "DUMMY" , "hook for number of signals" },'; | | 24 | echo ' { QwErTy SIGNALS , "DUMMY" , "hook for number of signals" },'; |
25 | ${SED} -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\ | | 25 | ${SED} -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\ |
26 | { QwErTy .signal = SIG\1 , .name = "\1", .mess = "\2" },\ | | 26 | { QwErTy .signal = SIG\1 , .name = "\1", .mess = "\2" },\ |
27 | #endif/') > $in | | 27 | #endif/') > $in |
28 | $CPP $in > $out | | 28 | $CPP $in > $out |
29 | ${SED} -n 's/{ QwErTy/{/p' < $out | ${AWK} '{print NR, $0}' | sort -k5n -k1n | | | 29 | ${SED} -n 's/{ QwErTy/{/p' < $out | ${AWK} '{print NR, $0}' | sort -k 5n -k 1n | |
30 | ${SED} 's/^[0-9]* //' | | | 30 | ${SED} 's/^[0-9]* //' | |
31 | ${AWK} 'BEGIN { last=0; nsigs=0; } | | 31 | ${AWK} 'BEGIN { last=0; nsigs=0; } |
32 | { | | 32 | { |
33 | if ($4 ~ /^[0-9][0-9]*$/ && $5 == ",") { | | 33 | if ($4 ~ /^[0-9][0-9]*$/ && $5 == ",") { |
34 | n = $4; | | 34 | n = $4; |
35 | if (n > 0 && n != last) { | | 35 | if (n > 0 && n != last) { |
36 | while (++last < n) { | | 36 | while (++last < n) { |
37 | printf "\t{ .signal = %d , .name = NULL, .mess = `Signal %d` } ,\n", last, last; | | 37 | printf "\t{ .signal = %d , .name = NULL, .mess = `Signal %d` } ,\n", last, last; |
38 | } | | 38 | } |
39 | print; | | 39 | print; |
40 | } | | 40 | } |
41 | } | | 41 | } |
42 | }' | | | 42 | }' | |