From 273d669a568ed9ee705916e42945f4239501cdcb Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 12 Dec 2019 10:22:24 +0000 Subject: 45001: Fix zero-length matches with ${...%...} As the shortest match is preferred, zero-length matches beat any other. --- Src/glob.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Src') 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)) -- cgit 1.4.1