Browse Source

parser/lexical.c, #5/10, change buf/linebuf usage

properly '\0' terminate the buffers where needed
instead of an unspecific bzero() invocation
pre-master-46
rlar 10 years ago
parent
commit
8f09c35c5a
  1. 12
      src/frontend/parser/lexical.c

12
src/frontend/parser/lexical.c

@ -80,8 +80,8 @@ static int numeofs = 0;
#define newword \ #define newword \
do { \ do { \
buf[i] = '\0'; \
append(copy(buf)); \ append(copy(buf)); \
bzero(buf, NEW_BSIZE_SP); \
i = 0; \ i = 0; \
} while(0) } while(0)
@ -145,8 +145,6 @@ nloop:
i = 0; i = 0;
j = 0; j = 0;
paren = 0; paren = 0;
bzero(linebuf, NEW_BSIZE_SP);
bzero(buf, NEW_BSIZE_SP);
for (;;) { for (;;) {
@ -214,10 +212,8 @@ nloop:
break; break;
case '\n': case '\n':
if (i) {
buf[i] = '\0';
if (i)
newword; newword;
}
if (!wlist_tail) if (!wlist_tail)
append(NULL); append(NULL);
goto done; goto done;
@ -273,9 +269,11 @@ nloop:
} }
// cp_ccom doesn't mess wlist, read only access to wlist->wl_word // cp_ccom doesn't mess wlist, read only access to wlist->wl_word
buf[i++] = '\0';
cp_ccom(wlist, buf, FALSE); cp_ccom(wlist, buf, FALSE);
(void) fputc('\r', cp_out); (void) fputc('\r', cp_out);
prompt(); prompt();
linebuf[j++] = '\0';
for (j = 0; linebuf[j]; j++) for (j = 0; linebuf[j]; j++)
#ifdef TIOCSTI #ifdef TIOCSTI
(void) ioctl(fileno(cp_out), TIOCSTI, linebuf + j); (void) ioctl(fileno(cp_out), TIOCSTI, linebuf + j);
@ -300,6 +298,7 @@ nloop:
if (cp_interactive && !cp_nocc) { if (cp_interactive && !cp_nocc) {
fputs("\b\b \b\b\r", cp_out); fputs("\b\b \b\b\r", cp_out);
prompt(); prompt();
linebuf[j++] = '\0';
for (j = 0; linebuf[j]; j++) for (j = 0; linebuf[j]; j++)
#ifdef TIOCSTI #ifdef TIOCSTI
(void) ioctl(fileno(cp_out), TIOCSTI, linebuf + j); (void) ioctl(fileno(cp_out), TIOCSTI, linebuf + j);
@ -307,6 +306,7 @@ nloop:
fputc(linebuf[j], cp_out); /* But you can't edit */ fputc(linebuf[j], cp_out); /* But you can't edit */
#endif #endif
// cp_ccom doesn't mess wlist, read only access to wlist->wl_word // cp_ccom doesn't mess wlist, read only access to wlist->wl_word
buf[i++] = '\0';
cp_ccom(wlist, buf, TRUE); cp_ccom(wlist, buf, TRUE);
goto nloop; goto nloop;
} }

Loading…
Cancel
Save