diff --git a/arguments.c b/arguments.c index dd92a952..91141b99 100644 --- a/arguments.c +++ b/arguments.c @@ -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; diff --git a/cmd-find-window.c b/cmd-find-window.c index 4cd155e4..43f5f9be 100644 --- a/cmd-find-window.c +++ b/cmd-find-window.c @@ -48,7 +48,7 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item) struct cmd_find_state *target = cmdq_get_target(item); struct window_pane *wp = target->wp; const char *s = args->argv[0], *suffix = ""; - char *filter, *argv = { NULL }; + char *filter; int C, N, T; C = args_has(args, 'C'); @@ -91,7 +91,7 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item) else xasprintf(&filter, "#{m%s:*%s*,#{pane_title}}", suffix, s); - new_args = args_parse("", 1, &argv); + new_args = args_create(); if (args_has(args, 'Z')) args_set(new_args, 'Z', NULL); args_set(new_args, 'f', filter); diff --git a/tmux.h b/tmux.h index e6ba8e86..26f9dc3e 100644 --- a/tmux.h +++ b/tmux.h @@ -2182,6 +2182,7 @@ int tty_keys_next(struct tty *); /* arguments.c */ void args_set(struct args *, u_char, const char *); +struct args *args_create(void); struct args *args_parse(const char *, int, char **); void args_free(struct args *); char *args_print(struct args *);