diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-08-20 17:53:55 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-08-20 17:53:55 +0000 |
commit | 7945ba1cb9346b88267a4022df6945ee52e11e44 (patch) | |
tree | ec6b4eae16bb780fe1744d751007907b5dbc996f /usr.bin/tmux/arguments.c | |
parent | a1e05a9c0cbadc20fc2e9fcf1b48de3baf5cab0a (diff) |
Add a way to create an empty arguments set.
Diffstat (limited to 'usr.bin/tmux/arguments.c')
-rw-r--r-- | usr.bin/tmux/arguments.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/tmux/arguments.c b/usr.bin/tmux/arguments.c index 45ecaaacbaa..53649afe1ac 100644 --- a/usr.bin/tmux/arguments.c +++ b/usr.bin/tmux/arguments.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arguments.c,v 1.35 2020/06/12 07:10:43 nicm Exp $ */ +/* $OpenBSD: arguments.c,v 1.36 2021/08/20 17:53:54 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -64,6 +64,17 @@ args_find(struct args *args, u_char flag) return (RB_FIND(args_tree, &args->tree, &entry)); } +/* Create an empty arguments set. */ +struct args * +args_create(void) +{ + struct args *args; + + args = xcalloc(1, sizeof *args); + RB_INIT(&args->tree); + return (args); +} + /* Parse an argv and argc into a new argument set. */ struct args * args_parse(const char *template, int argc, char **argv) @@ -71,12 +82,11 @@ args_parse(const char *template, int argc, char **argv) struct args *args; int opt; - args = xcalloc(1, sizeof *args); - optreset = 1; optind = 1; optarg = NULL; + args = args_create(); while ((opt = getopt(argc, argv, template)) != -1) { if (opt < 0) continue; |