* src/pcf/pcfdrivr.c: Clean up interface.
Ensure that all driver functions use the signature of the service or driver. This avoids pointer mismatches, which are technically undefined behaviour. Recent compilers are more picky in catching them as part of Control Flow Integrity tests.
This commit is contained in:
parent
b9ce8e33a7
commit
0685b0ad36
|
@ -75,36 +75,36 @@ THE SOFTWARE.
|
|||
|
||||
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
pcf_cmap_init( FT_CMap pcfcmap, /* PCF_CMap */
|
||||
pcf_cmap_init( FT_CMap cmap, /* PCF_CMap */
|
||||
FT_Pointer init_data )
|
||||
{
|
||||
PCF_CMap cmap = (PCF_CMap)pcfcmap;
|
||||
PCF_Face face = (PCF_Face)FT_CMAP_FACE( pcfcmap );
|
||||
PCF_CMap pcfcmap = (PCF_CMap)cmap;
|
||||
PCF_Face face = (PCF_Face)FT_CMAP_FACE( cmap );
|
||||
|
||||
FT_UNUSED( init_data );
|
||||
|
||||
|
||||
cmap->enc = &face->enc;
|
||||
pcfcmap->enc = &face->enc;
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
pcf_cmap_done( FT_CMap pcfcmap ) /* PCF_CMap */
|
||||
pcf_cmap_done( FT_CMap cmap ) /* PCF_CMap */
|
||||
{
|
||||
PCF_CMap cmap = (PCF_CMap)pcfcmap;
|
||||
PCF_CMap pcfcmap = (PCF_CMap)cmap;
|
||||
|
||||
|
||||
cmap->enc = NULL;
|
||||
pcfcmap->enc = NULL;
|
||||
}
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( FT_UInt )
|
||||
pcf_cmap_char_index( FT_CMap pcfcmap, /* PCF_CMap */
|
||||
pcf_cmap_char_index( FT_CMap cmap, /* PCF_CMap */
|
||||
FT_UInt32 charcode )
|
||||
{
|
||||
PCF_Enc enc = ( (PCF_CMap)pcfcmap )->enc;
|
||||
PCF_Enc enc = ( (PCF_CMap)cmap )->enc;
|
||||
|
||||
FT_UInt32 i = ( charcode >> 8 ) - enc->firstRow;
|
||||
FT_UInt32 j = ( charcode & 0xFF ) - enc->firstCol;
|
||||
|
@ -121,10 +121,10 @@ THE SOFTWARE.
|
|||
|
||||
|
||||
FT_CALLBACK_DEF( FT_UInt )
|
||||
pcf_cmap_char_next( FT_CMap pcfcmap, /* PCF_CMap */
|
||||
pcf_cmap_char_next( FT_CMap cmap, /* PCF_CMap */
|
||||
FT_UInt32 *acharcode )
|
||||
{
|
||||
PCF_Enc enc = ( (PCF_CMap)pcfcmap )->enc;
|
||||
PCF_Enc enc = ( (PCF_CMap)cmap )->enc;
|
||||
FT_UInt32 charcode = *acharcode + 1;
|
||||
|
||||
FT_UInt32 i = ( charcode >> 8 ) - enc->firstRow;
|
||||
|
@ -170,9 +170,9 @@ THE SOFTWARE.
|
|||
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
PCF_Face_Done( FT_Face pcfface ) /* PCF_Face */
|
||||
PCF_Face_Done( FT_Face face ) /* PCF_Face */
|
||||
{
|
||||
PCF_Face face = (PCF_Face)pcfface;
|
||||
PCF_Face pcfface = (PCF_Face)face;
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
|
@ -181,18 +181,18 @@ THE SOFTWARE.
|
|||
|
||||
memory = FT_FACE_MEMORY( face );
|
||||
|
||||
FT_FREE( face->metrics );
|
||||
FT_FREE( face->enc.offset );
|
||||
FT_FREE( pcfface->metrics );
|
||||
FT_FREE( pcfface->enc.offset );
|
||||
|
||||
/* free properties */
|
||||
if ( face->properties )
|
||||
if ( pcfface->properties )
|
||||
{
|
||||
FT_Int i;
|
||||
|
||||
|
||||
for ( i = 0; i < face->nprops; i++ )
|
||||
for ( i = 0; i < pcfface->nprops; i++ )
|
||||
{
|
||||
PCF_Property prop = &face->properties[i];
|
||||
PCF_Property prop = &pcfface->properties[i];
|
||||
|
||||
|
||||
if ( prop )
|
||||
|
@ -203,33 +203,33 @@ THE SOFTWARE.
|
|||
}
|
||||
}
|
||||
|
||||
FT_FREE( face->properties );
|
||||
FT_FREE( pcfface->properties );
|
||||
}
|
||||
|
||||
FT_FREE( face->toc.tables );
|
||||
FT_FREE( pcfface->family_name );
|
||||
FT_FREE( pcfface->style_name );
|
||||
FT_FREE( pcfface->available_sizes );
|
||||
FT_FREE( face->charset_encoding );
|
||||
FT_FREE( face->charset_registry );
|
||||
FT_FREE( pcfface->toc.tables );
|
||||
FT_FREE( face->family_name );
|
||||
FT_FREE( face->style_name );
|
||||
FT_FREE( face->available_sizes );
|
||||
FT_FREE( pcfface->charset_encoding );
|
||||
FT_FREE( pcfface->charset_registry );
|
||||
|
||||
/* close compressed stream if any */
|
||||
if ( pcfface->stream == &face->comp_stream )
|
||||
if ( face->stream == &pcfface->comp_stream )
|
||||
{
|
||||
FT_Stream_Close( &face->comp_stream );
|
||||
pcfface->stream = face->comp_source;
|
||||
FT_Stream_Close( &pcfface->comp_stream );
|
||||
face->stream = pcfface->comp_source;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
PCF_Face_Init( FT_Stream stream,
|
||||
FT_Face pcfface, /* PCF_Face */
|
||||
FT_Face face, /* PCF_Face */
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
PCF_Face face = (PCF_Face)pcfface;
|
||||
PCF_Face pcfface = (PCF_Face)face;
|
||||
FT_Error error;
|
||||
|
||||
FT_UNUSED( num_params );
|
||||
|
@ -238,10 +238,10 @@ THE SOFTWARE.
|
|||
|
||||
FT_TRACE2(( "PCF driver\n" ));
|
||||
|
||||
error = pcf_load_font( stream, face, face_index );
|
||||
error = pcf_load_font( stream, pcfface, face_index );
|
||||
if ( error )
|
||||
{
|
||||
PCF_Face_Done( pcfface );
|
||||
PCF_Face_Done( face );
|
||||
|
||||
#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \
|
||||
defined( FT_CONFIG_OPTION_USE_LZW ) || \
|
||||
|
@ -254,7 +254,7 @@ THE SOFTWARE.
|
|||
|
||||
/* this didn't work, try gzip support! */
|
||||
FT_TRACE2(( " ... try gzip stream\n" ));
|
||||
error2 = FT_Stream_OpenGzip( &face->comp_stream, stream );
|
||||
error2 = FT_Stream_OpenGzip( &pcfface->comp_stream, stream );
|
||||
if ( FT_ERR_EQ( error2, Unimplemented_Feature ) )
|
||||
goto Fail;
|
||||
|
||||
|
@ -270,7 +270,7 @@ THE SOFTWARE.
|
|||
|
||||
/* this didn't work, try LZW support! */
|
||||
FT_TRACE2(( " ... try LZW stream\n" ));
|
||||
error3 = FT_Stream_OpenLZW( &face->comp_stream, stream );
|
||||
error3 = FT_Stream_OpenLZW( &pcfface->comp_stream, stream );
|
||||
if ( FT_ERR_EQ( error3, Unimplemented_Feature ) )
|
||||
goto Fail;
|
||||
|
||||
|
@ -286,7 +286,7 @@ THE SOFTWARE.
|
|||
|
||||
/* this didn't work, try Bzip2 support! */
|
||||
FT_TRACE2(( " ... try Bzip2 stream\n" ));
|
||||
error4 = FT_Stream_OpenBzip2( &face->comp_stream, stream );
|
||||
error4 = FT_Stream_OpenBzip2( &pcfface->comp_stream, stream );
|
||||
if ( FT_ERR_EQ( error4, Unimplemented_Feature ) )
|
||||
goto Fail;
|
||||
|
||||
|
@ -297,12 +297,12 @@ THE SOFTWARE.
|
|||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
face->comp_source = stream;
|
||||
pcfface->stream = &face->comp_stream;
|
||||
pcfface->comp_source = stream;
|
||||
face->stream = &pcfface->comp_stream;
|
||||
|
||||
stream = pcfface->stream;
|
||||
stream = face->stream;
|
||||
|
||||
error = pcf_load_font( stream, face, face_index );
|
||||
error = pcf_load_font( stream, pcfface, face_index );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
|
@ -326,14 +326,14 @@ THE SOFTWARE.
|
|||
else if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
|
||||
{
|
||||
FT_ERROR(( "PCF_Face_Init: invalid face index\n" ));
|
||||
PCF_Face_Done( pcfface );
|
||||
PCF_Face_Done( face );
|
||||
return FT_THROW( Invalid_Argument );
|
||||
}
|
||||
|
||||
/* set up charmap */
|
||||
{
|
||||
FT_String *charset_registry = face->charset_registry;
|
||||
FT_String *charset_encoding = face->charset_encoding;
|
||||
FT_String *charset_registry = pcfface->charset_registry;
|
||||
FT_String *charset_encoding = pcfface->charset_encoding;
|
||||
FT_Bool unicode_charmap = 0;
|
||||
|
||||
|
||||
|
@ -349,13 +349,13 @@ THE SOFTWARE.
|
|||
( s[2] == 'o' || s[2] == 'O' ) )
|
||||
{
|
||||
s += 3;
|
||||
if ( !ft_strcmp( s, "10646" ) ||
|
||||
( !ft_strcmp( s, "8859" ) &&
|
||||
!ft_strcmp( face->charset_encoding, "1" ) ) )
|
||||
if ( !ft_strcmp( s, "10646" ) ||
|
||||
( !ft_strcmp( s, "8859" ) &&
|
||||
!ft_strcmp( pcfface->charset_encoding, "1" ) ) )
|
||||
unicode_charmap = 1;
|
||||
/* another name for ASCII */
|
||||
else if ( !ft_strcmp( s, "646.1991" ) &&
|
||||
!ft_strcmp( face->charset_encoding, "IRV" ) )
|
||||
else if ( !ft_strcmp( s, "646.1991" ) &&
|
||||
!ft_strcmp( pcfface->charset_encoding, "IRV" ) )
|
||||
unicode_charmap = 1;
|
||||
}
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ THE SOFTWARE.
|
|||
FT_CharMapRec charmap;
|
||||
|
||||
|
||||
charmap.face = FT_FACE( face );
|
||||
charmap.face = face;
|
||||
charmap.encoding = FT_ENCODING_NONE;
|
||||
/* initial platform/encoding should indicate unset status? */
|
||||
charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
|
||||
|
@ -386,7 +386,7 @@ THE SOFTWARE.
|
|||
|
||||
Fail:
|
||||
FT_TRACE2(( " not a PCF file\n" ));
|
||||
PCF_Face_Done( pcfface );
|
||||
PCF_Face_Done( face );
|
||||
error = FT_THROW( Unknown_File_Format ); /* error */
|
||||
goto Exit;
|
||||
}
|
||||
|
@ -569,15 +569,16 @@ THE SOFTWARE.
|
|||
*
|
||||
*/
|
||||
|
||||
static FT_Error
|
||||
pcf_get_bdf_property( PCF_Face face,
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
pcf_get_bdf_property( FT_Face face, /* PCF_Face */
|
||||
const char* prop_name,
|
||||
BDF_PropertyRec *aproperty )
|
||||
{
|
||||
PCF_Face pcfface = (PCF_Face)face;
|
||||
PCF_Property prop;
|
||||
|
||||
|
||||
prop = pcf_find_property( face, prop_name );
|
||||
prop = pcf_find_property( pcfface, prop_name );
|
||||
if ( prop )
|
||||
{
|
||||
if ( prop->isString )
|
||||
|
@ -611,13 +612,16 @@ THE SOFTWARE.
|
|||
}
|
||||
|
||||
|
||||
static FT_Error
|
||||
pcf_get_charset_id( PCF_Face face,
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
pcf_get_charset_id( FT_Face face, /* PCF_Face */
|
||||
const char* *acharset_encoding,
|
||||
const char* *acharset_registry )
|
||||
{
|
||||
*acharset_encoding = face->charset_encoding;
|
||||
*acharset_registry = face->charset_registry;
|
||||
PCF_Face pcfface = (PCF_Face)face;
|
||||
|
||||
|
||||
*acharset_encoding = pcfface->charset_encoding;
|
||||
*acharset_registry = pcfface->charset_registry;
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
@ -634,7 +638,7 @@ THE SOFTWARE.
|
|||
* PROPERTY SERVICE
|
||||
*
|
||||
*/
|
||||
static FT_Error
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
pcf_property_set( FT_Module module, /* PCF_Driver */
|
||||
const char* property_name,
|
||||
const void* value,
|
||||
|
@ -695,7 +699,7 @@ THE SOFTWARE.
|
|||
}
|
||||
|
||||
|
||||
static FT_Error
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
pcf_property_get( FT_Module module, /* PCF_Driver */
|
||||
const char* property_name,
|
||||
const void* value )
|
||||
|
|
Loading…
Reference in New Issue