mirror of
https://github.com/tmux/tmux.git
synced 2026-10-09 19:54:22 +00:00
Do not count arguments starting - as optional arguments, makes old
resize-pane syntax work. GitHub issue 5275, based on a changed from Dane Jensen.
This commit is contained in:
14
arguments.c
14
arguments.c
@@ -149,7 +149,7 @@ args_parse_flag_argument(struct args_value *values, u_int count, char **cause,
|
|||||||
int optional_argument)
|
int optional_argument)
|
||||||
{
|
{
|
||||||
struct args_value *argument, *new;
|
struct args_value *argument, *new;
|
||||||
const char *s;
|
const char *s, *as;
|
||||||
|
|
||||||
new = xcalloc(1, sizeof *new);
|
new = xcalloc(1, sizeof *new);
|
||||||
if (*string != '\0') {
|
if (*string != '\0') {
|
||||||
@@ -180,12 +180,24 @@ args_parse_flag_argument(struct args_value *values, u_int count, char **cause,
|
|||||||
xasprintf(cause, "-%c expects an argument", flag);
|
xasprintf(cause, "-%c expects an argument", flag);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (optional_argument && argument->type == ARGS_STRING) {
|
||||||
|
as = argument->string;
|
||||||
|
if (as[0] == '-' && (as[1] == '-' || isalpha((u_char)as[1]))) {
|
||||||
|
args_free_value(new);
|
||||||
|
free(new);
|
||||||
|
log_debug("%s: -%c (optional)", __func__, flag);
|
||||||
|
args_set(args, flag, NULL, ARGS_ENTRY_OPTIONAL_VALUE);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
args_copy_value(new, argument);
|
args_copy_value(new, argument);
|
||||||
(*i)++;
|
(*i)++;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
s = args_value_as_string(new);
|
s = args_value_as_string(new);
|
||||||
log_debug("%s: -%c = %s", __func__, flag, s);
|
log_debug("%s: -%c = %s", __func__, flag, s);
|
||||||
|
|
||||||
args_set(args, flag, new, 0);
|
args_set(args, flag, new, 0);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -63,8 +64,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
const char *errstr, *argval;
|
const char *errstr, *argval;
|
||||||
const char flags[4] = { 'U', 'D', 'L', 'R' };
|
const char flags[4] = { 'U', 'D', 'L', 'R' };
|
||||||
char *cause = NULL, flag;
|
char *cause = NULL, flag;
|
||||||
u_int opposite = 0;
|
int adjust, x, y, status, opposite = 0;
|
||||||
int adjust, x, y, status;
|
|
||||||
long unsigned i;
|
long unsigned i;
|
||||||
struct grid *gd = wp->base.grid;
|
struct grid *gd = wp->base.grid;
|
||||||
|
|
||||||
@@ -147,8 +147,12 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
argval = args_get(args, flag);
|
argval = args_get(args, flag);
|
||||||
if (argval == NULL)
|
if (argval == NULL) {
|
||||||
argval = "1";
|
if (args_count(args) == 0)
|
||||||
|
argval = "1";
|
||||||
|
else
|
||||||
|
argval = args_string(args, 0);
|
||||||
|
}
|
||||||
|
|
||||||
adjust = strtonum(argval, INT_MIN, INT_MAX, &errstr);
|
adjust = strtonum(argval, INT_MIN, INT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user