Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Last active March 7, 2017 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpluimers/baad4455ccf47d37fdb774e7dccff35c to your computer and use it in GitHub Desktop.
Save jpluimers/baad4455ccf47d37fdb774e7dccff35c to your computer and use it in GitHub Desktop.
# Be careful with scripts, always do your backup or play on a copy
# Finding abandoned events
for i in `find . -name "*.pas" -type f`; do if [ -f ${i%.*}.dfm ]; then cat $i | grep "(Sender: TObject" | grep -v "\." | sed -e "s/\(.*\)\ \(.*\)(\(.*\)/\2/g" | xargs -n1 -I @@ sh -c "echo -n \"${i%.*}.dfm->@@: \"; grep -s -c @@ ${i%.*}.dfm" |grep ": 0"; fi; done
# Finding events with every other occurence than "1"
for i in `find . -name "*.pas" -type f`; do if [ -f ${i%.*}.dfm ]; then cat $i | grep "(Sender: TObject" | grep -v "\." | sed -e "s/\(.*\)\ \(.*\)(\(.*\)/\2/g" | xargs -n1 -I @@ sh -c "echo -n \"${i%.*}.dfm->@@: \"; grep -s -c @@ ${i%.*}.dfm" |grep -v ": 1"; fi; done
# !!! Be careful with scripts, always do your backup or play on a copy !!!
# Finding abandoned events v2
for i in `find . -name "*.pas" -type f`; do if [ -f ${i%.*}.dfm ]; then cat $i | \
sed -nr "/=(\s)*class/I,/(private|protected|public|published|automated)/I{p}" | \
sed -nr "/procedure/Ip" | \
sed -e "s/\(.*\)\ \(.*\)(\(.*\)/\2/g" | \
xargs -n1 -I @@ sh -c "echo -n \"${i%.*}.dfm->@@: \"; grep -i -s -c @@ ${i%.*}.dfm" | \
grep ": 0"; fi; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment