From 226f3619750ff34ca698304f1d009d0abdcf720e Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Sat, 14 Jan 2012 06:40:03 +0900 Subject: [PATCH] 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. --- ChangeLog | 16 ++++++++++++++++ src/cff/cffdrivr.c | 26 +++++++++++++++++++++----- src/psnames/psmodule.c | 12 ++++++++++++ src/sfnt/sfdriver.c | 13 ++++++++++++- src/truetype/ttdriver.c | 18 +++++++++++++++++- 5 files changed, 78 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77bc180de..6c0a3b4d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2012-01-13 suzuki toshiya + + 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 Make PIC files to include module error headers, to use the diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c index 61ab70589..49453f116 100644 --- 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; - result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface ); - if ( result != NULL ) - return 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; + + /* `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; } diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c index 752869693..2577382ec 100644 --- 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 ); } diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index 17ef310bd..fadb15b76 100644 --- 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 ); } diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index b2171976a..c30bec238 100644 --- 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 );