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

Diff for /src/usr.bin/sendbug/sendbug.c between version 1.30 and 1.31

version 1.30, 2007/03/26 07:16:11 version 1.31, 2007/03/26 18:13:08
Line 285 
Line 285 
 void  void
 init(void)  init(void)
 {  {
         size_t len = 0, namelen;          size_t amp, len, namelen;
         const char *src;          const char *src;
         int sysname[2];          int sysname[2];
         char *dst, *cp;          char *dst, *cp;
Line 294 
Line 294 
                 err(1, "getpwuid");                  err(1, "getpwuid");
         namelen = strlen(pw->pw_name);          namelen = strlen(pw->pw_name);
   
         /* Add length of expanded '&', minus existing '&'. */          /* Count number of '&'. */
         src = pw->pw_gecos;          for (amp = 0, src = pw->pw_gecos; *src && *src != ','; ++src)
         src += strcspn(src, ",&");                  if (*src == '&')
         while (*src == '&') {                          ++amp;
                 len += namelen - 1;          /* Expanded str = orig str - '&' chars + concatenated logins. */
                 /* Look for next '&', skipping the one we just found. */          len = (src - pw->pw_gecos) - amp + (amp * namelen);
                 src += 1 + strcspn(src, ",&");  
         }  
         /* Add full name length, including all those '&' we skipped. */  
         len += src - pw->pw_gecos;  
         if ((fullname = malloc(len + 1)) == NULL)          if ((fullname = malloc(len + 1)) == NULL)
                 err(1, "malloc");                  err(1, "malloc");
   

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31