From ec55298764cca634231a6bd6badc257230037bc1 Mon Sep 17 00:00:00 2001 From: winesync Date: Sun, 16 Jan 2022 20:51:04 +0100 Subject: [PATCH] [WINESYNC] reg: Use wide-char string literals in export.c. Signed-off-by: Hugh McMaster Signed-off-by: Alexandre Julliard wine commit id 1b746c1e1c4da4a07a1293fe9e60429867c86697 by Hugh McMaster manual adjustment needed --- base/applications/cmdutils/reg/export.c | 32 +++++++++---------------- sdk/tools/winesync/reg.cfg | 2 +- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/base/applications/cmdutils/reg/export.c b/base/applications/cmdutils/reg/export.c index e9945308212..74c6ecf195d 100644 --- a/base/applications/cmdutils/reg/export.c +++ b/base/applications/cmdutils/reg/export.c @@ -79,15 +79,14 @@ static WCHAR *escape_string(WCHAR *str, size_t str_len, size_t *line_len) static size_t export_value_name(HANDLE hFile, WCHAR *name, size_t len) { - static const WCHAR quoted_fmt[] = {'"','%','s','"','=',0}; - static const WCHAR default_name[] = {'@','=',0}; + static const WCHAR *default_name = L"@="; size_t line_len; if (name && *name) { WCHAR *str = escape_string(name, len, &line_len); WCHAR *buf = malloc((line_len + 4) * sizeof(WCHAR)); - line_len = swprintf(buf, quoted_fmt, str); + line_len = swprintf(buf, L"\"%s\"=", str); write_file(hFile, buf); free(buf); free(str); @@ -105,28 +104,24 @@ static void export_string_data(WCHAR **buf, WCHAR *data, size_t size) { size_t len = 0, line_len; WCHAR *str; - static const WCHAR fmt[] = {'"','%','s','"',0}; if (size) len = size / sizeof(WCHAR) - 1; str = escape_string(data, len, &line_len); *buf = malloc((line_len + 3) * sizeof(WCHAR)); - swprintf(*buf, fmt, str); + swprintf(*buf, L"\"%s\"", str); free(str); } static void export_dword_data(WCHAR **buf, DWORD *data) { - static const WCHAR fmt[] = {'d','w','o','r','d',':','%','0','8','x',0}; - *buf = malloc(15 * sizeof(WCHAR)); - swprintf(*buf, fmt, *data); + swprintf(*buf, L"dword:%08x", *data); } static size_t export_hex_data_type(HANDLE hFile, DWORD type) { - static const WCHAR hex[] = {'h','e','x',':',0}; - static const WCHAR hexp_fmt[] = {'h','e','x','(','%','x',')',':',0}; + static const WCHAR *hex = L"hex:"; size_t line_len; if (type == REG_BINARY) @@ -137,7 +132,7 @@ static size_t export_hex_data_type(HANDLE hFile, DWORD type) else { WCHAR *buf = malloc(15 * sizeof(WCHAR)); - line_len = swprintf(buf, hexp_fmt, type); + line_len = swprintf(buf, L"hex(%x):", type); write_file(hFile, buf); free(buf); } @@ -150,8 +145,6 @@ static size_t export_hex_data_type(HANDLE hFile, DWORD type) static void export_hex_data(HANDLE hFile, WCHAR **buf, DWORD type, DWORD line_len, void *data, DWORD size) { - static const WCHAR fmt[] = {'%','0','2','x',0}; - static const WCHAR hex_concat[] = {'\\','\r','\n',' ',' ',0}; size_t num_commas, i, pos; line_len += export_hex_data_type(hFile, type); @@ -163,7 +156,7 @@ static void export_hex_data(HANDLE hFile, WCHAR **buf, DWORD type, for (i = 0, pos = 0; i < size; i++) { - pos += swprintf(*buf + pos, fmt, ((BYTE *)data)[i]); + pos += swprintf(*buf + pos, L"%02x", ((BYTE *)data)[i]); if (i == num_commas) break; (*buf)[pos++] = ','; (*buf)[pos] = 0; @@ -172,7 +165,7 @@ static void export_hex_data(HANDLE hFile, WCHAR **buf, DWORD type, if (line_len >= MAX_HEX_CHARS) { write_file(hFile, *buf); - write_file(hFile, hex_concat); + write_file(hFile, L"\\\r\n "); line_len = 2; pos = 0; } @@ -181,7 +174,7 @@ static void export_hex_data(HANDLE hFile, WCHAR **buf, DWORD type, static void export_newline(HANDLE hFile) { - static const WCHAR newline[] = {'\r','\n',0}; + static const WCHAR *newline = L"\r\n"; write_file(hFile, newline); } @@ -224,11 +217,10 @@ static void export_data(HANDLE hFile, WCHAR *value_name, DWORD value_len, static void export_key_name(HANDLE hFile, WCHAR *name) { - static const WCHAR fmt[] = {'\r','\n','[','%','s',']','\r','\n',0}; WCHAR *buf; buf = malloc((lstrlenW(name) + 7) * sizeof(WCHAR)); - swprintf(buf, fmt, name); + swprintf(buf, L"\r\n[%s]\r\n", name); write_file(hFile, buf); free(buf); } @@ -309,9 +301,7 @@ static int export_registry_data(HANDLE hFile, HKEY key, WCHAR *path) static void export_file_header(HANDLE hFile) { - static const WCHAR header[] = { 0xfeff,'W','i','n','d','o','w','s',' ', - 'R','e','g','i','s','t','r','y',' ','E','d','i','t','o','r',' ', - 'V','e','r','s','i','o','n',' ','5','.','0','0','\r','\n',0}; + static const WCHAR *header = L"\uFEFFWindows Registry Editor Version 5.00\r\n"; write_file(hFile, header); } diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index 7da30342ea8..7479d9dbf89 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: 1fadcf240997f77b4bf31f708893051c94e299b2 + wine: 1b746c1e1c4da4a07a1293fe9e60429867c86697