From 4fa342bcfdb5ebcbe65cabe1fb9ac3a46ea4ddca Mon Sep 17 00:00:00 2001 From: dacctal Date: Sun, 9 Aug 2026 07:30:59 +0000 Subject: checkpoint (it doesn't compile) --- src/lua_state.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/lua_state.c') diff --git a/src/lua_state.c b/src/lua_state.c index aa5247f..18040fc 100644 --- a/src/lua_state.c +++ b/src/lua_state.c @@ -10,6 +10,9 @@ lua_State *L = NULL; bool L_is_loaded = false; +cli_flags_t flags = {0}; +user_config_t config = {0}; + static void lua_path_push(const char *new_path) { lua_getglobal(L, "package"); lua_getfield(L, -1, "path"); @@ -90,28 +93,17 @@ static void setup_base_dirs(void) { ); } -#define lua_get_field_type(name, type, file) \ - do { \ - lua_getfield(L, -1, name); \ - if (!lua_is##type(L, -1)) { \ - log_error("lua: expected type " #type " for " name " in %.*s", \ - str_fmt(file)); \ - lua_pop(L, 1); \ - return false; \ - } \ - } while (0) - static bool load_init_lua(void) { lua_setglobal(L, "__PkgitUserConfig"); lua_getglobal(L, "__PkgitUserConfig"); - lua_get_field_type("dirs", table, &config.init_path); + lua_get_field_type("dirs", table, &config.init_path, 1); #define X(field) \ do { \ - lua_get_field_type(#field, string, &config.init_path); \ + lua_get_field_type(#field, string, &config.init_path, 1); \ config.inst_dirs.field = str_adopt((char *)lua_tostring(L, -1)); \ - lua_pop(L, 1); \ + lua_pop(L, 1); \ } while (0) X(prefix); @@ -147,4 +139,12 @@ void free_lua_state(void) { void free_lua_config(void) { free_lua_state(); + str_free(&config.inst_dirs.prefix); + str_free(&config.inst_dirs.src); + str_free(&config.inst_dirs.bin); + str_free(&config.inst_dirs.lib); + str_free(&config.inst_dirs.include); + str_free(&config.dir); + str_free(&config.init_path); + str_free(&config.autogenerated_path); } -- cgit v1.2.3