From: Hugh McMaster Subject: [PATCH 2/5] reg: Update general help logic Message-Id: Date: Tue, 24 May 2016 12:48:26 +0000 In-Reply-To: <1464094072-2819-1-git-send-email-hugh.mcmaster@outlook.com> References: <1464094072-2819-1-git-send-email-hugh.mcmaster@outlook.com> Signed-off-by: Hugh McMaster --- programs/reg/reg.c | 13 ++++++++++--- programs/reg/reg.h | 3 +++ programs/reg/reg.rc | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/programs/reg/reg.c b/programs/reg/reg.c index f8c6103..f048f1e 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -894,8 +894,14 @@ int wmain(int argc, WCHAR *argvW[]) static const WCHAR slashVEW[] = {'/','v','e',0}; static const WCHAR slashHelpW[] = {'/','?',0}; - if (argc < 2 || !lstrcmpW(argvW[1], slashHelpW) - || !lstrcmpiW(argvW[1], slashHW)) + if (argc == 1) + { + output_message(STRING_INVALID_SYNTAX); + output_message(STRING_REG_HELP); + return 1; + } + + if (!lstrcmpW(argvW[1], slashHelpW) || !lstrcmpiW(argvW[1], slashHW)) { output_message(STRING_USAGE); return 0; @@ -1032,7 +1038,8 @@ int wmain(int argc, WCHAR *argvW[]) } else { - output_message(STRING_INVALID_CMDLINE); + output_message(STRING_INVALID_OPTION, argvW[1]); + output_message(STRING_REG_HELP); return 1; } } diff --git a/programs/reg/reg.h b/programs/reg/reg.h index 102284e..eeee4c9 100644 --- a/programs/reg/reg.h +++ b/programs/reg/reg.h @@ -47,3 +47,6 @@ #define STRING_VALUEALL_FAILED 124 #define STRING_GENERAL_FAILURE 125 #define STRING_MATCHES_FOUND 126 +#define STRING_INVALID_SYNTAX 127 +#define STRING_INVALID_OPTION 128 +#define STRING_REG_HELP 129 diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc index 23144a3..eb752b7 100644 --- a/programs/reg/reg.rc +++ b/programs/reg/reg.rc @@ -52,4 +52,7 @@ STRINGTABLE STRING_VALUEALL_FAILED, "reg: Unable to delete all registry values in '%1'. An unexpected error occurred.\n" STRING_GENERAL_FAILURE, "reg: Unable to complete the specified operation. An unexpected error occurred.\n" STRING_MATCHES_FOUND, "Search complete. Number of matches found: %1!d!\n" + STRING_INVALID_SYNTAX, "reg: Invalid syntax. " + STRING_INVALID_OPTION, "reg: Invalid option [%1]. " + STRING_REG_HELP, "Type \"REG /?\" for help.\n" } -- 1.9.1