From: Tor Lillqvist Date: Thu, 13 Aug 2009 21:16:18 +0000 (+0300) Subject: Use multi-byte codepage aware string function on Windows X-Git-Tag: 2.7.2~5 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=8b1ceef0b7f41703775c163d6ac595a5407e9159;p=fontconfig.git Use multi-byte codepage aware string function on Windows 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. --- diff --git a/src/fcxml.c b/src/fcxml.c index e829422..ef85a4f 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -57,6 +57,7 @@ #define STRICT #include #undef STRICT +#include #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"); }