-- v2: odbccp32: SQLWritePrivateProfileStringW correctly hanndle ODBC_BOTH_DSN
From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/odbccp32/odbccp32.c | 49 +++++++++++++++++++++----------------- dlls/odbccp32/tests/misc.c | 40 +++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 22 deletions(-)
diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c index fd02391a384..1183cbddd35 100644 --- a/dlls/odbccp32/odbccp32.c +++ b/dlls/odbccp32/odbccp32.c @@ -1802,6 +1802,7 @@ BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry { LONG ret; HKEY hkey; + WCHAR *regpath;
clear_errors(); TRACE("%s %s %s %s\n", debugstr_w(lpszSection), debugstr_w(lpszEntry), @@ -1813,37 +1814,41 @@ BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry return FALSE; }
+ regpath = malloc ( (wcslen(L"Software\ODBC\") + wcslen(lpszFilename) + wcslen(L"\") + + wcslen(lpszSection) + 1) * sizeof(WCHAR)); + if (!regpath) + { + push_error(ODBC_ERROR_OUT_OF_MEM, L"Out of memory"); + return FALSE; + } + wcscpy(regpath, L"Software\ODBC\"); + wcscat(regpath, lpszFilename); + wcscat(regpath, L"\"); + wcscat(regpath, lpszSection); + /* odbcinit.ini is only for drivers, so default to local Machine */ if (!wcsicmp(lpszFilename, L"ODBCINST.INI") || config_mode == ODBC_SYSTEM_DSN) - ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, L"Software\ODBC", &hkey); + ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, regpath, &hkey); else if (config_mode == ODBC_USER_DSN) - ret = RegCreateKeyW(HKEY_CURRENT_USER, L"Software\ODBC", &hkey); + ret = RegCreateKeyW(HKEY_CURRENT_USER, regpath, &hkey); else { - ret = RegCreateKeyW(HKEY_CURRENT_USER, L"Software\ODBC", &hkey); - if (ret) ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, L"Software\ODBC", &hkey); + /* Check existing keys first */ + if ((ret = RegOpenKeyW(HKEY_CURRENT_USER, regpath, &hkey)) != ERROR_SUCCESS) + ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, regpath, &hkey); + + if (ret != ERROR_SUCCESS) + ret = RegCreateKeyW(HKEY_CURRENT_USER, regpath, &hkey); }
+ free(regpath); + if (ret == ERROR_SUCCESS) { - HKEY hkeyfilename; - - if ((ret = RegCreateKeyW(hkey, lpszFilename, &hkeyfilename)) == ERROR_SUCCESS) - { - HKEY hkey_section; - - if ((ret = RegCreateKeyW(hkeyfilename, lpszSection, &hkey_section)) == ERROR_SUCCESS) - { - if(lpszString) - ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ, (BYTE*)lpszString, (lstrlenW(lpszString)+1)*sizeof(WCHAR)); - else - ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ, (BYTE*)L"", sizeof(L"")); - RegCloseKey(hkey_section); - } - - RegCloseKey(hkeyfilename); - } - + if(lpszString) + ret = RegSetValueExW(hkey, lpszEntry, 0, REG_SZ, (BYTE*)lpszString, (lstrlenW(lpszString)+1)*sizeof(WCHAR)); + else + ret = RegSetValueExW(hkey, lpszEntry, 0, REG_SZ, (BYTE*)L"", sizeof(L"")); RegCloseKey(hkey); }
diff --git a/dlls/odbccp32/tests/misc.c b/dlls/odbccp32/tests/misc.c index ccd3caea977..e9f879edda6 100644 --- a/dlls/odbccp32/tests/misc.c +++ b/dlls/odbccp32/tests/misc.c @@ -432,6 +432,9 @@ static void test_SQLGetPrivateProfileStringW(void) } ok(ret, "SQLWritePrivateProfileString failed\n");
+ ret = SQLWritePrivateProfileStringW(L"wineodbc1", L"testing" , L"systemdsn", L"ODBC.INI"); + ok(ret, "SQLWritePrivateProfileString failed\n"); + ret = SQLGetPrivateProfileStringW(L"wineodbc", NULL, L"", buffer, 256, L"ODBC.INI"); ok(ret, "SQLGetPrivateProfileStringW failed\n");
@@ -441,6 +444,9 @@ static void test_SQLGetPrivateProfileStringW(void) ret = SQLGetPrivateProfileStringW(L"wineodbc", NULL, L"", buffer, 256, L"ODBC.INI"); ok(!ret, "SQLGetPrivateProfileStringW succeeded\n");
+ ret = SQLWritePrivateProfileStringW(L"wineodbc1", L"testing" , L"userdsn", L"ODBC.INI"); + ok(ret, "SQLWritePrivateProfileString failed\n"); + ret = SQLSetConfigMode(ODBC_BOTH_DSN); ok(ret, "SQLSetConfigMode failed\n");
@@ -450,6 +456,40 @@ static void test_SQLGetPrivateProfileStringW(void) reg_ret = RegDeleteKeyW(HKEY_LOCAL_MACHINE, L"Software\ODBC\ODBC.INI\wineodbc"); ok(reg_ret == ERROR_SUCCESS, "RegDeleteKeyW failed %ld\n", reg_ret);
+ /* Show existing USER DSN is checked before MACHINE */ + ret = SQLWritePrivateProfileStringW(L"wineodbc1", L"testing" , L"bothdsn", L"ODBC.INI"); + ok(ret, "SQLWritePrivateProfileString failed\n"); + + ret = SQLSetConfigMode(ODBC_SYSTEM_DSN); + ok(ret, "SQLSetConfigMode failed\n"); + + ret = SQLGetPrivateProfileStringW(L"wineodbc1", L"testing", L"", buffer, 256, L"ODBC.INI"); + ok(ret, "SQLGetPrivateProfileStringW failed\n"); + ok(!wcscmp(buffer, L"systemdsn"), "Wrong value\n"); + + reg_ret = RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\ODBC\ODBC.INI\wineodbc1"); + ok(reg_ret == ERROR_SUCCESS, "RegDeleteKeyW failed %ld\n", reg_ret); + + reg_ret = RegDeleteKeyW(HKEY_LOCAL_MACHINE, L"Software\ODBC\ODBC.INI\wineodbc1"); + ok(reg_ret == ERROR_SUCCESS, "RegDeleteKeyW failed %ld\n", reg_ret); + + ret = SQLSetConfigMode(ODBC_BOTH_DSN); + ok(ret, "SQLSetConfigMode failed\n"); + + /* Writes to USER if no key found */ + ret = SQLWritePrivateProfileStringW(L"wineodbc1", L"testing" , L"userwrite", L"ODBC.INI"); + ok(ret, "SQLWritePrivateProfileString failed\n"); + + ret = SQLSetConfigMode(ODBC_USER_DSN); + ok(ret, "SQLSetConfigMode failed\n"); + + ret = SQLGetPrivateProfileStringW(L"wineodbc1", L"testing", L"", buffer, 256, L"ODBC.INI"); + ok(ret, "SQLGetPrivateProfileStringW failed\n"); + ok(!wcscmp(buffer, L"userwrite"), "Wrong value\n"); + + reg_ret = RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\ODBC\ODBC.INI\wineodbc1"); + ok(reg_ret == ERROR_SUCCESS, "RegDeleteKeyW failed %ld\n", reg_ret); + ret = SQLSetConfigMode(ODBC_USER_DSN); ok(ret, "SQLSetConfigMode failed\n");
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147826
Your paranoid android.
=== debian11b (64 bit WoW report) ===
ddraw: ddraw4.c:3969: Test failed: Expected message 0x5, but didn't receive it.
user32: input.c:4305: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 0000000000D800D6, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032 input.c:733: Test failed: peek: raw_legacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey F, message WM_KEYDOWN, extra 0 input.c:733: Test failed: peek: raw_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0x46, lparam 0x10001 input.c:733: Test failed: peek: raw_legacy: 0: test->expect 2 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_CHAR, wparam 0x66, lparam 0x10001 input.c:734: Test failed: peek: raw_legacy: 0: got F: 0 input.c:733: Test failed: peek: raw_legacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey F, message WM_KEYUP, extra 0 input.c:733: Test failed: peek: raw_legacy: 1: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0x46, lparam 0xffffffffc0020001 input.c:733: Test failed: peek: raw_vk_packet_legacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey 0xe7, message WM_KEYDOWN, extra 0 input.c:733: Test failed: peek: raw_vk_packet_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0xe7, lparam 0x10001 input.c:734: Test failed: peek: raw_vk_packet_legacy: 0: got 0xe7: 0 input.c:733: Test failed: peek: raw_vk_packet_legacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey 0xe7, message WM_KEYUP, extra 0 input.c:733: Test failed: peek: raw_vk_packet_legacy: 1: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0xe7, lparam 0xffffffffc0020001 input.c:733: Test failed: peek: raw_unicode_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_CHAR, wparam 0x3c0, lparam 0x1 input.c:734: Test failed: peek: raw_unicode_legacy: 0: got 0xe7: 0 input.c:733: Test failed: peek: raw_unicode_vkey_ctrl_legacy: 0: test->expect 0 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0x11, lparam 0xc00001 input.c:734: Test failed: peek: raw_unicode_vkey_ctrl_legacy: 0: got VK_CONTROL: 0 input.c:734: Test failed: peek: raw_unicode_vkey_ctrl_legacy: 0: got VK_LCONTROL: 0 input.c:733: Test failed: peek: raw_unicode_vkey_ctrl_legacy: 1: test->expect 0 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0x11, lparam 0xffffffffc0c00001 input.c:733: Test failed: peek: raw_nolegacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey F, message WM_KEYDOWN, extra 0 input.c:733: Test failed: peek: raw_nolegacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey F, message WM_KEYUP, extra 0 input.c:733: Test failed: peek: raw_vk_packet_nolegacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey 0xe7, message WM_KEYDOWN, extra 0 input.c:733: Test failed: peek: raw_vk_packet_nolegacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey 0xe7, message WM_KEYUP, extra 0 input.c:733: Test failed: receive: raw_legacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey F, message WM_KEYDOWN, extra 0 input.c:733: Test failed: receive: raw_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0x46, lparam 0x10001 input.c:733: Test failed: receive: raw_legacy: 0: test->expect 2 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_CHAR, wparam 0x66, lparam 0x10001 input.c:734: Test failed: receive: raw_legacy: 0: got F: 0 input.c:733: Test failed: receive: raw_legacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey F, message WM_KEYUP, extra 0 input.c:733: Test failed: receive: raw_legacy: 1: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0x46, lparam 0xffffffffc0020001 input.c:733: Test failed: receive: raw_vk_packet_legacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey 0xe7, message WM_KEYDOWN, extra 0 input.c:733: Test failed: receive: raw_vk_packet_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0xe7, lparam 0x10001 input.c:734: Test failed: receive: raw_vk_packet_legacy: 0: got 0xe7: 0 input.c:733: Test failed: receive: raw_vk_packet_legacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey 0xe7, message WM_KEYUP, extra 0 input.c:733: Test failed: receive: raw_vk_packet_legacy: 1: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0xe7, lparam 0xffffffffc0020001 input.c:733: Test failed: receive: raw_unicode_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_CHAR, wparam 0x3c0, lparam 0x1 input.c:734: Test failed: receive: raw_unicode_legacy: 0: got 0xe7: 0 input.c:733: Test failed: receive: raw_unicode_vkey_ctrl_legacy: 0: test->expect 0 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0x11, lparam 0xc00001 input.c:734: Test failed: receive: raw_unicode_vkey_ctrl_legacy: 0: got VK_CONTROL: 0 input.c:734: Test failed: receive: raw_unicode_vkey_ctrl_legacy: 0: got VK_LCONTROL: 0 input.c:733: Test failed: receive: raw_unicode_vkey_ctrl_legacy: 1: test->expect 0 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0x11, lparam 0xffffffffc0c00001 input.c:733: Test failed: receive: raw_nolegacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey F, message WM_KEYDOWN, extra 0 input.c:733: Test failed: receive: raw_nolegacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey F, message WM_KEYUP, extra 0 input.c:733: Test failed: receive: raw_vk_packet_nolegacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey 0xe7, message WM_KEYDOWN, extra 0 input.c:733: Test failed: receive: raw_vk_packet_nolegacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey 0xe7, message WM_KEYUP, extra 0
This merge request was approved by Hans Leidekker.