about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-06-14 17:53:24 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-06-14 17:53:24 +0000
commit7b0d0759b3fd93e6d420e6387bf2fb89b4d04e9c (patch)
tree711d188f172da656d90edbe34b1783ce56e3c65d
parent1bc37bf82a00053d81b8773cf73b42bfa862c457 (diff)
downloadzsh-7b0d0759b3fd93e6d420e6387bf2fb89b4d04e9c.tar.gz
zsh-7b0d0759b3fd93e6d420e6387bf2fb89b4d04e9c.tar.xz
zsh-7b0d0759b3fd93e6d420e6387bf2fb89b4d04e9c.zip
17318: ${(z)...} added an extra space when the lexical analyser failed.
-rw-r--r--ChangeLog5
-rw-r--r--Src/hist.c9
2 files changed, 14 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 49eb2bda6..3f0e70231 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2002-06-14  Peter Stephenson  <pws@csr.com>
+
+	* 17318: Src/hist.c: ${(z)...} appended an extra space when the
+	lexical analyser failed.
+
 2002-06-04  Peter Stephenson  <pws@pwstephenson.fsnet.co.uk>
 
 	* 17283: Src/parse.c: `func() { ... } this bit was ignored'.
diff --git a/Src/hist.c b/Src/hist.c
index e86252d17..57e429a7d 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2266,7 +2266,16 @@ bufferwords(LinkList list, char *buf, int *index)
 	}
     } while (tok != ENDINPUT && tok != LEXERR);
     if (buf && tok == LEXERR && tokstr && *tokstr) {
+	int plen;
 	untokenize((p = dupstring(tokstr)));
+	plen = strlen(p);
+	/*
+	 * Strip the space we added for lexing but which won't have
+	 * been swallowed by the lexer because we aborted early.
+	 * The test is paranoia.
+	 */
+	if (plen && p[plen-1] == ' ' && (plen == 1 || p[plen-2] != Meta))
+	    p[plen - 1] = '\0';
 	addlinknode(list, p);
 	num++;
     }