[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.12 and 1.13

version 1.12, 2007/03/23 05:08:03 version 1.13, 2007/03/23 06:16:24
Line 12 
Line 12 
 #include <sys/sysctl.h>  #include <sys/sysctl.h>
 #include <sys/wait.h>  #include <sys/wait.h>
   
   #include <ctype.h>
 #include <err.h>  #include <err.h>
 #include <errno.h>  #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
Line 242 
Line 243 
 void  void
 init(void)  init(void)
 {  {
         size_t len;          size_t len = 0, namelen;
         int sysname[2];          int sysname[2];
           const char *src;
           char *dst;
   
         if ((pw = getpwuid(getuid())) == NULL) {          if ((pw = getpwuid(getuid())) == NULL) {
                 err(1, "getpwuid");                  err(1, "getpwuid");
         }          }
           namelen = strlen(pw->pw_name);
   
         /* Get full name. */          /* Add length of expanded '&', minus existing '&'. */
         len = strcspn(pw->pw_gecos, ",");          src = pw->pw_gecos;
           src += strcspn(src, ",&");
           while (*src == '&') {
                   len += namelen - 1;
                   /* Look for next '&', skipping the one we just found. */
                   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");
         }          }
         memcpy(fullname, pw->pw_gecos, len);          dst = fullname;
         fullname[len] = '\0';          src = pw->pw_gecos;
           while (*src != ',' && *src != '\0') {
                   /* Copy text up to ',' or '&' and skip. */
                   len = strcspn(src, ",&");
                   memcpy(dst, src, len);
                   dst += len;
                   src += len;
                   /* Replace '&' with login. */
                   if (*src == '&') {
                           memcpy(dst, pw->pw_name, namelen);
                           *dst = toupper((unsigned char)*dst);
                           dst += namelen;
                           ++src;
                   }
           }
           *dst = '\0';
   
         sysname[0] = CTL_KERN;          sysname[0] = CTL_KERN;
         sysname[1] = KERN_OSTYPE;          sysname[1] = KERN_OSTYPE;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13