zsh-workers
 help / color / mirror / code / Atom feed
From: Clint Adams <schizo@debian.org>
To: Bart Schaefer <schaefer@candle.brasslantern.com>
Cc: zsh-workers@sunsite.auc.dk
Subject: PATCH: bin_ln - PATH_MAX
Date: Mon, 18 Sep 2000 13:21:42 -0400	[thread overview]
Message-ID: <20000918132142.B11367@dman.com> (raw)
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;
 }
 


  reply	other threads:[~2000-09-18 17:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-18  3:51 PATCH: PATH_MAX and mailstat, part I Clint Adams
2000-09-18  4:09 ` PATCH: PATH_MAX and mailstat, part II Clint Adams
2000-09-18  6:39   ` PATCH: Redo a couple of PATH_MAX changes Bart Schaefer
2000-09-18 17:21     ` Clint Adams [this message]
2000-09-19  3:18       ` PATCH: bin_ln - PATH_MAX Bart Schaefer
2000-09-19 15:23         ` PATCH: files module " Clint Adams
2000-09-19 16:19           ` PATCH: whence " Clint Adams

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=20000918132142.B11367@dman.com \
    --to=schizo@debian.org \
    --cc=schaefer@candle.brasslantern.com \
    --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).