summaryrefslogtreecommitdiffhomepage
path: root/lexer.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2023-07-11 12:10:53 +0200
committerJo-Philipp Wich <jo@mein.io>2023-07-12 00:38:49 +0200
commit9df91602e3aba0edc4771b220663f442f836f986 (patch)
treef1c2ff50c3fbc5ce4e236c09044da85565974532 /lexer.c
parent62775f4a4492ec2d6f19f2bc0af882de041b0bb7 (diff)
lexer: don't count EOF token as newline
Avoid reporting a nonexisting final line by not counting the EOF character as physical newline. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lexer.c')
-rw-r--r--lexer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lexer.c b/lexer.c
index b6f082d..934a531 100644
--- a/lexer.c
+++ b/lexer.c
@@ -94,9 +94,9 @@ fill_buf(uc_lexer_t *lex) {
static int
update_line(uc_lexer_t *lex, int ch) {
- if (ch == '\n' || ch == EOF)
+ if (ch == '\n')
uc_source_line_next(lex->source);
- else
+ else if (ch != EOF)
uc_source_line_update(lex->source, 1);
lex->source->off++;