From 166b788d61a443a1576f8b56abdf06fea5a2178e Mon Sep 17 00:00:00 2001 From: dacctal Date: Wed, 1 Jul 2026 07:50:01 +0000 Subject: ezntek: checkpoint! --- src/lua_vars.c | 51 ++++++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) (limited to 'src/lua_vars.c') diff --git a/src/lua_vars.c b/src/lua_vars.c index 3519d7a..3fd2ddb 100644 --- a/src/lua_vars.c +++ b/src/lua_vars.c @@ -20,8 +20,8 @@ #include "lua_vars.h" -#include "lua_globs.h" #include "globs.h" +#include "lua_globs.h" void init_install_directories(void) { init_lua_state(); @@ -32,37 +32,26 @@ void init_install_directories(void) { lua_isnt_type("install_directories", "table"); return; } - //lua_pop(L, 1); - lua_getfield(L, -1, "bin"); - if (!lua_isstring(L, -1)) { - lua_isnt_type("install_directories.bin", "string"); - } else { - str_copy_cstr_into(&bin, lua_tostring(L, -1)); - } - lua_pop(L, 1); +#define SETUP_INST_DIRS \ + X(bin) \ + X(lib) \ + X(include) \ + X(src) + +#define X(dir) \ + do { \ + lua_getfield(L, -1, #dir); \ + if (!lua_isstring(L, -1)) { \ + lua_isnt_type("install_directories." #dir, "string"); \ + } else { \ + str_copy_cstr_into(&inst_dirs.dir, lua_tostring(L, -1)); \ + } \ + lua_pop(L, 1); \ + } while (0); + + SETUP_INST_DIRS +#undef X - lua_getfield(L, -1, "lib"); - if (!lua_isstring(L, -1)) { - lua_isnt_type("install_directories.lib", "string"); - } else { - str_copy_cstr_into(&lib, lua_tostring(L, -1)); - } - lua_pop(L, 1); - - lua_getfield(L, -1, "include"); - if (!lua_isstring(L, -1)) { - lua_isnt_type("install_directories.include", "string"); - } else { - str_copy_cstr_into(&include, lua_tostring(L, -1)); - } - lua_pop(L, 1); - - lua_getfield(L, -1, "src"); - if (!lua_isstring(L, -1)) { - lua_isnt_type("install_directories.src", "string"); - } else { - str_copy_cstr_into(&src, lua_tostring(L, -1)); - } lua_pop(L, 1); } -- cgit v1.2.3