From cd1b5d86e0a6ac37e982c6a3b8725fd11076f14c Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 1 May 2012 19:43:44 +0000 Subject: users/17046: don't count too many elements when splitting quoted parameter substitution on null parameter --- ChangeLog | 8 +++++++- Src/utils.c | 2 +- Test/D04parameter.ztst | 16 +++++++++++++++- 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 + + * 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 * 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)*]}" -- cgit 1.4.1