about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2017-03-23 21:01:59 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2017-03-23 21:01:59 +0000
commite78ec8610d16732e566526ceb1d513d71ccf942b (patch)
tree987354530748fd218b8e9c54f544b60323a1fc78
parent086656241c3ccca377474bfea1cb269ac9a67d60 (diff)
downloadzsh-e78ec8610d16732e566526ceb1d513d71ccf942b.tar.gz
zsh-e78ec8610d16732e566526ceb1d513d71ccf942b.tar.xz
zsh-e78ec8610d16732e566526ceb1d513d71ccf942b.zip
40891: fix more zero-length matches.
This time at the end of the trial string.
-rw-r--r--ChangeLog7
-rw-r--r--Src/glob.c4
-rw-r--r--Test/D04parameter.ztst10
3 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ce95e6ed8..9090c4cbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
+2017-03-23  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 40891: Src/glob.c, Test/D04parameter.ztst: another similar fix
+	for zero-length matches at the end of a string.
+
 2017-03-23  Peter Stephenson  <p.stephenson@samsung.com>
 
-	* 22601: Src/glob.c, Test/D04parameter.ztst: problem matching
+	* users/22601: Src/glob.c, Test/D04parameter.ztst: problem matching
 	pattern against zero-length string in parameter substitutions.
 
 2017-03-21  Peter Stephenson  <p.stephenson@samsung.com>
diff --git a/Src/glob.c b/Src/glob.c
index 9ac0ae66c..af5d0821c 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2929,7 +2929,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
 	     * move forward along string until we get a match. *
 	     * Again there's no optimisation.                  */
 	    mb_charinit();
-	    for (ioff = 0, t = s, umlen = umltot; t < send ; ioff++) {
+	    for (ioff = 0, t = s, umlen = umltot; t <= send ; ioff++) {
 		set_pat_start(p, t-s);
 		if (pattrylen(p, t, umlen, 0, &patstralloc, ioff)) {
 		    *sp = get_match_ret(&imd, t-s, umltot);
@@ -2937,6 +2937,8 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
 		}
 		if (fl & SUB_START)
 		    break;
+		if (t == send)
+		    break;
 		umlen -= iincchar(&t, send - t);
 	    }
 	    if (!(fl & SUB_START) && pattrylen(p, send, 0, 0,
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 99f7dd91a..66d9022e2 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2158,3 +2158,13 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
 >x
 >x
 >y
+
+  a=(1 "" 3)
+  print -rl -- "${(@)a//#%*/x}"
+  a=""
+  print -rl -- "${(@)a//#%*/y}"
+0:Zero-length string match at end
+>x
+>x
+>x
+>y