summaryrefslogtreecommitdiffstats
path: root/arguments.c
diff options
context:
space:
mode:
authornicm <nicm>2020-03-17 16:02:38 +0000
committernicm <nicm>2020-03-17 16:02:38 +0000
commitbd0342b0a7ac4b5dc00ffc9cce7f9b0fbeb7ec91 (patch)
treea5424a14192b2983611fd5aba9c07d3251232fb4 /arguments.c
parent1ddc128860597bdded53a60c074596a4d39cc153 (diff)
getopt is not required to set optarg to NULL when there is no argument
and some do not, so set it explicitly each time.
Diffstat (limited to 'arguments.c')
-rw-r--r--arguments.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/arguments.c b/arguments.c
index acdaf8aa..cb527bcd 100644
--- a/arguments.c
+++ b/arguments.c
@@ -75,6 +75,7 @@ args_parse(const char *template, int argc, char **argv)
optreset = 1;
optind = 1;
+ optarg = NULL;
while ((opt = getopt(argc, argv, template)) != -1) {
if (opt < 0)
@@ -84,6 +85,7 @@ args_parse(const char *template, int argc, char **argv)
return (NULL);
}
args_set(args, opt, optarg);
+ optarg = NULL;
}
argc -= optind;
argv += optind;