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

Diff for /src/usr.bin/tmux/Attic/cmd-string.c between version 1.18 and 1.19

version 1.18, 2013/03/24 09:54:10 version 1.19, 2013/10/10 12:14:09
Line 318 
Line 318 
 {  {
         struct passwd           *pw;          struct passwd           *pw;
         struct environ_entry    *envent;          struct environ_entry    *envent;
         char                    *home, *path, *username;          char                    *home, *path, *user, *cp;
           int                      last;
   
         home = NULL;          home = NULL;
         if (cmd_string_getc(s, p) == '/') {  
           last = cmd_string_getc(s, p);
           if (last == EOF || last == '/' || last == ' '|| last == '\t') {
                 envent = environ_find(&global_environ, "HOME");                  envent = environ_find(&global_environ, "HOME");
                 if (envent != NULL && *envent->value != '\0')                  if (envent != NULL && *envent->value != '\0')
                         home = envent->value;                          home = envent->value;
Line 329 
Line 332 
                         home = pw->pw_dir;                          home = pw->pw_dir;
         } else {          } else {
                 cmd_string_ungetc(p);                  cmd_string_ungetc(p);
                 if ((username = cmd_string_string(s, p, '/', 0)) == NULL)  
                         return (NULL);                  cp = user = xmalloc(strlen(s));
                 if ((pw = getpwnam(username)) != NULL)                  for (;;) {
                           last = cmd_string_getc(s, p);
                           if (last == EOF || last == '/' || last == ' '|| last == '\t')
                                   break;
                           *cp++ = last;
                   }
                   *cp = '\0';
   
                   if ((pw = getpwnam(user)) != NULL)
                         home = pw->pw_dir;                          home = pw->pw_dir;
                 free(username);                  free(user);
         }          }
   
         if (home == NULL)          if (home == NULL)
                 return (NULL);                  return (NULL);
   
         xasprintf(&path, "%s/", home);          if (last != EOF)
                   xasprintf(&path, "%s%c", home, last);
           else
                   xasprintf(&path, "%s", home);
         return (path);          return (path);
 }  }

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19