]> git.wh0rd.org - fontconfig.git/commitdiff
Use multi-byte codepage aware string function on Windows
authorTor Lillqvist <tml@iki.fi>
Thu, 13 Aug 2009 21:16:18 +0000 (00:16 +0300)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 13 Aug 2009 22:19:56 +0000 (18:19 -0400)
The East Asian double-byte codepages have characters with backslash as
the second byte, so we must use _mbsrchr() instead of strrchr() when
looking at pathnames in the system codepage.

src/fcxml.c

index e829422b318fc3fd35ae767a5dd54fc73a5fe4f8..ef85a4f312b8404f73977c8449205148cc2d3936 100644 (file)
@@ -57,6 +57,7 @@
 #define STRICT
 #include <windows.h>
 #undef STRICT
+#include <mbstring.h>
 #endif
 
 static void
@@ -2059,7 +2060,13 @@ FcEndElement(void *userData, const XML_Char *name)
                        FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed");
                        break;
                }
-               p = strrchr (data, '\\');
+               /*
+                * Must use the multi-byte aware function to search
+                * for backslash because East Asian double-byte code
+                * pages have characters with backslash as the second
+                * byte.
+                */
+               p = _mbsrchr (data, '\\');
                if (p) *p = '\0';
                strcat (data, "\\fonts");
        }
@@ -2072,7 +2079,7 @@ FcEndElement(void *userData, const XML_Char *name)
                        FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed");
                        break;
                }
-               p = strrchr (data, '\\');
+               p = _mbsrchr (data, '\\');
                if (p) *p = '\0';
                strcat (data, "\\..\\share\\fonts");
        }