mirror of
git://git.code.sf.net/p/zsh/code
synced 2026-01-04 09:01:06 +01:00
45001: Fix zero-length matches with ${...%...}
As the shortest match is preferred, zero-length matches beat any other.
This commit is contained in:
parent
c578f0a08b
commit
273d669a56
3 changed files with 35 additions and 0 deletions
|
|
@ -1,3 +1,9 @@
|
|||
2019-12-12 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 45001: Src/glob.c, Test/D04parameter.ztst: ${...%...} didn't
|
||||
test for zero-length matches, which should be preferred where
|
||||
possible.
|
||||
|
||||
2019-12-11 Martijn Dekker <martijn@inlv.org>
|
||||
|
||||
* 45004: Src/builtin.c, Src/compat.c, Src/exec.c, 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))
|
||||
|
|
|
|||
|
|
@ -2534,3 +2534,26 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
|
|||
0:Global variables are not trashed by "foo=bar builtin" (regression test)
|
||||
>function-value
|
||||
>global-value
|
||||
|
||||
foo=pws
|
||||
print ${foo%*}
|
||||
0:Smallest match at end can match zero-length string
|
||||
>pws
|
||||
|
||||
foo=pws
|
||||
print ${foo%?}
|
||||
0:Smallest match at end with a character always matches one
|
||||
>pw
|
||||
|
||||
setopt extendedglob
|
||||
foo=pws
|
||||
print ${foo%s#}
|
||||
print ${foo%%s#}
|
||||
0:Smallest / largest match with non-trivial closure
|
||||
>pws
|
||||
>pw
|
||||
|
||||
foo=pws
|
||||
print ${foo%%*}
|
||||
0:Largest match at end matches entire string
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue