comparison fix-casts.sh @ 25374:e22bc87b758b

explicit merge of '9a5e549612efd8ca6f60fc57b51a4eee7e32c861' and 'f398f87ffee8b1b11295a0a0138936074c5dff7a'
author Richard Laager <rlaager@wiktel.com>
date Fri, 02 Jan 2009 22:09:40 +0000
parents c3ca613ab550
children
comparison
equal deleted inserted replaced
24731:295464ae2d2a 25374:e22bc87b758b
1 #!/bin/sh
2
3 if [ $# -eq 0 ]; then
4 echo "Usage: `basename "$0"` PurpleFoo..."
5 echo
6 echo "This script searches the *current working directory* and replaces casts"
7 echo "with GObject-style type checking and casting macros."
8 echo 'For example, "(PurpleBuddy *)b" becomes "PURPLE_BUDDY(b)".'
9 exit 0
10 fi
11
12 for struct in $* ; do
13 cast=`echo $struct | sed "s|[A-Z]|_\0|g" | tr "a-z" "A-Z" | sed "s|^_||"`
14 for file in `grep -rl "([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)" . --include=*.c --exclude=purple-client-bindings.c` ; do
15 sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*(|$cast(|g" $file
16 sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*\([^(][^,);]*\)|$cast(\1)|g" $file
17 done
18 done