blob: d4bcda94e740c6e8cf8496d7db44196946ce5403 (
plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#! /bin/sh
t=__wt.$$
trap 'rm -f $t' 0 1 2 3 13 15
# Insulate against locale-specific sort order and IFS from the user's env
LC_ALL=C
export LC_ALL
IFS=' '' ''
'
export IFS
build() {
# Build the standard typedefs.
f=../src/include/wt_internal.h
(sed -e '/Forward type declarations .*: BEGIN/{' \
-e 'n' \
-e 'q' \
-e '}' < $f
l=`ls ../src/include/*.[hi] ../src/include/*.in |
sed -e '/wiredtiger.*/d' -e '/queue.h/d'`
egrep -h \
'^[ ]*(((struct|union)[ ].*__wt_.*{)|WT_PACKED_STRUCT_BEGIN)' \
$l |
sed -e 's/WT_PACKED_STRUCT_BEGIN(\(.*\))/struct \1 {/' \
-e 's/WT_COMPILER_TYPE_ALIGN(.*)[ ]*//' \
-e 's/^[ ]*//' -e 's/[ ]*{.*//' | sort -u | \
while read t n; do
upper=`echo $n | sed -e 's/^__//' | tr [a-z] [A-Z]`
echo "$t $n;"
echo " typedef $t $n $upper;"
done
echo '/*'
sed -e '/Forward type declarations .*: END/,${' \
-e 'p' \
-e '}' \
-e 'd' < $f) > $t
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f)
}
check() {
# Complain about unused #typedefs.
# List of files to search.
l=`sed -e '/^[a-z]/!d' -e 's/[ ].*$//' -e 's,^,../,' filelist`
l="$l `echo ../src/utilities/*.c`"
(
# Get the list of typedefs
search=`cat ../src/include/*.h ../src/include/*.in |
sed -e 's/^struct.*typedef.* \(.*\);$/\1/p' \
-e 's/^union.*typedef.* \(.*\);$/\1/p' \
-e d |
sort -u`
echo "$search"
fgrep -who "$search" $l
) | sort | uniq -u > $t
test -s $t && cat $t
}
usage()
{
echo 'usage: s_typedef [-bc]' >&2
exit 1
}
test "$#" -eq 1 || usage
while :
do case "$1" in
-b) # -b builds the typedefs
build
shift;;
-c) # -c checks the typedefs
check
shift;;
*)
test "$#" -eq 0 || usage
break;;
esac
done
exit 0
|