msvcrt: Add MBCS handling for _splitpath.

This commit is contained in:
Akihiro Sagawa 2014-04-14 00:08:33 +09:00 committed by Alexandre Julliard
parent e67f84122d
commit ab5db46477
2 changed files with 36 additions and 1 deletions

View File

@ -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 */
{

View File

@ -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();
}