Make this a bit less fork-happy.

This commit is contained in:
mycroft 1998-07-03 17:50:10 +00:00
parent 39fbcd87b6
commit b742a40a8c
1 changed files with 22 additions and 13 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh -
# $NetBSD: makelintstub,v 1.3 1998/03/01 10:20:06 fvdl Exp $
# $NetBSD: makelintstub,v 1.4 1998/07/03 17:50:10 mycroft Exp $
#
# Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
#
@ -71,25 +71,30 @@ header()
syscall_stub()
{
syscallhdr="$1"
syscalldump="$1"
syscallname="$2"
funcname="$3"
arglist="`printf '#include "'"$syscallhdr"'"' | cpp -C | \
grep '^/\* syscall: "'"$syscallname"'" ' | \
sed -e 's,^/\* syscall: ,,;s, \*/$,,'`"
arglist="`
sed -e 'ta
:a
s,^/\* syscall: "'"$syscallname"'" ,,
tb
d
:b
s, \*/$,,' $syscalldump
`"
eval set -f -- "$arglist"
if [ $# -lt 4 ]; then
if [ $# -lt 3 ]; then
echo syscall $syscallname not found! 1>&2
exit 1
fi
syscallname=$1
shift 2 # kill name and "ret:"
returntype=$1
shift 2 # kill return type and "args:"
shift # kill "ret:"
returntype=$1; shift
shift # kill "args:"
cat <<- __EOF__
/*ARGSUSED*/
@ -176,6 +181,7 @@ pflag=NO
nflag=NO
oarg=""
syscallhdr=/usr/include/sys/syscall.h
syscalldump=/tmp/makelintstub.$$
if test $? -ne 0; then
usage
@ -200,15 +206,18 @@ if [ "X$oarg" != "X" ]; then
exec > $oarg
fi
trap "rm -f $syscalldump" 0 1 2 15
header
printf '#include "'"$syscallhdr"'"' | cpp -C >$syscalldump
for syscall; do
fnname=`echo $syscall | sed -e 's,\.o$,,'`
fnname=${syscall%.o}
if [ $pflag = YES ]; then
scname=`echo $fnname | sed -e 's,^_,,'`
scname=${fnname#_}
else
scname=$fnname
fi
syscall_stub $syscallhdr $scname $fnname
syscall_stub $syscalldump $scname $fnname
echo ""
done
trailer