aboutsummaryrefslogtreecommitdiff
path: root/src/lua_vars.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua_vars.c')
-rw-r--r--src/lua_vars.c51
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);
}