Fix:maptool:Convert character set
[navit-package] / navit / tools / cleanattr.sh
1 #!/bin/sh
2
3 # This script scans the navit sources for attributes that 
4 # remained in attr_def.h but are no longer used. 
5
6 ATTRFILE=attr_def.h
7 TMPDIR=/tmp
8
9 if [ ! -f ./navit.c ] ; then
10                 echo "Please execute this script from navit's source folder."
11                 exit 1;
12 fi
13
14 TMPFILE=$TMPDIR/navit-cleanattr.tmp
15 TMPFILE2=$TMPDIR/navit-cleanattr.tmp2
16
17 if [ -f $TMPFILE ] ; then
18                 echo "Temporary file $TMPFILE already exists."
19                 echo "Please don't run this tool twice at the same time. If you are sure that no other instance of this tool is running, remove the file."
20                 exit 1;
21 fi
22
23 touch $TMPFILE
24 if [ $? -ne 0 ] ; then
25                 echo "Could not write to temporary file $TEMPFILE."
26                 echo "Please make sure you have write access to the temporary directory."
27                 exit 1;
28 fi
29
30
31 ATTRLIST=`grep 'ATTR(.*)' $ATTRFILE | sed 's#^ATTR(##' | sed 's#).*##'`
32
33 cp $ATTRFILE $TMPFILE
34
35 for ATTRNAME in $ATTRLIST ; do
36                 ATTR="attr_$ATTRNAME"
37
38                 grep -rI $ATTR ./* > /dev/null
39
40                 if [ $? -ne 0 ] ; then                          
41                                 echo "Unused attribute: $ATTR"
42                                 grep -v "ATTR($ATTRNAME)" $TMPFILE > $TMPFILE2
43                                 mv $TMPFILE2 $TMPFILE
44                 fi
45 done
46
47 echo "==== Creating patch ===="
48 diff -U 3 $ATTRFILE $TMPFILE
49
50 rm $TMPFILE