From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/odbccp32/odbccp32.c | 45 +++++++++++++++++++------------------- dlls/odbccp32/tests/misc.c | 17 ++++++++++++++ 2 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c index fd02391a384..debb28d4227 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,37 @@ 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); + if ((ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, regpath, &hkey)) != 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..31a7c9899e8 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"value", L"ODBC.INI"); + ok(ret, "SQLWritePrivateProfileString failed\n"); + ret = SQLGetPrivateProfileStringW(L"wineodbc", NULL, L"", buffer, 256, L"ODBC.INI"); ok(ret, "SQLGetPrivateProfileStringW failed\n");
@@ -450,6 +453,20 @@ 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 MACHINE DSN is checked before USER */ + ret = SQLWritePrivateProfileStringW(L"wineodbc1", L"testing" , L"value1", 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"value1"), "Wrong value\n"); + + 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_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=147823
Your paranoid android.
=== debian11b (64 bit WoW report) ===
ddraw: ddraw4.c:3969: Test failed: Expected message 0x5, but didn't receive it.
Hans Leidekker (@hans) commented about dlls/odbccp32/tests/misc.c:
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 MACHINE DSN is checked before USER */
- ret = SQLWritePrivateProfileStringW(L"wineodbc1", L"testing" , L"value1", L"ODBC.INI");
- ok(ret, "SQLWritePrivateProfileString failed\n");
To test this properly you also need to write a different value with ODBC_USER_DSN set.