diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-12-13 15:00:38 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-12-13 15:00:38 +0000 |
commit | 8f60fc3cb34f0063cf5716446c7ba15f455626ac (patch) | |
tree | 03c0d513aa1fff5494f92b374ebcebca20f4f9c0 /usr.bin/tmux | |
parent | e09bfc7e556d93074ecd379a6bdc8ed7cbd9c6e7 (diff) |
Move logging into cmd_find_target rather than each function.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-find.c | 47 | ||||
-rw-r--r-- | usr.bin/tmux/cmd.c | 7 |
2 files changed, 26 insertions, 28 deletions
diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c index 1b2b39b3985..99474ef9d5b 100644 --- a/usr.bin/tmux/cmd-find.c +++ b/usr.bin/tmux/cmd-find.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find.c,v 1.17 2015/10/28 09:51:55 nicm Exp $ */ +/* $OpenBSD: cmd-find.c,v 1.18 2015/12/13 15:00:37 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicm@users.sourceforge.net> @@ -76,7 +76,7 @@ int cmd_find_get_pane_with_session(struct cmd_find_state *, const char *); int cmd_find_get_pane_with_window(struct cmd_find_state *, const char *); void cmd_find_clear_state(struct cmd_find_state *, struct cmd_q *, int); -void cmd_find_log_state(const char *, const char *, struct cmd_find_state *); +void cmd_find_log_state(const char *, struct cmd_find_state *); struct cmd_find_state *cmd_find_target(struct cmd_q *, const char *, enum cmd_find_type, int); @@ -827,6 +827,13 @@ cmd_find_target(struct cmd_q *cmdq, const char *target, enum cmd_find_type type, char *colon, *period, *copy = NULL; const char *session, *window, *pane; + /* Log the arguments. */ + if (target == NULL) + log_debug("%s: target none, type %d", __func__, type); + else + log_debug("%s: target %s, type %d", __func__, target, type); + log_debug("%s: cmdq %p, flags %#x", __func__, cmdq, flags); + /* Find current state. */ cmd_find_clear_state(¤t, cmdq, flags); if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) { @@ -873,7 +880,7 @@ cmd_find_target(struct cmd_q *cmdq, const char *target, enum cmd_find_type type, cmdq_error(cmdq, "no mouse target"); goto error; } - return (&fs); + goto found; } /* Marked target is a plain ~ or {marked}. */ @@ -888,7 +895,7 @@ cmd_find_target(struct cmd_q *cmdq, const char *target, enum cmd_find_type type, fs.idx = fs.wl->idx; fs.w = fs.wl->window; fs.wp = marked_window_pane; - return (&fs); + goto found; } /* Find separators if they exist. */ @@ -1053,13 +1060,16 @@ current: free(copy); if (flags & CMD_FIND_WINDOW_INDEX) current.idx = -1; + cmd_find_log_state(__func__, ¤t); return (¤t); error: free(copy); + log_debug(" error"); return (NULL); found: + cmd_find_log_state(__func__, &fs); free(copy); return (&fs); @@ -1081,29 +1091,25 @@ no_pane: /* Log the result. */ void -cmd_find_log_state(const char *f, const char *target, struct cmd_find_state *fs) +cmd_find_log_state(const char *prefix, struct cmd_find_state *fs) { - log_debug("%s: target %s%s", f, target == NULL ? "none" : target, - fs != NULL ? "" : " (failed)"); - if (fs == NULL) - return; if (fs->s != NULL) - log_debug("\ts=$%u", fs->s->id); + log_debug("%s: s=$%u", prefix, fs->s->id); else - log_debug("\ts=none"); + log_debug("%s: s=none", prefix); if (fs->wl != NULL) { - log_debug("\twl=%u %d w=@%u %s", fs->wl->idx, + log_debug("%s: wl=%u %d w=@%u %s", prefix, fs->wl->idx, fs->wl->window == fs->w, fs->w->id, fs->w->name); } else - log_debug("\twl=none"); + log_debug("%s: wl=none", prefix); if (fs->wp != NULL) - log_debug("\twp=%%%u", fs->wp->id); + log_debug("%s: wp=%%%u", prefix, fs->wp->id); else - log_debug("\twp=none"); + log_debug("%s: wp=none", prefix); if (fs->idx != -1) - log_debug("\tidx=%d", fs->idx); + log_debug("%s: idx=%d", prefix, fs->idx); else - log_debug("\tidx=none"); + log_debug("%s: idx=none", prefix); } /* Find the current session. */ @@ -1114,7 +1120,6 @@ cmd_find_current(struct cmd_q *cmdq) int flags = CMD_FIND_QUIET; fs = cmd_find_target(cmdq, NULL, CMD_FIND_SESSION, flags); - cmd_find_log_state(__func__, NULL, fs); if (fs == NULL) return (NULL); @@ -1132,7 +1137,6 @@ cmd_find_session(struct cmd_q *cmdq, const char *target, int prefer_unattached) flags |= CMD_FIND_PREFER_UNATTACHED; fs = cmd_find_target(cmdq, target, CMD_FIND_SESSION, flags); - cmd_find_log_state(__func__, target, fs); if (fs == NULL) return (NULL); @@ -1146,7 +1150,6 @@ cmd_find_window(struct cmd_q *cmdq, const char *target, struct session **sp) struct cmd_find_state *fs; fs = cmd_find_target(cmdq, target, CMD_FIND_WINDOW, 0); - cmd_find_log_state(__func__, target, fs); if (fs == NULL) return (NULL); @@ -1164,7 +1167,6 @@ cmd_find_window_marked(struct cmd_q *cmdq, const char *target, int flags = CMD_FIND_DEFAULT_MARKED; fs = cmd_find_target(cmdq, target, CMD_FIND_WINDOW, flags); - cmd_find_log_state(__func__, target, fs); if (fs == NULL) return (NULL); @@ -1181,7 +1183,6 @@ cmd_find_pane(struct cmd_q *cmdq, const char *target, struct session **sp, struct cmd_find_state *fs; fs = cmd_find_target(cmdq, target, CMD_FIND_PANE, 0); - cmd_find_log_state(__func__, target, fs); if (fs == NULL) return (NULL); @@ -1201,7 +1202,6 @@ cmd_find_pane_marked(struct cmd_q *cmdq, const char *target, int flags = CMD_FIND_DEFAULT_MARKED; fs = cmd_find_target(cmdq, target, CMD_FIND_PANE, flags); - cmd_find_log_state(__func__, target, fs); if (fs == NULL) return (NULL); @@ -1275,7 +1275,6 @@ cmd_find_index(struct cmd_q *cmdq, const char *target, struct session **sp) int flags = CMD_FIND_WINDOW_INDEX; fs = cmd_find_target(cmdq, target, CMD_FIND_WINDOW, flags); - cmd_find_log_state(__func__, target, fs); if (fs == NULL) return (-2); diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c index 465053292a3..71db55c0b9f 100644 --- a/usr.bin/tmux/cmd.c +++ b/usr.bin/tmux/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.108 2015/12/13 14:32:38 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.109 2015/12/13 15:00:37 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -538,8 +538,8 @@ cmd_set_state_flag(struct cmd *cmd, struct cmd_q *cmdq, char c) if (statef->wl == NULL) return (-1); break; - case CMD_PANE_MARKED_S: case CMD_PANE_MARKED_T: + case CMD_PANE_MARKED_S: statef->wl = cmd_find_pane_marked(cmdq, flag, &statef->s, &statef->wp); if (statef->wl == NULL) @@ -595,8 +595,7 @@ cmd_prepare_state(struct cmd *cmd, struct cmd_q *cmdq) int error; tmp = cmd_print(cmd); - log_debug("preparing state for: %s (client %d)", tmp, - cmdq->client != NULL ? cmdq->client->fd : -1); + log_debug("preparing state for: %s (client %p)", tmp, cmdq->client); free(tmp); /* Start with an empty state. */ |