From 0eda62ca1ce21a58f74d853827141a7362071486 Mon Sep 17 00:00:00 2001 From: _N3m0 Date: Mon, 1 Jan 2024 14:43:04 +0100 Subject: [PATCH] fix: lexer nextchar return unavailave chunk --- lexer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lexer.c b/lexer.c index 7f00a0f..fb4035d 100644 --- a/lexer.c +++ b/lexer.c @@ -8,9 +8,6 @@ Cursor cursor = { }; char* nextchar(void){ - if (cursor.chunk >= page.len){ - return NULL; - } if (page.chunks[cursor.chunk][cursor.offset+1] == '\0'){ cursor.chunk++; cursor.offset = 0; @@ -18,6 +15,10 @@ char* nextchar(void){ cursor.offset++; } + if (cursor.chunk >= page.len){ + return NULL; + } + return &page.chunks[cursor.chunk][cursor.offset]; }