# HG changeset patch # User Richard Laager # Date 1226629588 0 # Node ID d1a4088528ce4a68e5325c462e2e443fedb716a5 # Parent f3fb7a5187ae3fbc6a9d2b7288f915fe1fc389c7 Add a script to change casts to GObject macros. We'll run this later. diff -r f3fb7a5187ae -r d1a4088528ce Makefile.am --- a/Makefile.am Tue Nov 11 02:01:43 2008 +0000 +++ b/Makefile.am Fri Nov 14 02:26:28 2008 +0000 @@ -10,6 +10,7 @@ README.mingw \ config.h.mingw \ doxy2devhelp.xsl \ + fix-casts.sh \ gaim.pc.in \ gaim-uninstalled.pc.in \ intltool-extract.in \ diff -r f3fb7a5187ae -r d1a4088528ce fix-casts.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fix-casts.sh Fri Nov 14 02:26:28 2008 +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` ; do + sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*(|$cast(|" $file + sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*\([^(][^,);]*\)|$cast(\1)|" $file + done +done