mirror of
https://github.com/tmux/tmux.git
synced 2024-10-31 22:58:49 +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));
|
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. */
|
/* Parse an argv and argc into a new argument set. */
|
||||||
struct args *
|
struct args *
|
||||||
args_parse(const char *template, int argc, char **argv)
|
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;
|
struct args *args;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
args = xcalloc(1, sizeof *args);
|
|
||||||
|
|
||||||
optreset = 1;
|
optreset = 1;
|
||||||
optind = 1;
|
optind = 1;
|
||||||
optarg = NULL;
|
optarg = NULL;
|
||||||
|
|
||||||
|
args = args_create();
|
||||||
while ((opt = getopt(argc, argv, template)) != -1) {
|
while ((opt = getopt(argc, argv, template)) != -1) {
|
||||||
if (opt < 0)
|
if (opt < 0)
|
||||||
continue;
|
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 cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct window_pane *wp = target->wp;
|
struct window_pane *wp = target->wp;
|
||||||
const char *s = args->argv[0], *suffix = "";
|
const char *s = args->argv[0], *suffix = "";
|
||||||
char *filter, *argv = { NULL };
|
char *filter;
|
||||||
int C, N, T;
|
int C, N, T;
|
||||||
|
|
||||||
C = args_has(args, 'C');
|
C = args_has(args, 'C');
|
||||||
@ -91,7 +91,7 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
else
|
else
|
||||||
xasprintf(&filter, "#{m%s:*%s*,#{pane_title}}", suffix, s);
|
xasprintf(&filter, "#{m%s:*%s*,#{pane_title}}", suffix, s);
|
||||||
|
|
||||||
new_args = args_parse("", 1, &argv);
|
new_args = args_create();
|
||||||
if (args_has(args, 'Z'))
|
if (args_has(args, 'Z'))
|
||||||
args_set(new_args, 'Z', NULL);
|
args_set(new_args, 'Z', NULL);
|
||||||
args_set(new_args, 'f', filter);
|
args_set(new_args, 'f', filter);
|
||||||
|
1
tmux.h
1
tmux.h
@ -2182,6 +2182,7 @@ int tty_keys_next(struct tty *);
|
|||||||
|
|
||||||
/* arguments.c */
|
/* arguments.c */
|
||||||
void args_set(struct args *, u_char, const char *);
|
void args_set(struct args *, u_char, const char *);
|
||||||
|
struct args *args_create(void);
|
||||||
struct args *args_parse(const char *, int, char **);
|
struct args *args_parse(const char *, int, char **);
|
||||||
void args_free(struct args *);
|
void args_free(struct args *);
|
||||||
char *args_print(struct args *);
|
char *args_print(struct args *);
|
||||||
|
Loading…
Reference in New Issue
Block a user