Commit f3a924dd53346dbb9da36f4917ff017b2b2cfd96

Suzuki, Toshiya (鈴木俊哉) 2008-06-24T17:13:58

Fix for 10.4u SDK bundled to Mac OS X 10.5

diff --git a/ChangeLog b/ChangeLog
index 9325a60..47fc4e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-06-24  suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
+	* builds/unix/configure.raw: Check type "ResourceIndex" explicitly
+	and define HAVE_TYPE_RESOURCE_INDEX if it is defined. Mac OS X
+	10.5 bundles 10.4u SDK with MAC_OS_X_VERSION_10_5 macro but without
+	ResourceIndex type definition. The macro does not inform the type
+	availability.
+	* src/base/ftmac.c: More parentheses are inserted to clarify the
+	conditionals to disable legacy APIs in "10.5 and later" cases.
+	If HAVE_TYPE_RESOURCE_INDEX is not defined, ResourceIndex is
+	defined.
+
 2008-06-24  Werner Lemberg  <wl@gnu.org>
 
 	* src/truetype/ttinterp. (Ins_SCANTYPE): Don't check rendering mode.
diff --git a/builds/unix/configure.raw b/builds/unix/configure.raw
index 939e439..b69e4ae 100644
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -260,7 +260,37 @@ if test x$with_old_mac_fonts = xyes; then
        ],
        [AC_MSG_RESULT([no, ANSI incompatible])
         CFLAGS="$orig_CFLAGS"
-       ])],
+       ])
+     AC_MSG_CHECKING([type ResourceIndex])
+     orig_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $XX_CFLAGS $XX_ANSIFLAGS"
+     AC_COMPILE_IFELSE([
+       AC_LANG_PROGRAM([
+
+#if defined(__GNUC__) && defined(__APPLE_CC__)
+# include <Carbon/Carbon.h>
+# include <ApplicationServices/ApplicationServices.h>
+#else
+# include <ConditionalMacros.h>
+# include <Files.h>
+# include <Resources.h>
+#endif
+
+         ],
+         [
+
+           ResourceIndex i = 0;
+           return i;
+
+         ])],
+       [AC_MSG_RESULT([ok])
+        CFLAGS="$orig_CFLAGS"
+        CFLAGS="$CFLAGS -DHAVE_TYPE_RESOURCE_INDEX"
+       ],
+       [AC_MSG_RESULT([no])
+        CFLAGS="$orig_CFLAGS"
+       ])
+    ],
     [AC_MSG_RESULT([not found])
      LDFLAGS="${orig_LDFLAGS}"
      CFLAGS="$CFLAGS -DDARWIN_NO_CARBON"])
diff --git a/src/base/ftmac.c b/src/base/ftmac.c
index 7f05907..4f4ab9d 100644
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -77,8 +77,8 @@
 #define OS_INLINE  static __inline__
 #endif
 
-  /* The ResourceIndex type was only added in the 10.5 SDK */
-#ifndef MAC_OS_X_VERSION_10_5
+  /* The ResourceIndex type was available SDKs on 10.5 */
+#ifndef HAVE_TYPE_RESOURCE_INDEX
 typedef short ResourceIndex;
 #endif
 
@@ -134,7 +134,7 @@ typedef short ResourceIndex;
                               FSRef*      ats_font_ref )
   {
 #if defined( MAC_OS_X_VERSION_10_5 ) && \
-    MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+    ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
  
     OSStatus  err;
 
@@ -235,7 +235,7 @@ typedef short ResourceIndex;
                                 FT_Long*     face_index )
   {
 #if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
-      MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
+      ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
     FT_UNUSED( fontName );
     FT_UNUSED( pathSpec );
     FT_UNUSED( face_index );
@@ -1108,7 +1108,7 @@ typedef short ResourceIndex;
                            FT_Face*       aface )
   {
 #if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
-      MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
+      ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
     FT_UNUSED( library );
     FT_UNUSED( spec );
     FT_UNUSED( face_index );