about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/hist.c9
1 files changed, 9 insertions, 0 deletions
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++;
     }