YongHao Hu : msvcp110: Add tr2_sys__Equivalent_wchar implementation and test.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Aug 17 09:01:13 CDT 2015


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

Author: YongHao Hu <christopherwuy at gmail.com>
Date:   Mon Aug 10 14:38:34 2015 +0800

msvcp110: Add tr2_sys__Equivalent_wchar implementation and test.

---

 dlls/msvcp110/msvcp110.spec         |  4 ++--
 dlls/msvcp120/msvcp120.spec         |  4 ++--
 dlls/msvcp120/tests/msvcp120.c      | 18 +++++++++++++++---
 dlls/msvcp120_app/msvcp120_app.spec |  4 ++--
 dlls/msvcp90/ios.c                  | 36 ++++++++++++++++++++++++++++++++++++
 5 files changed, 57 insertions(+), 9 deletions(-)

diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec
index 858af32..a245681 100644
--- a/dlls/msvcp110/msvcp110.spec
+++ b/dlls/msvcp110/msvcp110.spec
@@ -1198,8 +1198,8 @@
 @ cdecl -arch=win64 ?_Empty@?$_Yarn at _W@std@@QEBA_NXZ(ptr) _Yarn_wchar__Empty
 @ cdecl -arch=win32 ?_Equivalent at sys@tr2 at std@@YAHPBD0 at Z(str str) tr2_sys__Equivalent
 @ cdecl -arch=win64 ?_Equivalent at sys@tr2 at std@@YAHPEBD0 at Z(str str) tr2_sys__Equivalent
-@ stub -arch=win32 ?_Equivalent at sys@tr2 at std@@YAHPB_W0 at Z
-@ stub -arch=win64 ?_Equivalent at sys@tr2 at std@@YAHPEB_W0 at Z
+@ cdecl -arch=win32 ?_Equivalent at sys@tr2 at std@@YAHPB_W0 at Z(wstr wstr) tr2_sys__Equivalent_wchar
+@ cdecl -arch=win64 ?_Equivalent at sys@tr2 at std@@YAHPEB_W0 at Z(wstr wstr) tr2_sys__Equivalent_wchar
 @ cdecl -arch=win32 ?_Ffmt@?$num_put at DV?$ostreambuf_iterator at DU?$char_traits at D@std@@@std@@@std@@ABAPADPADDH at Z(ptr ptr long long) num_put_char__Ffmt
 @ cdecl -arch=win64 ?_Ffmt@?$num_put at DV?$ostreambuf_iterator at DU?$char_traits at D@std@@@std@@@std@@AEBAPEADPEADDH at Z(ptr ptr long long) num_put_char__Ffmt
 @ cdecl -arch=win32 ?_Ffmt@?$num_put at GV?$ostreambuf_iterator at GU?$char_traits at G@std@@@std@@@std@@ABAPADPADDH at Z(ptr ptr long long) num_put_wchar__Ffmt
diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec
index 430690c..a0357de 100644
--- a/dlls/msvcp120/msvcp120.spec
+++ b/dlls/msvcp120/msvcp120.spec
@@ -1163,8 +1163,8 @@
 @ cdecl -arch=win64 ?_Empty@?$_Yarn at _W@std@@QEBA_NXZ(ptr) _Yarn_wchar__Empty
 @ cdecl -arch=win32 ?_Equivalent at sys@tr2 at std@@YAHPBD0 at Z(str str) tr2_sys__Equivalent
 @ cdecl -arch=win64 ?_Equivalent at sys@tr2 at std@@YAHPEBD0 at Z(str str) tr2_sys__Equivalent
-@ stub -arch=win32 ?_Equivalent at sys@tr2 at std@@YAHPB_W0 at Z
-@ stub -arch=win64 ?_Equivalent at sys@tr2 at std@@YAHPEB_W0 at Z
+@ cdecl -arch=win32 ?_Equivalent at sys@tr2 at std@@YAHPB_W0 at Z(wstr wstr) tr2_sys__Equivalent_wchar
+@ cdecl -arch=win64 ?_Equivalent at sys@tr2 at std@@YAHPEB_W0 at Z(wstr wstr) tr2_sys__Equivalent_wchar
 @ cdecl -arch=win32 ?_Ffmt@?$num_put at DV?$ostreambuf_iterator at DU?$char_traits at D@std@@@std@@@std@@ABAPADPADDH at Z(ptr ptr long long) num_put_char__Ffmt
 @ cdecl -arch=win64 ?_Ffmt@?$num_put at DV?$ostreambuf_iterator at DU?$char_traits at D@std@@@std@@@std@@AEBAPEADPEADDH at Z(ptr ptr long long) num_put_char__Ffmt
 @ cdecl -arch=win32 ?_Ffmt@?$num_put at GV?$ostreambuf_iterator at GU?$char_traits at G@std@@@std@@@std@@ABAPADPADDH at Z(ptr ptr long long) num_put_wchar__Ffmt
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index f2fdd92..9fca0c2 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -75,6 +75,7 @@ static void (CDECL *p__Do_call)(void *this);
 static ULONGLONG(__cdecl *p_tr2_sys__File_size)(char const*);
 static ULONGLONG(__cdecl *p_tr2_sys__File_size_wchar)(WCHAR const*);
 static int (__cdecl *p_tr2_sys__Equivalent)(char const*, char const*);
