diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-07-15 07:50:34 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-07-15 07:50:34 +0000 |
commit | ca617d679ff296a4abe0e7526d8e8cab4f87e338 (patch) | |
tree | c854ff73d8b545170ef71d2966524dcbd946720a /cmd-set-window-option.c | |
parent | 615d85fb23e8eea75d3c630eccc21e98dd8a8ec7 (diff) | |
download | rtmux-ca617d679ff296a4abe0e7526d8e8cab4f87e338.tar.gz rtmux-ca617d679ff296a4abe0e7526d8e8cab4f87e338.tar.bz2 rtmux-ca617d679ff296a4abe0e7526d8e8cab4f87e338.zip |
Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.
Diffstat (limited to 'cmd-set-window-option.c')
-rw-r--r-- | cmd-set-window-option.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/cmd-set-window-option.c b/cmd-set-window-option.c index 46e94732..9499b46a 100644 --- a/cmd-set-window-option.c +++ b/cmd-set-window-option.c @@ -48,7 +48,7 @@ const char *set_option_mode_keys_list[] = { const char *set_option_clock_mode_style_list[] = { "12", "24", NULL }; -const struct set_option_entry set_window_option_table[NSETWINDOWOPTION] = { +const struct set_option_entry set_window_option_table[] = { { "aggressive-resize", SET_OPTION_FLAG, 0, 0, NULL }, { "automatic-rename", SET_OPTION_FLAG, 0, 0, NULL }, { "clock-mode-colour", SET_OPTION_COLOUR, 0, 0, NULL }, @@ -70,6 +70,7 @@ const struct set_option_entry set_window_option_table[NSETWINDOWOPTION] = { { "window-status-bg", SET_OPTION_COLOUR, 0, 0, NULL }, { "window-status-fg", SET_OPTION_COLOUR, 0, 0, NULL }, { "xterm-keys", SET_OPTION_FLAG, 0, 0, NULL }, + { NULL, 0, 0, 0, NULL } }; int @@ -79,7 +80,7 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx) struct winlink *wl; struct client *c; struct options *oo; - const struct set_option_entry *entry; + const struct set_option_entry *entry, *opt; u_int i; if (data->chflags & CMD_CHFLAG('g')) @@ -96,15 +97,14 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx) } entry = NULL; - for (i = 0; i < NSETWINDOWOPTION; i++) { - if (strncmp(set_window_option_table[i].name, - data->option, strlen(data->option)) != 0) + for (opt = set_window_option_table; opt->name != NULL; opt++) { + if (strncmp(opt->name, data->option, strlen(data->option)) != 0) continue; if (entry != NULL) { ctx->error(ctx, "ambiguous option: %s", data->option); return (-1); } - entry = &set_window_option_table[i]; + entry = opt; /* Bail now if an exact match. */ if (strcmp(entry->name, data->option) == 0) |