about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-03-11 10:00:38 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-03-11 10:00:38 +0000
commite9b11fa9f00cb061d8f92d469a12d47b6d230214 (patch)
tree85d649d9a332a20d50e8947c5b1c8eb4a4fac835
parent9e1c419497c8b604174c4af5af90ebd8c3707a77 (diff)
downloadzsh-e9b11fa9f00cb061d8f92d469a12d47b6d230214.tar.gz
zsh-e9b11fa9f00cb061d8f92d469a12d47b6d230214.tar.xz
zsh-e9b11fa9f00cb061d8f92d469a12d47b6d230214.zip
unposted: make test for added space in 24699 safer
-rw-r--r--ChangeLog5
-rw-r--r--Src/hist.c8
-rw-r--r--Test/D04parameter.ztst2
3 files changed, 10 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 2323d62c9..c8b152cbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-03-11  Peter Stephenson  <pws@csr.com>
+
+	* unposted: Src/hist.c: make test in 24699 for the extra
+	space safer.
+
 2008-03-09  Clint Adams  <clint@zsh.org>
 
 	* 24701, 24702: Completion/Unix/Command/_git: use $service instead of
diff --git a/Src/hist.c b/Src/hist.c
index 806bd9be3..a19c94818 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2479,7 +2479,7 @@ bufferwords(LinkList list, char *buf, int *index)
 	 */
 	addedspaceptr = p + l;
 	*addedspaceptr = ' ';
-	p[l + 1] = '\0';
+	addedspaceptr[1] = '\0';
 	inpush(p, 0, NULL);
 	zlemetall = strlen(p) ;
 	zlemetacs = zlemetall + 1;
@@ -2503,7 +2503,7 @@ bufferwords(LinkList list, char *buf, int *index)
 	    memcpy(p + (hptr - chline), linein, ll);
 	    addedspaceptr = p + (hptr - chline) + ll;
 	    *addedspaceptr = ' ';
-	    p[(hptr - chline) + zlemetall] = '\0';
+	    addedspaceptr[1] = '\0';
 	    inpush(p, 0, NULL);
 
 	    /*
@@ -2536,11 +2536,11 @@ bufferwords(LinkList list, char *buf, int *index)
 	    break;
 	if (tokstr && *tokstr) {
 	    untokenize((p = dupstring(tokstr)));
-	    if (ingetptr() > addedspaceptr) {
+	    if (ingetptr() == addedspaceptr + 1) {
 		/*
 		 * Whoops, we've read past the space we added, probably
 		 * because we were expecting a terminator but when
-		 * it didn't turn up and shrugged our shoulders thinking
+		 * it didn't turn up we shrugged our shoulders thinking
 		 * it might as well be a complete string anyway.
 		 * So remove the space.  C.f. below for the case
 		 * where the missing terminator caused a lex error.
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 57b87d687..79aecb6c3 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -336,7 +336,7 @@
   # The following may look a bit random.
   # For the split we are checking that anything that
   # would normally be followed by a different word has
-  # an argument break after it and anything that doesn't doesn't.
+  # an argument break after it and anything that wouldn't doesn't.
   # For the (Q) we are simply checking that nothing disappears
   # in the parsing.
   foo='<five> {six} (seven) >eight< }nine{ |forty-two| $many$ )ten( more'