added tlibc error handling everywhere

This commit is contained in:
2025-11-26 16:42:28 +05:00
parent 048542d079
commit 2082d56c25
27 changed files with 374 additions and 308 deletions

View File

@@ -4,7 +4,7 @@
#include <inttypes.h>
#include <assert.h>
#include "tlibtoml/toml.h"
#include "tlibtoml.h"
#ifndef PROJECT_SOURCE_DIR
#define PROJECT_SOURCE_DIR ".."
@@ -38,7 +38,7 @@ void print_value(const TomlValue* value)
print_array(value->value.array);
break;
case TLIBTOML_STRING:
printf("\"%s\"", value->value.s.data);
printf("'" FMT_str "'", value->value.s->len, value->value.s->data);
break;
case TLIBTOML_INTEGER:
printf("%" PRId64, value->value.i);
@@ -80,14 +80,12 @@ void print_table(const TomlTable* table)
Result(void) test_run(cstr filename)
{
Deferral(4);
Deferral(1);
try(TomlTable* table, p, toml_load_filename(filename));
Defer(TomlTable_free(table));
print_table(table);
printf("\n");
cleanup:
;
Return RESULT_VOID;
}
i32 main(void)
@@ -95,6 +93,8 @@ i32 main(void)
Deferral(32);
try_fatal_void(tlibc_init());
Defer(tlibc_deinit());
try_fatal_void(tlibtoml_init());
Defer(tlibtoml_deinit());
static cstr const filenames[] = {
/* should parse */
@@ -131,5 +131,5 @@ i32 main(void)
printf("total %d tests, %d passed, %d failed\n",
total_tests, num_passed, num_failed);
return num_failed;
Return num_failed;
}