fix-casts.sh

Fri, 10 Jul 2009 15:18:09 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Fri, 10 Jul 2009 15:18:09 +0000
changeset 27716
a3ed37ab91b8
parent 24975
7abe1341dc45
permissions
-rwxr-xr-x

Allow setting some personal information for an account.

Currently the name and phone number(s) can be set. It's possible to set a
lot of information about a Yahoo! account that can be set for an XMPP
account, but the list looked too huge for me. So I just picked the ones
that I thought could be useful. Someone might want to know about the
birthdays too ... I don't know.

Someone should test this on Yahoo! JAPAN (why not 'Japan', by the way?)

#!/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

mercurial