From 6dc9a1062897ac662b1191accb90286f1ffd156e Mon Sep 17 00:00:00 2001 From: Francesco Cozzuto Date: Sun, 24 Aug 2025 14:30:04 +0200 Subject: [PATCH] Fix TODOs --- 3p/WL.c | 31 +++++++++++++++---------------- Makefile | 2 +- src/session.c | 2 -- src/sqlite3utils.c | 2 -- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/3p/WL.c b/3p/WL.c index 46ef162..83dc75b 100644 --- a/3p/WL.c +++ b/3p/WL.c @@ -778,7 +778,8 @@ static Node *parse_html(Parser *p) } if (s->cur == s->len) { - ASSERT(0); // TODO + parser_report(p, "Invaid end of source inside HTML tag"); + return NULL; } s->cur++; @@ -789,7 +790,8 @@ static Node *parse_html(Parser *p) while (s->cur < s->len && is_space(s->src[s->cur])) s->cur++; if (s->cur == s->len || s->src[s->cur] != '>') { - ASSERT(0); // TODO + parser_report(p, "Invalid character inside HTML closing tag"); + return NULL; } s->cur++; no_body = true; @@ -833,7 +835,8 @@ static Node *parse_html(Parser *p) } if (s->cur == s->len) { - ASSERT(0); // TODO + parser_report(p, "Missing closing HTML tag ", tagname.len, tagname.ptr); + return NULL; } s->cur++; @@ -845,17 +848,20 @@ static Node *parse_html(Parser *p) t = next_token(p); if (t.type != TOKEN_IDENT) { - ASSERT(0); // TODO + parser_report(p, "Missing tag name after '' in closing HTML tag"); + return NULL; } break; @@ -2546,9 +2552,6 @@ static void cg_pop_scope(Codegen *cg) call->next = cg->free_list_calls; cg->free_list_calls = call; - - // TODO: remove - ASSERT(cg->scopes[cg->num_scopes-1].calls == NULL || (cg->scopes[cg->num_scopes-1].calls - cg->calls >= 0 && cg->scopes[cg->num_scopes-1].calls - cg->calls < MAX_UNPATCHED_CALLS)); } cg->num_syms = scope->idx_syms; @@ -2621,9 +2624,6 @@ static void walk_node(Codegen *cg, Node *node); static void walk_expr_node(Codegen *cg, Node *node, bool one) { - // TODO: remove - ASSERT(cg->scopes[cg->num_scopes-1].calls == NULL || (cg->scopes[cg->num_scopes-1].calls - cg->calls >= 0 && cg->scopes[cg->num_scopes-1].calls - cg->calls < MAX_UNPATCHED_CALLS)); - switch (node->type) { case NODE_NESTED: @@ -2927,9 +2927,6 @@ static void walk_expr_node(Codegen *cg, Node *node, bool one) static void walk_node(Codegen *cg, Node *node) { - // TODO: remove - ASSERT(cg->scopes[cg->num_scopes-1].calls == NULL || (cg->scopes[cg->num_scopes-1].calls - cg->calls >= 0 && cg->scopes[cg->num_scopes-1].calls - cg->calls < MAX_UNPATCHED_CALLS)); - switch (node->type) { case NODE_GLOBAL: @@ -3586,7 +3583,9 @@ WL_AddResult wl_compiler_add(WL_Compiler *compiler, WL_String content) if (include->include_root == NULL) { if (compiler->num_files == FILE_LIMIT) { - ASSERT(0); // TODO + snprintf(compiler->err, sizeof(compiler->err), "File limit reached"); + compiler->err = true; + return (WL_AddResult) { .type=WL_ADD_ERROR }; } // TODO: Make the path relative to the compiled file diff --git a/Makefile b/Makefile index b325198..8f9a58d 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ else LFLAGS = endif -CFLAGS = -Wall -Wextra -O0 -g3 -I3p -fsanitize=address,undefined +CFLAGS = -Wall -Wextra -O0 -g3 -I3p HFILES = $(shell find src 3p -name "*.h") CFILES = $(filter-out 3p/sqlite3.c, $(shell find src 3p -name "*.c")) diff --git a/src/session.c b/src/session.c index 2f27d2d..c80d1f6 100644 --- a/src/session.c +++ b/src/session.c @@ -86,8 +86,6 @@ void session_storage_free(SessionStorage *storage) free(storage); } -#include // TODO - static Session *lookup_session_slot(SessionStorage *storage, HTTP_String sess, bool find_unused) { if (find_unused && 2 * storage->count + 2 > storage->capacity) diff --git a/src/sqlite3utils.c b/src/sqlite3utils.c index 61360fb..6261f3e 100644 --- a/src/sqlite3utils.c +++ b/src/sqlite3utils.c @@ -91,8 +91,6 @@ int sqlite3utils_prepare(SQLiteCache *cache, sqlite3_stmt **pstmt, char *fmt, in int i = lookup(cache, fmt, fmtlen); if (cache->items[i].stmt == NULL) { - printf("Preparing statement [%.*s]\n", fmtlen, fmt); // TODO - sqlite3_stmt *stmt; int ret = sqlite3_prepare_v2(cache->db, fmt, -1, &stmt, NULL); if (ret != SQLITE_OK) {