From 8f09c35c5a04197f3d725d62d36e794799c4bbc4 Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 11 Mar 2016 22:39:53 +0100 Subject: [PATCH] parser/lexical.c, #5/10, change buf/linebuf usage properly '\0' terminate the buffers where needed instead of an unspecific bzero() invocation --- src/frontend/parser/lexical.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/frontend/parser/lexical.c b/src/frontend/parser/lexical.c index 777fa9d68..912a4cc25 100644 --- a/src/frontend/parser/lexical.c +++ b/src/frontend/parser/lexical.c @@ -80,8 +80,8 @@ static int numeofs = 0; #define newword \ do { \ + buf[i] = '\0'; \ append(copy(buf)); \ - bzero(buf, NEW_BSIZE_SP); \ i = 0; \ } while(0) @@ -145,8 +145,6 @@ nloop: i = 0; j = 0; paren = 0; - bzero(linebuf, NEW_BSIZE_SP); - bzero(buf, NEW_BSIZE_SP); for (;;) { @@ -214,10 +212,8 @@ nloop: break; case '\n': - if (i) { - buf[i] = '\0'; + if (i) newword; - } if (!wlist_tail) append(NULL); goto done; @@ -273,9 +269,11 @@ nloop: } // cp_ccom doesn't mess wlist, read only access to wlist->wl_word + buf[i++] = '\0'; cp_ccom(wlist, buf, FALSE); (void) fputc('\r', cp_out); prompt(); + linebuf[j++] = '\0'; for (j = 0; linebuf[j]; j++) #ifdef TIOCSTI (void) ioctl(fileno(cp_out), TIOCSTI, linebuf + j); @@ -300,6 +298,7 @@ nloop: if (cp_interactive && !cp_nocc) { fputs("\b\b \b\b\r", cp_out); prompt(); + linebuf[j++] = '\0'; for (j = 0; linebuf[j]; j++) #ifdef TIOCSTI (void) ioctl(fileno(cp_out), TIOCSTI, linebuf + j); @@ -307,6 +306,7 @@ nloop: fputc(linebuf[j], cp_out); /* But you can't edit */ #endif // cp_ccom doesn't mess wlist, read only access to wlist->wl_word + buf[i++] = '\0'; cp_ccom(wlist, buf, TRUE); goto nloop; }