about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <danielsh@apache.org>2019-12-31 18:07:02 +0000
committerDaniel Shahaf <danielsh@apache.org>2020-01-02 16:00:11 +0000
commitb591d431130a2648738a899296638245b0b93d3a (patch)
treedb63bba73adc02223900829a3754f767eeb08486
parentda19b67388770514b44f28796d9de4dd239297bd (diff)
downloadzsh-b591d431130a2648738a899296638245b0b93d3a.tar.gz
zsh-b591d431130a2648738a899296638245b0b93d3a.tar.xz
zsh-b591d431130a2648738a899296638245b0b93d3a.zip
45181: Fix workers/45164: ${(S)%%} will now consider the empty string as a potential match.
-rw-r--r--ChangeLog5
-rw-r--r--Src/glob.c4
-rw-r--r--Test/D04parameter.ztst2
3 files changed, 8 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index f959d054a..355dd30b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-02  Daniel Shahaf  <danielsh@apache.org>
+
+	* 45181: Src/glob.c, Test/D04parameter.ztst: Fix workers/45164:
+	${(S)%%} will now consider the empty string as a potential match.
+
 2020-01-01  dana  <dana@dana.is>
 
 	* Stephane: 45183: Doc/Zsh/builtins.yo, Doc/Zsh/contrib.yo,
diff --git a/Src/glob.c b/Src/glob.c
index ca5846704..f67a376b9 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -3059,7 +3059,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
 	case (SUB_END|SUB_SUBSTR):
 	case (SUB_END|SUB_LONG|SUB_SUBSTR):
 	    /* Longest/shortest at end, matching substrings.       */
-	    if (!(fl & SUB_LONG)) {
+	    {
 		set_pat_start(p, l);
 		if (pattrylen(p, send, 0, 0, &patstralloc, umltot) &&
 		    !--n) {
@@ -3397,7 +3397,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
 	case (SUB_END|SUB_SUBSTR):
 	case (SUB_END|SUB_LONG|SUB_SUBSTR):
 	    /* Longest/shortest at end, matching substrings.       */
-	    if (!(fl & SUB_LONG)) {
+	    {
 		set_pat_start(p, l);
 		if (pattrylen(p, send, 0, 0, &patstralloc, uml) && !--n) {
 		    *sp = get_match_ret(&imd, uml, uml);
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index f4af5d59c..83ac7ebf4 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2639,7 +2639,7 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
 
  foo=pws
  print 2: ${(S)foo%%*}
--f:(S) with zero-length matches at end, part 1 (workers/45164)
+0:(S) with zero-length matches at end, part 1 (workers/45164)
 >2: pws
 
  foo=pws