From: Paul Eggert Date: Sat, 9 Apr 2011 19:14:12 +0000 (-0700) Subject: * ftfont.c: Distingish more carefully between FcChar8 and char. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~356^2~15 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dae0cd48d84709e8f3662b7bbf14d22cc46038de;p=emacs.git * ftfont.c: Distingish more carefully between FcChar8 and char. The previous code passed unsigned char * to a functions like strlen and xstrcasecmp that expect char *, which does not conform to the C standard. (get_adstyle_property, ftfont_pattern_entity): Use FcChar8 for arguments to FcPatternGetString, and explicitly cast FcChar8 * to char * when the C standard requires it. --- diff --git a/src/ChangeLog b/src/ChangeLog index 27dbdd7cb11..c8811f7708b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2011-04-09 Paul Eggert + * ftfont.c: Distingish more carefully between FcChar8 and char. + The previous code passed unsigned char * to a functions like + strlen and xstrcasecmp that expect char *, which does not + conform to the C standard. + (get_adstyle_property, ftfont_pattern_entity): Use FcChar8 for + arguments to FcPatternGetString, and explicitly cast FcChar8 * to + char * when the C standard requires it. + * keyboard.c (read_char): Remove unused var. * eval.c: Port to Windows vsnprintf (Bug#8435). diff --git a/src/ftfont.c b/src/ftfont.c index 06ba6d7fe25..2e66222d268 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -160,11 +160,13 @@ static struct static Lisp_Object get_adstyle_property (FcPattern *p) { - unsigned char *str, *end; + FcChar8 *fcstr; + char *str, *end; Lisp_Object adstyle; - if (FcPatternGetString (p, FC_STYLE, 0, (FcChar8 **) &str) != FcResultMatch) + if (FcPatternGetString (p, FC_STYLE, 0, &fcstr) != FcResultMatch) return Qnil; + str = (char *) fcstr; for (end = str; *end && *end != ' '; end++); if (*end) { @@ -189,19 +191,20 @@ static Lisp_Object ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) { Lisp_Object key, cache, entity; - unsigned char *file, *str; + FcChar8 *str; + char *file; int idx; int numeric; double dbl; FcBool b; - if (FcPatternGetString (p, FC_FILE, 0, (FcChar8 **) &file) != FcResultMatch) + if (FcPatternGetString (p, FC_FILE, 0, &str) != FcResultMatch) return Qnil; if (FcPatternGetInteger (p, FC_INDEX, 0, &idx) != FcResultMatch) return Qnil; - key = Fcons (make_unibyte_string ((char *) file, strlen ((char *) file)), - make_number (idx)); + file = (char *) str; + key = Fcons (make_unibyte_string (file, strlen (file)), make_number (idx)); cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY); entity = XCAR (cache); if (! NILP (entity)) @@ -219,10 +222,16 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) ASET (entity, FONT_TYPE_INDEX, Qfreetype); ASET (entity, FONT_REGISTRY_INDEX, Qiso10646_1); - if (FcPatternGetString (p, FC_FOUNDRY, 0, (FcChar8 **) &str) == FcResultMatch) - ASET (entity, FONT_FOUNDRY_INDEX, font_intern_prop (str, strlen (str), 1)); - if (FcPatternGetString (p, FC_FAMILY, 0, (FcChar8 **) &str) == FcResultMatch) - ASET (entity, FONT_FAMILY_INDEX, font_intern_prop (str, strlen (str), 1)); + if (FcPatternGetString (p, FC_FOUNDRY, 0, &str) == FcResultMatch) + { + char *s = (char *) str; + ASET (entity, FONT_FOUNDRY_INDEX, font_intern_prop (s, strlen (s), 1)); + } + if (FcPatternGetString (p, FC_FAMILY, 0, &str) == FcResultMatch) + { + char *s = (char *) str; + ASET (entity, FONT_FAMILY_INDEX, font_intern_prop (s, strlen (s), 1)); + } if (FcPatternGetInteger (p, FC_WEIGHT, 0, &numeric) == FcResultMatch) { if (numeric >= FC_WEIGHT_REGULAR && numeric < FC_WEIGHT_MEDIUM)