=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-set-option.c,v retrieving revision 1.100 retrieving revision 1.101 diff -u -r1.100 -r1.101 --- src/usr.bin/tmux/cmd-set-option.c 2016/10/14 22:14:22 1.100 +++ src/usr.bin/tmux/cmd-set-option.c 2016/10/16 19:04:05 1.101 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.100 2016/10/14 22:14:22 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.101 2016/10/16 19:04:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -27,42 +27,42 @@ * Set an option. */ -static enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmd_q *); +static enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmdq_item *); -static enum cmd_retval cmd_set_option_user(struct cmd *, struct cmd_q *, - const char *, const char *); +static enum cmd_retval cmd_set_option_user(struct cmd *, struct cmdq_item *, + const char *, const char *); -static int cmd_set_option_unset(struct cmd *, struct cmd_q *, +static int cmd_set_option_unset(struct cmd *, struct cmdq_item *, const struct options_table_entry *, struct options *, const char *); -static int cmd_set_option_set(struct cmd *, struct cmd_q *, +static int cmd_set_option_set(struct cmd *, struct cmdq_item *, const struct options_table_entry *, struct options *, const char *); -static struct options_entry *cmd_set_option_string(struct cmd *, struct cmd_q *, - const struct options_table_entry *, struct options *, - const char *); -static struct options_entry *cmd_set_option_number(struct cmd *, struct cmd_q *, - const struct options_table_entry *, struct options *, - const char *); -static struct options_entry *cmd_set_option_key(struct cmd *, struct cmd_q *, - const struct options_table_entry *, struct options *, - const char *); -static struct options_entry *cmd_set_option_colour(struct cmd *, struct cmd_q *, - const struct options_table_entry *, struct options *, - const char *); +static struct options_entry *cmd_set_option_string(struct cmd *, + struct cmdq_item *, const struct options_table_entry *, + struct options *, const char *); +static struct options_entry *cmd_set_option_number(struct cmd *, + struct cmdq_item *, const struct options_table_entry *, + struct options *, const char *); +static struct options_entry *cmd_set_option_key(struct cmd *, + struct cmdq_item *, const struct options_table_entry *, + struct options *, const char *); +static struct options_entry *cmd_set_option_colour(struct cmd *, + struct cmdq_item *, const struct options_table_entry *, + struct options *, const char *); static struct options_entry *cmd_set_option_attributes(struct cmd *, - struct cmd_q *, const struct options_table_entry *, + struct cmdq_item *, const struct options_table_entry *, struct options *, const char *); -static struct options_entry *cmd_set_option_flag(struct cmd *, struct cmd_q *, - const struct options_table_entry *, struct options *, - const char *); -static struct options_entry *cmd_set_option_choice(struct cmd *, struct cmd_q *, - const struct options_table_entry *, struct options *, - const char *); -static struct options_entry *cmd_set_option_style(struct cmd *, struct cmd_q *, - const struct options_table_entry *, struct options *, - const char *); +static struct options_entry *cmd_set_option_flag(struct cmd *, + struct cmdq_item *, const struct options_table_entry *, + struct options *, const char *); +static struct options_entry *cmd_set_option_choice(struct cmd *, + struct cmdq_item *, const struct options_table_entry *, + struct options *, const char *); +static struct options_entry *cmd_set_option_style(struct cmd *, + struct cmdq_item *, const struct options_table_entry *, + struct options *, const char *); const struct cmd_entry cmd_set_option_entry = { .name = "set-option", @@ -91,11 +91,11 @@ }; static enum cmd_retval -cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq) +cmd_set_option_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; - struct session *s = cmdq->state.tflag.s; - struct winlink *wl = cmdq->state.tflag.wl; + struct session *s = item->state.tflag.s; + struct winlink *wl = item->state.tflag.wl; struct window *w; struct client *c; const struct options_table_entry *oe; @@ -105,7 +105,7 @@ /* Get the option name and value. */ optstr = args->argv[0]; if (*optstr == '\0') { - cmdq_error(cmdq, "invalid option"); + cmdq_error(item, "invalid option"); return (CMD_RETURN_ERROR); } if (args->argc < 2) @@ -115,20 +115,20 @@ /* Is this a user option? */ if (*optstr == '@') - return (cmd_set_option_user(self, cmdq, optstr, valstr)); + return (cmd_set_option_user(self, item, optstr, valstr)); /* Find the option entry, try each table. */ oe = NULL; if (options_table_find(optstr, &oe) != 0) { if (!args_has(args, 'q')) { - cmdq_error(cmdq, "ambiguous option: %s", optstr); + cmdq_error(item, "ambiguous option: %s", optstr); return (CMD_RETURN_ERROR); } return (CMD_RETURN_NORMAL); } if (oe == NULL) { if (!args_has(args, 'q')) { - cmdq_error(cmdq, "unknown option: %s", optstr); + cmdq_error(item, "unknown option: %s", optstr); return (CMD_RETURN_ERROR); } return (CMD_RETURN_NORMAL); @@ -143,10 +143,10 @@ else if (wl == NULL) { target = args_get(args, 't'); if (target != NULL) { - cmdq_error(cmdq, "no such window: %s", + cmdq_error(item, "no such window: %s", target); } else - cmdq_error(cmdq, "no current window"); + cmdq_error(item, "no current window"); return (CMD_RETURN_ERROR); } else oo = wl->window->options; @@ -156,31 +156,31 @@ else if (s == NULL) { target = args_get(args, 't'); if (target != NULL) { - cmdq_error(cmdq, "no such session: %s", + cmdq_error(item, "no such session: %s", target); } else - cmdq_error(cmdq, "no current session"); + cmdq_error(item, "no current session"); return (CMD_RETURN_ERROR); } else oo = s->options; } else { - cmdq_error(cmdq, "unknown table"); + cmdq_error(item, "unknown table"); return (CMD_RETURN_ERROR); } /* Unset or set the option. */ if (args_has(args, 'u')) { - if (cmd_set_option_unset(self, cmdq, oe, oo, valstr) != 0) + if (cmd_set_option_unset(self, item, oe, oo, valstr) != 0) return (CMD_RETURN_ERROR); } else { if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) { if (!args_has(args, 'q')) { - cmdq_error(cmdq, "already set: %s", optstr); + cmdq_error(item, "already set: %s", optstr); return (CMD_RETURN_ERROR); } return (CMD_RETURN_NORMAL); } - if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0) + if (cmd_set_option_set(self, item, oe, oo, valstr) != 0) return (CMD_RETURN_ERROR); } @@ -224,12 +224,12 @@ /* Set user option. */ static enum cmd_retval -cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr, - const char *valstr) +cmd_set_option_user(struct cmd *self, struct cmdq_item *item, + const char *optstr, const char *valstr) { struct args *args = self->args; - struct session *s = cmdq->state.tflag.s; - struct winlink *wl = cmdq->state.tflag.wl; + struct session *s = item->state.tflag.s; + struct winlink *wl = item->state.tflag.wl; struct options *oo; struct options_entry *o; const char *target; @@ -243,10 +243,10 @@ else if (wl == NULL) { target = args_get(args, 't'); if (target != NULL) { - cmdq_error(cmdq, "no such window: %s", + cmdq_error(item, "no such window: %s", target); } else - cmdq_error(cmdq, "no current window"); + cmdq_error(item, "no current window"); return (CMD_RETURN_ERROR); } else oo = wl->window->options; @@ -256,10 +256,10 @@ else if (s == NULL) { target = args_get(args, 't'); if (target != NULL) { - cmdq_error(cmdq, "no such session: %s", + cmdq_error(item, "no such session: %s", target); } else - cmdq_error(cmdq, "no current session"); + cmdq_error(item, "no current session"); return (CMD_RETURN_ERROR); } else oo = s->options; @@ -268,13 +268,13 @@ if (args_has(args, 'u')) { if (options_find1(oo, optstr) == NULL) { if (!args_has(args, 'q')) { - cmdq_error(cmdq, "unknown option: %s", optstr); + cmdq_error(item, "unknown option: %s", optstr); return (CMD_RETURN_ERROR); } return (CMD_RETURN_NORMAL); } if (valstr != NULL) { - cmdq_error(cmdq, "value passed to unset option: %s", + cmdq_error(item, "value passed to unset option: %s", optstr); return (CMD_RETURN_ERROR); } @@ -283,13 +283,13 @@ o = options_find1(oo, optstr); if (args_has(args, 'o') && o != NULL) { if (!args_has(args, 'q')) { - cmdq_error(cmdq, "already set: %s", optstr); + cmdq_error(item, "already set: %s", optstr); return (CMD_RETURN_ERROR); } return (CMD_RETURN_NORMAL); } if (valstr == NULL) { - cmdq_error(cmdq, "empty value"); + cmdq_error(item, "empty value"); return (CMD_RETURN_ERROR); } if (o != NULL && args_has(args, 'a')) @@ -302,14 +302,14 @@ /* Unset an option. */ static int -cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq, +cmd_set_option_unset(struct cmd *self, struct cmdq_item *item, const struct options_table_entry *oe, struct options *oo, const char *value) { struct args *args = self->args; if (value != NULL) { - cmdq_error(cmdq, "value passed to unset option: %s", oe->name); + cmdq_error(item, "value passed to unset option: %s", oe->name); return (-1); } @@ -332,7 +332,7 @@ /* Set an option. */ static int -cmd_set_option_set(struct cmd *self, struct cmd_q *cmdq, +cmd_set_option_set(struct cmd *self, struct cmdq_item *item, const struct options_table_entry *oe, struct options *oo, const char *value) { @@ -344,7 +344,7 @@ break; default: if (value == NULL) { - cmdq_error(cmdq, "empty value"); + cmdq_error(item, "empty value"); return (-1); } } @@ -352,32 +352,32 @@ o = NULL; switch (oe->type) { case OPTIONS_TABLE_STRING: - o = cmd_set_option_string(self, cmdq, oe, oo, value); + o = cmd_set_option_string(self, item, oe, oo, value); break; case OPTIONS_TABLE_NUMBER: - o = cmd_set_option_number(self, cmdq, oe, oo, value); + o = cmd_set_option_number(self, item, oe, oo, value); break; case OPTIONS_TABLE_KEY: - o = cmd_set_option_key(self, cmdq, oe, oo, value); + o = cmd_set_option_key(self, item, oe, oo, value); break; case OPTIONS_TABLE_COLOUR: - o = cmd_set_option_colour(self, cmdq, oe, oo, value); + o = cmd_set_option_colour(self, item, oe, oo, value); if (o != NULL) style_update_new(oo, o->name, oe->style); break; case OPTIONS_TABLE_ATTRIBUTES: - o = cmd_set_option_attributes(self, cmdq, oe, oo, value); + o = cmd_set_option_attributes(self, item, oe, oo, value); if (o != NULL) style_update_new(oo, o->name, oe->style); break; case OPTIONS_TABLE_FLAG: - o = cmd_set_option_flag(self, cmdq, oe, oo, value); + o = cmd_set_option_flag(self, item, oe, oo, value); break; case OPTIONS_TABLE_CHOICE: - o = cmd_set_option_choice(self, cmdq, oe, oo, value); + o = cmd_set_option_choice(self, item, oe, oo, value); break; case OPTIONS_TABLE_STYLE: - o = cmd_set_option_style(self, cmdq, oe, oo, value); + o = cmd_set_option_style(self, item, oe, oo, value); break; } if (o == NULL) @@ -387,7 +387,7 @@ /* Set a string option. */ static struct options_entry * -cmd_set_option_string(struct cmd *self, __unused struct cmd_q *cmdq, +cmd_set_option_string(struct cmd *self, __unused struct cmdq_item *item, const struct options_table_entry *oe, struct options *oo, const char *value) { @@ -409,7 +409,7 @@ /* Set a number option. */ static struct options_entry * -cmd_set_option_number(__unused struct cmd *self, struct cmd_q *cmdq, +cmd_set_option_number(__unused struct cmd *self, struct cmdq_item *item, const struct options_table_entry *oe, struct options *oo, const char *value) { @@ -418,7 +418,7 @@ ll = strtonum(value, oe->minimum, oe->maximum, &errstr); if (errstr != NULL) { - cmdq_error(cmdq, "value is %s: %s", errstr, value); + cmdq_error(item, "value is %s: %s", errstr, value); return (NULL); } @@ -427,7 +427,7 @@ /* Set a key option. */ static struct options_entry * -cmd_set_option_key(__unused struct cmd *self, struct cmd_q *cmdq, +cmd_set_option_key(__unused struct cmd *self, struct cmdq_item *item, const struct options_table_entry *oe, struct options *oo, const char *value) { @@ -435,7 +435,7 @@ key = key_string_lookup_string(value); if (key == KEYC_UNKNOWN) { - cmdq_error(cmdq, "bad key: %s", value); + cmdq_error(item, "bad key: %s", value); return (NULL); } @@ -444,14 +444,14 @@ /* Set a colour option. */ static struct options_entry * -cmd_set_option_colour(__unused struct cmd *self, struct cmd_q *cmdq, +cmd_set_option_colour(__unused struct cmd *self, struct cmdq_item *item, const struct options_table_entry *oe, struct options *oo, const char *value) { int colour; if ((colour = colour_fromstring(value)) == -1) { - cmdq_error(cmdq, "bad colour: %s", value); + cmdq_error(item, "bad colour: %s", value); return (NULL); } @@ -460,14 +460,14 @@ /* Set an attributes option. */ static struct options_entry * -cmd_set_option_attributes(__unused struct cmd *self, struct cmd_q *cmdq, +cmd_set_option_attributes(__unused struct cmd *self, struct cmdq_item *item, const struct options_table_entry *oe, struct options *oo, const char *value) { int attr; if ((attr = attributes_fromstring(value)) == -1) { - cmdq_error(cmdq, "bad attributes: %s", value); + cmdq_error(item, "bad attributes: %s", value); return (NULL); } @@ -476,7 +476,7 @@ /* Set a flag option. */ static struct options_entry * -cmd_set_option_flag(__unused struct cmd *self, struct cmd_q *cmdq, +cmd_set_option_flag(__unused struct cmd *self, struct cmdq_item *item, const struct options_table_entry *oe, struct options *oo, const char *value) { @@ -494,7 +494,7 @@ strcasecmp(value, "no") == 0) flag = 0; else { - cmdq_error(cmdq, "bad value: %s", value); + cmdq_error(item, "bad value: %s", value); return (NULL); } } @@ -504,7 +504,7 @@ /* Set a choice option. */ static struct options_entry * -cmd_set_option_choice(__unused struct cmd *self, struct cmd_q *cmdq, +cmd_set_option_choice(__unused struct cmd *self, struct cmdq_item *item, const struct options_table_entry *oe, struct options *oo, const char *value) { @@ -523,13 +523,13 @@ continue; if (choice != -1) { - cmdq_error(cmdq, "ambiguous value: %s", value); + cmdq_error(item, "ambiguous value: %s", value); return (NULL); } choice = n - 1; } if (choice == -1) { - cmdq_error(cmdq, "unknown value: %s", value); + cmdq_error(item, "unknown value: %s", value); return (NULL); } } @@ -539,7 +539,7 @@ /* Set a style option. */ static struct options_entry * -cmd_set_option_style(struct cmd *self, struct cmd_q *cmdq, +cmd_set_option_style(struct cmd *self, struct cmdq_item *item, const struct options_table_entry *oe, struct options *oo, const char *value) { @@ -549,7 +549,7 @@ append = args_has(args, 'a'); if ((o = options_set_style(oo, oe->name, value, append)) == NULL) { - cmdq_error(cmdq, "bad style: %s", value); + cmdq_error(item, "bad style: %s", value); return (NULL); }