From e9b11fa9f00cb061d8f92d469a12d47b6d230214 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 11 Mar 2008 10:00:38 +0000 Subject: unposted: make test for added space in 24699 safer --- Src/hist.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Src/hist.c') 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. -- cgit 1.4.1