shithub: freetype+ttf2subf

Download patch

ref: 226f3619750ff34ca698304f1d009d0abdcf720e
parent: 4b733517d77856d192c5929dbbff449b813dc23a
author: suzuki toshiya <[email protected]>
date: Sat Jan 14 01:40:03 EST 2012

Fix PIC build broken by d9145241fe378104ba4c12a42534549faacc92e6.

Under PIC configuration, FT_{CFF,PSCMAPS,SFNT,TT}_SERVICES_GET
take no arguments but derefer the variable named `library'
internally.

* src/cff/cffdrivr.c (cff_get_interface): Declare `library' and
set it if non-NULL driver is passed.
* src/truetype/ttdriver.c (tt_get_interface): Ditto.

* src/sfnt/sfdriver.c (sfnt_get_interface): Declare `library'
under PIC configuration, and set it if non-NULL module is given.
* src/psnames/psmodule.c (psnames_get_interface): Ditto.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2012-01-13  suzuki toshiya  <[email protected]>
 
+	Fix PIC build broken by d9145241fe378104ba4c12a42534549faacc92e6.
+
+	Under PIC configuration, FT_{CFF,PSCMAPS,SFNT,TT}_SERVICES_GET
+	take no arguments but derefer the variable named `library'
+	internally.
+
+	* src/cff/cffdrivr.c (cff_get_interface): Declare `library' and
+	set it if non-NULL driver is passed.
+	* src/truetype/ttdriver.c (tt_get_interface): Ditto.
+
+	* src/sfnt/sfdriver.c (sfnt_get_interface): Declare `library'
+	under PIC configuration, and set it if non-NULL module is given.
+	* src/psnames/psmodule.c (psnames_get_interface): Ditto.
+
+2012-01-13  suzuki toshiya  <[email protected]>
+
 	Make PIC files to include module error headers, to use the
 	error codes with per-module prefix.
 
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -599,19 +599,35 @@
   cff_get_interface( FT_Module    driver,       /* CFF_Driver */
                      const char*  module_interface )
   {
+    FT_Library           library;
     FT_Module            sfnt;
     FT_Module_Interface  result;
 
 
+    /* FT_CFF_SERVICES_GET derefers `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+    if ( !driver )
+      return NULL;
+    library = driver->library;
+    if ( !library )
+      return NULL;
+#endif
+
     result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface );
     if ( result != NULL )
-      return  result;
+      return result;
 
+    /* `driver' is not yet evaluated in non-PIC mode */
+#ifndef FT_CONFIG_OPTION_PIC
     if ( !driver )
       return NULL;
+    library = driver->library;
+    if ( !library )
+      return NULL;
+#endif
 
     /* we pass our request to the `sfnt' module */
-    sfnt = FT_Get_Module( driver->library, "sfnt" );
+    sfnt = FT_Get_Module( library, "sfnt" );
 
     return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0;
   }
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -563,7 +563,19 @@
   psnames_get_service( FT_Module    module,
                        const char*  service_id )
   {
+    /* FT_PSCMAPS_SERVICES_GET derefers `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+    FT_Library  library;
+
+
+    if ( !module )
+      return NULL;
+    library = module->library;
+    if ( !library )
+      return NULL;
+#else
     FT_UNUSED( module );
+#endif
 
     return ft_service_list_lookup( FT_PSCMAPS_SERVICES_GET, service_id );
   }
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -422,8 +422,19 @@
   sfnt_get_interface( FT_Module    module,
                       const char*  module_interface )
   {
-    FT_UNUSED( module );
+    /* FT_SFNT_SERVICES_GET derefers `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+    FT_Library  library;
 
+
+    if ( !module )
+      return NULL;
+    library = module->library;
+    if ( !library ) 
+      return NULL;
+#else
+    FT_UNUSED( module );
+#endif
     return ft_service_list_lookup( FT_SFNT_SERVICES_GET, module_interface );
   }
 
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -402,19 +402,35 @@
   tt_get_interface( FT_Module    driver,    /* TT_Driver */
                     const char*  tt_interface )
   {
+    FT_Library           library;
     FT_Module_Interface  result;
     FT_Module            sfntd;
     SFNT_Service         sfnt;
 
+
+    /* FT_TT_SERVICES_GET derefers `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+    if ( !driver )
+      return NULL;
+    library = driver->library;
+    if ( !library )
+      return NULL;
+#endif
+
     result = ft_service_list_lookup( FT_TT_SERVICES_GET, tt_interface );
     if ( result != NULL )
       return result;
 
+#ifndef FT_CONFIG_OPTION_PIC
     if ( !driver )
       return NULL;
+    library = driver->library;
+    if ( !library )
+      return NULL;
+#endif
 
     /* only return the default interface from the SFNT module */
-    sfntd = FT_Get_Module( driver->library, "sfnt" );
+    sfntd = FT_Get_Module( library, "sfnt" );
     if ( sfntd )
     {
       sfnt = (SFNT_Service)( sfntd->clazz->module_interface );