Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: bin_ln - PATH_MAX
- X-seq: zsh-workers 12836
- From: Clint Adams <schizo@xxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- Subject: PATCH: bin_ln - PATH_MAX
- Date: Mon, 18 Sep 2000 13:21:42 -0400
- Cc: zsh-workers@xxxxxxxxxxxxxx
- In-reply-to: <1000918063956.ZM24783@xxxxxxxxxxxxxxxxxxxxxxx>; from schaefer@xxxxxxxxxxxxxxxxxxxxxxx on Mon, Sep 18, 2000 at 06:39:56AM +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <20000917235109.A6793@xxxxxxxx> <20000918000915.B6793@xxxxxxxx> <1000918063956.ZM24783@xxxxxxxxxxxxxxxxxxxxxxx>
> After 12828, utils.c doesn't compile when MAILDIR_SUPPORT is defined.
> It must have been issuing warnings about prototypes even before that, so
> I can't believe it's a very widely-used [*] feature, but as commited it
> has a structure-access error (->d.name should be ->d_name).
That was my typo in 12827. Thanks for the cleanup.
> * Move dyncat() and tricat() from glob.c to utils.c; they've not been
> specific to the glob code for some years now. (Though it may be time
> to break utils.c up into a couple of files, or move some of the string
> allocation functions to mem.c where ztrdup() lives.)
Why not a string.c for all of those?
> I'm certain we can replace all uses of PATH_MAX with one of VARARR(),
> tricat(), zhtricat(), or ztrdup()+appstr(). The point is to analyze the
> way the buffer is used and pick the best of those alternatives, not just
> to pick one and use it everywhere.
PATH_MAX removed from bin_ln
Index: Src/Modules/files.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/files.c,v
retrieving revision 1.7
diff -u -r1.7 files.c
--- Src/Modules/files.c 2000/08/14 07:30:29 1.7
+++ Src/Modules/files.c 2000/09/18 17:10:23
@@ -186,10 +186,10 @@
bin_ln(char *nam, char **args, char *ops, int func)
{
MoveFunc move;
- int flags, space, err = 0;
- char **a, *ptr, *rp;
+ int flags, err = 0;
+ char **a, *ptr, *rp, *buf;
struct stat st;
- char buf[PATH_MAX * 2 + 1];
+ size_t blen;
if(func == BIN_MV) {
@@ -203,7 +203,7 @@
move = (MoveFunc) symlink;
else
#endif
- {
+ {
move = (MoveFunc) link;
if(!ops['d'])
flags |= MV_NODIRS;
@@ -229,31 +229,24 @@
args[1] = args[0];
}
return domove(nam, move, args[0], args[1], flags);
- havedir:
- strcpy(buf, *a);
+ havedir:
+ buf = ztrdup(*a);
*a = NULL;
- space = PATH_MAX - 1 - ztrlen(buf);
- rp = strchr(buf, 0);
- *rp++ = '/';
+ buf = appstr(buf, "/");
+ blen = strlen(buf);
for(; *args; args++) {
- if(ztrlen(*args) > PATH_MAX) {
- zwarnnam(nam, "%s: %e", *args, ENAMETOOLONG);
- err = 1;
- continue;
- }
+
ptr = strrchr(*args, '/');
if(ptr)
ptr++;
else
ptr = *args;
- if(ztrlen(ptr) > space) {
- zwarnnam(nam, "%s: %e", ptr, ENAMETOOLONG);
- err = 1;
- continue;
- }
- strcpy(rp, ptr);
+
+ buf[blen] = 0;
+ buf = appstr(buf, ptr);
err |= domove(nam, move, *args, buf, flags);
}
+ zsfree(buf);
return err;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author