diff -ru pango-1.14.9.orig/pango/fonts.c pango-1.14.9/pango/fonts.c --- pango-1.14.9.orig/pango/fonts.c 2006-08-17 00:59:23.000000000 +0200 +++ pango-1.14.9/pango/fonts.c 2007-01-25 23:21:45.000000000 +0100 @@ -1,7 +1,7 @@ /* Pango * fonts.c: * - * Copyright (C) 1999 Red Hat Software + * Copyright (C) 1999, 2007 Red Hat Software * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -31,6 +31,13 @@ static const char bad_font_warning[] = "%s called with bad font, expect ugly output"; +#ifdef DEBUG +#include +#define ASSERT(X) assert((x)) +#else +#define ASSERT(X) +#endif + struct _PangoFontDescription { char *family_name; @@ -795,10 +802,27 @@ { PANGO_STRETCH_ULTRA_EXPANDED, "Ultra-Expanded" } }; +union field_val { + PangoStyle sty; + PangoVariant var; + PangoWeight wei; + PangoStretch str; +}; + static gboolean -find_field (const FieldMap *map, int n_elements, const char *str, int len, int *val) +find_field (const FieldMap *map, int n_elements, const char *str, int len, union field_val *val) { int i; + + /* + Assure that all enums are of the same size. I can see no conceivable way this would arise, but doing a "static_assert()" to be sure. + */ + ASSERT( sizeof ( field_val.sty ) == sizeof ( field_val.var) && + sizeof ( field_val.sty ) == sizeof ( field_val.wei) && + sizeof ( field_val.sty ) == sizeof ( field_val.str) ); + + + for (i=0; isty = map[i].value; return TRUE; } } @@ -819,13 +843,13 @@ { return (g_ascii_strcasecmp (str, "Normal") == 0 || find_field (style_map, G_N_ELEMENTS (style_map), str, len, - desc ? (int *)&desc->style : NULL) || + desc ? (union field_val*)&desc->style : NULL) || find_field (variant_map, G_N_ELEMENTS (variant_map), str, len, - desc ? (int *)&desc->variant : NULL) || + desc ? (union field_val*)&desc->variant : NULL) || find_field (weight_map, G_N_ELEMENTS (weight_map), str, len, - desc ? (int *)&desc->weight : NULL) || + desc ? (union field_val*)&desc->weight : NULL) || find_field (stretch_map, G_N_ELEMENTS (stretch_map), str, len, - desc ? (int *)&desc->stretch : NULL)); + desc ? (union field_val*)&desc->stretch : NULL)); } static const char * diff -ru pango-1.14.9.orig/pango/modules.c pango-1.14.9/pango/modules.c --- pango-1.14.9.orig/pango/modules.c 2006-10-13 19:14:46.000000000 +0200 +++ pango-1.14.9/pango/modules.c 2007-01-25 05:04:38.000000000 +0100 @@ -39,6 +39,8 @@ #define PANGO_TYPE_MODULE (pango_module_get_type ()) #define PANGO_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), PANGO_TYPE_MODULE, PangoModule)) #define PANGO_IS_MODULE(module) (G_TYPE_CHECK_INSTANCE_TYPE ((module), PANGO_TYPE_MODULE)) +#define GET_SYMBOL(module,name,location) \ + g_module_symbol (module, name, (gpointer *)(void *)&(location)) typedef struct _PangoMapInfo PangoMapInfo; typedef struct _PangoEnginePair PangoEnginePair; @@ -177,14 +179,14 @@ } /* extract symbols from the lib */ - if (!g_module_symbol (pango_module->library, "script_engine_init", - (gpointer *)&pango_module->init) || - !g_module_symbol (pango_module->library, "script_engine_exit", - (gpointer *)&pango_module->exit) || - !g_module_symbol (pango_module->library, "script_engine_list", - (gpointer *)&pango_module->list) || - !g_module_symbol (pango_module->library, "script_engine_create", - (gpointer *)&pango_module->create)) + if (! GET_SYMBOL (pango_module->library, "script_engine_init", + pango_module->init) || + ! GET_SYMBOL (pango_module->library, "script_engine_exit", + pango_module->exit) || + ! GET_SYMBOL (pango_module->library, "script_engine_list", + pango_module->list) || + ! GET_SYMBOL (pango_module->library, "script_engine_create", + pango_module->create)) { g_warning ("%s", g_module_error()); g_module_close (pango_module->library); diff -ru pango-1.14.9.orig/pango/pangofc-fontmap.c pango-1.14.9/pango/pangofc-fontmap.c --- pango-1.14.9.orig/pango/pangofc-fontmap.c 2006-08-17 20:18:28.000000000 +0200 +++ pango-1.14.9/pango/pangofc-fontmap.c 2007-01-25 05:22:41.000000000 +0100 @@ -75,7 +75,7 @@ struct _PangoFcCoverageKey { - char *filename; + FcChar8 *filename; int id; /* needed to handle TTC files with multiple faces */ }; @@ -1312,7 +1312,7 @@ * a filename/index pair; there shouldn't be any reason * this isn't true, but it's not specified anywhere */ - if (FcPatternGetString (fcfont->font_pattern, FC_FILE, 0, (FcChar8 **) &key.filename) != FcResultMatch) + if (FcPatternGetString (fcfont->font_pattern, FC_FILE, 0, &key.filename) != FcResultMatch) return NULL; if (FcPatternGetInteger (fcfont->font_pattern, FC_INDEX, 0, &key.id) != FcResultMatch) diff -ru pango-1.14.9.orig/pango/querymodules.c pango-1.14.9/pango/querymodules.c --- pango-1.14.9.orig/pango/querymodules.c 2006-04-05 00:53:04.000000000 +0200 +++ pango-1.14.9/pango/querymodules.c 2007-01-25 05:02:24.000000000 +0100 @@ -90,7 +90,7 @@ } #define GET_SYMBOL(module,name,location) \ - g_module_symbol (module, name, (gpointer *)(void *)&location) + g_module_symbol (module, name, (gpointer *)(void *)&(location)) static const char * string_from_script (PangoScript script)