Module: wine Branch: master Commit: 4a22ba5b46f463484ef09f0618e8c750aadbb513 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4a22ba5b46f463484ef09f0618...
Author: Hugh McMaster hugh.mcmaster@outlook.com Date: Wed Jun 15 02:30:53 2016 +0000
reg: Parse the registry key using a helper function.
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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++) {