Skip to content

Commit

Permalink
Merge branch 'obsd-master'
Browse files Browse the repository at this point in the history
Conflicts:
	tmux.h
  • Loading branch information
ThomasAdam committed Nov 21, 2015
2 parents 2c48293 + 933929c commit 78a00c8
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 115 deletions.
12 changes: 2 additions & 10 deletions alerts.c
Expand Up @@ -77,8 +77,8 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
int
alerts_enabled(struct window *w, int flags)
{
struct session *s;

if (flags & WINDOW_BELL)
return (1);
if (flags & WINDOW_ACTIVITY) {
if (options_get_number(w->options, "monitor-activity"))
return (1);
Expand All @@ -87,14 +87,6 @@ alerts_enabled(struct window *w, int flags)
if (options_get_number(w->options, "monitor-silence") != 0)
return (1);
}
if (~flags & WINDOW_BELL)
return (0);
RB_FOREACH(s, sessions, &sessions) {
if (!session_has(s, w))
continue;
if (options_get_number(s->options, "bell-action") != BELL_NONE)
return (1);
}
return (0);
}

Expand Down
1 change: 1 addition & 0 deletions cmd-if-shell.c
Expand Up @@ -97,6 +97,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
cmd = args->argv[1];
else if (args->argc == 3)
cmd = args->argv[2];
free(shellcmd);
if (cmd == NULL)
return (CMD_RETURN_NORMAL);
if (cmd_string_parse(cmd, &cmdlist, NULL, 0, &cause) != 0) {
Expand Down
2 changes: 1 addition & 1 deletion cmd-new-window.c
Expand Up @@ -97,7 +97,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
ft = format_create();
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,
NULL);
cwd = format_expand(ft, args_get(args, 'c'));
cwd = to_free = format_expand(ft, args_get(args, 'c'));
format_free(ft);
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
cwd = cmdq->client->cwd;
Expand Down
14 changes: 7 additions & 7 deletions cmd-set-option.c
Expand Up @@ -84,7 +84,7 @@ enum cmd_retval
cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
const struct options_table_entry *table, *oe;
const struct options_table_entry *oe;
struct session *s;
struct winlink *wl;
struct client *c;
Expand All @@ -108,8 +108,8 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
return (cmd_set_option_user(self, cmdq, optstr, valstr));

/* Find the option entry, try each table. */
table = oe = NULL;
if (options_table_find(optstr, &table, &oe) != 0) {
oe = NULL;
if (options_table_find(optstr, &oe) != 0) {
if (!args_has(args, 'q')) {
cmdq_error(cmdq, "ambiguous option: %s", optstr);
return (CMD_RETURN_ERROR);
Expand All @@ -124,10 +124,10 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL);
}

/* Work out the tree from the table. */
if (table == server_options_table)
/* Work out the tree from the scope of the option. */
if (oe->scope == OPTIONS_TABLE_SERVER)
oo = global_options;
else if (table == window_options_table) {
else if (oe->scope == OPTIONS_TABLE_WINDOW) {
if (args_has(self->args, 'g'))
oo = global_w_options;
else {
Expand All @@ -141,7 +141,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
}
oo = wl->window->options;
}
} else if (table == session_options_table) {
} else if (oe->scope == OPTIONS_TABLE_SESSION) {
if (args_has(self->args, 'g'))
oo = global_s_options;
else {
Expand Down
45 changes: 23 additions & 22 deletions cmd-show-options.c
Expand Up @@ -32,7 +32,7 @@ enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_show_options_one(struct cmd *, struct cmd_q *,
struct options *, int);
enum cmd_retval cmd_show_options_all(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *);
struct options *, enum options_table_scope);

const struct cmd_entry cmd_show_options_entry = {
"show-options", "show",
Expand All @@ -53,19 +53,19 @@ const struct cmd_entry cmd_show_window_options_entry = {
enum cmd_retval
cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct session *s;
struct winlink *wl;
const struct options_table_entry *table;
struct options *oo;
int quiet;
struct args *args = self->args;
struct session *s;
struct winlink *wl;
struct options *oo;
int quiet;
enum options_table_scope scope;

if (args_has(self->args, 's')) {
oo = global_options;
table = server_options_table;
scope = OPTIONS_TABLE_SERVER;
} else if (args_has(self->args, 'w') ||
self->entry == &cmd_show_window_options_entry) {
table = window_options_table;
scope = OPTIONS_TABLE_WINDOW;
if (args_has(self->args, 'g'))
oo = global_w_options;
else {
Expand All @@ -75,7 +75,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
oo = wl->window->options;
}
} else {
table = session_options_table;
scope = OPTIONS_TABLE_SESSION;
if (args_has(self->args, 'g'))
oo = global_s_options;
else {
Expand All @@ -88,7 +88,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)

quiet = args_has(self->args, 'q');
if (args->argc == 0)
return (cmd_show_options_all(self, cmdq, table, oo));
return (cmd_show_options_all(self, cmdq, oo, scope));
else
return (cmd_show_options_one(self, cmdq, oo, quiet));
}
Expand All @@ -99,7 +99,7 @@ cmd_show_options_one(struct cmd *self, struct cmd_q *cmdq,
{
struct args *args = self->args;
const char *name = args->argv[0];
const struct options_table_entry *table, *oe;
const struct options_table_entry *oe;
struct options_entry *o;
const char *optval;

Expand All @@ -118,14 +118,14 @@ cmd_show_options_one(struct cmd *self, struct cmd_q *cmdq,
return (CMD_RETURN_NORMAL);
}

table = oe = NULL;
if (options_table_find(name, &table, &oe) != 0) {
oe = NULL;
if (options_table_find(name, &oe) != 0) {
cmdq_error(cmdq, "ambiguous option: %s", name);
return (CMD_RETURN_ERROR);
}
if (oe == NULL) {
if (quiet)
return (CMD_RETURN_NORMAL);
return (CMD_RETURN_NORMAL);
cmdq_error(cmdq, "unknown option: %s", name);
return (CMD_RETURN_ERROR);
}
Expand All @@ -144,12 +144,13 @@ cmd_show_options_one(struct cmd *self, struct cmd_q *cmdq,
}

enum cmd_retval
cmd_show_options_all(struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *table, struct options *oo)
cmd_show_options_all(struct cmd *self, struct cmd_q *cmdq, struct options *oo,
enum options_table_scope scope)
{
const struct options_table_entry *oe;
struct options_entry *o;
const char *optval;
int vflag;

o = options_first(oo);
while (o != NULL) {
Expand All @@ -162,14 +163,14 @@ cmd_show_options_all(struct cmd *self, struct cmd_q *cmdq,
o = options_next(o);
}

for (oe = table; oe->name != NULL; oe++) {
if (oe->style != NULL)
vflag = args_has(self->args, 'v');
for (oe = options_table; oe->name != NULL; oe++) {
if (oe->style != NULL || oe->scope != scope)
continue;
if ((o = options_find1(oo, oe->name)) == NULL)
continue;
optval = options_table_print_entry(oe, o,
args_has(self->args, 'v'));
if (args_has(self->args, 'v'))
optval = options_table_print_entry(oe, o, vflag);
if (vflag)
cmdq_print(cmdq, "%s", optval);
else
cmdq_print(cmdq, "%s %s", oe->name, optval);
Expand Down

0 comments on commit 78a00c8

Please sign in to comment.