changeset 95433:3ffecc48d809

(ftfont_font_format): Don't use strcasestr.
author Kenichi Handa <handa@m17n.org>
date Sat, 31 May 2008 02:27:46 +0000
parents e18e11dca65b
children a27eb04b8dc4
files src/ftfont.c
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/ftfont.c	Sat May 31 02:24:12 2008 +0000
+++ b/src/ftfont.c	Sat May 31 02:27:46 2008 +0000
@@ -1707,6 +1707,7 @@
 ftfont_font_format (FcPattern *pattern)
 {
   FcChar8 *str;
+  int len;
 
 #ifdef FC_FONTFORMAT
   if (FcPatternGetString (pattern, FC_FONTFORMAT, 0, &str) != FcResultMatch)
@@ -1722,14 +1723,19 @@
 #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");
 }