summaryrefslogtreecommitdiff
path: root/navit/tools
diff options
context:
space:
mode:
authortinloaf <tinloaf@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-03-16 17:24:47 +0000
committertinloaf <tinloaf@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-03-16 17:24:47 +0000
commit42a1e6d01cc7c31a0a0ba27fea779452222f5035 (patch)
tree40805005d24df213746ac854e4b2e8b014ef4262 /navit/tools
parent830c727d3ae1193e9ef3def980903d15deeaa003 (diff)
downloadnavit-svn-42a1e6d01cc7c31a0a0ba27fea779452222f5035.tar.gz
Add:Tools:Adding a quick 'n dirty script to scan for attributes that could be removed
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2133 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/tools')
-rwxr-xr-xnavit/tools/cleanattr.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/navit/tools/cleanattr.sh b/navit/tools/cleanattr.sh
new file mode 100755
index 00000000..dc2f0dc4
--- /dev/null
+++ b/navit/tools/cleanattr.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# This script scans the navit sources for attributes that
+# remained in attr_def.h but are no longer used.
+
+ATTRFILE=attr_def.h
+TMPDIR=/tmp
+
+if [ ! -f ./navit.c ] ; then
+ echo "Please execute this script from navit's source folder."
+ exit 1;
+fi
+
+TMPFILE=$TMPDIR/navit-cleanattr.tmp
+TMPFILE2=$TMPDIR/navit-cleanattr.tmp2
+
+if [ -f $TMPFILE ] ; then
+ echo "Temporary file $TMPFILE already exists."
+ echo "Please don't run this tool twice at the same time. If you are shure that no other instance of this tool is running, remove the file."
+ exit 1;
+fi
+
+touch $TMPFILE
+if [ $? -ne 0 ] ; then
+ echo "Could not write to temporary file $TEMPFILE."
+ echo "Please make shure you have write access to the temporary directory."
+ exit 1;
+fi
+
+
+ATTRLIST=`grep 'ATTR(.*)' $ATTRFILE | sed 's#^ATTR(##' | sed 's#).*##'`
+
+cp $ATTRFILE $TMPFILE
+
+for ATTRNAME in $ATTRLIST ; do
+ ATTR="attr_$ATTRNAME"
+
+ grep -rI $ATTR ./* > /dev/null
+
+ if [ $? -ne 0 ] ; then
+ echo "Unused attribute: $ATTR"
+ grep -v "ATTR($ATTRNAME)" $TMPFILE > $TMPFILE2
+ mv $TMPFILE2 $TMPFILE
+ fi
+done
+
+echo "==== Creating patch ===="
+diff -U 3 $ATTRFILE $TMPFILE
+
+rm $TMPFILE