=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/patch/util.c,v retrieving revision 1.8 retrieving revision 1.9 diff -c -r1.8 -r1.9 *** src/usr.bin/patch/util.c 1999/12/04 01:04:14 1.8 --- src/usr.bin/patch/util.c 1999/12/04 21:00:03 1.9 *************** *** 1,7 **** ! /* $OpenBSD: util.c,v 1.8 1999/12/04 01:04:14 provos Exp $ */ #ifndef lint ! static char rcsid[] = "$OpenBSD: util.c,v 1.8 1999/12/04 01:04:14 provos Exp $"; #endif /* not lint */ #include "EXTERN.h" --- 1,7 ---- ! /* $OpenBSD: util.c,v 1.9 1999/12/04 21:00:03 provos Exp $ */ #ifndef lint ! static char rcsid[] = "$OpenBSD: util.c,v 1.9 1999/12/04 21:00:03 provos Exp $"; #endif /* not lint */ #include "EXTERN.h" *************** *** 328,372 **** Reg1 char *filename; bool striplast; { ! char tmpbuf[256]; ! 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 ! between the directories. */ ! while (*filename) { ! if (*filename == '/') { ! filename++; ! dirv[dirvp++] = s; ! *s++ = '\0'; ! } ! else { ! *s++ = *filename++; ! } } - *s = '\0'; - dirv[dirvp] = s; - if (striplast) - dirvp--; - if (dirvp < 0) - return; ! strcpy(buf, "mkdir"); ! s = buf; ! for (i=0; i<=dirvp; i++) { ! struct stat sbuf; ! if (stat(tmpbuf, &sbuf) && errno == ENOENT) { ! while (*s) s++; ! *s++ = ' '; ! strcpy(s, tmpbuf); ! } ! *dirv[i] = '/'; ! } ! if (s != buf) ! system(buf); } /* Make filenames more reasonable. */ --- 328,351 ---- Reg1 char *filename; bool striplast; { ! char *tmpbuf; ! if ((tmpbuf = strdup(filename)) == NULL) ! fatal1("out of memory\n"); ! ! if (striplast) { ! char *s = strrchr(tmpbuf, '/'); ! if (s == NULL) ! return; /* nothing to be done */ ! *s = '\0'; } ! strcpy(buf, "/bin/mkdir -p "); ! if (strlcat(buf, tmpbuf, sizeof(buf)) >= sizeof(buf)) ! fatal2("buffer too small to hold %.20s...\n", tmpbuf); ! if (system(buf)) ! pfatal2("%.40s failed", buf); } /* Make filenames more reasonable. */