From: Clint Adams <schizo@debian.org>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: tail-dropping in files module mkdir
Date: Fri, 4 Aug 2000 10:53:23 -0400 [thread overview]
Message-ID: <20000804105323.B4820@dman.com> (raw)
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;
}
next reply other threads:[~2000-08-04 14:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-08-04 14:53 Clint Adams [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20000804105323.B4820@dman.com \
--to=schizo@debian.org \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).