[PATCH 3/3] Don't crash on Win9x/WinMe by using more A-functions
Paul Vriens
Paul.Vriens.Wine at gmail.com
Thu Dec 10 04:55:58 CST 2009
---
dlls/ole32/tests/storage32.c | 72 +++++++++++++++++++++++++-----------------
1 files changed, 43 insertions(+), 29 deletions(-)
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index b5ecf22..97339da 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -36,7 +36,9 @@ DEFINE_GUID( test_stg_cls, 0x88888888, 0x0425, 0x0000, 0,0,0,0,0,0,0,0);
static CHAR filenameA[MAX_PATH];
static WCHAR filename[MAX_PATH];
+static const char file1_nameA[] = {'c','o','p','y','t','e','s','t','A',0};
static const WCHAR file1_name[] = {'c','o','p','y','t','e','s','t','A',0};
+static const char file2_nameA[] = {'c','o','p','y','t','e','s','t','B',0};
static const WCHAR file2_name[] = {'c','o','p','y','t','e','s','t','B',0};
static const WCHAR stgA_name[] = {'S','t','o','r','a','g','e','A',0};
static const WCHAR stgB_name[] = {'S','t','o','r','a','g','e','B',0};
@@ -44,6 +46,15 @@ static const WCHAR strmA_name[] = {'S','t','r','e','a','m','A',0};
static const WCHAR strmB_name[] = {'S','t','r','e','a','m','B',0};
static const WCHAR strmC_name[] = {'S','t','r','e','a','m','C',0};
+/* Win9x and WinMe don't have lstrcmpW */
+static int strcmp_ww(LPCWSTR strw1, LPCWSTR strw2)
+{
+ CHAR stra1[512], stra2[512];
+ WideCharToMultiByte(CP_ACP, 0, strw1, -1, stra1, sizeof(stra1), NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, strw2, -1, stra2, sizeof(stra2), NULL, NULL);
+ return lstrcmpA(stra1, stra2);
+}
+
static void test_hglobal_storage_stat(void)
{
ILockBytes *ilb = NULL;
@@ -1891,6 +1902,7 @@ static void test_fmtusertypestg(void)
IStorage *stg;
IEnumSTATSTG *stat;
HRESULT hr;
+ static const char fileA[] = {'f','m','t','t','e','s','t',0};
static const WCHAR fileW[] = {'f','m','t','t','e','s','t',0};
static WCHAR userTypeW[] = {'S','t','g','U','s','r','T','y','p','e',0};
static WCHAR strmNameW[] = {1,'C','o','m','p','O','b','j',0};
@@ -1914,7 +1926,7 @@ static void test_fmtusertypestg(void)
DWORD got;
while ((hr = IEnumSTATSTG_Next(stat, 1, &statstg, &got)) == S_OK && got == 1)
{
- if (lstrcmpW(statstg.pwcsName, strmNameW) == 0)
+ if (strcmp_ww(statstg.pwcsName, strmNameW) == 0)
found = TRUE;
else
ok(0, "found unexpected stream or storage\n");
@@ -1937,7 +1949,7 @@ static void test_fmtusertypestg(void)
DWORD got;
while ((hr = IEnumSTATSTG_Next(stat, 1, &statstg, &got)) == S_OK && got == 1)
{
- if (lstrcmpW(statstg.pwcsName, strmNameW) == 0)
+ if (strcmp_ww(statstg.pwcsName, strmNameW) == 0)
found = TRUE;
else
ok(0, "found unexpected stream or storage\n");
@@ -1947,7 +1959,7 @@ static void test_fmtusertypestg(void)
}
IStorage_Release(stg);
- DeleteFileW( fileW );
+ DeleteFileA( fileA );
}
}
@@ -2105,7 +2117,7 @@ static void test_copyto(void)
hr = IStream_Read(strm_tmp, buf, sizeof(buf), NULL);
ok(hr == S_OK, "Read failed: 0x%08x\n", hr);
if(SUCCEEDED(hr))
- ok(lstrcmpW(buf, strmA_name) == 0,
+ ok(strcmp_ww(buf, strmA_name) == 0,
"Expected %s to be read, got %s\n", wine_dbgstr_w(strmA_name), wine_dbgstr_w(buf));
IStream_Release(strm_tmp);
@@ -2128,7 +2140,7 @@ static void test_copyto(void)
hr = IStream_Read(strm_tmp, buf, sizeof(buf), NULL);
ok(hr == S_OK, "Read failed: 0x%08x\n", hr);
if(SUCCEEDED(hr))
- ok(lstrcmpW(buf, strmB_name) == 0,
+ ok(strcmp_ww(buf, strmB_name) == 0,
"Expected %s to be read, got %s\n", wine_dbgstr_w(strmB_name), wine_dbgstr_w(buf));
IStream_Release(strm_tmp);
@@ -2146,7 +2158,7 @@ static void test_copyto(void)
hr = IStream_Read(strm_tmp, buf, sizeof(buf), NULL);
ok(hr == S_OK, "Read failed: 0x%08x\n", hr);
if(SUCCEEDED(hr))
- ok(lstrcmpW(buf, strmC_name) == 0,
+ ok(strcmp_ww(buf, strmC_name) == 0,
"Expected %s to be read, got %s\n", wine_dbgstr_w(strmC_name), wine_dbgstr_w(buf));
IStream_Release(strm_tmp);
@@ -2158,8 +2170,8 @@ cleanup:
if(file2)
IStorage_Release(file2);
- DeleteFileW(file1_name);
- DeleteFileW(file2_name);
+ DeleteFileA(file1_nameA);
+ DeleteFileA(file2_nameA);
}
static void test_copyto_snbexclusions(void)
@@ -2220,7 +2232,7 @@ static void test_copyto_snbexclusions(void)
hr = IStream_Read(strm_tmp, buf, sizeof(buf), NULL);
ok(hr == S_OK, "Read failed: 0x%08x\n", hr);
if(SUCCEEDED(hr))
- ok(lstrcmpW(buf, strmB_name) == 0,
+ ok(strcmp_ww(buf, strmB_name) == 0,
"Expected %s to be read, got %s\n", wine_dbgstr_w(strmB_name), wine_dbgstr_w(buf));
IStream_Release(strm_tmp);
@@ -2241,8 +2253,8 @@ cleanup:
if(file2)
IStorage_Release(file2);
- DeleteFileW(file1_name);
- DeleteFileW(file2_name);
+ DeleteFileA(file1_nameA);
+ DeleteFileA(file2_nameA);
}
static void test_copyto_iidexclusions_storage(void)
@@ -2308,7 +2320,7 @@ static void test_copyto_iidexclusions_storage(void)
hr = IStream_Read(strm_tmp, buf, sizeof(buf), NULL);
ok(hr == S_OK, "Read failed: 0x%08x\n", hr);
if(SUCCEEDED(hr))
- ok(lstrcmpW(buf, strmC_name) == 0,
+ ok(strcmp_ww(buf, strmC_name) == 0,
"Expected %s to be read, got %s\n", wine_dbgstr_w(strmC_name), wine_dbgstr_w(buf));
IStream_Release(strm_tmp);
@@ -2320,8 +2332,8 @@ cleanup:
if(file2)
IStorage_Release(file2);
- DeleteFileW(file1_name);
- DeleteFileW(file2_name);
+ DeleteFileA(file1_nameA);
+ DeleteFileA(file2_nameA);
}
static void test_copyto_iidexclusions_stream(void)
@@ -2393,8 +2405,8 @@ cleanup:
if(file2)
IStorage_Release(file2);
- DeleteFileW(file1_name);
- DeleteFileW(file2_name);
+ DeleteFileA(file1_nameA);
+ DeleteFileA(file2_nameA);
}
static void test_rename(void)
@@ -2471,10 +2483,11 @@ static void test_toplevel_stat(void)
IStorage *stg = NULL;
HRESULT r;
STATSTG stat;
- WCHAR prev_dir[MAX_PATH];
- WCHAR temp[MAX_PATH];
- WCHAR full_path[MAX_PATH];
- LPWSTR rel_path;
+ char prev_dir[MAX_PATH];
+ char temp[MAX_PATH];
+ char full_path[MAX_PATH];
+ LPSTR rel_pathA;
+ WCHAR rel_path[MAX_PATH];
DeleteFileA(filenameA);
@@ -2483,7 +2496,7 @@ static void test_toplevel_stat(void)
ok(r==S_OK, "StgCreateDocfile failed\n");
r = IStorage_Stat( stg, &stat, STATFLAG_DEFAULT );
- ok(!lstrcmpW(stat.pwcsName, filename), "expected %s, got %s\n",
+ ok(!strcmp_ww(stat.pwcsName, filename), "expected %s, got %s\n",
wine_dbgstr_w(filename), wine_dbgstr_w(stat.pwcsName));
CoTaskMemFree(stat.pwcsName);
@@ -2493,7 +2506,7 @@ static void test_toplevel_stat(void)
ok(r==S_OK, "StgOpenStorage failed with error 0x%08x\n", r);
r = IStorage_Stat( stg, &stat, STATFLAG_DEFAULT );
- ok(!lstrcmpW(stat.pwcsName, filename), "expected %s, got %s\n",
+ ok(!strcmp_ww(stat.pwcsName, filename), "expected %s, got %s\n",
wine_dbgstr_w(filename), wine_dbgstr_w(stat.pwcsName));
CoTaskMemFree(stat.pwcsName);
@@ -2502,20 +2515,21 @@ static void test_toplevel_stat(void)
DeleteFileA(filenameA);
/* Stat always returns the full path, even for files opened with a relative path. */
- GetCurrentDirectoryW(MAX_PATH, prev_dir);
+ GetCurrentDirectoryA(MAX_PATH, prev_dir);
- GetTempPathW(MAX_PATH, temp);
+ GetTempPathA(MAX_PATH, temp);
- SetCurrentDirectoryW(temp);
+ SetCurrentDirectoryA(temp);
- GetFullPathNameW(filename, MAX_PATH, full_path, &rel_path);
+ GetFullPathNameA(filenameA, MAX_PATH, full_path, &rel_pathA);
+ MultiByteToWideChar(CP_ACP, 0, rel_pathA, -1, rel_path, MAX_PATH);
r = StgCreateDocfile( rel_path, STGM_CREATE | STGM_SHARE_EXCLUSIVE |
STGM_READWRITE |STGM_TRANSACTED, 0, &stg);
ok(r==S_OK, "StgCreateDocfile failed\n");
r = IStorage_Stat( stg, &stat, STATFLAG_DEFAULT );
- ok(!lstrcmpW(stat.pwcsName, filename), "expected %s, got %s\n",
+ ok(!strcmp_ww(stat.pwcsName, filename), "expected %s, got %s\n",
wine_dbgstr_w(filename), wine_dbgstr_w(stat.pwcsName));
CoTaskMemFree(stat.pwcsName);
@@ -2525,13 +2539,13 @@ static void test_toplevel_stat(void)
ok(r==S_OK, "StgOpenStorage failed with error 0x%08x\n", r);
r = IStorage_Stat( stg, &stat, STATFLAG_DEFAULT );
- ok(!lstrcmpW(stat.pwcsName, filename), "expected %s, got %s\n",
+ ok(!strcmp_ww(stat.pwcsName, filename), "expected %s, got %s\n",
wine_dbgstr_w(filename), wine_dbgstr_w(stat.pwcsName));
CoTaskMemFree(stat.pwcsName);
IStorage_Release( stg );
- SetCurrentDirectoryW(prev_dir);
+ SetCurrentDirectoryA(prev_dir);
DeleteFileA(filenameA);
}
--
1.6.2.5
--------------090703060308020209000202--
More information about the wine-patches
mailing list