+static int (__cdecl *p_tr2_sys__Equivalent_wchar)(WCHAR const*, WCHAR const*);
 static char* (__cdecl *p_tr2_sys__Current_get)(char *);
 static MSVCP_bool (__cdecl *p_tr2_sys__Current_set)(char const*);
 static int (__cdecl *p_tr2_sys__Make_dir)(char const*);
@@ -118,6 +119,8 @@ static BOOL init(void)
                 "?_File_size at sys@tr2 at std@@YA_KPEB_W at Z");
         SET(p_tr2_sys__Equivalent,
                 "?_Equivalent at sys@tr2 at std@@YAHPEBD0 at Z");
+        SET(p_tr2_sys__Equivalent_wchar,
+                "?_Equivalent at sys@tr2 at std@@YAHPEB_W0 at Z");
         SET(p_tr2_sys__Current_get,
                 "?_Current_get at sys@tr2 at std@@YAPEADAEAY0BAE at D@Z");
         SET(p_tr2_sys__Current_set,
@@ -143,6 +146,8 @@ static BOOL init(void)
                 "?_File_size at sys@tr2 at std@@YA_KPB_W at Z");
         SET(p_tr2_sys__Equivalent,
                 "?_Equivalent at sys@tr2 at std@@YAHPBD0 at Z");
