From 8d85c8442ff15100eeb7262bf7ea37472fd78095 Mon Sep 17 00:00:00 2001 From: s-over-4 Date: Wed, 21 Jun 2023 17:36:09 -0400 Subject: RETURN OGHF TEH BORKED SHIAT D: D: D: --- src/lexer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lexer.c b/src/lexer.c index 731210e..6d9d5a8 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -121,9 +121,8 @@ token_t* lexer_collect(lexer_t* lexer, int (*end_char)(char), int fskip, int lsk size_t len; // length of collected token so far char* token; // collected token so far - len = 1; + len = 0; token = calloc(len, sizeof(char)); - token[0] = '\0'; if (fskip) { lexer_next(lexer); } @@ -133,11 +132,11 @@ token_t* lexer_collect(lexer_t* lexer, int (*end_char)(char), int fskip, int lsk current = lexer_get_c_as_string(lexer); token = realloc( token, - (len + sizeof(char) * strlen(current)) + (len + sizeof(current)) ); memcpy(token + len, current, sizeof(char) * strlen(current)); - len += sizeof(char) * strlen(current); + len += strlen(current) * sizeof(char); lexer_next(lexer); free(current); -- cgit v1.2.3