changeset 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 f3fb7a5187ae
children 0e08c847517d
files Makefile.am fix-casts.sh
diffstat 2 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 \
--- /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