Mercurial > pidgin.yaz
diff fix-casts.sh @ 25378:47540809ae91
explicit merge of '82e4edbe06cb0ef0fa59f70db44a289bb91e1343'
and '8edc2ac791e936a5d9eddd85e451d25e1afa5ba6'
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 02 Jan 2009 22:23:19 +0000 |
parents | c3ca613ab550 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fix-casts.sh Fri Jan 02 22:23:19 2009 +0000 @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ $# -eq 0 ]; then + echo "Usage: `basename "$0"` PurpleFoo..." + echo + echo "This script searches the *current working directory* and replaces casts" + echo "with GObject-style type checking and casting macros." + echo 'For example, "(PurpleBuddy *)b" becomes "PURPLE_BUDDY(b)".' + exit 0 +fi + +for struct in $* ; do + cast=`echo $struct | sed "s|[A-Z]|_\0|g" | tr "a-z" "A-Z" | sed "s|^_||"` + for file in `grep -rl "([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)" . --include=*.c --exclude=purple-client-bindings.c` ; do + sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*(|$cast(|g" $file + sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*\([^(][^,);]*\)|$cast(\1)|g" $file + done +done