From 815e52cdbf0a62bf795d5af8e7089aaca5709806 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 17 Aug 2011 19:00:08 +0000 Subject: users/16253, users/16255: a nulstring should be split like an empty string --- ChangeLog | 7 +++++-- Src/utils.c | 4 ++++ Test/D04parameter.ztst | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd9d9229b..76eb0d1dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ 2011-08-17 Peter Stephenson - * Anthony R Fletcher: users/16260: + * users/16253, users/16255: Src/utils.c, Test/D04parameter.ztst: + A nulstring should be split like an empty string. + + * Anthony R Fletcher: users/16260: Completion/Unix/Command/_systemctl: new completion. 2011-08-17 Nikolai Weibull @@ -15294,5 +15297,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5437 $ +* $Revision: 1.5438 $ ***************************************************** diff --git a/Src/utils.c b/Src/utils.c index 439b43aa9..c8d021c66 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -3176,6 +3176,10 @@ sepsplit(char *s, char *sep, int allownull, int heap) int n, sl; char *t, *tt, **r, **p; + /* Null string? Treat as empty string. */ + if (s[0] == Nularg && !s[1]) + s++; + if (!sep) return spacesplit(s, allownull, heap, 0); diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index 8f95420dd..71c79687f 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -1453,3 +1453,8 @@ print ${foo:5:-6} 1:Regression test for total length < 0 in array ?(eval):2: substring expression: 3 < 5 + + foo=(${(0)"$(print -n)"}) + print ${#foo} +0:Nularg removed from split empty string +>0 -- cgit 1.4.1