zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: tail-dropping in files module mkdir
@ 2000-08-04 14:53 Clint Adams
  2000-08-04 15:17 ` Bart Schaefer
  0 siblings, 1 reply; 18+ messages in thread
From: Clint Adams @ 2000-08-04 14:53 UTC (permalink / raw)
  To: zsh-workers

This should let mkdir work a little better.

In addition to the -p problem, I think that zpathmax needs to
be modified to do one of the following:

a) return the number from pathconf() so that it can be compared
with strlen of the full pathname with tail

b) take aforementioned strlen as an argument

BTW, I think pathconf does the "errno unchanged" bit because of
some prohibition of the library settings errno to 0 or setting
errno on success.

Index: Src/Modules/files.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/files.c,v
retrieving revision 1.4
diff -u -r1.4 files.c
--- Src/Modules/files.c	2000/08/04 07:09:46	1.4
+++ Src/Modules/files.c	2000/08/04 14:43:36
@@ -71,6 +71,7 @@
     mode_t oumask = umask(0);
     mode_t mode = 0777 & ~oumask;
     int err = 0;
+    char *head;
 
     umask(oumask);
     if(ops['m']) {
@@ -91,8 +92,19 @@
 
 	while(ptr > *args + (**args == '/') && *--ptr == '/')
 	    *ptr = 0;
-	if(zpathmax(unmeta(*args)) < 0) {
-	    zwarnnam(nam, "%s: %e", *args, errno);
+
+/* Drop the tail so that pathconf receives a potentially valid pathname */
+	head = (char *) ztrdup(*args);
+	if ((ptr = strrchr(head, '/')))
+	    *ptr = 0;
+	else {
+/* Relative to current directory */
+	    *head = '.';
+	    *(head + 1) = '\0';
+	}
+
+	if(zpathmax(unmeta(head)) < 0) {
+	    zwarnnam(nam, "%s: %e", head, errno);
 	    err = 1;
 	    continue;
 	}
@@ -121,6 +133,8 @@
 	    }
 	} else
 	    err |= domkdir(nam, *args, mode, 0);
+
+	free(head);
     }
     return err;
 }


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2000-08-09 17:51 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-04 14:53 PATCH: tail-dropping in files module mkdir Clint Adams
2000-08-04 15:17 ` Bart Schaefer
2000-08-04 15:32   ` Clint Adams
2000-08-04 16:10     ` Bart Schaefer
2000-08-05  0:40       ` Clint Adams
2000-08-04  7:02         ` PATCH: pathconf() again Bart Schaefer
2000-08-04 13:19           ` Clint Adams
2000-08-04 18:15             ` Bart Schaefer
2000-08-05  0:52               ` Clint Adams
2000-08-05  4:48                 ` PATCH: tail-dropping in files module mkdir Bart Schaefer
2000-08-07 18:04                   ` Clint Adams
2000-08-07 20:39                     ` Bart Schaefer
2000-08-08 11:40                       ` Clint Adams
2000-08-08 21:47                         ` Bart Schaefer
2000-08-09 14:25                           ` PATH_MAX vs. _PC_PATH_MAX vs. POSIX (was Re: PATCH: tail-dropping in files module mkdir) Clint Adams
2000-08-09 17:07                             ` Bart Schaefer
2000-08-09 17:51                             ` Bart Schaefer
2000-08-05  6:45           ` PATCH: pathconf() again Wayne Davison

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).