File: checkInternalPrototype.sh

package info (click to toggle)
crossfire 1.71.0%2Bdfsg1-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 28,076 kB
  • sloc: ansic: 85,126; sh: 11,978; perl: 2,659; lex: 2,044; makefile: 1,271
file content (32 lines) | stat: -rwxr-xr-x 812 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

#
# This will scan the whole source tree and given file in argument
# for functions that should go static or are dead
#
# example invocation:
# utils/checkInternalPrototype.sh common/object.c
#
FILENAME=$1
BASENAME=`basename $FILENAME`
TEMPNAME=`tempfile`
INTERNAL_METHODS=
methods=`cproto $FILENAME -I include/ -f 1 | sed -e 's/\([^ ]\{1,\} \)\{1,\}\**\([^ ]\{1,\}\)();/\2/' -e 's/\/\*.*\*\///'`
rm $TEMPNAME
find * -iname '*.c' -and -not -iname $BASENAME -exec cat '{}' ';' > $TEMPNAME
for i in $methods
do
MATCH=`grep -l -e "$i *(" $TEMPNAME`
if test "x$MATCH" = x; then
INTERNAL_METHODS="$INTERNAL_METHODS $i"
fi
done
for i in $INTERNAL_METHODS
do
MATCH=`grep -l -e "$i *(" $FILENAME`
if test "x$MATCH" != x; then
echo $i should be static
else
echo "$i seems a dead function (not called)"
fi
done