parser/lexical.c, #2/10, move the `wlist' and `cw' resetting

nearer to the `goto nloop'
This commit is contained in:
rlar 2016-03-11 22:37:25 +01:00
parent a2af93685f
commit a0f5111436
1 changed files with 8 additions and 5 deletions

View File

@ -124,7 +124,7 @@ cp_lexer(char *string)
{ {
int c, d; int c, d;
int i, j; int i, j;
wordlist *wlist = NULL, *cw = NULL; wordlist *wlist, *cw;
char buf[NEW_BSIZE_SP], linebuf[NEW_BSIZE_SP]; char buf[NEW_BSIZE_SP], linebuf[NEW_BSIZE_SP];
int paren; int paren;
@ -137,6 +137,7 @@ cp_lexer(char *string)
prompt(); prompt();
} }
wlist = cw = NULL;
nloop: nloop:
wlist = cw = NULL; wlist = cw = NULL;
i = 0; i = 0;
@ -188,12 +189,14 @@ nloop:
c = '\n'; c = '\n';
if ((c == cp_hash) && !cp_interactive && (j == 1)) { if ((c == cp_hash) && !cp_interactive && (j == 1)) {
wl_free(wlist); if (string) {
wlist = cw = NULL; wl_free(wlist);
if (string)
return NULL; return NULL;
}
while (((c = cp_readchar(&string, cp_inp_cur)) != '\n') && (c != EOF)) while (((c = cp_readchar(&string, cp_inp_cur)) != '\n') && (c != EOF))
; ;
wl_free(wlist);
wlist = cw = NULL;
goto nloop; goto nloop;
} }
@ -271,7 +274,6 @@ 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
cp_ccom(wlist, buf, FALSE); cp_ccom(wlist, buf, FALSE);
wl_free(wlist);
(void) fputc('\r', cp_out); (void) fputc('\r', cp_out);
prompt(); prompt();
for (j = 0; linebuf[j]; j++) for (j = 0; linebuf[j]; j++)
@ -280,6 +282,7 @@ nloop:
#else #else
fputc(linebuf[j], cp_out); /* But you can't edit */ fputc(linebuf[j], cp_out); /* But you can't edit */
#endif #endif
wl_free(wlist);
wlist = cw = NULL; wlist = cw = NULL;
goto nloop; goto nloop;
} }