No empty .Rs/.Re
[netbsd-mini2440.git] / usr.bin / ktruss / makeerrnos.sh
blobd4a8a4a9576f73e1bdef5e476561f8ba400e161c
1 #! /bin/sh
3 # $NetBSD: makeerrnos.sh,v 1.4 2005/07/17 09:45:50 he Exp $
5 if [ $# -ne 3 ]; then
6 echo "usage: makeerrnos.sh errno.h signal.h output"
7 exit 1;
8 fi
10 ERRNOH=$1
11 SIGNALH=$2
12 CFILE=$3.c
13 HFILE=$3.h
15 : ${AWK:=awk}
16 : ${CPP:=cpp}
17 : ${CPPFLAGS:=}
19 cat <<__EOF__ > $CFILE
20 #include "misc.h"
22 struct systab errnos[] = {
23 __EOF__
24 cat ${ERRNOH} | ${CPP} ${CPPFLAGS} -dM |
25 ${AWK} '
26 /^#[ ]*define[ ]*E[A-Z0-9]*[ ]*[0-9-][0-9]*[ ]*.*/ {
27 for (i = 1; i <= NF; i++)
28 if ($i ~ /define/)
29 break;
30 i++;
31 j = i + 1;
33 printf("\t{ \"%s\", %s },\n", $i, $j);
35 END {
36 print " { \"0\", 0 },\n";
38 ' | sort -n +2 >> $CFILE
39 echo " { 0L, 0},
40 };" >> $CFILE
41 lines=`wc -l $CFILE | ${AWK} ' { print $1; } ' -`
42 lines=`expr $lines - 4`
44 cat <<__EOF__ >> $CFILE
46 struct systab signals[] = {
47 __EOF__
48 cat ${SIGNALH} | ${CPP} ${CPPFLAGS} -dM |
49 ${AWK} '
50 /^#[ ]*define[ ]*S[A-Z0-9]*[ ]*[0-9-][0-9]*[ ]*.*/ {
51 for (i = 1; i <= NF; i++)
52 if ($i ~ /define/)
53 break;
54 i++;
55 j = i + 1;
57 printf("\t{ \"%s\", %s },\n", $i, $j);
59 END {
60 print " { \"0\", 0 },\n";
62 ' | sort -n +2 >> $CFILE
63 echo " { 0L, 0},
64 };" >> $CFILE
65 elines=`grep '{ "SIG' $CFILE | wc -l`
66 elines=`expr $elines + 1`
68 cat <<__EOF__ >$HFILE
69 struct systab {
70 const char *name;
71 int value;
74 extern struct systab errnos[$lines + 1];
75 extern struct systab signals[$elines + 1];
77 #define MAXERRNOS $lines
78 #define MAXSIGNALS $elines
79 __EOF__