Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / freetype2 / src / src / base / ftrfork.c
index 133c2de..33768b0 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Embedded resource forks accessor (body).                             */
 /*                                                                         */
-/*  Copyright 2004, 2005, 2006, 2007, 2008, 2009 by                        */
+/*  Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010 by                  */
 /*  Masatake YAMATO and Redhat K.K.                                        */
 /*                                                                         */
 /*  FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are     */
     FT_Long       tag_internal, rpos;
     FT_Memory     memory = library->memory;
     FT_Long       temp;
-    FT_Long       *offsets_internal;
-    FT_RFork_Ref  *ref;
+    FT_Long       *offsets_internal = NULL;
+    FT_RFork_Ref  *ref = NULL;
 
 
     error = FT_Stream_Seek( stream, map_offset );
                           const char  *insertion );
 
 
+  typedef enum  FT_RFork_Rule_ {
+    FT_RFork_Rule_invalid = -2,
+    FT_RFork_Rule_uknown, /* -1 */
+    FT_RFork_Rule_apple_double,
+    FT_RFork_Rule_apple_single,
+    FT_RFork_Rule_darwin_ufs_export,
+    FT_RFork_Rule_darwin_newvfs,
+    FT_RFork_Rule_darwin_hfsplus,
+    FT_RFork_Rule_vfat,
+    FT_RFork_Rule_linux_cap,
+    FT_RFork_Rule_linux_double,
+    FT_RFork_Rule_linux_netatalk
+  } FT_RFork_Rule;
+
+  /* For fast translation between rule index and rule type,
+   * the macros FT_RFORK_xxx should be kept consistent with
+   * the raccess_guess_funcs table
+   */
+  typedef struct raccess_guess_rec_ {
+    raccess_guess_func  func;
+    FT_RFork_Rule       type;
+  } raccess_guess_rec;
+
+  static raccess_guess_rec  raccess_guess_table[FT_RACCESS_N_RULES] =
+  {
+    { raccess_guess_apple_double,      FT_RFork_Rule_apple_double, },
+    { raccess_guess_apple_single,      FT_RFork_Rule_apple_single, },
+    { raccess_guess_darwin_ufs_export, FT_RFork_Rule_darwin_ufs_export, },
+    { raccess_guess_darwin_newvfs,     FT_RFork_Rule_darwin_newvfs, },
+    { raccess_guess_darwin_hfsplus,    FT_RFork_Rule_darwin_hfsplus, },
+    { raccess_guess_vfat,              FT_RFork_Rule_vfat, },
+    { raccess_guess_linux_cap,         FT_RFork_Rule_linux_cap, },
+    { raccess_guess_linux_double,      FT_RFork_Rule_linux_double, },
+    { raccess_guess_linux_netatalk,    FT_RFork_Rule_linux_netatalk, },
+  };
+
   FT_BASE_DEF( void )
   FT_Raccess_Guess( FT_Library  library,
                     FT_Stream   stream,
     FT_Long  i;
 
 
-    raccess_guess_func  funcs[FT_RACCESS_N_RULES] =
-    {
-      raccess_guess_apple_double,
-      raccess_guess_apple_single,
-      raccess_guess_darwin_ufs_export,
-      raccess_guess_darwin_newvfs,
-      raccess_guess_darwin_hfsplus,
-      raccess_guess_vfat,
-      raccess_guess_linux_cap,
-      raccess_guess_linux_double,
-      raccess_guess_linux_netatalk,
-    };
-
     for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
     {
       new_names[i] = NULL;
       if ( errors[i] )
         continue ;
 
-      errors[i] = (funcs[i])( library, stream, base_name,
-                              &(new_names[i]), &(offsets[i]) );
+      errors[i] = (raccess_guess_table[i].func)( library,
+                                                 stream, base_name,
+                                                 &(new_names[i]),
+                                                 &(offsets[i]) );
     }
 
     return;
   }
 
 
+#if !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON )
+  static FT_RFork_Rule
+  raccess_get_rule_type_from_rule_index( FT_UInt  rule_index )
+  {
+    if ( rule_index >= FT_RACCESS_N_RULES )
+      return FT_RFork_Rule_invalid;
+
+    return raccess_guess_table[rule_index].type;
+  }
+
+
+  FT_LOCAL_DEF( FT_Bool )
+  raccess_rule_by_darwin_vfs( FT_UInt  rule_index )
+  {
+    switch( raccess_get_rule_type_from_rule_index( rule_index ) )
+    {
+      case FT_RFork_Rule_darwin_newvfs:
+      case FT_RFork_Rule_darwin_hfsplus:
+        return TRUE;
+
+      default:
+        return FALSE;
+    }
+  }
+#endif
+
+
   static FT_Error
   raccess_guess_apple_double( FT_Library  library,
                               FT_Stream   stream,
       Only meaningful on systems with hfs+ drivers (or Macs).
      */
     FT_Error   error;
-    char*      newpath;
+    char*      newpath = NULL;
     FT_Memory  memory;
     FT_Long    base_file_len = ft_strlen( base_file_name );
 
       Only meaningful on systems with Mac OS X (> 10.1).
      */
     FT_Error   error;
-    char*      newpath;
+    char*      newpath = NULL;
     FT_Memory  memory;
     FT_Long    base_file_len = ft_strlen( base_file_name );
 
                           const char  *original_name,
                           const char  *insertion )
   {
-    char*        new_name;
+    char*        new_name = NULL;
     const char*  tmp;
     const char*  slash;
     size_t       new_length;