Sync OpenBSD patchset 840:

Fix next and previous session functions to actually work.
This commit is contained in:
Tiago Cunha 2011-01-21 23:52:36 +00:00
parent a880639f48
commit 43f8d62f6a

View File

@ -1,4 +1,4 @@
/* $Id: session.c,v 1.85 2011-01-03 23:27:54 tcunha Exp $ */
/* $Id: session.c,v 1.86 2011-01-21 23:52:36 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -180,12 +180,9 @@ session_next_session(struct session *s)
if (RB_EMPTY(&sessions) || !session_alive(s))
return (NULL);
s2 = s;
do {
s2 = RB_NEXT(sessions, &sessions, s2);
if (s2 == NULL)
s2 = RB_MIN(sessions, &sessions);
} while (s2 != s);
s2 = RB_NEXT(sessions, &sessions, s2);
if (s2 == NULL)
s2 = RB_MIN(sessions, &sessions);
if (s2 == s)
return (NULL);
return (s2);
@ -200,12 +197,9 @@ session_previous_session(struct session *s)
if (RB_EMPTY(&sessions) || !session_alive(s))
return (NULL);
s2 = s;
do {
s2 = RB_PREV(sessions, &sessions, s2);
if (s2 == NULL)
s2 = RB_MAX(sessions, &sessions);
} while (s2 != s);
s2 = RB_PREV(sessions, &sessions, s2);
if (s2 == NULL)
s2 = RB_MAX(sessions, &sessions);
if (s2 == s)
return (NULL);
return (s2);