diff options
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/tokenizer.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 5dc2ae6..e52d498 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -983,7 +983,8 @@ tok_nextc(struct tok_state *tok) return EOF; /* Last line does not end in \n, fake one */ - strcpy(tok->inp, "\n"); + if (tok->inp[-1] != '\n') + strcpy(tok->inp, "\n"); } tok->inp = strchr(tok->inp, '\0'); done = tok->inp[-1] == '\n'; @@ -1674,6 +1675,14 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end) tok->cur = tok->inp; return ERRORTOKEN; } + c = tok_nextc(tok); + if (c == EOF) { + tok->done = E_EOF; + tok->cur = tok->inp; + return ERRORTOKEN; + } else { + tok_backup(tok, c); + } tok->cont_line = 1; goto again; /* Read next line */ } |