-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi,
Thanks, this time the patches apply OK for me. I've told Alexandre that the patches look OK to me, let's see what he says.
Cheers, Stefan
Am 2015-09-03 um 21:51 schrieb Michel Zou:
Split patch from Jonathan Vollebregt: https://github.com/jnvsor/wine/commit/ea0e2fc70db6ce4904655ea4a27ee34531d967...
programs/reg/reg.c | 85 +++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 42 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 4ec25bc..0f28b63 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -22,6 +22,32 @@
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
+static const WCHAR short_hklm[] = {'H','K','L','M',0}; +static const WCHAR short_hkcu[] = {'H','K','C','U',0}; +static const WCHAR short_hkcr[] = {'H','K','C','R',0}; +static const WCHAR short_hku[] = {'H','K','U',0}; +static const WCHAR short_hkcc[] = {'H','K','C','C',0}; +static const WCHAR long_hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0}; +static const WCHAR long_hkcu[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0}; +static const WCHAR long_hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0}; +static const WCHAR long_hku[] = {'H','K','E','Y','_','U','S','E','R','S',0}; +static const WCHAR long_hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
+static const struct +{
- HKEY key;
- const WCHAR *short_name;
- const WCHAR *long_name;
+} +root_rels[] = +{
- {HKEY_LOCAL_MACHINE, short_hklm, long_hklm},
- {HKEY_CURRENT_USER, short_hkcu, long_hkcu},
- {HKEY_CLASSES_ROOT, short_hkcr, long_hkcr},
- {HKEY_USERS, short_hku, long_hku},
- {HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
+};
static const WCHAR type_none[] = {'R','E','G','_','N','O','N','E',0}; static const WCHAR type_sz[] = {'R','E','G','_','S','Z',0}; static const WCHAR type_expand_sz[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0}; @@ -95,51 +121,26 @@ static int reg_message(int msg) return reg_printfW(formatW, msg_buffer); }
-static int reg_StrCmpNIW(LPCWSTR str, LPCWSTR comp, int len) +static inline BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name) {
- int i;
- DWORD length = strlenW(rootkey_name);
- for (i = 0; i < len; i++)
- {
if (!str[i])
{
len = i + 1;
break;
}
- }
- return CompareStringW(CP_ACP, NORM_IGNORECASE, str, len, comp, len) - CSTR_EQUAL;
- return (!strncmpiW(input_path, rootkey_name, length) &&
(input_path[length] == 0 || input_path[length] == '\\'));
}
-static HKEY get_rootkey(LPWSTR key) +static HKEY path_get_rootkey(const WCHAR *path) {
- static const WCHAR szHKLM[] = {'H','K','L','M',0};
- static const WCHAR szHKEY_LOCAL_MACHINE[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
- static const WCHAR szHKCU[] = {'H','K','C','U',0};
- static const WCHAR szHKEY_CURRENT_USER[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
- static const WCHAR szHKCR[] = {'H','K','C','R',0};
- static const WCHAR szHKEY_CLASSES_ROOT[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
- static const WCHAR szHKU[] = {'H','K','U',0};
- static const WCHAR szHKEY_USERS[] = {'H','K','E','Y','_','U','S','E','R','S',0};
- static const WCHAR szHKCC[] = {'H','K','C','C',0};
- static const WCHAR szHKEY_CURRENT_CONFIG[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
- if (!reg_StrCmpNIW(key, szHKLM, 4) ||
!reg_StrCmpNIW(key, szHKEY_LOCAL_MACHINE, 18))
return HKEY_LOCAL_MACHINE;
- else if (!reg_StrCmpNIW(key, szHKCU, 4) ||
!reg_StrCmpNIW(key, szHKEY_CURRENT_USER, 17))
return HKEY_CURRENT_USER;
- else if (!reg_StrCmpNIW(key, szHKCR, 4) ||
!reg_StrCmpNIW(key, szHKEY_CLASSES_ROOT, 17))
return HKEY_CLASSES_ROOT;
- else if (!reg_StrCmpNIW(key, szHKU, 3) ||
!reg_StrCmpNIW(key, szHKEY_USERS, 10))
return HKEY_USERS;
- else if (!reg_StrCmpNIW(key, szHKCC, 4) ||
!reg_StrCmpNIW(key, szHKEY_CURRENT_CONFIG, 19))
return HKEY_CURRENT_CONFIG;
- else return NULL;
- DWORD i;
- for (i = 0; i < ARRAY_SIZE(root_rels); i++)
- {
if (path_rootname_cmp(path, root_rels[i].short_name) ||
path_rootname_cmp(path, root_rels[i].long_name))
return root_rels[i].key;
- }
- return NULL;
}
static DWORD wchar_get_type(const WCHAR *type_name) @@ -237,7 +238,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, } p++;
- root = get_rootkey(key_name);
- root = path_get_rootkey(key_name); if (!root) { reg_message(STRING_INVALID_KEY);
@@ -307,7 +308,7 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, } p++;
- root = get_rootkey(key_name);
- root = path_get_rootkey(key_name); if (!root) { reg_message(STRING_INVALID_KEY);
Hi,
Are those patches still ok ? I did not see a reply on wine-devel, did I miss something ?
M
Subject: Re: [PATCH 1/2] reg: simplify root key search To: wine-devel@winehq.org CC: xantares09@hotmail.com From: stefandoesinger@gmail.com Date: Fri, 4 Sep 2015 12:25:57 +0200
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi,
Thanks, this time the patches apply OK for me. I've told Alexandre that the patches look OK to me, let's see what he says.
Cheers, Stefan
Am 2015-09-03 um 21:51 schrieb Michel Zou:
Split patch from Jonathan Vollebregt: https://github.com/jnvsor/wine/commit/ea0e2fc70db6ce4904655ea4a27ee34531d967...
programs/reg/reg.c | 85 +++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 42 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 4ec25bc..0f28b63 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -22,6 +22,32 @@
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
+static const WCHAR short_hklm[] = {'H','K','L','M',0}; +static const WCHAR short_hkcu[] = {'H','K','C','U',0}; +static const WCHAR short_hkcr[] = {'H','K','C','R',0}; +static const WCHAR short_hku[] = {'H','K','U',0}; +static const WCHAR short_hkcc[] = {'H','K','C','C',0}; +static const WCHAR long_hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0}; +static const WCHAR long_hkcu[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0}; +static const WCHAR long_hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0}; +static const WCHAR long_hku[] = {'H','K','E','Y','_','U','S','E','R','S',0}; +static const WCHAR long_hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
+static const struct +{
- HKEY key;
- const WCHAR *short_name;
- const WCHAR *long_name;
+} +root_rels[] = +{
- {HKEY_LOCAL_MACHINE, short_hklm, long_hklm},
- {HKEY_CURRENT_USER, short_hkcu, long_hkcu},
- {HKEY_CLASSES_ROOT, short_hkcr, long_hkcr},
- {HKEY_USERS, short_hku, long_hku},
- {HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
+};
static const WCHAR type_none[] = {'R','E','G','_','N','O','N','E',0}; static const WCHAR type_sz[] = {'R','E','G','_','S','Z',0}; static const WCHAR type_expand_sz[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0}; @@ -95,51 +121,26 @@ static int reg_message(int msg) return reg_printfW(formatW, msg_buffer); }
-static int reg_StrCmpNIW(LPCWSTR str, LPCWSTR comp, int len) +static inline BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name) {
- int i;
- DWORD length = strlenW(rootkey_name);
- for (i = 0; i < len; i++)
- {
if (!str[i])
{
len = i + 1;
break;
}
- }
- return CompareStringW(CP_ACP, NORM_IGNORECASE, str, len, comp, len) - CSTR_EQUAL;
- return (!strncmpiW(input_path, rootkey_name, length) &&
(input_path[length] == 0 || input_path[length] == '\\'));
}
-static HKEY get_rootkey(LPWSTR key) +static HKEY path_get_rootkey(const WCHAR *path) {
- static const WCHAR szHKLM[] = {'H','K','L','M',0};
- static const WCHAR szHKEY_LOCAL_MACHINE[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
- static const WCHAR szHKCU[] = {'H','K','C','U',0};
- static const WCHAR szHKEY_CURRENT_USER[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
- static const WCHAR szHKCR[] = {'H','K','C','R',0};
- static const WCHAR szHKEY_CLASSES_ROOT[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
- static const WCHAR szHKU[] = {'H','K','U',0};
- static const WCHAR szHKEY_USERS[] = {'H','K','E','Y','_','U','S','E','R','S',0};
- static const WCHAR szHKCC[] = {'H','K','C','C',0};
- static const WCHAR szHKEY_CURRENT_CONFIG[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
- if (!reg_StrCmpNIW(key, szHKLM, 4) ||
!reg_StrCmpNIW(key, szHKEY_LOCAL_MACHINE, 18))
return HKEY_LOCAL_MACHINE;
- else if (!reg_StrCmpNIW(key, szHKCU, 4) ||
!reg_StrCmpNIW(key, szHKEY_CURRENT_USER, 17))
return HKEY_CURRENT_USER;
- else if (!reg_StrCmpNIW(key, szHKCR, 4) ||
!reg_StrCmpNIW(key, szHKEY_CLASSES_ROOT, 17))
return HKEY_CLASSES_ROOT;
- else if (!reg_StrCmpNIW(key, szHKU, 3) ||
!reg_StrCmpNIW(key, szHKEY_USERS, 10))
return HKEY_USERS;
- else if (!reg_StrCmpNIW(key, szHKCC, 4) ||
!reg_StrCmpNIW(key, szHKEY_CURRENT_CONFIG, 19))
return HKEY_CURRENT_CONFIG;
- else return NULL;
- DWORD i;
- for (i = 0; i < ARRAY_SIZE(root_rels); i++)
- {
if (path_rootname_cmp(path, root_rels[i].short_name) ||
path_rootname_cmp(path, root_rels[i].long_name))
return root_rels[i].key;
- }
- return NULL;
}
static DWORD wchar_get_type(const WCHAR *type_name) @@ -237,7 +238,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, } p++;
- root = get_rootkey(key_name);
- root = path_get_rootkey(key_name); if (!root) { reg_message(STRING_INVALID_KEY);
@@ -307,7 +308,7 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, } p++;
- root = get_rootkey(key_name);
- root = path_get_rootkey(key_name); if (!root) { reg_message(STRING_INVALID_KEY);
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2
iQIcBAEBAgAGBQJV6XG1AAoJEN0/YqbEcdMwWysP/0BvR0rXG67sd/NC5pPItrVv R2bGZceGH8yJpBuYOxpp2W5p9sCRMfoc2giTXrhmvUwVrutXrUbI9c/SqOlLZL6I YLOObNIo/DI6MxBwGaZ2jKGJKWEW3kzg5qKkJWzPIMg92zfbgtQxiTxhvAvd1xaR MxXLzKt+mhMWjPwyFR3omSFCTkvTguWxnXIVEf2S6TRshJnI0A10vJQUj1AC4dsX ZnHZkuXOAgwzgzmvkEnxbNsgkRzqmXCZaUbapcgJ5TXwwuiLMr4AuPbEcYmdf2g+ CqIYeIUYVtbg3pga/9WFdSki0YaAcJJ7kYTt5lEYRN3/V93W6QsPp/SaUXyx1J1B UOCbuj1UNx8OvRRvmABLrTvgbUQMrjlDXPP9QeNBHe8xQCQ1iV/AJ02DdbLrRleJ a/+CgisljGNzuH6Mu+5bKoKAEyEV3KAF3CIz6dJyBB5KQRY6Rk5AZMhWSQAhkJke ICBh+ITIBWYCsm+NDF+RuYutXhtstxvbewRHmwg4KnF2ouOTtQ2ypV+N2Z9JLNQ8 I25+6YB+1WDuDKYa87MPzbac6DX5IyzIPKiGsvLBngMiUcpfSDj6mgJTS4DkTwSM O+JYL5v8x7TIOmxKLGUfXXnvA+aiZ29/nrlLrZY8QoKLvHvpAxOz/SjUhDZa02IC twXso6DreRFxb4DyflTj =BizJ -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Hi,
Those patches look OK to me, and I've informed Alexandre on IRC about that. My guess is that he'd prefer if the original author (Jonathan) sent the code. I can't give any guarantees about that though, I can't look into Alexandre's mind.
Cheers, Stefan
Am 2015-09-14 um 15:18 schrieb Michel Zou:
Hi,
Are those patches still ok ? I did not see a reply on wine-devel, did I miss something ?
M
Subject: Re: [PATCH 1/2] reg: simplify root key search To: wine-devel@winehq.org CC: xantares09@hotmail.com From: stefandoesinger@gmail.com Date: Fri, 4 Sep 2015 12:25:57 +0200
Hi,
Thanks, this time the patches apply OK for me. I've told Alexandre
that the patches look OK to me, let's see what he says.
Cheers, Stefan
Am 2015-09-03 um 21:51 schrieb Michel Zou:
Split patch from Jonathan Vollebregt:
https://github.com/jnvsor/wine/commit/ea0e2fc70db6ce4904655ea4a27ee34531d967...
- ---
programs/reg/reg.c | 85 +++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 42 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 4ec25bc..0f28b63 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -22,6 +22,32 @@
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
+static const WCHAR short_hklm[] = {'H','K','L','M',0}; +static const WCHAR short_hkcu[] = {'H','K','C','U',0}; +static const WCHAR short_hkcr[] = {'H','K','C','R',0}; +static const WCHAR short_hku[] = {'H','K','U',0}; +static const WCHAR short_hkcc[] = {'H','K','C','C',0}; +static const WCHAR long_hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
+static const WCHAR long_hkcu[] =
{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
+static const WCHAR long_hkcr[] =
{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
+static const WCHAR long_hku[] =
{'H','K','E','Y','_','U','S','E','R','S',0}; +static const WCHAR long_hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
+
+static const struct +{ + HKEY key; + const WCHAR *short_name; + const WCHAR *long_name; +} +root_rels[] = +{ + {HKEY_LOCAL_MACHINE, short_hklm, long_hklm}, + {HKEY_CURRENT_USER, short_hkcu, long_hkcu}, + {HKEY_CLASSES_ROOT, short_hkcr, long_hkcr}, + {HKEY_USERS, short_hku, long_hku}, + {HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc}, +}; + static const WCHAR type_none[] = {'R','E','G','_','N','O','N','E',0}; static const WCHAR type_sz[] = {'R','E','G','_','S','Z',0}; static const WCHAR type_expand_sz[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0}; @@ -95,51 +121,26 @@ static int reg_message(int msg) return reg_printfW(formatW, msg_buffer); }
-static int reg_StrCmpNIW(LPCWSTR str, LPCWSTR comp, int len) +static inline BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name) { - int i; + DWORD length = strlenW(rootkey_name);
- for (i = 0; i < len; i++) - { - if (!str[i]) - { - len = i +
1; - break; - } - } - - return CompareStringW(CP_ACP, NORM_IGNORECASE, str, len, comp, len) - CSTR_EQUAL; + return (!strncmpiW(input_path, rootkey_name, length) && + (input_path[length] == 0 || input_path[length] == '\')); }
-static HKEY get_rootkey(LPWSTR key) +static HKEY path_get_rootkey(const WCHAR *path) { - static const WCHAR szHKLM[] = {'H','K','L','M',0}; - static const WCHAR szHKEY_LOCAL_MACHINE[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
- - static const WCHAR szHKCU[] = {'H','K','C','U',0};
- static const WCHAR szHKEY_CURRENT_USER[] =
{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
- - static const WCHAR szHKCR[] = {'H','K','C','R',0};
- static const WCHAR szHKEY_CLASSES_ROOT[] =
{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
- - static const WCHAR szHKU[] = {'H','K','U',0};
- static const WCHAR szHKEY_USERS[] =
{'H','K','E','Y','_','U','S','E','R','S',0}; - static const WCHAR szHKCC[] = {'H','K','C','C',0}; - static const WCHAR szHKEY_CURRENT_CONFIG[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
- -
- if (!reg_StrCmpNIW(key, szHKLM, 4) || - !reg_StrCmpNIW(key,
szHKEY_LOCAL_MACHINE, 18)) - return HKEY_LOCAL_MACHINE; - else if (!reg_StrCmpNIW(key, szHKCU, 4) || - !reg_StrCmpNIW(key, szHKEY_CURRENT_USER, 17)) - return HKEY_CURRENT_USER; - else if (!reg_StrCmpNIW(key, szHKCR, 4) || - !reg_StrCmpNIW(key, szHKEY_CLASSES_ROOT, 17)) - return HKEY_CLASSES_ROOT; - else if (!reg_StrCmpNIW(key, szHKU, 3) || - !reg_StrCmpNIW(key, szHKEY_USERS, 10)) - return HKEY_USERS; - else if (!reg_StrCmpNIW(key, szHKCC, 4) || - !reg_StrCmpNIW(key, szHKEY_CURRENT_CONFIG, 19)) - return HKEY_CURRENT_CONFIG; - else return NULL; + DWORD i; + + for (i = 0; i < ARRAY_SIZE(root_rels); i++) + { + if (path_rootname_cmp(path, root_rels[i].short_name) || + path_rootname_cmp(path, root_rels[i].long_name)) + return root_rels[i].key; + } + + return NULL; }
static DWORD wchar_get_type(const WCHAR *type_name) @@ -237,7 +238,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, } p++;
- root = get_rootkey(key_name); + root =
path_get_rootkey(key_name); if (!root) { reg_message(STRING_INVALID_KEY); @@ -307,7 +308,7 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, } p++;
- root = get_rootkey(key_name); + root =
path_get_rootkey(key_name); if (!root) { reg_message(STRING_INVALID_KEY);
Hi,
Jonathan clearly mentionned he isn't interested in wine anymore though and did not respond to Alexandre.
Cheers
Subject: Re: [PATCH 1/2] reg: simplify root key search To: xantares09@hotmail.com; wine-devel@winehq.org From: stefandoesinger@gmail.com Date: Tue, 15 Sep 2015 11:38:21 +0200
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Hi,
Those patches look OK to me, and I've informed Alexandre on IRC about that. My guess is that he'd prefer if the original author (Jonathan) sent the code. I can't give any guarantees about that though, I can't look into Alexandre's mind.
Cheers, Stefan
Am 2015-09-14 um 15:18 schrieb Michel Zou:
Hi,
Are those patches still ok ? I did not see a reply on wine-devel, did I miss something ?
M
Subject: Re: [PATCH 1/2] reg: simplify root key search To: wine-devel@winehq.org CC: xantares09@hotmail.com From: stefandoesinger@gmail.com Date: Fri, 4 Sep 2015 12:25:57 +0200
Hi,
Thanks, this time the patches apply OK for me. I've told Alexandre
that the patches look OK to me, let's see what he says.
Cheers, Stefan
Am 2015-09-03 um 21:51 schrieb Michel Zou:
Split patch from Jonathan Vollebregt:
https://github.com/jnvsor/wine/commit/ea0e2fc70db6ce4904655ea4a27ee34531d967...
programs/reg/reg.c | 85 +++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 42 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 4ec25bc..0f28b63 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -22,6 +22,32 @@
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
+static const WCHAR short_hklm[] = {'H','K','L','M',0}; +static const WCHAR short_hkcu[] = {'H','K','C','U',0}; +static const WCHAR short_hkcr[] = {'H','K','C','R',0}; +static const WCHAR short_hku[] = {'H','K','U',0}; +static const WCHAR short_hkcc[] = {'H','K','C','C',0}; +static const WCHAR long_hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
+static const WCHAR long_hkcu[] =
{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
+static const WCHAR long_hkcr[] =
{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
+static const WCHAR long_hku[] =
{'H','K','E','Y','_','U','S','E','R','S',0}; +static const WCHAR long_hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
+static const struct +{ + HKEY key; + const WCHAR *short_name; + const WCHAR *long_name; +} +root_rels[] = +{ + {HKEY_LOCAL_MACHINE, short_hklm, long_hklm}, + {HKEY_CURRENT_USER, short_hkcu, long_hkcu}, + {HKEY_CLASSES_ROOT, short_hkcr, long_hkcr}, + {HKEY_USERS, short_hku, long_hku}, + {HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc}, +}; + static const WCHAR type_none[] = {'R','E','G','_','N','O','N','E',0}; static const WCHAR type_sz[] = {'R','E','G','_','S','Z',0}; static const WCHAR type_expand_sz[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0}; @@ -95,51 +121,26 @@ static int reg_message(int msg) return reg_printfW(formatW, msg_buffer); }
-static int reg_StrCmpNIW(LPCWSTR str, LPCWSTR comp, int len) +static inline BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name) { - int i; + DWORD length = strlenW(rootkey_name);
- for (i = 0; i < len; i++) - { - if (!str[i]) - { - len = i +
1; - break; - } - } - - return CompareStringW(CP_ACP, NORM_IGNORECASE, str, len, comp, len) - CSTR_EQUAL; + return (!strncmpiW(input_path, rootkey_name, length) && + (input_path[length] == 0 || input_path[length] == '\')); }
-static HKEY get_rootkey(LPWSTR key) +static HKEY path_get_rootkey(const WCHAR *path) { - static const WCHAR szHKLM[] = {'H','K','L','M',0}; - static const WCHAR szHKEY_LOCAL_MACHINE[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
- static const WCHAR szHKCU[] = {'H','K','C','U',0};
- static const WCHAR szHKEY_CURRENT_USER[] =
{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
- static const WCHAR szHKCR[] = {'H','K','C','R',0};
- static const WCHAR szHKEY_CLASSES_ROOT[] =
{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
- static const WCHAR szHKU[] = {'H','K','U',0};
- static const WCHAR szHKEY_USERS[] =
{'H','K','E','Y','_','U','S','E','R','S',0}; - static const WCHAR szHKCC[] = {'H','K','C','C',0}; - static const WCHAR szHKEY_CURRENT_CONFIG[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
- if (!reg_StrCmpNIW(key, szHKLM, 4) || - !reg_StrCmpNIW(key,
szHKEY_LOCAL_MACHINE, 18)) - return HKEY_LOCAL_MACHINE; - else if (!reg_StrCmpNIW(key, szHKCU, 4) || - !reg_StrCmpNIW(key, szHKEY_CURRENT_USER, 17)) - return HKEY_CURRENT_USER; - else if (!reg_StrCmpNIW(key, szHKCR, 4) || - !reg_StrCmpNIW(key, szHKEY_CLASSES_ROOT, 17)) - return HKEY_CLASSES_ROOT; - else if (!reg_StrCmpNIW(key, szHKU, 3) || - !reg_StrCmpNIW(key, szHKEY_USERS, 10)) - return HKEY_USERS; - else if (!reg_StrCmpNIW(key, szHKCC, 4) || - !reg_StrCmpNIW(key, szHKEY_CURRENT_CONFIG, 19)) - return HKEY_CURRENT_CONFIG; - else return NULL; + DWORD i; + + for (i = 0; i < ARRAY_SIZE(root_rels); i++) + { + if (path_rootname_cmp(path, root_rels[i].short_name) || + path_rootname_cmp(path, root_rels[i].long_name)) + return root_rels[i].key; + } + + return NULL; }
static DWORD wchar_get_type(const WCHAR *type_name) @@ -237,7 +238,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, } p++;
- root = get_rootkey(key_name); + root =
path_get_rootkey(key_name); if (!root) { reg_message(STRING_INVALID_KEY); @@ -307,7 +308,7 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, } p++;
- root = get_rootkey(key_name); + root =
path_get_rootkey(key_name); if (!root) { reg_message(STRING_INVALID_KEY);
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2
iQIcBAEBCAAGBQJV9+cNAAoJEN0/YqbEcdMwaSEP/0DplIaF0ppoxF8ILAoGiZv/ vRuinCBw3i/QwQwy7SNtrlm+Utj5o/g1OIMkedPBbgVvRTPKGfwahbw9rykr4DnD akaQHBfjvxVLT4XxKwoi+uGDyKEfkrEgSMq8Nc0+GB5MjJi4jHCgA1LAMp9r5J7t OSRbbPKprQUALRT4LzKCah/yXXMKz8qBjQ4SDldAbxEm8UiEpJJe1NL2WfIJAsTT tasBTT+8gs2aBJsO4LARrNRpAXojHpzvOAihDiCr782t3ZsPUg8gVr4d9Wp7xx+c 9X/xpbygEZQ3Icwa8/7kuClHvU8UXhJBcgt3FyPPux/lMgiRSlDM/uUEthDYOzB0 xxyhx9tOW5led+40IfBlp94d6E9HKmaOzcbbCU8y+bv20eN5lMGNH9EH3QKZv8R6 AniBoPp+AVokFuvmPPC7DKxqHrYJR2+TRm2iIPIdfxvDbo5/O0jfh5zpOvlk64dK hecpYVyZNTwDdCZPkkts6Y0PfOTB+rC5sR1Hx75nO3TWXKDtVQawFPdqMrnfJdCP TH6wUXXlas9HI5/KyzyWU9i6IcDnzhEVpUbmVLtgpfCGLU0lXUBmK6qa7mboRxD2 DpMSbwsEU/Dwc0YKXM1B2F5dmkgsjtQ7pdkEjwLvn2pKn3QBKkLEjcarNWWXPptO MENLGfZu3FJOFXu0CwKH =MV7q -----END PGP SIGNATURE-----
Hi,
Jonathan clearly mentionned he is not interested in wine development anymore though and did not respond to Alexandre. I dont think I can do much more now that the paches are reviewed and (finally) correctly transmitted. I hope AJ will consider looking at it someday.
Regards
Subject: Re: [PATCH 1/2] reg: simplify root key search To: xantares09@hotmail.com; wine-devel@winehq.org From: stefandoesinger@gmail.com Date: Tue, 15 Sep 2015 11:38:21 +0200
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Hi,
Those patches look OK to me, and I've informed Alexandre on IRC about that. My guess is that he'd prefer if the original author (Jonathan) sent the code. I can't give any guarantees about that though, I can't look into Alexandre's mind.
Cheers, Stefan
Am 2015-09-14 um 15:18 schrieb Michel Zou:
Hi,
Are those patches still ok ? I did not see a reply on wine-devel, did I miss something ?
M
Subject: Re: [PATCH 1/2] reg: simplify root key search To: wine-devel@winehq.org CC: xantares09@hotmail.com From: stefandoesinger@gmail.com Date: Fri, 4 Sep 2015 12:25:57 +0200
Hi,
Thanks, this time the patches apply OK for me. I've told Alexandre
that the patches look OK to me, let's see what he says.
Cheers, Stefan
Am 2015-09-03 um 21:51 schrieb Michel Zou:
Split patch from Jonathan Vollebregt:
https://github.com/jnvsor/wine/commit/ea0e2fc70db6ce4904655ea4a27ee34531d967...
programs/reg/reg.c | 85 +++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 42 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 4ec25bc..0f28b63 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -22,6 +22,32 @@
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
+static const WCHAR short_hklm[] = {'H','K','L','M',0}; +static const WCHAR short_hkcu[] = {'H','K','C','U',0}; +static const WCHAR short_hkcr[] = {'H','K','C','R',0}; +static const WCHAR short_hku[] = {'H','K','U',0}; +static const WCHAR short_hkcc[] = {'H','K','C','C',0}; +static const WCHAR long_hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
+static const WCHAR long_hkcu[] =
{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
+static const WCHAR long_hkcr[] =
{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
+static const WCHAR long_hku[] =
{'H','K','E','Y','_','U','S','E','R','S',0}; +static const WCHAR long_hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
+static const struct +{ + HKEY key; + const WCHAR *short_name; + const WCHAR *long_name; +} +root_rels[] = +{ + {HKEY_LOCAL_MACHINE, short_hklm, long_hklm}, + {HKEY_CURRENT_USER, short_hkcu, long_hkcu}, + {HKEY_CLASSES_ROOT, short_hkcr, long_hkcr}, + {HKEY_USERS, short_hku, long_hku}, + {HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc}, +}; + static const WCHAR type_none[] = {'R','E','G','_','N','O','N','E',0}; static const WCHAR type_sz[] = {'R','E','G','_','S','Z',0}; static const WCHAR type_expand_sz[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0}; @@ -95,51 +121,26 @@ static int reg_message(int msg) return reg_printfW(formatW, msg_buffer); }
-static int reg_StrCmpNIW(LPCWSTR str, LPCWSTR comp, int len) +static inline BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name) { - int i; + DWORD length = strlenW(rootkey_name);
- for (i = 0; i < len; i++) - { - if (!str[i]) - { - len = i +
1; - break; - } - } - - return CompareStringW(CP_ACP, NORM_IGNORECASE, str, len, comp, len) - CSTR_EQUAL; + return (!strncmpiW(input_path, rootkey_name, length) && + (input_path[length] == 0 || input_path[length] == '\')); }
-static HKEY get_rootkey(LPWSTR key) +static HKEY path_get_rootkey(const WCHAR *path) { - static const WCHAR szHKLM[] = {'H','K','L','M',0}; - static const WCHAR szHKEY_LOCAL_MACHINE[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
- static const WCHAR szHKCU[] = {'H','K','C','U',0};
- static const WCHAR szHKEY_CURRENT_USER[] =
{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
- static const WCHAR szHKCR[] = {'H','K','C','R',0};
- static const WCHAR szHKEY_CLASSES_ROOT[] =
{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
- static const WCHAR szHKU[] = {'H','K','U',0};
- static const WCHAR szHKEY_USERS[] =
{'H','K','E','Y','_','U','S','E','R','S',0}; - static const WCHAR szHKCC[] = {'H','K','C','C',0}; - static const WCHAR szHKEY_CURRENT_CONFIG[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
- if (!reg_StrCmpNIW(key, szHKLM, 4) || - !reg_StrCmpNIW(key,
szHKEY_LOCAL_MACHINE, 18)) - return HKEY_LOCAL_MACHINE; - else if (!reg_StrCmpNIW(key, szHKCU, 4) || - !reg_StrCmpNIW(key, szHKEY_CURRENT_USER, 17)) - return HKEY_CURRENT_USER; - else if (!reg_StrCmpNIW(key, szHKCR, 4) || - !reg_StrCmpNIW(key, szHKEY_CLASSES_ROOT, 17)) - return HKEY_CLASSES_ROOT; - else if (!reg_StrCmpNIW(key, szHKU, 3) || - !reg_StrCmpNIW(key, szHKEY_USERS, 10)) - return HKEY_USERS; - else if (!reg_StrCmpNIW(key, szHKCC, 4) || - !reg_StrCmpNIW(key, szHKEY_CURRENT_CONFIG, 19)) - return HKEY_CURRENT_CONFIG; - else return NULL; + DWORD i; + + for (i = 0; i < ARRAY_SIZE(root_rels); i++) + { + if (path_rootname_cmp(path, root_rels[i].short_name) || + path_rootname_cmp(path, root_rels[i].long_name)) + return root_rels[i].key; + } + + return NULL; }
static DWORD wchar_get_type(const WCHAR *type_name) @@ -237,7 +238,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, } p++;
- root = get_rootkey(key_name); + root =
path_get_rootkey(key_name); if (!root) { reg_message(STRING_INVALID_KEY); @@ -307,7 +308,7 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, } p++;
- root = get_rootkey(key_name); + root =
path_get_rootkey(key_name); if (!root) { reg_message(STRING_INVALID_KEY);
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2
iQIcBAEBCAAGBQJV9+cNAAoJEN0/YqbEcdMwaSEP/0DplIaF0ppoxF8ILAoGiZv/ vRuinCBw3i/QwQwy7SNtrlm+Utj5o/g1OIMkedPBbgVvRTPKGfwahbw9rykr4DnD akaQHBfjvxVLT4XxKwoi+uGDyKEfkrEgSMq8Nc0+GB5MjJi4jHCgA1LAMp9r5J7t OSRbbPKprQUALRT4LzKCah/yXXMKz8qBjQ4SDldAbxEm8UiEpJJe1NL2WfIJAsTT tasBTT+8gs2aBJsO4LARrNRpAXojHpzvOAihDiCr782t3ZsPUg8gVr4d9Wp7xx+c 9X/xpbygEZQ3Icwa8/7kuClHvU8UXhJBcgt3FyPPux/lMgiRSlDM/uUEthDYOzB0 xxyhx9tOW5led+40IfBlp94d6E9HKmaOzcbbCU8y+bv20eN5lMGNH9EH3QKZv8R6 AniBoPp+AVokFuvmPPC7DKxqHrYJR2+TRm2iIPIdfxvDbo5/O0jfh5zpOvlk64dK hecpYVyZNTwDdCZPkkts6Y0PfOTB+rC5sR1Hx75nO3TWXKDtVQawFPdqMrnfJdCP TH6wUXXlas9HI5/KyzyWU9i6IcDnzhEVpUbmVLtgpfCGLU0lXUBmK6qa7mboRxD2 DpMSbwsEU/Dwc0YKXM1B2F5dmkgsjtQ7pdkEjwLvn2pKn3QBKkLEjcarNWWXPptO MENLGfZu3FJOFXu0CwKH =MV7q -----END PGP SIGNATURE-----