diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-07-15 17:44:47 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-07-15 17:44:47 +0000 |
commit | ff90170738dad3ab6d302790672c57a3e10e9075 (patch) | |
tree | 7bee01c0f92b2536cb6850cdfbb4d040b61ab8a2 /cmd-set-window-option.c | |
parent | 6ebb1df8fe161678c3550e59774ec4894551ba3e (diff) | |
download | rtmux-ff90170738dad3ab6d302790672c57a3e10e9075.tar.gz rtmux-ff90170738dad3ab6d302790672c57a3e10e9075.tar.bz2 rtmux-ff90170738dad3ab6d302790672c57a3e10e9075.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 | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/cmd-set-window-option.c b/cmd-set-window-option.c index 75c4d27f..1ea8f971 100644 --- a/cmd-set-window-option.c +++ b/cmd-set-window-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-window-option.c,v 1.32 2009-07-15 17:44:25 nicm Exp $ */ +/* $Id: cmd-set-window-option.c,v 1.33 2009-07-15 17:44:47 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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) |