Commit ee11f6ff authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

regedit/tests: Combine and rename the r_exec_import_*str functions.

parent 77442049
...@@ -67,48 +67,38 @@ static BOOL write_file(const void *str, DWORD size) ...@@ -67,48 +67,38 @@ static BOOL write_file(const void *str, DWORD size)
return ret; return ret;
} }
#define exec_import_str(c) r_exec_import_str(__LINE__, c) #define exec_import_str(c) import_reg(__LINE__,c,FALSE)
static BOOL r_exec_import_str(unsigned line, const char *file_contents) #define exec_import_wstr(c) import_reg(__LINE__,c,TRUE)
{
BOOL br;
if (!write_file(file_contents, strlen(file_contents)))
return FALSE;
run_regedit_exe("regedit.exe /s test.reg");
br = DeleteFileA("test.reg");
lok(br, "DeleteFile failed: %u\n", GetLastError());
return br; static BOOL import_reg(unsigned line, const char *contents, BOOL unicode)
}
#define exec_import_wstr(c) r_exec_import_wstr(__LINE__, c)
static BOOL r_exec_import_wstr(unsigned line, const char *file_contents)
{ {
int lenA, len, memsize; int lenA;
WCHAR *wstr; BOOL ret;
BOOL br = FALSE;
lenA = strlen(file_contents); lenA = strlen(contents);
len = MultiByteToWideChar(CP_UTF8, 0, file_contents, lenA, NULL, 0); if (unicode)
memsize = len * sizeof(WCHAR); {
wstr = HeapAlloc(GetProcessHeap(), 0, memsize); int len = MultiByteToWideChar(CP_UTF8, 0, contents, lenA, NULL, 0);
if (!wstr) return FALSE; int size = len * sizeof(WCHAR);
MultiByteToWideChar(CP_UTF8, 0, file_contents, lenA, wstr, len); WCHAR *wstr = HeapAlloc(GetProcessHeap(), 0, size);
if (!wstr) return FALSE;
MultiByteToWideChar(CP_UTF8, 0, contents, lenA, wstr, len);
ret = write_file(wstr, size);
HeapFree(GetProcessHeap(), 0, wstr);
}
else
ret = write_file(contents, lenA);
if (!write_file(wstr, memsize)) if (!ret) return FALSE;
goto exit;
run_regedit_exe("regedit.exe /s test.reg"); run_regedit_exe("regedit.exe /s test.reg");
br = DeleteFileA("test.reg"); ret = DeleteFileA("test.reg");
lok(br, "DeleteFile failed: %u\n", GetLastError()); lok(ret, "DeleteFile failed: %u\n", GetLastError());
exit: return ret;
HeapFree(GetProcessHeap(), 0, wstr);
return br;
} }
#define TODO_REG_TYPE (0x0001u) #define TODO_REG_TYPE (0x0001u)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment