diff options
author | Laslo Hunhold <dev@frign.de> | 2017-08-02 13:44:02 +0200 |
---|---|---|
committer | Laslo Hunhold <dev@frign.de> | 2017-08-02 13:46:00 +0200 |
commit | bb8c945c0481123fc4082aa1cbd4f23efa683033 (patch) | |
tree | 1ccef84bad5ce3374227ab87233640922d76f8f6 | |
parent | 37e44c95655e252aa7763671f53524dceaf8a65b (diff) |
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!
-rw-r--r-- | arg.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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') { \ |