Commit 07fdd503 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

reg: Only call get_long_key() when operations require it.

parent b1eba226
......@@ -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++)
......
......@@ -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:
......
......@@ -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);
......
......@@ -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:
......
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment