Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/add.c | 74 ++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 36 deletions(-)
diff --git a/programs/reg/add.c b/programs/reg/add.c index e1fd2223716..f259f0a4100 100644 --- a/programs/reg/add.c +++ b/programs/reg/add.c @@ -222,46 +222,48 @@ int reg_add(int argc, WCHAR *argvW[])
for (i = 3; i < argc; i++) { - if (argvW[i][0] == '/' || argvW[i][0] == '-') + WCHAR *str; + + if (argvW[i][0] != '/' && argvW[i][0] != '-') + goto invalid; + + str = &argvW[i][1]; + + if (!lstrcmpiW(str, L"ve")) { - WCHAR *str = &argvW[i][1]; + if (value_empty) goto invalid; + value_empty = TRUE; + continue; + } + else if (!str[0] || str[1]) + goto invalid;
- if (!lstrcmpiW(str, L"ve")) - { - if (value_empty) goto invalid; - value_empty = TRUE; - continue; - } - else if (!str[0] || str[1]) + switch (towlower(*str)) + { + case 'v': + if (value_name || !(value_name = argvW[++i])) goto invalid; - - switch (towlower(*str)) - { - case 'v': - if (value_name || !(value_name = argvW[++i])) - goto invalid; - break; - case 't': - if (type || !(type = argvW[++i])) - goto invalid; - break; - case 'd': - if (data || !(data = argvW[++i])) - goto invalid; - break; - case 's': - str = argvW[++i]; - if (separator || !str || lstrlenW(str) != 1) - goto invalid; - separator = str[0]; - break; - case 'f': - if (force) goto invalid; - force = TRUE; - break; - default: + break; + case 't': + if (type || !(type = argvW[++i])) goto invalid; - } + break; + case 'd': + if (data || !(data = argvW[++i])) + goto invalid; + break; + case 's': + str = argvW[++i]; + if (separator || !str || lstrlenW(str) != 1) + goto invalid; + separator = str[0]; + break; + case 'f': + if (force) goto invalid; + force = TRUE; + break; + default: + goto invalid; } }
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/delete.c | 60 ++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 29 deletions(-)
diff --git a/programs/reg/delete.c b/programs/reg/delete.c index 519d4b880ec..b23b14e8dab 100644 --- a/programs/reg/delete.c +++ b/programs/reg/delete.c @@ -118,38 +118,40 @@ int reg_delete(int argc, WCHAR *argvW[])
for (i = 3; i < argc; i++) { - if (argvW[i][0] == '/' || argvW[i][0] == '-') - { - WCHAR *str = &argvW[i][1]; + WCHAR *str;
- 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; + if (argvW[i][0] != '/' && argvW[i][0] != '-') + 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: + 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; } }
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/query.c | 48 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/programs/reg/query.c b/programs/reg/query.c index 656ac875ec4..cc8f264e780 100644 --- a/programs/reg/query.c +++ b/programs/reg/query.c @@ -334,32 +334,34 @@ int reg_query(int argc, WCHAR *argvW[])
for (i = 3; i < argc; i++) { - if (argvW[i][0] == '/' || argvW[i][0] == '-') - { - WCHAR *str = &argvW[i][1]; + WCHAR *str;
- if (!lstrcmpiW(str, L"ve")) - { - if (value_empty) goto invalid; - value_empty = TRUE; - continue; - } - else if (!str[0] || str[1]) - goto invalid; + if (argvW[i][0] != '/' && argvW[i][0] != '-') + goto invalid;
- switch (towlower(*str)) - { - case 'v': - if (value_name || !(value_name = argvW[++i])) - goto invalid; - break; - case 's': - if (recurse) goto invalid; - recurse = TRUE; - break; - default: + str = &argvW[i][1]; + + 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 's': + if (recurse) goto invalid; + recurse = TRUE; + break; + default: + goto invalid; } }