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

Diff for /src/usr.bin/tmux/tmux.c between version 1.69 and 1.70

version 1.69, 2010/02/06 17:15:33 version 1.70, 2010/02/06 18:29:15
Line 46 
Line 46 
 char            *socket_path;  char            *socket_path;
 int              login_shell;  int              login_shell;
   
   struct env_data {
           char    *path;
           pid_t    pid;
           u_int    idx;
   };
   
 __dead void      usage(void);  __dead void      usage(void);
 void             fill_session(struct msg_command_data *);  void             parse_env(struct env_data *);
 char            *makesockpath(const char *);  char            *makesockpath(const char *);
 __dead void      shell_exec(const char *, const char *);  __dead void      shell_exec(const char *, const char *);
   
Line 129 
Line 135 
 }  }
   
 void  void
 fill_session(struct msg_command_data *data)  parse_env(struct env_data *data)
 {  {
         char            *env, *ptr1, *ptr2, buf[256];          char            *env, *path_pid, *pid_idx, buf[256];
         size_t           len;          size_t           len;
         const char      *errstr;          const char      *errstr;
         long long        ll;          long long        ll;
Line 140 
Line 146 
         if ((env = getenv("TMUX")) == NULL)          if ((env = getenv("TMUX")) == NULL)
                 return;                  return;
   
         if ((ptr2 = strrchr(env, ',')) == NULL || ptr2 == env)          if ((path_pid = strchr(env, ',')) == NULL || path_pid == env)
                 return;                  return;
         for (ptr1 = ptr2 - 1; ptr1 > env && *ptr1 != ','; ptr1--)          if ((pid_idx = strchr(path_pid + 1, ',')) == NULL)
                 ;  
         if (*ptr1 != ',')  
                 return;                  return;
         ptr1++;          if ((pid_idx == path_pid + 1 || pid_idx[1] == '\0'))
         ptr2++;                  return;
   
         len = ptr2 - ptr1 - 1;          /* path */
           len = path_pid - env;
           data->path = xmalloc (len + 1);
           memcpy(data->path, env, len);
           data->path[len] = '\0';
   
           /* pid */
           len = pid_idx - path_pid - 1;
         if (len > (sizeof buf) - 1)          if (len > (sizeof buf) - 1)
                 return;                  return;
         memcpy(buf, ptr1, len);          memcpy(buf, path_pid + 1, len);
         buf[len] = '\0';          buf[len] = '\0';
   
         ll = strtonum(buf, 0, LONG_MAX, &errstr);          ll = strtonum(buf, 0, LONG_MAX, &errstr);
Line 160 
Line 171 
                 return;                  return;
         data->pid = ll;          data->pid = ll;
   
         ll = strtonum(ptr2, 0, UINT_MAX, &errstr);          /* idx */
           ll = strtonum(pid_idx+1, 0, UINT_MAX, &errstr);
         if (errstr != NULL)          if (errstr != NULL)
                 return;                  return;
         data->idx = ll;          data->idx = ll;
Line 224 
Line 236 
         struct passwd           *pw;          struct passwd           *pw;
         struct options          *oo, *so, *wo;          struct options          *oo, *so, *wo;
         struct keylist          *keylist;          struct keylist          *keylist;
           struct env_data          envdata;
         struct msg_command_data  cmddata;          struct msg_command_data  cmddata;
         char                    *s, *shellcmd, *path, *label, *home, *cause;          char                    *s, *shellcmd, *path, *label, *home, *cause;
         char                     cwd[MAXPATHLEN], **var;          char                     cwd[MAXPATHLEN], **var;
Line 238 
Line 251 
   
         flags = 0;          flags = 0;
         shellcmd = label = path = NULL;          shellcmd = label = path = NULL;
           envdata.path = NULL;
         login_shell = (**argv == '-');          login_shell = (**argv == '-');
         while ((opt = getopt(argc, argv, "28c:df:lL:qS:uUv")) != -1) {          while ((opt = getopt(argc, argv, "28c:df:lL:qS:uUv")) != -1) {
                 switch (opt) {                  switch (opt) {
Line 442 
Line 456 
          * Figure out the socket path. If specified on the command-line with           * Figure out the socket path. If specified on the command-line with
          * -S or -L, use it, otherwise try $TMUX or assume -L default.           * -S or -L, use it, otherwise try $TMUX or assume -L default.
          */           */
           parse_env(&envdata);
         if (path == NULL) {          if (path == NULL) {
                 /* No -L. Try $TMUX, or default. */                  /* No -L. Try $TMUX, or default. */
                 if (label == NULL) {                  if (label == NULL) {
                         if ((path = getenv("TMUX")) != NULL) {                          path = envdata.path;
                                 path = xstrdup(path);                          if (path == NULL)
                                 path[strcspn(path, ",")] = '\0';  
                         } else  
                                 label = xstrdup("default");                                  label = xstrdup("default");
                 }                  }
   
Line 468 
Line 481 
                 buf = NULL;                  buf = NULL;
                 len = 0;                  len = 0;
         } else {          } else {
                 fill_session(&cmddata);                  cmddata.pid = envdata.pid;
                   cmddata.idx = envdata.idx;
   
                 cmddata.argc = argc;                  cmddata.argc = argc;
                 if (cmd_pack_argv(                  if (cmd_pack_argv(

Legend:
Removed from v.1.69  
changed lines
  Added in v.1.70