+        SET(p_tr2_sys__Equivalent_wchar,
+                "?_Equivalent at sys@tr2 at std@@YAHPB_W0 at Z");
         SET(p_tr2_sys__Current_get,
                 "?_Current_get at sys@tr2 at std@@YAPADAAY0BAE at D@Z");
         SET(p_tr2_sys__Current_set,
@@ -415,6 +420,8 @@ static void test_tr2_sys__Equivalent(void)
     int val, i;
     HANDLE file;
     char temp_path[MAX_PATH], current_path[MAX_PATH];
+    WCHAR testW[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','1',0};
+    WCHAR testW2[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','2',0};
     struct {
         char const *path1;
         char const *path2;
@@ -456,9 +463,14 @@ static void test_tr2_sys__Equivalent(void)
         ok(errno == 0xdeadbeef, "errno = %d\n", errno);
     }
 
-    ok(DeleteFileA("tr2_test_dir/f1"), "Expected tr2_test_dir/f1 to exist\n");
-    ok(DeleteFileA("tr2_test_dir/f2"), "Expected tr2_test_dir/f2 to exist\n");
-    ok(RemoveDirectoryA("tr2_test_dir"), "Expected tr2_test_dir to exist\n");
+    val = p_tr2_sys__Equivalent_wchar(testW, testW);
+    ok(val == 1, "tr2_sys__Equivalent(): expect: 1, got %d\n", val);
+    val = p_tr2_sys__Equivalent_wchar(testW, testW2);
+    ok(val == 0, "tr2_sys__Equivalent(): expect: 0, got %d\n", val);
+
+    ok(DeleteFileA("tr2_test_dir/f1"), "expect tr2_test_dir/f1 to exist\n");
+    ok(DeleteFileA("tr2_test_dir/f2"), "expect tr2_test_dir/f2 to exist\n");
+    ok(p_tr2_sys__Remove_dir("tr2_test_dir"), "expect tr2_test_dir to exist\n");
     ok(SetCurrentDirectoryA(current_path), "SetCurrentDirectoryA failed\n");
 }
 
diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec
index 04585c1..515ca2b 100644
--- a/dlls/msvcp120_app/msvcp120_app.spec
+++ b/dlls/msvcp120_app/msvcp120_app.spec
@@ -1163,8 +1163,8 @@
 @ cdecl -arch=win64 ?_Empty@?$_Yarn at _W@std@@QEBA_NXZ(ptr) msvcp120.?_Empty@?$_Yarn at _W@std@@QEBA_NXZ
 @ cdecl -arch=win32 ?_Equivalent at sys@tr2 at std@@YAHPBD0 at Z(str str) msvcp120.?_Equivalent at sys@tr2 at std@@YAHPBD0 at Z
 @ cdecl -arch=win64 ?_Equivalent at sys@tr2 at std@@YAHPEBD0 at Z(str str) msvcp120.?_Equivalent at sys@tr2 at std@@YAHPEBD0 at Z
-@ stub -arch=win32 ?_Equivalent at sys@tr2 at std@@YAHPB_W0 at Z
-@ stub -arch=win64 ?_Equivalent at sys@tr2 at std@@YAHPEB_W0 at Z
+@ cdecl -arch=win32 ?_Equivalent at sys@tr2 at std@@YAHPB_W0 at Z(wstr wstr) msvcp120.?_Equivalent at sys@tr2 at std@@YAHPB_W0 at Z
+@ cdecl -arch=win64 ?_Equivalent at sys@tr2 at std@@YAHPEB_W0 at Z(wstr wstr) msvcp120.?_Equivalent at sys@tr2 at std@@YAHPEB_W0 at Z
 @ cdecl -arch=win32 ?_Ffmt@?$num_put at DV?$ostreambuf_iterator at DU?$char_traits at D@std@@@std@@@std@@ABAPADPADDH at Z(ptr ptr long long) msvcp120.?_Ffmt@?$num_put at DV?$ostreambuf_iterator at DU?$char_traits at D@std@@@std@@@std@@ABAPADPADDH at Z
 @ cdecl -arch=win64 ?_Ffmt@?$num_put at DV?$ostreambuf_iterator at DU?$char_traits at D@std@@@std@@@std@@AEBAPEADPEADDH at Z(ptr ptr long long) msvcp120.?_Ffmt@?$num_put at DV?$ostreambuf_iterator at DU?$char_traits at D@std@@@std@@@std@@AEBAPEADPEADDH at Z
 @ cdecl -arch=win32 ?_Ffmt@?$num_put at GV?$ostreambuf_iterator at GU?$char_traits at G@std@@@std@@@std@@ABAPADPADDH at Z(ptr ptr long long) msvcp120.?_Ffmt@?$num_put at GV?$ostreambuf_iterator at GU?$char_traits at G@std@@@std@@@std@@ABAPADPADDH at Z
diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c
index 49a3e4b..af3f569 100644
--- a/dlls/msvcp90/ios.c
+++ b/dlls/msvcp90/ios.c
@@ -14754,6 +14754,42 @@ ULONGLONG __cdecl tr2_sys__File_size_wchar(WCHAR const* path)
     return ((ULONGLONG)(fad.nFileSizeHigh) << 32) + fad.nFileSizeLow;
 }
 
+/* ?_Equivalent at sys@tr2 at std@@YAHPB_W0 at Z */
+/* ?_Equivalent at sys@tr2 at std@@YAHPEB_W0 at Z */
+int __cdecl tr2_sys__Equivalent_wchar(WCHAR const* path1, WCHAR const* path2)
+{
+    HANDLE h1, h2;
+    int ret;
+    BY_HANDLE_FILE_INFORMATION info1, info2;
+    TRACE("(%s %s)\n", debugstr_w(path1), debugstr_w(path2));
+
+    h1 = CreateFileW(path1, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
+            NULL, OPEN_EXISTING, 0, 0);
+    h2 = CreateFileW(path2, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
+            NULL, OPEN_EXISTING, 0, 0);
+    if(h1 == INVALID_HANDLE_VALUE) {
+        if(h2 == INVALID_HANDLE_VALUE) {
+            return -1;
+        }else {
+            CloseHandle(h2);
+            return 0;
+        }
+    }else if(h2 == INVALID_HANDLE_VALUE) {
+        CloseHandle(h1);
+        return 0;
+    }
+
+    ret = GetFileInformationByHandle(h1, &info1) && GetFileInformationByHandle(h2, &info2);
+    CloseHandle(h1);
+    CloseHandle(h2);
+    if(!ret)
+        return -1;
+    return (info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber
+            && info1.nFileIndexHigh == info2.nFileIndexHigh
+            && info1.nFileIndexLow == info2.nFileIndexLow
+            );
+}
+
 /* ??1_Winit at std@@QAE at XZ */
 /* ??1_Winit at std@@QAE at XZ */
 DEFINE_THISCALL_WRAPPER(_Winit_dtor, 4)




More information about the wine-cvs mailing list