From: Michael Haggerty Date: Tue, 17 Mar 2015 16:00:13 GMT Subject: [PATCH 11/14] opt_arg(): report errors parsing option values Message-ID: <1426608016-2978-12-git-send-email-mhagger@alum.mit.edu> In-Reply-To: <1426608016-2978-1-git-send-email-mhagger@alum.mit.edu> If an argument is there, but it can't be parsed as a non-positive number, then die() rather than returning 0. Signed-off-by: Michael Haggerty --- diff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff.c b/diff.c index 77c7acb..03cdabf 100644 --- a/diff.c +++ b/diff.c @@ -3368,7 +3368,7 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va if (!c) return 1; /* optional argument was missing */ if (convert_i(arg, 10, val)) - return 0; + die("The value for -%c must be a non-negative integer", arg_short); return 1; } if (c != '-') @@ -3381,7 +3381,7 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va if (!*eq) return 1; /* '=' and optional argument were missing */ if (convert_i(eq + 1, 10, val)) - return 0; + die("The value for --%s must be a non-negative integer", arg_long); return 1; } -- 2.1.4