Module: wine Branch: master Commit: ecdd3c8e84bac9be42686b576b64ee49674ee4f6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=ecdd3c8e84bac9be42686b576b...
Author: Hugh McMaster hugh.mcmaster@outlook.com Date: Wed Jun 15 02:31:05 2016 +0000
reg: Always output the long key name when printing strings.
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
programs/reg/reg.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 6f8a882..38861f8 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -818,7 +818,34 @@ 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) +static WCHAR *get_long_key(HKEY root, WCHAR *path) +{ + DWORD i, array_size = ARRAY_SIZE(root_rels), len; + WCHAR *long_key; + WCHAR fmt[] = {'%','s','\','%','s',0}; + + for (i = 0; i < array_size; i++) + { + if (root == root_rels[i].key) + break; + } + + len = strlenW(root_rels[i].long_name); + + if (!path) + { + long_key = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + strcpyW(long_key, root_rels[i].long_name); + return long_key; + } + + len += strlenW(path) + 1; /* add one for the backslash */ + long_key = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + sprintfW(long_key, fmt, root_rels[i].long_name, path); + return long_key; +} + +static BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key) { if (!sane_path(key)) return FALSE; @@ -833,6 +860,8 @@ static BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path) *path = strchrW(key, '\'); if (*path) (*path)++;
+ *long_key = get_long_key(*root, *path); + return TRUE; }
@@ -924,11 +953,9 @@ int wmain(int argc, WCHAR *argvW[]) return 0; }
- if (!parse_registry_key(argvW[2], &root, &path)) + if (!parse_registry_key(argvW[2], &root, &path, &key_name)) return 1;
- key_name = argvW[2]; - for (i = 3; i < argc; i++) { if (argvW[i][0] == '/' || argvW[i][0] == '-')