about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2017-08-08 19:04:49 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2017-08-08 19:04:49 +0100
commita9b579a9d3921c4d843be7a52faeb8a3f3f6c35e (patch)
tree49101e5c9c5d4b94839338ee9b41aa99954d9149 /Src
parent2fba415a71dca55158900569b85bc4fabd3c1595 (diff)
downloadzsh-a9b579a9d3921c4d843be7a52faeb8a3f3f6c35e.tar.gz
zsh-a9b579a9d3921c4d843be7a52faeb8a3f3f6c35e.tar.xz
zsh-a9b579a9d3921c4d843be7a52faeb8a3f3f6c35e.zip
Revert "41499 (with one further tweak): POSIX_STRINGS behaviour."
This reverts commit 2eacbef91913fe967335812900d43cf2edfa54d9.

Conflicts:
	ChangeLog
Diffstat (limited to 'Src')
-rw-r--r--Src/utils.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/Src/utils.c b/Src/utils.c
index d30a7b47e..5055d69fe 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3500,12 +3500,12 @@ skipwsep(char **s)
 mod_export char **
 spacesplit(char *s, int allownull, int heap, int quote)
 {
-    char *t, **ret, **ptr, **eptr;
+    char *t, **ret, **ptr;
     int l = sizeof(*ret) * (wordcount(s, NULL, -!allownull) + 1);
     char *(*dup)(const char *) = (heap ? dupstring : ztrdup);
 
     /* ### TODO: s/calloc/alloc/ */
-    eptr = ptr = ret = (char **) (heap ? hcalloc(l) : zshcalloc(l));
+    ptr = ret = (char **) (heap ? hcalloc(l) : zshcalloc(l));
 
     if (quote) {
 	/*
@@ -3537,7 +3537,6 @@ spacesplit(char *s, int allownull, int heap, int quote)
 	if (s > t || allownull) {
 	    *ptr = (char *) (heap ? zhalloc((s - t) + 1) :
 		                     zalloc((s - t) + 1));
-	    eptr = ptr;
 	    ztrncpy(*ptr++, t, s - t);
 	} else
 	    *ptr++ = dup(nulstring);
@@ -3546,21 +3545,6 @@ spacesplit(char *s, int allownull, int heap, int quote)
     }
     if (!allownull && t != s)
 	*ptr++ = dup("");
-    if (isset(POSIXSTRINGS) && ptr > eptr + 1) {
-	/*
-	 * Trailing separators do not generate extra fields in POSIX.
-	 * Note this is only the final separator --- if the
-	 * immediately preceding field was null it is still counted.
-	 * So just back up one.
-	 */
-	--ptr;
-	if (!heap) {
-	    char **ret2 = realloc(ret, sizeof(*ret) * (ptr+1-ret));
-	    ptr -= ret-ret2;
-	    free(ret);
-	    ret = ret2;
-	}
-    }
     *ptr = NULL;
     return ret;
 }