lang: lex: only read linefeeds up to the end of the current line buffer
This commit is contained in:
10
lang/lex.c
10
lang/lex.c
@@ -482,6 +482,11 @@ static int advance(struct ivy_lexer *lex)
|
||||
return c;
|
||||
}
|
||||
|
||||
static bool input_available(struct ivy_lexer* lex)
|
||||
{
|
||||
return lex->lex_linebuf_ptr < lex->lex_linebuf_len;
|
||||
}
|
||||
|
||||
static bool char_can_begin_symbol(char c)
|
||||
{
|
||||
for (size_t i = 0; i < nr_symbols; i++) {
|
||||
@@ -999,6 +1004,11 @@ static enum ivy_status pump_tokens(struct ivy_lexer *lex)
|
||||
if (c == '\n') {
|
||||
while (c == '\n') {
|
||||
advance(lex);
|
||||
|
||||
if (!input_available(lex)) {
|
||||
break;
|
||||
}
|
||||
|
||||
c = peek(lex);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user