From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12540 invoked from network); 18 Sep 2000 17:22:57 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Sep 2000 17:22:57 -0000 Received: (qmail 16362 invoked by alias); 18 Sep 2000 17:22:25 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12836 Received: (qmail 16355 invoked from network); 18 Sep 2000 17:22:25 -0000 Date: Mon, 18 Sep 2000 13:21:42 -0400 From: Clint Adams To: Bart Schaefer Cc: zsh-workers@sunsite.auc.dk Subject: PATCH: bin_ln - PATH_MAX Message-ID: <20000918132142.B11367@dman.com> References: <20000917235109.A6793@dman.com> <20000918000915.B6793@dman.com> <1000918063956.ZM24783@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.1.2i In-Reply-To: <1000918063956.ZM24783@candle.brasslantern.com>; from schaefer@candle.brasslantern.com on Mon, Sep 18, 2000 at 06:39:56AM +0000 > 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; }