123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- #!/bin/sh
- # (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
- # See the copyright notice in the ACK home directory, in the file "Copyright".
- #
- # $Id$
- # L I N T D R I V E R
- PATH=/bin:/usr/bin
- EMDIR=/usr/em
- EMLINT=$EMDIR/lib.bin/lint
- INCLUDES=-I$EMDIR/include/_tail_cc
- #LDEFMACH=-Dmc68000
- PARAMS1=$LDEFMACH
- LPASS1=${LPASS1-"$EMLINT/lpass1"} # pass 1 program
- LPASS2=${LPASS2-"$EMLINT/lpass2"} # pass 2 program
- LLIB=${LLIB-"$EMLINT/llib"} # lint libraries directory
- LINTLIB=${LINTLIB-$LLIB}
- CLIB=c.llb
- TMP=/tmp/lint1.$$
- NEW=/tmp/lint2.$$
- trap "rm -f $TMP $NEW; exit 1" 1 2 15
- trap "rm -f $TMP $NEW; exit 0" 0
- set dummy $LINTFLAGS "$@" # dummy as a shield for $LINTFLAGS
- shift # remove dummy
- LIBRARY=
- # get the non-library options
- while test -n "$1"
- do
- case "$1" in
- -ansi) LPASS1=${LPASS1}.ansi
- INCLUDES=-I$EMDIR/include/tail_ac
- CLIB=ansi_c.llb
- shift
- ;;
- -l*) # library parameter; start pass 1
- break
- ;;
- -KR) # strictly Kernighan & Ritchie, pass 1
- PARAMS1="$PARAMS1 -R"
- shift
- ;;
- -D*=*) # Define with equal sign; for pass 1 only
- # be careful about funny characters in -D
- # this is still not entirely correct
- HD=`expr "$1" : '\([^=]*\)=.*'`
- TL=`expr "$1" : '[^=]*=\(.*\)'`
- PARAMS1="$PARAMS1 $HD='$TL'"
- shift
- ;;
- -[DUI]*)# Define, Undef and Include, otherwise; for pass 1 only
- # this is the simple case
- PARAMS1="$PARAMS1 $1"
- shift
- ;;
- -L*) # make a lint library
- LIBRARY=`expr "$1" : '-L\(.*\)'`
- shift
- ;;
- -*) # for pass 1 or pass 2
- PARAMS1="$PARAMS1 $1"
- PARAMS2="$PARAMS2 $1"
- shift
- ;;
- *) # input file; start pass 1
- break
- ;;
- esac
- done
- case "$LIBRARY" in
- '') # normal lint; we want its messages on stdout; this takes some doing
- ( # intermediate file has to go to stdout for pipe connection
- ( # pass 1: messages to stderr
- LIBC=true # true if $CLIB to be included
- STATNR=0 # static scope number
- for F in $*
- do
- case $F in
- -l) # do NOT include $CLIB
- LIBC=false
- ;;
- -lc) # do include $CLIB
- LIBC=true
- ;;
- -l*) # include special lint library
- cat $LINTLIB/`expr $F : '-l\(.*\)'`.llb
- ;;
- *.c) # a real C-file
- STATNR=` expr $STATNR + 1 `
- eval "$LPASS1 -S$STATNR -Dlint \
- $PARAMS1 $INCLUDES $F"
- ;;
- *) # a lint library?
- case `basename $F` in
- *.llb) # yes, it is
- cat $F
- ;;
- *)
- echo $0: unknown input $F >&2
- ;;
- esac
- ;;
- esac
- done
- case "$LIBC" in
- true) # append $CLIB
- cat $LINTLIB/$CLIB
- ;;
- esac
- ) |
- sort -u |
- ( # pass 2: divert messages to avoid interleaving
- $LPASS2 $PARAMS2 2>$TMP
- )
- ) 2>&1 # messages pass 1 to stdout
- # append messages pass 2
- cat $TMP
- ;;
- ?*) # making a lint library
- set -e # stop at first sign of trouble
- case `basename $LIBRARY` in
- *.llb) # OK
- ;;
- *) # no suffix .llb
- LIBRARY=$LIBRARY.llb
- ;;
- esac
- if test ! -r $LIBRARY
- then cp /dev/null $LIBRARY
- fi
- # collect pass 1 intermediate output for all input files
- for F in $@
- do
- case $F in
- *.c) # a C file
- eval "$LPASS1 $PARAMS1 $INCLUDES -Dlint -L $F"
- ;;
- *) # a library?
- case `basename $F` in
- *.llb) # yes, it is
- cat $F
- ;;
- *)
- echo $0: unknown input $F >&2
- ;;
- esac
- ;;
- esac
- done >$NEW
- # get the last line for each name and sort them
- cat $LIBRARY $NEW |
- awk -F: '
- {
- entry[$1] = $0;
- }
- END {
- for (e in entry) {print entry[e];}
- }
- ' |
- sort |
- grep -v '^main:' >$TMP
- cp $TMP $LIBRARY
- esac
- rm -f $TMP $NEW
|