summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/options.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2020-08-25 11:35:32 +0000
committernicm <nicm@openbsd.org>2020-08-25 11:35:32 +0000
commit43dc5f42effc06c58acd15fa132373d1202807ae (patch)
treec5b0dc7f3659da4faeeb258676483e115e202c84 /usr.bin/tmux/options.c
parentRename rtable filter variables and simplify buffer handling (diff)
downloadwireguard-openbsd-43dc5f42effc06c58acd15fa132373d1202807ae.tar.xz
wireguard-openbsd-43dc5f42effc06c58acd15fa132373d1202807ae.zip
Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.
Diffstat (limited to 'usr.bin/tmux/options.c')
-rw-r--r--usr.bin/tmux/options.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/usr.bin/tmux/options.c b/usr.bin/tmux/options.c
index 273b3e8c795..4967915767f 100644
--- a/usr.bin/tmux/options.c
+++ b/usr.bin/tmux/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.59 2020/06/16 08:18:34 nicm Exp $ */
+/* $OpenBSD: options.c,v 1.60 2020/08/25 11:35:32 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -95,6 +95,18 @@ options_cmp(struct options_entry *lhs, struct options_entry *rhs)
return (strcmp(lhs->name, rhs->name));
}
+static const char *
+options_map_name(const char *name)
+{
+ const struct options_name_map *map;
+
+ for (map = options_other_names; map->from != NULL; map++) {
+ if (strcmp(map->from, name) == 0)
+ return (map->to);
+ }
+ return (name);
+}
+
static const struct options_table_entry *
options_parent_table_entry(struct options *oo, const char *s)
{
@@ -204,10 +216,14 @@ options_next(struct options_entry *o)
struct options_entry *
options_get_only(struct options *oo, const char *name)
{
- struct options_entry o;
+ struct options_entry o = { .name = name }, *found;
- o.name = name;
- return (RB_FIND(options_tree, &oo->tree, &o));
+ found = RB_FIND(options_tree, &oo->tree, &o);
+ if (found == NULL) {
+ o.name = options_map_name(name);
+ return (RB_FIND(options_tree, &oo->tree, &o));
+ }
+ return (found);
}
struct options_entry *
@@ -608,19 +624,21 @@ char *
options_match(const char *s, int *idx, int *ambiguous)
{
const struct options_table_entry *oe, *found;
- char *name;
+ char *parsed;
+ const char *name;
size_t namelen;
- name = options_parse(s, idx);
- if (name == NULL)
+ parsed = options_parse(s, idx);
+ if (parsed == NULL)
return (NULL);
- namelen = strlen(name);
-
- if (*name == '@') {
+ if (*parsed == '@') {
*ambiguous = 0;
- return (name);
+ return (parsed);
}
+ name = options_map_name(parsed);
+ namelen = strlen(name);
+
found = NULL;
for (oe = options_table; oe->name != NULL; oe++) {
if (strcmp(oe->name, name) == 0) {
@@ -630,13 +648,13 @@ options_match(const char *s, int *idx, int *ambiguous)
if (strncmp(oe->name, name, namelen) == 0) {
if (found != NULL) {
*ambiguous = 1;
- free(name);
+ free(parsed);
return (NULL);
}
found = oe;
}
}
- free(name);
+ free(parsed);
if (found == NULL) {
*ambiguous = 0;
return (NULL);