[PATCH 1/2] reg: Parse the registry key using a helper function
Hugh McMaster
hugh.mcmaster at outlook.com
Tue Jun 14 21:30:53 CDT 2016
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/reg/reg.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index 20df2dd..6f8a882 100644
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -818,6 +818,24 @@ static int reg_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
return ret;
}
+static BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path)
+{
+ if (!sane_path(key))
+ return FALSE;
+
+ *root = path_get_rootkey(key);
+ if (!*root)
+ {
+ output_message(STRING_INVALID_KEY);
+ return FALSE;
+ }
+
+ *path = strchrW(key, '\\');
+ if (*path) (*path)++;
+
+ return TRUE;
+}
+
static BOOL is_help_switch(const WCHAR *s)
{
if (strlenW(s) > 2)
@@ -906,20 +924,10 @@ int wmain(int argc, WCHAR *argvW[])
return 0;
}
- key_name = argvW[2];
-
- if (!sane_path(key_name))
- return 1;
-
- root = path_get_rootkey(key_name);
- if (!root)
- {
- output_message(STRING_INVALID_KEY);
+ if (!parse_registry_key(argvW[2], &root, &path))
return 1;
- }
- path = strchrW(key_name, '\\');
- if (path) path++;
+ key_name = argvW[2];
for (i = 3; i < argc; i++)
{
--
2.7.4
More information about the wine-patches
mailing list