2 # (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 # See the copyright notice in the ACK home directory, in the file "Copyright".
5 # $Id: lint,v 1.9 1994/09/16 12:41:55 ceriel Exp $
12 EMLINT=$EMDIR/lib.bin/lint
13 INCLUDES=-I$EMDIR/include/_tail_cc
18 LPASS1=${LPASS1-"$EMLINT/lpass1"} # pass 1 program
19 LPASS2=${LPASS2-"$EMLINT/lpass2"} # pass 2 program
20 LLIB=${LLIB-"$EMLINT/llib"} # lint libraries directory
22 LINTLIB=${LINTLIB-$LLIB}
28 trap "rm -f $TMP $NEW; exit 1" 1 2 15
29 trap "rm -f $TMP $NEW; exit 0" 0
31 set dummy $LINTFLAGS "$@" # dummy as a shield for $LINTFLAGS
36 # get the non-library options
40 -ansi) LPASS1=${LPASS1}.ansi
41 INCLUDES=-I$EMDIR/include/tail_ac
45 -l*) # library parameter; start pass 1
48 -KR) # strictly Kernighan & Ritchie, pass 1
52 -D*=*) # Define with equal sign; for pass 1 only
53 # be careful about funny characters in -D
54 # this is still not entirely correct
55 HD=`expr "$1" : '\([^=]*\)=.*'`
56 TL=`expr "$1" : '[^=]*=\(.*\)'`
57 PARAMS1="$PARAMS1 $HD='$TL'"
60 -[DUI]*)# Define, Undef and Include, otherwise; for pass 1 only
61 # this is the simple case
65 -L*) # make a lint library
66 LIBRARY=`expr "$1" : '-L\(.*\)'`
69 -*) # for pass 1 or pass 2
74 *) # input file; start pass 1
81 '') # normal lint; we want its messages on stdout; this takes some doing
82 ( # intermediate file has to go to stdout for pipe connection
83 ( # pass 1: messages to stderr
84 LIBC=true # true if $CLIB to be included
85 STATNR=0 # static scope number
90 -l) # do NOT include $CLIB
93 -lc) # do include $CLIB
96 -l*) # include special lint library
97 cat $LINTLIB/`expr $F : '-l\(.*\)'`.llb
100 STATNR=` expr $STATNR + 1 `
101 eval "$LPASS1 -S$STATNR -Dlint \
102 $PARAMS1 $INCLUDES $F"
105 case `basename $F` in
110 echo $0: unknown input $F >&2
124 ( # pass 2: divert messages to avoid interleaving
125 $LPASS2 $PARAMS2 2>$TMP
127 ) 2>&1 # messages pass 1 to stdout
129 # append messages pass 2
133 ?*) # making a lint library
134 set -e # stop at first sign of trouble
136 case `basename $LIBRARY` in
144 if test ! -r $LIBRARY
145 then cp /dev/null $LIBRARY
148 # collect pass 1 intermediate output for all input files
153 eval "$LPASS1 $PARAMS1 $INCLUDES -Dlint -L $F"
156 case `basename $F` in
161 echo $0: unknown input $F >&2
168 # get the last line for each name and sort them
175 for (e in entry) {print entry[e];}
179 grep -v '^main:' >$TMP