#! /bin/sh -e
## 300289_ftbfs_ppc64_gcc4.0.dpatch by Andreas Jochens <aj@andaco.de>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix FTBFS on ppc64 with gcc-4.0.

if [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch) patch -f --no-backup-if-mismatch -p1 < $0;;
    -unpatch) patch -f --no-backup-if-mismatch -R -p1 < $0;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1;;
esac

exit 0

diff -x debian -ruN old/hfsplus-1.0.4/libhfsp/src/swab.h hfsplus-1.0.4/libhfsp/src/swab.h
--- old/hfsplus-1.0.4/libhfsp/src/swab.h	2002-03-05 19:50:29.000000000 +0000
+++ hfsplus-1.0.4/libhfsp/src/swab.h	2006-09-13 20:52:15.000000000 +0000
@@ -48,25 +48,25 @@
 
 #define bswabU16(val) val
 
-#define bswabU16_inc(ptr) (*((UInt16*) (ptr))++)
+#define bswabU16_inc(ptr) ptr = (UInt16*)ptr + 1
 /* Only available as a GCC extension, but required on sparc due to
    alignment issues in some of the on-disk structs */
 #if defined(__GNUC__) && defined(__sparc__)
 #define bswabU32_inc(ptr) ({			\
 	unsigned char *c = (char*)ptr;		\
-	((UInt32 *)ptr)++;			\
+	ptr = ((UInt32 *)ptr) + 1;		\
 	((c[0] << 24)+(c[1] << 16)+(c[2] << 8)+c[3]);})
 #define bswabU64_inc(ptr) ({			\
 	unsigned char *c = (char*)ptr;		\
 	UInt64 val = 0;				\
 	int i = 0;				\
-	((UInt64 *)ptr)++;			\
+	ptr = ((UInt64 *)ptr) + 1;		\
 	while (i < 8)				\
 		val += (c[i] << (8*(7-i++)));	\
 	val;})
 #else
-#define bswabU32_inc(ptr) (*((UInt32*) (ptr))++)
-#define bswabU64_inc(ptr) (*((UInt64*) (ptr))++)
+#define bswabU32_inc(ptr) ptr = (UInt32*)ptr + 1
+#define bswabU64_inc(ptr) ptr = (UInt64*)ptr + 1
 #endif
 
 #define bstoreU16_inc(ptr, val) *((UInt16*) (ptr)) = val; ptr = (UInt16*)ptr + 1
