Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/add.c | 4 ++-- programs/reg/delete.c | 4 +++- programs/reg/export.c | 8 +++++--- programs/reg/query.c | 4 +++- programs/reg/reg.c | 6 ++---- programs/reg/reg.h | 3 ++- 6 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/programs/reg/add.c b/programs/reg/add.c index f259f0a4100..d94789ad484 100644 --- a/programs/reg/add.c +++ b/programs/reg/add.c @@ -213,11 +213,11 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, int reg_add(int argc, WCHAR *argvW[]) { HKEY root; - WCHAR *path, *key_name, *value_name = NULL, *type = NULL, *data = NULL, separator = '\0'; + WCHAR *path, *value_name = NULL, *type = NULL, *data = NULL, separator = '\0'; BOOL value_empty = FALSE, force = FALSE; int i;
- if (!parse_registry_key(argvW[2], &root, &path, &key_name)) + if (!parse_registry_key(argvW[2], &root, &path)) return 1;
for (i = 3; i < argc; i++) diff --git a/programs/reg/delete.c b/programs/reg/delete.c index b23b14e8dab..626fcf3b341 100644 --- a/programs/reg/delete.c +++ b/programs/reg/delete.c @@ -113,7 +113,7 @@ int reg_delete(int argc, WCHAR *argvW[]) BOOL value_all = FALSE, value_empty = FALSE, force = FALSE; int i;
- if (!parse_registry_key(argvW[2], &root, &path, &key_name)) + if (!parse_registry_key(argvW[2], &root, &path)) return 1;
for (i = 3; i < argc; i++) @@ -158,6 +158,8 @@ int reg_delete(int argc, WCHAR *argvW[]) if ((value_name && value_empty) || (value_name && value_all) || (value_empty && value_all)) goto invalid;
+ key_name = get_long_key(root, path); + return run_delete(root, path, key_name, value_name, value_empty, value_all, force);
invalid: diff --git a/programs/reg/export.c b/programs/reg/export.c index 5d55eaad407..13d5871d57e 100644 --- a/programs/reg/export.c +++ b/programs/reg/export.c @@ -347,14 +347,14 @@ static HANDLE get_file_handle(WCHAR *filename, BOOL overwrite_file) int reg_export(int argc, WCHAR *argvW[]) { HKEY root, hkey; - WCHAR *path, *long_key; + WCHAR *path, *key_name; BOOL overwrite_file = FALSE; HANDLE hFile; int i, ret;
if (argc < 4) goto invalid;
- if (!parse_registry_key(argvW[2], &root, &path, &long_key)) + if (!parse_registry_key(argvW[2], &root, &path)) return 1;
for (i = 4; i < argc; i++) @@ -378,9 +378,11 @@ int reg_export(int argc, WCHAR *argvW[]) return 1; }
+ key_name = get_long_key(root, path); + hFile = get_file_handle(argvW[3], overwrite_file); export_file_header(hFile); - ret = export_registry_data(hFile, hkey, long_key); + ret = export_registry_data(hFile, hkey, key_name); export_newline(hFile); CloseHandle(hFile);
diff --git a/programs/reg/query.c b/programs/reg/query.c index cc8f264e780..76f12b4a2d3 100644 --- a/programs/reg/query.c +++ b/programs/reg/query.c @@ -329,7 +329,7 @@ int reg_query(int argc, WCHAR *argvW[]) BOOL value_empty = FALSE, recurse = FALSE; int i;
- if (!parse_registry_key(argvW[2], &root, &path, &key_name)) + if (!parse_registry_key(argvW[2], &root, &path)) return 1;
for (i = 3; i < argc; i++) @@ -368,6 +368,8 @@ int reg_query(int argc, WCHAR *argvW[]) if (value_name && value_empty) goto invalid;
+ key_name = get_long_key(root, path); + return run_query(root, path, key_name, value_name, value_empty, recurse);
invalid: diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 6b337f5d415..3ffc5fe3d8f 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -203,7 +203,7 @@ WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD return subkey_path; }
-static WCHAR *get_long_key(HKEY root, WCHAR *path) +WCHAR *get_long_key(HKEY root, WCHAR *path) { DWORD i, array_size = ARRAY_SIZE(root_rels), len; WCHAR *long_key; @@ -229,7 +229,7 @@ static WCHAR *get_long_key(HKEY root, WCHAR *path) return long_key; }
-BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key) +BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path) { if (!sane_path(key)) return FALSE; @@ -245,8 +245,6 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long return FALSE; }
- *long_key = get_long_key(*root, *path); - return TRUE; }
diff --git a/programs/reg/reg.h b/programs/reg/reg.h index c281770bdb4..c71ae2445e9 100644 --- a/programs/reg/reg.h +++ b/programs/reg/reg.h @@ -39,7 +39,8 @@ void WINAPIV output_string(const WCHAR *fmt, ...); BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info); HKEY path_get_rootkey(const WCHAR *path); WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len); -BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key); +WCHAR *get_long_key(HKEY root, WCHAR *path); +BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path); BOOL is_char(const WCHAR s, const WCHAR c); BOOL is_switch(const WCHAR *s, const WCHAR c);