[BACK]Return to cmd-find.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/cmd-find.c between version 1.14 and 1.15

version 1.14, 2015/10/22 11:23:00 version 1.15, 2015/10/23 16:29:07
Line 23 
Line 23 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <paths.h>  #include <paths.h>
   #include <unistd.h>
   
 #include "tmux.h"  #include "tmux.h"
   
Line 51 
Line 52 
         int                      idx;          int                      idx;
 };  };
   
   struct session  *cmd_find_try_TMUX(struct client *, struct window *);
 int              cmd_find_client_better(struct client *, struct client *);  int              cmd_find_client_better(struct client *, struct client *);
 struct client   *cmd_find_best_client(struct client **, u_int);  struct client   *cmd_find_best_client(struct client **, u_int);
 int              cmd_find_session_better(struct session *, struct session *,  int              cmd_find_session_better(struct session *, struct session *,
Line 109 
Line 111 
         { NULL, NULL }          { NULL, NULL }
 };  };
   
   /* Get session from TMUX if present. */
   struct session *
   cmd_find_try_TMUX(struct client *c, struct window *w)
   {
           struct environ_entry    *envent;
           char                     tmp[256];
           long long                pid;
           u_int                    session;
           struct session          *s;
   
           envent = environ_find(&c->environ, "TMUX");
           if (envent == NULL)
                   return (NULL);
   
           if (sscanf(envent->value, "%255[^,],%lld,%d", tmp, &pid, &session) != 3)
                   return (NULL);
           if (pid != getpid())
                   return (NULL);
           log_debug("client %d TMUX is %s (session @%u)", c->ibuf.fd,
               envent->value, session);
   
           s = session_find_by_id(session);
           if (s == NULL || (w != NULL && !session_has(s, w)))
                   return (NULL);
           return (s);
   }
   
 /* Is this client better? */  /* Is this client better? */
 int  int
 cmd_find_client_better(struct client *c, struct client *than)  cmd_find_client_better(struct client *c, struct client *than)
Line 192 
Line 221 
         u_int             ssize;          u_int             ssize;
         struct session   *s;          struct session   *s;
   
           if (fs->cmdq->client != NULL) {
                   fs->s = cmd_find_try_TMUX(fs->cmdq->client, fs->w);
                   if (fs->s != NULL)
                           return (cmd_find_best_winlink_with_window(fs));
           }
   
         ssize = 0;          ssize = 0;
         RB_FOREACH(s, sessions, &sessions) {          RB_FOREACH(s, sessions, &sessions) {
                 if (!session_has(s, fs->w))                  if (!session_has(s, fs->w))
Line 277 
Line 312 
         return (0);          return (0);
   
 unknown_pane:  unknown_pane:
         fs->s = cmd_find_best_session(NULL, 0, fs->flags);          fs->s = cmd_find_try_TMUX(fs->cmdq->client, NULL);
           if (fs->s == NULL)
                   fs->s = cmd_find_best_session(NULL, 0, fs->flags);
         if (fs->s == NULL)          if (fs->s == NULL)
                 return (-1);                  return (-1);
         fs->wl = fs->s->curw;          fs->wl = fs->s->curw;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15