zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: some directory changing tools to share
Date: Mon, 13 Mar 2000 10:29:08 +0100 (MET)	[thread overview]
Message-ID: <200003130929.KAA15692@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Tue, 7 Mar 2000 17:46:28 +0000


Bart Schaefer wrote (on zsh-users):

> ...
> 
> By the way, in 3.0.7 this works:
> 
> zagzig% setopt extendedglob
> zagzig% cd /usr/src/local/zsh/zsh-3.1.6
> zagzig% echo (../)#
>  ../ ../../ ../../../ ../../../../ ../../../../../
> 
> But in 3.1.6 it crashes the shell:
> 
> zagzig% setopt extendedglob
> zagzig% cd /usr/src/local/zsh/zsh-3.1.6
> zagzig% echo (../)#
> BUG: statfullpath(): pathname too long
> zsh: segmentation fault (core dumped)  $ZSH_NAME -f

Here is my attempt. Peter should have the last word, I think.

The place where I put that already had a test for `./', though. And
I've also changed that, a bit: (./)# gave me `no match' and I thought
it would be better to make it give `./'. If everyone disagrees, I can
change it back.

Bye
 Sven

diff -ru ../z.old/Src/glob.c Src/glob.c
--- ../z.old/Src/glob.c	Mon Mar 13 10:18:26 2000
+++ Src/glob.c	Mon Mar 13 10:25:31 2000
@@ -479,11 +479,26 @@
 	    /* Not the last path section. Just add it to the path. */
 	    int oppos = pathpos;
 
-	    if (!errflag && !(q->closure && !strcmp(str, "."))) {
-		addpath(str);
-		if (!closure || !statfullpath("", NULL, 1))
-		    scanner((q->closure) ? q : q->next);
-		pathbuf[pathpos = oppos] = '\0';
+	    if (!errflag) {
+		int add = 1;
+
+		if (q->closure && *pathbuf) {
+		    if (!strcmp(str, "."))
+			add = 0;
+		    else if (!strcmp(str, "..")) {
+			struct stat sc, sr;
+
+			add = (stat("/", &sr) || stat(pathbuf, &sc) ||
+			       sr.st_ino != sc.st_ino ||
+			       sr.st_dev != sc.st_dev);
+		    }
+		}
+		if (add) {
+		    addpath(str);
+		    if (!closure || !statfullpath("", NULL, 1))
+			scanner((q->closure) ? q : q->next);
+		    pathbuf[pathpos = oppos] = '\0';
+		}
 	    }
 	} else
 	    insert(str, 0);

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


                 reply	other threads:[~2000-03-13  9:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200003130929.KAA15692@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --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).