=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/options.c,v retrieving revision 1.64 retrieving revision 1.65 diff -c -r1.64 -r1.65 *** src/usr.bin/tmux/options.c 2021/08/21 17:25:32 1.64 --- src/usr.bin/tmux/options.c 2021/10/14 13:19:01 1.65 *************** *** 1,4 **** ! /* $OpenBSD: options.c,v 1.64 2021/08/21 17:25:32 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: options.c,v 1.65 2021/10/14 13:19:01 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott *************** *** 989,1016 **** return (0); } static int options_from_string_choice(const struct options_table_entry *oe, struct options *oo, const char *name, const char *value, char **cause) { ! const char **cp; ! int n, choice = -1; if (value == NULL) { choice = options_get_number(oo, name); if (choice < 2) choice = !choice; } else { ! n = 0; ! for (cp = oe->choices; *cp != NULL; cp++) { ! if (strcmp(*cp, value) == 0) ! choice = n; ! n++; ! } ! if (choice == -1) { ! xasprintf(cause, "unknown value: %s", value); return (-1); - } } options_set_number(oo, name, choice); return (0); --- 989,1027 ---- return (0); } + int + options_find_choice(const struct options_table_entry *oe, const char *value, + char **cause) + { + const char **cp; + int n = 0, choice = -1; + + for (cp = oe->choices; *cp != NULL; cp++) { + if (strcmp(*cp, value) == 0) + choice = n; + n++; + } + if (choice == -1) { + xasprintf(cause, "unknown value: %s", value); + return (-1); + } + return (choice); + } + static int options_from_string_choice(const struct options_table_entry *oe, struct options *oo, const char *name, const char *value, char **cause) { ! int choice = -1; if (value == NULL) { choice = options_get_number(oo, name); if (choice < 2) choice = !choice; } else { ! choice = options_find_choice(oe, value, cause); ! if (choice < 0) return (-1); } options_set_number(oo, name, choice); return (0);