Sync OpenBSD patchset 802:

Use pointer rather than index for the client's last session.
This commit is contained in:
Tiago Cunha 2010-12-22 15:31:00 +00:00
parent 64d16cf2d6
commit bb728b89a7
5 changed files with 19 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-new-session.c,v 1.79 2010-12-11 18:42:20 nicm Exp $ */ /* $Id: cmd-new-session.c,v 1.80 2010-12-22 15:31:00 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -122,7 +122,7 @@ int
cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
{ {
struct cmd_new_session_data *data = self->data; struct cmd_new_session_data *data = self->data;
struct session *s, *groupwith; struct session *s, *old_s, *groupwith;
struct window *w; struct window *w;
struct window_pane *wp; struct window_pane *wp;
struct environ env; struct environ env;
@ -279,17 +279,16 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (!detached) { if (!detached) {
if (ctx->cmdclient != NULL) { if (ctx->cmdclient != NULL) {
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0); server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
if (ctx->cmdclient->session != NULL) {
session_index(ctx->cmdclient->session, old_s = ctx->cmdclient->session;
&ctx->cmdclient->last_session); if (old_s != NULL)
} ctx->cmdclient->last_session = old_s;
ctx->cmdclient->session = s; ctx->cmdclient->session = s;
server_redraw_client(ctx->cmdclient); server_redraw_client(ctx->cmdclient);
} else { } else {
if (ctx->curclient->session != NULL) { old_s = ctx->curclient->session;
session_index(ctx->curclient->session, if (old_s != NULL)
&ctx->curclient->last_session); ctx->curclient->last_session = old_s;
}
ctx->curclient->session = s; ctx->curclient->session = s;
server_redraw_client(ctx->curclient); server_redraw_client(ctx->curclient);
} }

View File

@ -1,4 +1,4 @@
/* $Id: cmd-switch-client.c,v 1.22 2010-12-11 18:42:20 nicm Exp $ */ /* $Id: cmd-switch-client.c,v 1.23 2010-12-22 15:31:00 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -159,9 +159,8 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
} }
} else if (data->flag_last) { } else if (data->flag_last) {
if (c->last_session != UINT_MAX && if (c->last_session != NULL && session_alive(c->last_session))
c->last_session < ARRAY_LENGTH(&sessions)) s = c->last_session;
s = ARRAY_ITEM(&sessions, c->last_session);
if (s == NULL) { if (s == NULL) {
ctx->error(ctx, "can't find last session"); ctx->error(ctx, "can't find last session");
return (-1); return (-1);
@ -172,7 +171,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
if (c->session != NULL) if (c->session != NULL)
session_index(c->session, &c->last_session); c->last_session = c->session;
c->session = s; c->session = s;
recalculate_sizes(); recalculate_sizes();

View File

@ -1,4 +1,4 @@
/* $Id: server-client.c,v 1.47 2010-12-11 18:42:20 nicm Exp $ */ /* $Id: server-client.c,v 1.48 2010-12-22 15:31:00 tcunha Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -77,7 +77,7 @@ server_client_create(int fd)
c->title = NULL; c->title = NULL;
c->session = NULL; c->session = NULL;
c->last_session = UINT_MAX; c->last_session = NULL;
c->tty.sx = 80; c->tty.sx = 80;
c->tty.sy = 24; c->tty.sy = 24;

View File

@ -1,4 +1,4 @@
/* $Id: server-fn.c,v 1.114 2010-12-11 18:42:20 nicm Exp $ */ /* $Id: server-fn.c,v 1.115 2010-12-22 15:31:00 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -399,7 +399,7 @@ server_destroy_session(struct session *s)
c->session = NULL; c->session = NULL;
c->flags |= CLIENT_EXIT; c->flags |= CLIENT_EXIT;
} else { } else {
c->last_session = UINT_MAX; c->last_session = NULL;
c->session = s_new; c->session = s_new;
server_redraw_client(c); server_redraw_client(c);
} }

4
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.588 2010-12-22 15:28:51 tcunha Exp $ */ /* $Id: tmux.h,v 1.589 2010-12-22 15:31:00 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -1153,7 +1153,7 @@ struct client {
struct mode_key_data prompt_mdata; struct mode_key_data prompt_mdata;
struct session *session; struct session *session;
u_int last_session; struct session *last_session;
int references; int references;
}; };