comparison fix-casts.sh @ 25317:d1a4088528ce

Add a script to change casts to GObject macros. We'll run this later.
author Richard Laager <rlaager@wiktel.com>
date Fri, 14 Nov 2008 02:26:28 +0000
parents
children c3ca613ab550
comparison
equal deleted inserted replaced
25316:f3fb7a5187ae 25317:d1a4088528ce
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` ; do
15 sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*(|$cast(|" $file
16 sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*\([^(][^,);]*\)|$cast(\1)|" $file
17 done
18 done