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.
This commit is contained in:
Tor Lillqvist 2009-08-14 00:16:18 +03:00 committed by Behdad Esfahbod
parent d15678127a
commit 8b1ceef0b7
1 changed files with 9 additions and 2 deletions

View File

@ -57,6 +57,7 @@
#define STRICT #define STRICT
#include <windows.h> #include <windows.h>
#undef STRICT #undef STRICT
#include <mbstring.h>
#endif #endif
static void static void
@ -2059,7 +2060,13 @@ FcEndElement(void *userData, const XML_Char *name)
FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed"); FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed");
break; 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'; if (p) *p = '\0';
strcat (data, "\\fonts"); strcat (data, "\\fonts");
} }
@ -2072,7 +2079,7 @@ FcEndElement(void *userData, const XML_Char *name)
FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed"); FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed");
break; break;
} }
p = strrchr (data, '\\'); p = _mbsrchr (data, '\\');
if (p) *p = '\0'; if (p) *p = '\0';
strcat (data, "\\..\\share\\fonts"); strcat (data, "\\..\\share\\fonts");
} }