diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-04-05 10:49:47 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-04-05 10:49:47 +0000 |
commit | 5ad796c4d39cb763d98baa40578628d6d3e4434f (patch) | |
tree | d0d64c4589b72b70481b27544e654f609dc235a0 /usr.bin/tmux/cmd-find.c | |
parent | 1776cb2009fb88cbe8699def10c76d867abb5486 (diff) |
Give each client a name. This defaults to the tty name as before but
falls back to an alternative if the tty name is not available. This is
clearer than overloading the client ttyname member and allows us to
remove the path stored in the tty struct, it should always be the same
as the client.
Diffstat (limited to 'usr.bin/tmux/cmd-find.c')
-rw-r--r-- | usr.bin/tmux/cmd-find.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c index 28b131c4f05..5842611551f 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.42 2017/03/13 10:53:32 nicm Exp $ */ +/* $OpenBSD: cmd-find.c,v 1.43 2017/04/05 10:49:46 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -256,9 +256,9 @@ cmd_find_current_session_with_client(struct cmd_find_state *fs) * sessions to those containing that pane (we still use the current * window in the best session). */ - if (fs->item != NULL && fs->item->client->tty.path != NULL) { + if (fs->item != NULL) { RB_FOREACH(wp, window_pane_tree, &all_window_panes) { - if (strcmp(wp->tty, fs->item->client->tty.path) == 0) + if (strcmp(wp->tty, fs->item->client->ttyname) == 0) break; } } else @@ -1248,7 +1248,6 @@ cmd_find_client(struct cmdq_item *item, const char *target, int quiet) struct client *c; char *copy; size_t size; - const char *path; /* A NULL argument means the current client. */ if (item != NULL && target == NULL) { @@ -1265,20 +1264,20 @@ cmd_find_client(struct cmdq_item *item, const char *target, int quiet) if (size != 0 && copy[size - 1] == ':') copy[size - 1] = '\0'; - /* Check path of each client. */ + /* Check name and path of each client. */ TAILQ_FOREACH(c, &clients, entry) { - if (c->session == NULL || c->tty.path == NULL) + if (c->session == NULL) continue; - path = c->tty.path; - - /* Try for exact match. */ - if (strcmp(copy, path) == 0) + if (strcmp(copy, c->name) == 0) break; - /* Try without leading /dev. */ - if (strncmp(path, _PATH_DEV, (sizeof _PATH_DEV) - 1) != 0) + if (*c->ttyname == '\0') + continue; + if (strcmp(copy, c->ttyname) == 0) + break; + if (strncmp(c->ttyname, _PATH_DEV, (sizeof _PATH_DEV) - 1) != 0) continue; - if (strcmp(copy, path + (sizeof _PATH_DEV) - 1) == 0) + if (strcmp(copy, c->ttyname + (sizeof _PATH_DEV) - 1) == 0) break; } |