zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: Kobayashi Noritada <nori1@dolphin.c.u-tokyo.ac.jp>,
	zsh-workers@sunsite.dk
Subject: Re: Globbing for directory names with two '='-s fail after 4.2.2.
Date: Wed, 16 Mar 2005 11:13:49 +0000	[thread overview]
Message-ID: <200503161113.j2GBDnAk009527@news01.csr.com> (raw)
In-Reply-To: <20050316.165718.71117897.nori1@dolphin.c.u-tokyo.ac.jp>

Kobayashi Noritada wrote:
> Hi,
> 
> Globbing for directory names with two '='-s sometimes fails
> (i.e. wildcards '*' and '?' don't work) with Zsh after 4.2.2.
> It seems to be related to changes in Src/{glob.c,pattern.c} on 2004-10-18.

Thanks for noticing.  Could you try the following patch and see if it
fixes all the problems you are seeing?

The problem was that a string was no longer null-terminated in the case
that it was examined by the pattern matcher, but found to contain no
patterns.

I will commit this on both branches and some time around (western-style)
Easter we should probably produce 4.2.5.  There may be other patches to
transfer.

Index: Src/glob.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/glob.c,v
retrieving revision 1.38
diff -u -r1.38 glob.c
--- Src/glob.c	10 Jan 2005 17:31:19 -0000	1.38
+++ Src/glob.c	16 Mar 2005 11:12:12 -0000
@@ -223,13 +223,14 @@
 
 /**/
 static void
-addpath(char *s)
+addpath(char *s, int l)
 {
     DPUTS(!pathbuf, "BUG: pathbuf not initialised");
-    while (pathpos + (int) strlen(s) + 1 >= pathbufsz)
+    while (pathpos + l + 1 >= pathbufsz)
 	pathbuf = realloc(pathbuf, pathbufsz *= 2);
-    while ((pathbuf[pathpos++] = *s++));
-    pathbuf[pathpos - 1] = '/';
+    while (l--)
+	pathbuf[pathpos++] = *s++;
+    pathbuf[pathpos++] = '/';
     pathbuf[pathpos] = '\0';
 }
 
@@ -504,14 +505,17 @@
 		    }
 		}
 		if (add) {
-		    addpath(str);
+		    addpath(str, l);
 		    if (!closure || !statfullpath("", NULL, 1))
 			scanner((q->closure) ? q : q->next);
 		    pathbuf[pathpos = oppos] = '\0';
 		}
 	    }
-	} else
+	} else {
+	    if (str[l])
+		str = dupstrpfx(str, l);
 	    insert(str, 0);
+	}
     } else {
 	/* Do pattern matching on current path section. */
 	char *fn = pathbuf[pathbufcwd] ? unmeta(pathbuf + pathbufcwd) : ".";
@@ -608,8 +612,9 @@
 	    int oppos = pathpos;
 
 	    for (fn = subdirs; fn < subdirs+subdirlen; ) {
-		addpath(fn);
-		fn += strlen(fn) + 1;
+		int l = strlen(fn);
+		addpath(fn, l);
+		fn += l + 1;
 		memcpy((char *)&errsfound, fn, sizeof(int));
 		fn += sizeof(int);
 		scanner((q->closure) ? q : q->next);  /* scan next level */
Index: Test/D02glob.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D02glob.ztst,v
retrieving revision 1.8
diff -u -r1.8 D02glob.ztst
--- Test/D02glob.ztst	26 Oct 2004 17:20:29 -0000	1.8
+++ Test/D02glob.ztst	16 Mar 2005 11:12:12 -0000
@@ -317,3 +317,9 @@
  print ${foo%% #:*}
 0:Must-match arguments in complex patterns
 >this string has a
+
+ mkdir glob.tmp/ra=1.0_et=3.5
+ touch glob.tmp/ra=1.0_et=3.5/foo
+ print glob.tmp/ra=1.0_et=3.5/???
+0:Bug with intermediate paths with plain strings but tokenized characters
+>glob.tmp/ra=1.0_et=3.5/foo

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


  reply	other threads:[~2005-03-16 11:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-16  7:57 Kobayashi Noritada
2005-03-16 11:13 ` Peter Stephenson [this message]
2005-03-17  6:13   ` Kobayashi Noritada

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=200503161113.j2GBDnAk009527@news01.csr.com \
    --to=pws@csr.com \
    --cc=nori1@dolphin.c.u-tokyo.ac.jp \
    --cc=zsh-workers@sunsite.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).