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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
#!/bin/sh
#
# Hunt for __pmFoo stuff that is the target of migration
#
if [ -z "$1" ]
then
echo >&2 "Usage: hunter <__pmFoo>"
exit 1
fi
tmp=/var/tmp/$$
trap "rm -f $tmp.*; exit 0" 0 1 2 3 15
out=/tmp/hunted
rm -f $out
# exact match
tail="[^a-zA-Z0-9_]"
# prefix match
tail=""
full=true
full=false
rm -f $tmp.*
find src man qa books -type f \
| while read file
do
if $full
then
echo "$file"
else
case "$file"
in
# known to be already fixed completely
#
src/pmlogger/src/*|src/dbpmda/src/*|src/pmval/*.c)
;;
# ones already fixed indirectly thru a local header
#
src/pmcd/src/*.c|src/pmcd/src/client.h|src/pmcd/src/pmcd.h)
;;
src/pmdas/weblog/pmda.c|src/pmdas/weblog/sproc.c|src/pmdas/weblog/weblog.c)
;;
src/pmproxy/client.c|src/pmproxy/pmproxy.c)
;;
src/pmie/src/andor.c|src/pmie/src/dstruct.c|src/pmie/src/eval.c|src/pmie/src/grammar.y|src/pmie/src/lexicon.c|src/pmie/src/match_inst.c|src/pmie/src/pmie.c|src/pmie/src/pragmatics.c|src/pmie/src/show.c|src/pmie/src/symbol.c|src/pmie/src/syntax.c|src/pmie/src/systemlog.c)
;;
src/pmchart/*.cpp)
;;
src/pmlogreduce/domentric.c|src/pmlogreduce/indom.c|src/pmlogreduce/logio.c|src/pmlogreduce/pmlogreduce.c|src/pmlogreduce/rewrite.c|src/pmlogreduce/scan.c|src/pmlogreduce/util.c)
;;
src/pmlogreduce_new/indom.c|src/pmlogreduce_new/logio.c|src/pmlogreduce_new/pmlogreduce.c|src/pmlogreduce_new/rewrite.c|src/pmlogreduce_new/scan.c|src/pmlogreduce_new/util.c)
;;
src/pmseries/load.c|src/pmseries/pmseries.c|src/pmseries/query_parser.y|src/pmseries/series.c)
# load.h
;;
src/libpcp_pmcd/src/trace.c)
# ../../pmcd/src/pmcd.h
;;
src/pmdas/linux/*.c)
# linux.h
;;
src/pmdas/pipe/pipe.c)
# event.h
;;
src/perl/PMDA/local.c|src/perl/PMDA/PMDA.c|src/perl/PMDA/PMDA.xs)
# local.h
;;
src/pmdas/trace/src/client.h)
# all includers include libpcp.h first
;;
src/pmdas/cisco/cisco.c|src/pmdas/cisco/interface.c|src/pmdas/cisco/pmda.c|src/pmdas/cisco/probe.c|src/pmdas/cisco/telnet.c)
# cisco.h
;;
src/libpcp_pmcd/src/client.c|src/libpcp_pmcd/src/data.c|src/libpcp_pmcd/src/trace.c)
# ../../../src/pmcd/src/pmcd.h
;;
# special ones to skip
qa/src/libpcp.h|src/libpcp/src/internal.h)
;;
qa/valgrind-*)
;;
*)
echo "$file"
;;
esac
fi
done \
| while read file
do
case $file
in
*.c|*.h|*.cpp|*.cxx|*.in|*.y|*.l|*.xs|*/|*.[1-8])
sed -e 's/$/ /' -e 's/^/ /' $file \
| grep -E "[^a-zA-Z_0-9]$1$tail" \
| sed -e "s@^ @$file:@" -e 's/ $//' >>$tmp.out
;;
esac
done
grep /include/ $tmp.out >$tmp.tmp
if [ -s $tmp.tmp ]
then
echo | tee -a $out
echo "Header files ..." | tee -a $out
cat $tmp.tmp | tee -a $out
grep -v /include/ $tmp.out >$tmp.tmp; mv $tmp.tmp $tmp.out
fi
grep '^src/' $tmp.out >$tmp.tmp
if [ -s $tmp.tmp ]
then
echo | tee -a $out
echo "Source ..." | tee -a $out
cat $tmp.tmp \
| while read line
do
if $full
then
echo "$line" | tee -a $out
else
file=`echo "$line" | sed -e 's/:.*//'`
if grep "include.*libpcp.h" <$file >/dev/null
then
# done already
:
else
echo "$line" | tee -a $out
fi
fi
done
grep -v '^src/' $tmp.out >$tmp.tmp; mv $tmp.tmp $tmp.out
fi
grep '^man/man' $tmp.out >$tmp.tmp
if [ -s $tmp.tmp ]
then
echo | tee -a $out
echo "Man pages ..." | tee -a $out
cat $tmp.tmp | tee -a $out
grep -v '^man/man' $tmp.out >$tmp.tmp; mv $tmp.tmp $tmp.out
fi
grep '^qa/' $tmp.out >$tmp.tmp
if [ -s $tmp.tmp ]
then
echo | tee -a $out
echo "QA ..." | tee -a $out
cat $tmp.tmp \
| while read line
do
file=`echo "$line" | sed -e 's/:.*//'`
if grep "include.*libpcp.h" <$file >/dev/null
then
# done already
:
else
echo "$line" | tee -a $out
fi
done
grep -v '^qa/' $tmp.out >$tmp.tmp; mv $tmp.tmp $tmp.out
fi
if [ -s $tmp.out ]
then
echo | tee -a $out
echo "Others ..." | tee -a $out
cat $tmp.out | tee -a $out
fi
|