Akihiro Sagawa : msvcrt: Add MBCS handling for _splitpath.

Alexandre Julliard julliard at winehq.org
Mon Apr 14 14:18:56 CDT 2014


Module: wine
Branch: master
Commit: ab5db46477dff9fc46773f1e2c5e497ef6a97743
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ab5db46477dff9fc46773f1e2c5e497ef6a97743

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Mon Apr 14 00:08:33 2014 +0900

msvcrt: Add MBCS handling for _splitpath.

---

 dlls/msvcrt/dir.c       |   10 +++++++++-
 dlls/msvcrt/tests/dir.c |   27 +++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c
index fa87ac1..d6dd661 100644
--- a/dlls/msvcrt/dir.c
+++ b/dlls/msvcrt/dir.c
@@ -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 */
     {
diff --git a/dlls/msvcrt/tests/dir.c b/dlls/msvcrt/tests/dir.c
index fa19e1e..aa273ea 100644
--- a/dlls/msvcrt/tests/dir.c
+++ b/dlls/msvcrt/tests/dir.c
@@ -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();
 }




More information about the wine-cvs mailing list