Commit ab5db464 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

msvcrt: Add MBCS handling for _splitpath.

parent e67f8412
......@@ -1059,7 +1059,15 @@ int CDECL _splitpath_s(const char* inpath,
/* look for end of directory part */
end = NULL;
for (p = inpath; *p; p++) if (*p == '/' || *p == '\\') end = p + 1;
for (p = inpath; *p; p++)
{
if (_ismbblead((unsigned char)*p))
{
p++;
continue;
}
if (*p == '/' || *p == '\\') end = p + 1;
}
if (end) /* got a directory */
{
......
......@@ -25,6 +25,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <io.h>
#include <mbctype.h>
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
......@@ -390,6 +391,31 @@ static void test_fullpath(void)
RemoveDirectoryA(level1);
}
static void test_splitpath(void)
{
const char* path = "c:\\\x83\x5c\x83\x74\x83\x67.bin";
char drive[3], dir[MAX_PATH], fname[MAX_PATH], ext[MAX_PATH];
int prev_cp = _getmbcp();
/* SBCS codepage */
_setmbcp(1252);
_splitpath(path, drive, dir, fname, ext);
ok(!strcmp(drive, "c:"), "got %s\n", drive);
ok(!strcmp(dir, "\\\x83\x5c"), "got %s\n", dir);
ok(!strcmp(fname, "\x83\x74\x83\x67"), "got %s\n", fname);
ok(!strcmp(ext, ".bin"), "got %s\n", ext);
/* MBCS (Japanese) codepage */
_setmbcp(932);
_splitpath(path, drive, dir, fname, ext);
ok(!strcmp(drive, "c:"), "got %s\n", drive);
ok(!strcmp(dir, "\\"), "got %s\n", dir);
ok(!strcmp(fname, "\x83\x5c\x83\x74\x83\x67"), "got %s\n", fname);
ok(!strcmp(ext, ".bin"), "got %s\n", ext);
_setmbcp(prev_cp);
}
START_TEST(dir)
{
init();
......@@ -397,4 +423,5 @@ START_TEST(dir)
test_fullpath();
test_makepath();
test_makepath_s();
test_splitpath();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment