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

Diff for /src/usr.bin/patch/util.c between version 1.8 and 1.9

version 1.8, 1999/12/04 01:04:14 version 1.9, 1999/12/04 21:00:03
Line 328 
Line 328 
 Reg1 char *filename;  Reg1 char *filename;
 bool striplast;  bool striplast;
 {  {
     char tmpbuf[256];      char *tmpbuf;
     Reg2 char *s = tmpbuf;  
     char *dirv[20];             /* Point to the NULs between elements.  */  
     Reg3 int i;  
     Reg4 int dirvp = 0;         /* Number of finished entries in dirv. */  
   
     /* Copy `filename' into `tmpbuf' with a NUL instead of a slash      if ((tmpbuf = strdup(filename)) == NULL)
        between the directories.  */          fatal1("out of memory\n");
     while (*filename) {  
         if (*filename == '/') {      if (striplast) {
             filename++;          char *s = strrchr(tmpbuf, '/');
             dirv[dirvp++] = s;          if (s == NULL)
             *s++ = '\0';            return; /* nothing to be done */
         }          *s = '\0';
         else {  
             *s++ = *filename++;  
         }  
     }      }
     *s = '\0';  
     dirv[dirvp] = s;  
     if (striplast)  
         dirvp--;  
     if (dirvp < 0)  
         return;  
   
     strcpy(buf, "mkdir");      strcpy(buf, "/bin/mkdir -p ");
     s = buf;      if (strlcat(buf, tmpbuf, sizeof(buf)) >= sizeof(buf))
     for (i=0; i<=dirvp; i++) {        fatal2("buffer too small to hold %.20s...\n", tmpbuf);
         struct stat sbuf;  
   
         if (stat(tmpbuf, &sbuf) && errno == ENOENT) {      if (system(buf))
             while (*s) s++;        pfatal2("%.40s failed", buf);
             *s++ = ' ';  
             strcpy(s, tmpbuf);  
         }  
         *dirv[i] = '/';  
     }  
     if (s != buf)  
         system(buf);  
 }  }
   
 /* Make filenames more reasonable. */  /* Make filenames more reasonable. */

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9