view fix-casts.sh @ 30195:92a5d4b38f21

jabber: Stricter checks on the send_raw prpl function. This (should) avoids a crash in the gtalkinvisible plugin as seen in a crash log from #pidgin. The plugin is trying to send a stanza as the (eventual) result of the signing-on signal, which is before prpl_info->login() is called. Call stack: jabber_send_raw protocols/jabber/jabber.c:443 jabber_prpl_send_raw protocols/jabber/jabber.c:548 6EA0122D plugins\gtalkinvisible.dll plugin_invisible_cb gtalkinvisible.c:147 67D0410B purple_signal_emit_vargs signals.c:465 67D04217 purple_signal_emit signals.c:436 67CFB75F purple_prpl_change_account_status prpl.c:389 67D09B3F status_has_changed status.c:669 67CC4409 purple_account_set_status_list account.c:1783 67CC4717 purple_account_set_status account.c:1752 67D00F18 purple_savedstatus_activate_for_account savedstatuses.c:1174 67D01899 purple_savedstatus_set_idleaway savedstatuses.c:887 67CE5D13 check_idleness idle.c:193 67D0410B purple_signal_emit_vargs signals.c:465 67D04217 purple_signal_emit signals.c:436 67CD9F34 _purple_connection_new connection.c:157 67CC56C1 purple_account_connect account.c:1216
author Paul Aurich <paul@darkrain42.org>
date Tue, 15 Jun 2010 22:41:37 +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