Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/ksh put back the complex sed/awk since the code can't ha...
details: https://anonhg.NetBSD.org/src/rev/320a9582ed17
branches: trunk
changeset: 344231:320a9582ed17
user: christos <christos%NetBSD.org@localhost>
date: Thu Mar 17 13:54:31 2016 +0000
description:
put back the complex sed/awk since the code can't handle unsorted or repeated
entries (Rin Okuyama)
diffstat:
bin/ksh/siglist.sh | 42 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 37 insertions(+), 5 deletions(-)
diffs (55 lines):
diff -r 8316c37d9ed9 -r 320a9582ed17 bin/ksh/siglist.sh
--- a/bin/ksh/siglist.sh Thu Mar 17 09:44:56 2016 +0000
+++ b/bin/ksh/siglist.sh Thu Mar 17 13:54:31 2016 +0000
@@ -1,14 +1,46 @@
#!/bin/sh
-# $NetBSD: siglist.sh,v 1.10 2016/03/16 23:01:33 christos Exp $
+# $NetBSD: siglist.sh,v 1.11 2016/03/17 13:54:31 christos Exp $
#
# Script to generate a sorted, complete list of signals, suitable
# for inclusion in trap.c as array initializer.
#
+set -e
+
+: ${AWK:=awk}
: ${SED:=sed}
+in=tmpi$$.c
+out=tmpo$$.c
+ecode=1
+trapsigs='0 1 2 13 15'
+trap 'rm -f $in $out; trap 0; exit $ecode' $trapsigs
+
+CPP="${1-cc -E}"
+
# The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap
-
-${SED} -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\
- { .signal = SIG\1 , .name = "\1", .mess = "\2" },\
-#endif/'
+(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
+$CPP $in | grep -v '^#' | tr -d '\n' | sed 's/},/},\
+/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
Home |
Main Index |
Thread Index |
Old Index