view fix-casts.sh @ 32507:29e9fe5b9264

Pluck fixes for OIM charset conversion. *** Plucked rev 3053d6a37cc6d8774aba7607b992a4408216adcd (thijsalkemade@gmail.com): MSN Patch from Thijs (xnyhps) Alkemade which do verify/convert to UTF-8 incoming OIM. Fixes #14884 *** Plucked rev ecabfaee8a1ca02e18ebadbb41cdcce19e78bc2e (masca@cpw.pidgin.im): Apply second patch from xnyhps this time to show the message salvaged to user. Refs #14884 *** Plucked rev b1b8c222ab921963f43e83502b6c6e2e4489a8c4 (qulogic@pidgin.im): Add newlines to debug messages, and word-wrap lines. *** Plucked rev fdb56683f2b5f88f7b388aaef6c53c810d19e374 (qulogic@pidgin.im): We know the length of decode_msg here. *** Plucked rev f12c9f6a6c31bcd3512f162209285a88a86595ff (qulogic@pidgin.im): This extra if-level can be dropped.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 06 Feb 2012 22:42:32 +0000
parents c3ca613ab550
children
line wrap: on
line source

#!/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 --exclude=purple-client-bindings.c` ; do
		sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*(|$cast(|g" $file
		sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*\([^(][^,);]*\)|$cast(\1)|g" $file
	done
done