cleanup script; no functional change

This commit is contained in:
ehouse 2009-12-27 17:36:18 +00:00
parent d80c04dd6b
commit fe69b8403e

View file

@ -3,34 +3,36 @@
ID_FILE=${ID_FILE:-./strids.h} ID_FILE=${ID_FILE:-./strids.h}
if [ ! -f $ID_FILE ]; then if [ ! -f $ID_FILE ]; then
echo "$ID_FILE not found" echo "$0: $ID_FILE not found"
exit 0; exit 0;
elif [ -z "$1" ]; then elif [ -z "$1" ]; then
echo "usage: <rc file> [<rc file>*]" echo "usage: <rc file> [<rc file>*]"
fi fi
while [ -n "$1" ]; do while [ -n "$1" ]; do
RC_FILE=$1
cat $ID_FILE | grep '^# *define.* IDS' \ cat $ID_FILE | grep '^# *define.* IDS' \
| sed 's/^# *define *\(IDS_.*\) .*$/\1/' \ | sed 's/^# *define *\(IDS_.*\) .*$/\1/' \
| while read ID; do | while read ID; do
COUNT=$(grep -w -c $ID $1) COUNT=$(grep -w -c $ID $RC_FILE)
if [ 0 -eq "$COUNT" ]; then if [ 0 -eq "$COUNT" ]; then
echo $ID not found in $1 echo $ID not found in $RC_FILE
elif [ 1 -lt "$COUNT" ]; then elif [ 1 -lt "$COUNT" ]; then
echo "$ID found $COUNT times in $1" echo "$ID found $COUNT times in $RC_FILE"
fi fi
if ! grep -q $ID *.c; then if ! grep -q $ID *.c; then
echo $ID not used in any .c file echo $ID not used in any .c file
fi fi
done done
grep '^\s*IDS_.*' $1 | sed 's/^ *\(IDS[A-Z_]*\).*$/\1/' | sort -u > /tmp/ids_cur$$.txt grep '^\s*IDS_.*' "$RC_FILE" | sed 's/^ *\(IDS[A-Z_]*\).*$/\1/' | \
sort -u > /tmp/ids_cur$$.txt
if [ -e /tmp/ids_prev$$.txt ]; then if [ -e /tmp/ids_prev$$.txt ]; then
echo -e "\ncomparing IDs in $1, $PREV" echo -e "\ncomparing IDs in $RC_FILE, $PREV"
diff /tmp/ids_prev$$.txt /tmp/ids_cur$$.txt diff /tmp/ids_prev$$.txt /tmp/ids_cur$$.txt
fi fi
mv /tmp/ids_cur$$.txt /tmp/ids_prev$$.txt mv /tmp/ids_cur$$.txt /tmp/ids_prev$$.txt
PREV=$1 PREV=$RC_FILE
shift shift
done done