about summary refs log tree commit diff
path: root/Src/glob.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-03-16 11:50:50 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-03-16 11:50:50 +0000
commit51ec0b8079ed19c107f2f7f1ab4326c488ee3198 (patch)
tree63be7747f5eda8f203cd1ceddf6c9ce3366c9c5c /Src/glob.c
parent31aaabe1bc1ad32c7761dd8eb626b4efe77b01bb (diff)
downloadzsh-51ec0b8079ed19c107f2f7f1ab4326c488ee3198.tar.gz
zsh-51ec0b8079ed19c107f2f7f1ab4326c488ee3198.tar.xz
zsh-51ec0b8079ed19c107f2f7f1ab4326c488ee3198.zip
20983: failed glob from fixed strings segments in globbed paths
Diffstat (limited to 'Src/glob.c')
-rw-r--r--Src/glob.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/Src/glob.c b/Src/glob.c
index c1f2fc0dc..5334f70fa 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -223,13 +223,14 @@ struct complist {
 
 /**/
 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 @@ scanner(Complist q)
 		    }
 		}
 		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 @@ scanner(Complist q)
 	    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 */