From 719b3d63d338d1b31e042ca1c8fad8b3d402c78d Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Sat, 31 May 2008 02:29:58 +0000 Subject: [PATCH] (ftfont_font_format): Don't use strcasestr. --- src/ChangeLog | 4 ++++ src/ftfont.c | 22 ++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 0c1125c9e05..030c2a186bf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2008-05-31 Kenichi Handa + + * ftfont.c (ftfont_font_format): Don't use strcasestr. + 2008-05-30 Stefan Monnier * chartab.c (Foptimize_char_table, optimize_sub_char_table): diff --git a/src/ftfont.c b/src/ftfont.c index 574b7841067..bc8c4406257 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -1707,6 +1707,7 @@ Lisp_Object ftfont_font_format (FcPattern *pattern) { FcChar8 *str; + int len; #ifdef FC_FONTFORMAT if (FcPatternGetString (pattern, FC_FONTFORMAT, 0, &str) != FcResultMatch) @@ -1722,14 +1723,19 @@ ftfont_font_format (FcPattern *pattern) #else /* not FC_FONTFORMAT */ if (FcPatternGetString (pattern, FC_FILE, 0, &str) != FcResultMatch) return Qnil; - if (strcasestr ((char *) str, ".ttf") == 0) - return intern ("truetype"); - if (strcasestr ((char *) str, "pfb") == 0) - return intern ("type1"); - if (strcasestr ((char *) str, "pcf") == 0) - return intern ("pcf"); - if (strcasestr ((char *) str, "bdf") == 0) - return intern ("bdf"); + len = strlen ((char *) str); + if (len >= 4) + { + str += len - 4; + if (xstrcasecmp ((char *) str, ".ttf") == 0) + return intern ("truetype"); + if (xstrcasecmp ((char *) str, "pfb") == 0) + return intern ("type1"); + if (xstrcasecmp ((char *) str, "pcf") == 0) + return intern ("pcf"); + if (xstrcasecmp ((char *) str, "bdf") == 0) + return intern ("bdf"); + } #endif /* not FC_FONTFORMAT */ return intern ("unknown"); } -- 2.39.2