Mercurial > pidgin.yaz
diff fix-casts.sh @ 25380:e2b193decaa5
explicit merge of '814d53152c168c9c4732b3d084260711d536fba6'
and 'af375020001eed33302b471e7ee9dec6a478e824'
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 02 Jan 2009 22:23:58 +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:58 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