script to check functions and classes
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 14 Feb 2008 20:29:43 +0000 (20:29 +0000)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 14 Feb 2008 20:29:43 +0000 (20:29 +0000)
bin/getdep.sh [new file with mode: 0755]

diff --git a/bin/getdep.sh b/bin/getdep.sh
new file mode 100755 (executable)
index 0000000..1d7f88a
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+IFS='
+'
+for f in `find | grep '\.ph[ph]$'`; do
+    echo "-- file: $f ---------------------------------------"
+    st="out"
+    
+    for l in `egrep '^ *class |^} // end class|^ *function +'  $f`; do
+       if [ $st = "out" ]; then
+           echo "$l" | grep -q '^ *class \+' 
+           if [ $? -eq 0 ]; then
+               st="in"
+               class="`echo "$l" | sed 's/^ *class \+//g; s/ *{ *//g'`"
+               continue
+           fi
+       elif [ $st = "in" ]; then
+           echo "$l" | grep -q '^} // end class' 
+           if [ $? -eq 0 ]; then
+               st="out"
+               continue
+           fi
+       fi
+
+       fun="`echo "$l" | sed 's/ *function *//g'`"
+       funame="`echo "$fun" | sed 's/ *(.*//g'`"
+       if [ $st = "out" ]; then
+           echo "ss $f - $fun sssssssssssssssssss" 
+       elif [ $st = "in" ]; then
+           echo "xx $f - $class :: $fun xxxxxxxxxxxxxxxxxxxxxx"
+           if [ "$class" = "$funame" ]; then
+               # constructor case
+               egrep "new *$class" `find | grep '\.ph[ph]$'`
+           else
+               egrep -- "$class::$funame\(|->$funame\(" `find | grep '\.ph[ph]$'`
+           fi
+           echo 
+       fi
+    done
+    echo --------------------------------------------------------
+done
+
+
+#grep -r '^ *function \+' 
+#grep -r '^ *class' `find -name '*.ph*'`
+#grep -ir '} // end class' 
\ No newline at end of file