From 4382538e4bac2849262710c447e4b630e7f34bd7 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 28 May 2019 18:30:30 +0000 Subject: Do not read past the end of the argument string if it is empty. --- arguments.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arguments.c') diff --git a/arguments.c b/arguments.c index 68690deb..54bc3593 100644 --- a/arguments.c +++ b/arguments.c @@ -211,6 +211,8 @@ args_escape(const char *s) char *escaped, *result; int flags; + if (*s == '\0') + return (xstrdup(s)); if ((strchr(quoted, s[0]) != NULL || s[0] == '~') && s[1] == '\0') { xasprintf(&escaped, "\\%c", s[0]); return (escaped); -- cgit From 7dced376737ef685e09fd5a49161ca2bf423e91b Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 29 May 2019 20:05:14 +0000 Subject: Use VIS_CSTYLE for the arguments and add the missing escapes it can generate to the parser. --- arguments.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arguments.c') diff --git a/arguments.c b/arguments.c index 54bc3593..8e049aab 100644 --- a/arguments.c +++ b/arguments.c @@ -218,7 +218,7 @@ args_escape(const char *s) return (escaped); } - flags = VIS_OCTAL|VIS_TAB|VIS_NL; + flags = VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL; if (s[strcspn(s, quoted)] != '\0') flags |= VIS_DQ; utf8_stravis(&escaped, s, flags); -- cgit From cd1fc42df6d1bacac4f617e031c279ba31bc0632 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 20 Jun 2019 07:10:56 +0000 Subject: Add a -A flag to show-options to show parent options as well. --- arguments.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'arguments.c') diff --git a/arguments.c b/arguments.c index 8e049aab..751d0607 100644 --- a/arguments.c +++ b/arguments.c @@ -213,7 +213,9 @@ args_escape(const char *s) if (*s == '\0') return (xstrdup(s)); - if ((strchr(quoted, s[0]) != NULL || s[0] == '~') && s[1] == '\0') { + if (s[0] != ' ' && + (strchr(quoted, s[0]) != NULL || s[0] == '~') && + s[1] == '\0') { xasprintf(&escaped, "\\%c", s[0]); return (escaped); } -- cgit From fc2016dbb665f01e795a89632a1bb74294bfc4e1 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 9 Jul 2019 14:03:12 +0000 Subject: Add a -H flag to send-keys to send literal keys given as hex numbers (needed for control clients to send mouse sequences). Also add some format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in GitHub issues 1832 and 1833. --- arguments.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'arguments.c') diff --git a/arguments.c b/arguments.c index 751d0607..acdaf8aa 100644 --- a/arguments.c +++ b/arguments.c @@ -38,6 +38,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; }; @@ -174,6 +175,7 @@ args_print(struct args *args) size_t len; char *buf; int i; + u_int j; struct args_entry *entry; struct args_value *value; @@ -187,7 +189,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. */ @@ -244,7 +247,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. */ @@ -258,9 +266,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); -- cgit