pidgin/pidgin

Ensure backwards compatibility with Python 2
release-2.x.y
2015-07-12, Daniƫl van Eeden
8c851c1bc85b
file isExecutable
Ensure backwards compatibility with Python 2

Use python (which often defaults to python 2.x) instead of forcing python2
Also make it compatible with python 2.7 and 3.4

Tested with:
$ python2.7 libpurple/purple-url-handler xmpp:foo@example.com
$ python3.4 libpurple/purple-url-handler xmpp:bar@example.com
(grafted from a6f8c7cbdb24eb7113268beede61db120f940917)
#!/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