Mercurial > pidgin
comparison fix-casts.sh @ 25874:367b3ddcf5c3
propagate from branch 'im.pidgin.pidgin' (head 81aa401ac9855c99eb55a7cf91fa221860dee220)
to branch 'im.pidgin.pidgin.next.minor' (head cf7b71a77c33c3e1d2f392c46d090fb936eb47b7)
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 08 Dec 2008 17:57:09 +0000 |
parents | c3ca613ab550 |
children |
comparison
equal
deleted
inserted
replaced
24705:6f41450584a7 | 25874:367b3ddcf5c3 |
---|---|
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 |