From bb8c945c0481123fc4082aa1cbd4f23efa683033 Mon Sep 17 00:00:00 2001 From: Laslo Hunhold Date: Wed, 2 Aug 2017 13:44:02 +0200 Subject: arg.h: Handle { NULL } argv[] properly Previously, we would return argc as -1, which could cause some problems. This was not an issue introduced in the rewrite and is a bug present in the "old" arg.h as well. Thanks Isabella Parakiss for reporting this! --- arg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arg.h b/arg.h index 003f8ec..cf30d65 100644 --- a/arg.h +++ b/arg.h @@ -22,7 +22,7 @@ extern char *argv0; /* int main(int argc, char *argv[]) */ -#define ARGBEGIN for (argv0 = *argv, argc--, argv++; \ +#define ARGBEGIN for (argv0 = *argv, *argv ? (argc--, argv++) : ((void *)0); \ *argv && (*argv)[0] == '-' && (*argv)[1]; argc--, argv++) { \ int argparsed; \ if ((*argv)[1] == '-' && (*argv)[2] == '\0') { \ -- cgit v1.2.3