mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
Merge branch 'obsd-master'
This commit is contained in:
16
arguments.c
16
arguments.c
@ -37,6 +37,7 @@ TAILQ_HEAD(args_values, args_value);
|
||||
struct args_entry {
|
||||
u_char flag;
|
||||
struct args_values values;
|
||||
u_int count;
|
||||
RB_ENTRY(args_entry) entry;
|
||||
};
|
||||
|
||||
@ -173,6 +174,7 @@ args_print(struct args *args)
|
||||
size_t len;
|
||||
char *buf;
|
||||
int i;
|
||||
u_int j;
|
||||
struct args_entry *entry;
|
||||
struct args_value *value;
|
||||
|
||||
@ -186,7 +188,8 @@ args_print(struct args *args)
|
||||
|
||||
if (*buf == '\0')
|
||||
args_print_add(&buf, &len, "-");
|
||||
args_print_add(&buf, &len, "%c", entry->flag);
|
||||
for (j = 0; j < entry->count; j++)
|
||||
args_print_add(&buf, &len, "%c", entry->flag);
|
||||
}
|
||||
|
||||
/* Then the flags with arguments. */
|
||||
@ -243,7 +246,12 @@ args_escape(const char *s)
|
||||
int
|
||||
args_has(struct args *args, u_char ch)
|
||||
{
|
||||
return (args_find(args, ch) != NULL);
|
||||
struct args_entry *entry;
|
||||
|
||||
entry = args_find(args, ch);
|
||||
if (entry == NULL)
|
||||
return (0);
|
||||
return (entry->count);
|
||||
}
|
||||
|
||||
/* Set argument value in the arguments tree. */
|
||||
@ -257,9 +265,11 @@ args_set(struct args *args, u_char ch, const char *s)
|
||||
if (entry == NULL) {
|
||||
entry = xcalloc(1, sizeof *entry);
|
||||
entry->flag = ch;
|
||||
entry->count = 1;
|
||||
TAILQ_INIT(&entry->values);
|
||||
RB_INSERT(args_tree, &args->tree, entry);
|
||||
}
|
||||
} else
|
||||
entry->count++;
|
||||
|
||||
if (s != NULL) {
|
||||
value = xcalloc(1, sizeof *value);
|
||||
|
Reference in New Issue
Block a user