diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-08-21 08:45:00 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-08-21 08:45:00 +0000 |
commit | 74ec25b81c3a3e829dff01a606be13a1a2e1daf0 (patch) | |
tree | be89a0f28fdf1ed787bf888bba4fa31246479473 /usr.bin/tmux/arguments.c | |
parent | 8f793168bad3b38ed711f06a7e5d23b1743e97b0 (diff) |
Wrap command argument definitions in their own struct.
Diffstat (limited to 'usr.bin/tmux/arguments.c')
-rw-r--r-- | usr.bin/tmux/arguments.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/tmux/arguments.c b/usr.bin/tmux/arguments.c index 6bcbe2dd124..b38b07446e9 100644 --- a/usr.bin/tmux/arguments.c +++ b/usr.bin/tmux/arguments.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arguments.c,v 1.39 2021/08/20 20:08:30 nicm Exp $ */ +/* $OpenBSD: arguments.c,v 1.40 2021/08/21 08:44:59 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -79,7 +79,7 @@ args_create(void) /* Parse an argv and argc into a new argument set. */ struct args * -args_parse(const char *template, int argc, char **argv, int lower, int upper) +args_parse(const struct args_parse *parse, int argc, char **argv) { struct args *args; int opt; @@ -89,10 +89,10 @@ args_parse(const char *template, int argc, char **argv, int lower, int upper) optarg = NULL; args = args_create(); - while ((opt = getopt(argc, argv, template)) != -1) { + while ((opt = getopt(argc, argv, parse->template)) != -1) { if (opt < 0) continue; - if (opt == '?' || strchr(template, opt) == NULL) { + if (opt == '?' || strchr(parse->template, opt) == NULL) { args_free(args); return (NULL); } @@ -105,7 +105,8 @@ args_parse(const char *template, int argc, char **argv, int lower, int upper) args->argc = argc; args->argv = cmd_copy_argv(argc, argv); - if ((lower != -1 && argc < lower) || (upper != -1 && argc > upper)) { + if ((parse->lower != -1 && argc < parse->lower) || + (parse->upper != -1 && argc > parse->upper)) { args_free(args); return (NULL); } |