Thread View: gnu.utils.bug
1 messages
1 total messages
Started by Andreas Schwab
Tue, 06 Oct 1992 15:01
Improvements for patch 2.0 12g8
Author: Andreas Schwab
Date: Tue, 06 Oct 1992 15:01
Date: Tue, 06 Oct 1992 15:01
69 lines
2323 bytes
2323 bytes
Here is a patch to patch which i find very useful: when backing up the
patched file, automagically make the necessary directories. This
allows e.g.:
patch -B orig/ < patchfile
without worrying about directories to be created.
I also added code for systems having the mkdir system call, so that it
isn't necessary to call mkdir via system().
diff -ur orig/configure.in ./configure.in
--- orig/configure.in Tue Jul 14 08:40:33 1992
+++ ./configure.in Tue Oct 6 13:59:29 1992
@@ -16,7 +16,7 @@
AC_UNISTD_H
AC_USG
AC_REPLACE_FUNCS(rename)
-AC_HAVE_FUNCS(strerror)
+AC_HAVE_FUNCS(strerror mkdir)
AC_ALLOCA
AC_LONG_FILE_NAMES
AC_XENIX_DIR
diff -ur orig/util.c ./util.c
--- orig/util.c Tue Sep 15 04:04:31 1992
+++ ./util.c Tue Oct 6 13:59:30 1992
@@ -91,7 +91,10 @@
if (debug & 4)
say3("Moving %s to %s.\n", to, bakname);
#endif
- if (rename(to, bakname) < 0) {
+ if (rename(to, bakname) < 0
+ && (errno != EPATH
+ || (makedirs (bakname, TRUE),
+ rename (to, bakname) < 0))) {
say4("Can't backup %s, output is in %s: %s\n", to, from,
strerror(errno));
return -1;
@@ -337,6 +340,7 @@
if (dirvp < 0)
return;
+#ifndef HAVE_MKDIR
strcpy(buf, "mkdir");
s = buf;
for (i=0; i<=dirvp; i++) {
@@ -351,6 +355,20 @@
}
if (s != buf)
system(buf);
+#else
+ for (i = 0; i <= dirvp; i++)
+ {
+ struct stat sbuf;
+ if (stat (tmpbuf, &sbuf))
+ {
+ if (errno != ENOENT || mkdir (tmpbuf, 0777))
+ return;
+ }
+ else if (!S_ISDIR (sbuf.st_mode))
+ return;
+ *dirv[i] = '/';
+ }
+#endif
}
/* Make filenames more reasonable. */
--
Andreas Schwab
schwab@ls5.informatik.uni-dortmund.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads