about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2019-12-12 10:22:24 +0000
committerPeter Stephenson <p.stephenson@samsung.com>2019-12-12 10:23:47 +0000
commit273d669a568ed9ee705916e42945f4239501cdcb (patch)
tree7c7a1ac21687dea39d17327ee3d99cddd26fb5c6 /Src
parentc578f0a08b9257f3db85dab5431270f1a6eb8858 (diff)
downloadzsh-273d669a568ed9ee705916e42945f4239501cdcb.tar.gz
zsh-273d669a568ed9ee705916e42945f4239501cdcb.tar.xz
zsh-273d669a568ed9ee705916e42945f4239501cdcb.zip
45001: Fix zero-length matches with ${...%...}
As the shortest match is preferred, zero-length matches beat any other.
Diffstat (limited to 'Src')
-rw-r--r--Src/glob.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Src/glob.c b/Src/glob.c
index a367b082b..ca5846704 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2909,6 +2909,12 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
 	     */
 	    mb_charinit();
 	    tmatch = NULL;
+	    set_pat_start(p, l);
+	    if (pattrylen(p, send, 0, 0, &patstralloc, umltot) &&
+		!--n) {
+		*sp = get_match_ret(&imd, umltot, umltot);
+		return 1;
+	    }
 	    for (ioff = 0, t = s, umlen = umltot; t < send; ioff++) {
 		set_pat_start(p, t-s);
 		if (pattrylen(p, t, umlen, 0, &patstralloc, ioff))