diff options
| author | dacctal <donotcontactmevia@email.invalid> | 2026-08-09 07:30:59 +0000 |
|---|---|---|
| committer | dacctal <donotcontactmevia@email.invalid> | 2026-08-09 07:30:59 +0000 |
| commit | 4fa342bcfdb5ebcbe65cabe1fb9ac3a46ea4ddca (patch) | |
| tree | e7398fc7b26e9bd225f2c10ed0557baa771fca78 /src/lua_state.c | |
| parent | e2cda84ebbd073ece54692c6a3d785afc6148268 (diff) | |
checkpoint (it doesn't compile)
Diffstat (limited to 'src/lua_state.c')
| -rw-r--r-- | src/lua_state.c | 28 |
1 files changed, 14 insertions, 14 deletions
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); } |
