about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2012-05-01 19:43:44 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2012-05-01 19:43:44 +0000
commitcd1b5d86e0a6ac37e982c6a3b8725fd11076f14c (patch)
treee6e20319c704a612317e9459549315f77195a73c
parent8da652f6ae53990288690abc96f438f561f5af4c (diff)
downloadzsh-cd1b5d86e0a6ac37e982c6a3b8725fd11076f14c.tar.gz
zsh-cd1b5d86e0a6ac37e982c6a3b8725fd11076f14c.tar.xz
zsh-cd1b5d86e0a6ac37e982c6a3b8725fd11076f14c.zip
users/17046: don't count too many elements when splitting quoted parameter
substitution on null parameter
-rw-r--r--ChangeLog8
-rw-r--r--Src/utils.c2
-rw-r--r--Test/D04parameter.ztst16
3 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 2cefa9894..23713f54f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-01  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* users/17046: Src/utils.c, Test/D04parameter.ztst: don't
+	count too many elements when splitting quoted parameter
+	substitution on null separator.
+
 2012-05-01  Mikael Magnusson  <mikachu@gmail.com>
 
 	* 30456: Completion/Unix/Command/_getconf: Use new array syntax.
@@ -16254,5 +16260,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5644 $
+* $Revision: 1.5645 $
 *****************************************************
diff --git a/Src/utils.c b/Src/utils.c
index fb65ba815..9603389cc 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3114,7 +3114,7 @@ wordcount(char *s, char *sep, int mul)
 	r = 1;
 	sl = strlen(sep);
 	for (; (c = findsep(&s, sep, 0)) >= 0; s += sl)
-	    if ((c && *(s + sl)) || mul)
+	    if ((c || mul) && (sl || *(s + sl)))
 		r++;
     } else {
 	char *t = s;
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index cdeb15bfd..01f841218 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1292,7 +1292,7 @@
 >in
 >it
 
-  foo="line:with::missing::fields:in:it"
+  foo="line:with::missing::fields:in:it:"
   print -l "${(@s.:.)foo}"
 0:Retention of empty fields in quoted splitting with "@"
 >line
@@ -1303,6 +1303,20 @@
 >fields
 >in
 >it
+>
+
+  str=abcd
+  print -l ${(s..)str}
+  print -l "${(s..)str}"
+0:splitting of strings into characters
+>a
+>b
+>c
+>d
+>a
+>b
+>c
+>d
 
   array=('%' '$' 'j' '*' '$foo')
   print ${array[(i)*]} "${array[(i)*]}"