This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[UTIL] Perl system does not default to $_
[metaconfig.git] / dist / U / sig_name.U
CommitLineData
c6667804 1?RCS: $Id$
d8875586
MBT
2?RCS:
3?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
4?RCS:
c6667804 5?RCS: You may redistribute only under the terms of the Artistic License,
d8875586
MBT
6?RCS: as specified in the README file that comes with the distribution.
7?RCS: You may reuse parts of this distribution only within the terms of
c6667804 8?RCS: that same Artistic License; a copy of which may be found at the root
d8875586
MBT
9?RCS: of the source tree for dist 4.0.
10?RCS:
11?RCS: $Log: sig_name.U,v $
12?RCS: Revision 3.0.1.5 1997/02/28 16:21:25 ram
13?RCS: patch61: brand new algorithm for sig_name and (new!) sig_num
14?RCS:
15?RCS: Revision 3.0.1.4 1995/07/25 14:14:54 ram
16?RCS: patch56: added <asm/signal.h> lookup for linux
17?RCS:
18?RCS: Revision 3.0.1.3 1995/05/12 12:24:11 ram
19?RCS: patch54: now looks for <linux/signal.h> too (ADO)
20?RCS:
21?RCS: Revision 3.0.1.2 1994/06/20 07:06:57 ram
22?RCS: patch30: final echo was missing to close awk-printed string
23?RCS:
24?RCS: Revision 3.0.1.1 1994/05/06 15:17:55 ram
25?RCS: patch23: signal list now formatted to avoid scroll-ups (ADO)
26?RCS:
27?RCS: Revision 3.0 1993/08/18 12:09:47 ram
28?RCS: Baseline for dist 3.0 netwide release.
29?RCS:
30?MAKE:sig_name sig_name_init sig_num sig_num_init sig_count sig_size: \
31 awk Signal Oldconfig rm
32?MAKE: -pick add $@ %<
33?S:sig_name:
34?S: This variable holds the signal names, space separated. The leading
35?S: SIG in signal name is removed. A ZERO is prepended to the
36?S: list. This is currently not used.
37?S:.
38?S:sig_name_init:
39?S: This variable holds the signal names, enclosed in double quotes and
40?S: separated by commas, suitable for use in the SIG_NAME definition
41?S: below. A "ZERO" is prepended to the list, and the list is
42?S: terminated with a plain 0. The leading SIG in signal names
43?S: is removed. See sig_num.
44?S:.
45?S:sig_num:
46?S: This variable holds the signal numbers, space separated. A ZERO is
47?S: prepended to the list (corresponding to the fake SIGZERO), and
48?S: the list is terminated with a 0. Those numbers correspond to
49?S: the value of the signal listed in the same place within the
50?S: sig_name list.
51?S:.
52?S:sig_num_init:
53?S: This variable holds the signal numbers, enclosed in double quotes and
54?S: separated by commas, suitable for use in the SIG_NUM definition
55?S: below. A "ZERO" is prepended to the list, and the list is
56?S: terminated with a plain 0.
57?S:.
58?S:sig_count (sig_name.U):
59?S: This variable holds a number larger than the largest valid
60?S: signal number. This is usually the same as the NSIG macro.
61?S:.
62?S:sig_size:
63?S: This variable contains the number of elements of the sig_name
64?S: and sig_num arrays, excluding the final NULL entry.
65?S:.
66?C:SIG_NAME:
67?C: This symbol contains a list of signal names in order of
68?C: signal number. This is intended
69?C: to be used as a static array initialization, like this:
70?C: char *sig_name[] = { SIG_NAME };
71?C: The signals in the list are separated with commas, and each signal
72?C: is surrounded by double quotes. There is no leading SIG in the signal
73?C: name, i.e. SIGQUIT is known as "QUIT".
74?C: Gaps in the signal numbers (up to NSIG) are filled in with NUMnn,
75?C: etc., where nn is the actual signal number (e.g. NUM37).
76?C: The signal number for sig_name[i] is stored in sig_num[i].
77?C: The last element is 0 to terminate the list with a NULL. This
78?C: corresponds to the 0 at the end of the sig_num list.
79?C:.
80?C:SIG_NUM:
81?C: This symbol contains a list of signal numbers, in the same order as the
82?C: SIG_NAME list. It is suitable for static array initialization, as in:
83?C: int sig_num[] = { SIG_NUM };
84?C: The signals in the list are separated with commas, and the indices
85?C: within that list and the SIG_NAME list match, so it's easy to compute
86?C: the signal name from a number or vice versa at the price of a small
87?C: dynamic linear lookup.
88?C: Duplicates are allowed, but are moved to the end of the list.
89?C: The signal number corresponding to sig_name[i] is sig_number[i].
90?C: if (i < NSIG) then sig_number[i] == i.
91?C: The last element is 0, corresponding to the 0 at the end of
92?C: the sig_name list.
93?C:.
94?C:SIG_COUNT:
95?C: This variable contains a number larger than the largest
96?C: signal number. This is usually the same as the NSIG macro.
97?C:.
98?C:SIG_SIZE:
99?C: This variable contains the number of elements of the sig_name
100?C: and sig_num arrays, excluding the final NULL entry.
101?C:.
102?H:#define SIG_NAME $sig_name_init /**/
103?H:#define SIG_NUM $sig_num_init /**/
104?H:#define SIG_COUNT $sig_count /**/
105?H:#define SIG_SIZE $sig_size /**/
106?H:.
107?T:i doinit
108?F:!= !signal_cmd
109?X: signal.cmd creates a file signal.lst which has two columns:
110?X: NAME number, e.g.
111?X: HUP 1
112?X: The list is sorted on signal number, with duplicates moved to
113?X: the end..
114: generate list of signal names
115echo " "
116case "$sig_name_init" in
117'') doinit=yes ;;
118*) case "$sig_num_init" in
119 ''|*,*) doinit=yes ;;
120 esac ;;
121esac
122case "$doinit" in
123yes)
124 echo "Generating a list of signal names and numbers..." >&4
125 . ./signal_cmd
126 sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
127 sig_name=`$awk 'BEGIN { printf "ZERO " }
128 !/^NSIG/ { printf "%s ", $1 }' signal.lst`
129 sig_num=`$awk 'BEGIN { printf "0 " }
130 !/^NSIG/ { printf "%d ", $2 }' signal.lst`
131 sig_name_init=`$awk 'BEGIN { printf "\"ZERO\", " }
132 !/^NSIG/ { printf "\"%s\", ", $1 }
133 END { printf "0\n" }' signal.lst`
134 sig_num_init=`$awk 'BEGIN { printf "0, " }
135 !/^NSIG/ { printf "%d, ", $2}
136 END { printf "0\n"}' signal.lst`
137 ;;
138esac
139echo "The following $sig_count signals are available:"
140echo " "
141echo $sig_name | $awk \
142'BEGIN { linelen = 0 }
143{
144 for (i = 1; i <= NF; i++) {
145 name = "SIG" $i " "
146 linelen = linelen + length(name)
147 if (linelen > 70) {
148 printf "\n"
149 linelen = length(name)
150 }
151 printf "%s", name
152 }
153 printf "\n"
154}'
155sig_size=`echo $sig_name | awk '{print NF}'`
156$rm -f signal signal.c signal.awk signal.lst signal_cmd
157