diff options
| author | dacctal <donotcontactmevia@email.invalid> | 2026-07-01 07:50:01 +0000 |
|---|---|---|
| committer | dacctal <donotcontactmevia@email.invalid> | 2026-07-01 07:50:01 +0000 |
| commit | 166b788d61a443a1576f8b56abdf06fea5a2178e (patch) | |
| tree | e6f4760d01f83d0865fecdd097fca51e521a1376 /src/lua_vars.c | |
| parent | fcfb6ac21651e286092bcc92309e89c8fa2e87fd (diff) | |
ezntek: checkpoint!
Diffstat (limited to 'src/lua_vars.c')
| -rw-r--r-- | src/lua_vars.c | 51 |
1 files changed, 20 insertions, 31 deletions
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); } |
