diff options
author | nicm <nicm> | 2019-03-18 11:58:40 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-03-18 11:58:40 +0000 |
commit | ce6be7afd4d10b542f9cce8634d6bdd81754f775 (patch) | |
tree | 01a13843f212816c057069a13d02b46743ed8fd0 /status.c | |
parent | d2d43987d0f35af2bc012f1260fdb81c851fe390 (diff) | |
download | rtmux-ce6be7afd4d10b542f9cce8634d6bdd81754f775.tar.gz rtmux-ce6be7afd4d10b542f9cce8634d6bdd81754f775.tar.bz2 rtmux-ce6be7afd4d10b542f9cce8634d6bdd81754f775.zip |
Make array options a sparse tree instead of an array of char * and
remove the size limit.
Diffstat (limited to 'status.c')
-rw-r--r-- | status.c | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -1510,9 +1510,10 @@ status_prompt_complete_list(u_int *size, const char *s) const char **layout, *value, *cp; const struct cmd_entry **cmdent; const struct options_table_entry *oe; - u_int items, idx; + u_int idx; size_t slen = strlen(s), valuelen; struct options_entry *o; + struct options_array_item *a; const char *layouts[] = { "even-horizontal", "even-vertical", "main-horizontal", "main-vertical", "tiled", NULL @@ -1538,16 +1539,22 @@ status_prompt_complete_list(u_int *size, const char *s) } } o = options_get_only(global_options, "command-alias"); - if (o != NULL && options_array_size(o, &items) != -1) { - for (idx = 0; idx < items; idx++) { - value = options_array_get(o, idx); + if (o != NULL) { + a = options_array_first(o); + while (a != NULL) { + value = options_array_item_value(a);; if (value == NULL || (cp = strchr(value, '=')) == NULL) - continue; + goto next; + valuelen = cp - value; if (slen > valuelen || strncmp(value, s, slen) != 0) - continue; + goto next; + list = xreallocarray(list, (*size) + 1, sizeof *list); list[(*size)++] = xstrndup(value, valuelen); + + next: + a = options_array_next(a); } } for (idx = 0; idx < (*size); idx++) |