mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
Add a way to create an empty arguments set.
This commit is contained in:
parent
e463e8622d
commit
6cbc83c6a6
14
arguments.c
14
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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user