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

Diff for /src/usr.bin/apply/apply.c between version 1.21 and 1.22

version 1.21, 2005/05/15 16:22:12 version 1.22, 2005/11/14 15:30:54
Line 110 
Line 110 
          * the end to consume (nargs) arguments each time round the loop.           * the end to consume (nargs) arguments each time round the loop.
          * Allocate enough space to hold the maximum command.           * Allocate enough space to hold the maximum command.
          */           */
         len = sizeof("exec ") - 1 +  
             strlen(argv[0]) + 9 * (sizeof(" %1") - 1) + 1;  
         if ((cmd = malloc(len)) == NULL)  
                 err(1, NULL);  
   
         if (n == 0) {          if (n == 0) {
                 int l;                  int l;
   
                   len = sizeof("exec ") - 1 +
                       strlen(argv[0]) + 9 * (sizeof(" %1") - 1) + 1;
                   if ((cmd = malloc(len)) == NULL)
                           err(1, NULL);
   
                 /* If nargs not set, default to a single argument. */                  /* If nargs not set, default to a single argument. */
                 if (nargs == -1)                  if (nargs == -1)
                         nargs = 1;                          nargs = 1;
Line 143 
Line 143 
                 if (nargs == 0)                  if (nargs == 0)
                         nargs = 1;                          nargs = 1;
         } else {          } else {
                 (void)snprintf(cmd, len, "exec %s", argv[0]);                  if (asprintf(&cmd, "exec %s", argv[0]) == -1)
                           err(1, NULL);
                 nargs = n;                  nargs = n;
         }          }
   

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22