mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 11:18:48 +00:00
Merge branch 'obsd-master' into master
This commit is contained in:
commit
f84f1c0cfe
16
arguments.c
16
arguments.c
@ -131,8 +131,9 @@ args_parse(const struct args_parse *parse, struct args_value *values,
|
|||||||
u_int i;
|
u_int i;
|
||||||
enum args_parse_type type;
|
enum args_parse_type type;
|
||||||
struct args_value *value, *new;
|
struct args_value *value, *new;
|
||||||
u_char flag, argument;
|
u_char flag;
|
||||||
const char *found, *string, *s;
|
const char *found, *string, *s;
|
||||||
|
int optional_argument;
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return (args_create());
|
return (args_create());
|
||||||
@ -169,18 +170,27 @@ args_parse(const struct args_parse *parse, struct args_value *values,
|
|||||||
args_free(args);
|
args_free(args);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
argument = *++found;
|
if (*++found != ':') {
|
||||||
if (argument != ':') {
|
|
||||||
log_debug("%s: -%c", __func__, flag);
|
log_debug("%s: -%c", __func__, flag);
|
||||||
args_set(args, flag, NULL);
|
args_set(args, flag, NULL);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (*found == ':') {
|
||||||
|
optional_argument = 1;
|
||||||
|
found++;
|
||||||
|
}
|
||||||
new = xcalloc(1, sizeof *new);
|
new = xcalloc(1, sizeof *new);
|
||||||
if (*string != '\0') {
|
if (*string != '\0') {
|
||||||
new->type = ARGS_STRING;
|
new->type = ARGS_STRING;
|
||||||
new->string = xstrdup(string);
|
new->string = xstrdup(string);
|
||||||
} else {
|
} else {
|
||||||
if (i == count) {
|
if (i == count) {
|
||||||
|
if (optional_argument) {
|
||||||
|
log_debug("%s: -%c", __func__,
|
||||||
|
flag);
|
||||||
|
args_set(args, flag, NULL);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
xasprintf(cause,
|
xasprintf(cause,
|
||||||
"-%c expects an argument",
|
"-%c expects an argument",
|
||||||
flag);
|
flag);
|
||||||
|
Loading…
Reference in New Issue
Block a user