https://git.reactos.org/?p=reactos.git;a=commitdiff;h=409d7663c10c30c699048…
commit 409d7663c10c30c699048d4719dbfe5affc50c1d
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sun Jan 16 20:48:04 2022 +0100
Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com>
CommitDate: Sun Jun 19 13:06:31 2022 +0200
[WINESYNC] reg: Parse 'reg delete' command-line arguments in delete.c.
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 434c345e41222ae6eebe734e655a32bfd51871ae by Hugh McMaster
<hugh.mcmaster(a)outlook.com>
---
base/applications/cmdutils/reg/delete.c | 61 +++++++++++++++++++++++++++++++--
base/applications/cmdutils/reg/reg.c | 22 ++++--------
base/applications/cmdutils/reg/reg.h | 3 +-
sdk/tools/winesync/reg.cfg | 2 +-
4 files changed, 68 insertions(+), 20 deletions(-)
diff --git a/base/applications/cmdutils/reg/delete.c
b/base/applications/cmdutils/reg/delete.c
index c102fb4ad53..1f3755b3365 100644
--- a/base/applications/cmdutils/reg/delete.c
+++ b/base/applications/cmdutils/reg/delete.c
@@ -18,8 +18,8 @@
#include "reg.h"
-int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
- BOOL value_empty, BOOL value_all, BOOL force)
+static int run_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
+ BOOL value_empty, BOOL value_all, BOOL force)
{
HKEY key;
@@ -105,3 +105,60 @@ int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR
*value_name,
output_message(STRING_SUCCESS);
return 0;
}
+
+int reg_delete(int argc, WCHAR *argvW[])
+{
+ HKEY root;
+ WCHAR *path, *key_name, *value_name = NULL;
+ BOOL value_all = FALSE, value_empty = FALSE, force = FALSE;
+ int i;
+
+ if (!parse_registry_key(argvW[2], &root, &path, &key_name))
+ return 1;
+
+ for (i = 3; i < argc; i++)
+ {
+ if (argvW[i][0] == '/' || argvW[i][0] == '-')
+ {
+ WCHAR *str = &argvW[i][1];
+
+ if (!lstrcmpiW(str, L"va"))
+ {
+ if (value_all) goto invalid;
+ value_all = TRUE;
+ continue;
+ }
+ else if (!lstrcmpiW(str, L"ve"))
+ {
+ if (value_empty) goto invalid;
+ value_empty = TRUE;
+ continue;
+ }
+ else if (!str[0] || str[1])
+ goto invalid;
+
+ switch (towlower(*str))
+ {
+ case 'v':
+ if (value_name || !(value_name = argvW[++i]))
+ goto invalid;
+ break;
+ case 'f':
+ if (force) goto invalid;
+ force = TRUE;
+ break;
+ default:
+ goto invalid;
+ }
+ }
+ }
+
+ if ((value_name && value_empty) || (value_name && value_all) ||
(value_empty && value_all))
+ goto invalid;
+
+ return run_delete(root, path, key_name, value_name, value_empty, value_all, force);
+
+invalid:
+ output_message(STRING_INVALID_CMDLINE);
+ return 1;
+}
diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c
index 6089d701d3c..8dea9501730 100644
--- a/base/applications/cmdutils/reg/reg.c
+++ b/base/applications/cmdutils/reg/reg.c
@@ -333,11 +333,10 @@ static enum operations get_operation(const WCHAR *str, int
*op_help)
int __cdecl wmain(int argc, WCHAR *argvW[])
{
- int i, op, op_help, ret;
- static const WCHAR switchVAW[] = {'v','a',0};
+ int i, op, op_help;
static const WCHAR switchVEW[] = {'v','e',0};
WCHAR *key_name, *path, *value_name = NULL, *type = NULL, *data = NULL, separator =
'\0';
- BOOL value_empty = FALSE, value_all = FALSE, force = FALSE;
+ BOOL value_empty = FALSE, force = FALSE;
HKEY root;
if (argc == 1)
@@ -374,6 +373,9 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
return 0;
}
+ if (op == REG_DELETE)
+ return reg_delete(argc, argvW);
+
if (op == REG_EXPORT)
return reg_export(argc, argvW);
@@ -397,11 +399,6 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
value_empty = TRUE;
continue;
}
- else if (!lstrcmpiW(ptr, switchVAW))
- {
- value_all = TRUE;
- continue;
- }
else if (!ptr[0] || ptr[1])
{
output_message(STRING_INVALID_CMDLINE);
@@ -450,16 +447,11 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
}
}
- if ((value_name && value_empty) || (value_name && value_all) ||
(value_empty && value_all))
+ if (value_name && value_empty)
{
output_message(STRING_INVALID_CMDLINE);
return 1;
}
- if (op == REG_ADD)
- ret = reg_add(root, path, value_name, value_empty, type, separator, data,
force);
- else
- ret = reg_delete(root, path, key_name, value_name, value_empty, value_all,
force);
-
- return ret;
+ return reg_add(root, path, value_name, value_empty, type, separator, data, force);
}
diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h
index e1e4804d19d..e4ee13eca6e 100644
--- a/base/applications/cmdutils/reg/reg.h
+++ b/base/applications/cmdutils/reg/reg.h
@@ -47,8 +47,7 @@ int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL
value_empty,
WCHAR *type, WCHAR separator, WCHAR *data, BOOL force);
/* delete.c */
-int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
- BOOL value_empty, BOOL value_all, BOOL force);
+int reg_delete(int argc, WCHAR *argvW[]);
/* export.c */
int reg_export(int argc, WCHAR *argvW[]);
diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg
index b56101bb50b..b9f81cb1160 100644
--- a/sdk/tools/winesync/reg.cfg
+++ b/sdk/tools/winesync/reg.cfg
@@ -4,4 +4,4 @@ directories:
files:
programs/reg/resource.h: base/applications/cmdutils/reg/resource.h
tags:
- wine: cb749592e728119bdd5a30a1080a90cf1a53546a
+ wine: 434c345e41222ae6eebe734e655a32bfd51871ae