aboutsummaryrefslogtreecommitdiff
path: root/src/lua_globs.c
diff options
context:
space:
mode:
authordacctal <donotcontactmevia@email.invalid>2026-07-17 23:12:40 +0000
committerdacctal <donotcontactmevia@email.invalid>2026-07-17 23:12:40 +0000
commit518be7f92e2c2bc1a3cc3cfe1223390ae3cd9c2b (patch)
tree0541433f4bc62cd9032bfe881fdbb212360da077 /src/lua_globs.c
parent76ee567986a12c22e6a606d74e31425facf9f5f4 (diff)
update!
Diffstat (limited to 'src/lua_globs.c')
-rw-r--r--src/lua_globs.c69
1 files changed, 52 insertions, 17 deletions
diff --git a/src/lua_globs.c b/src/lua_globs.c
index 5f333a4..74a7faa 100644
--- a/src/lua_globs.c
+++ b/src/lua_globs.c
@@ -114,23 +114,6 @@ void bldit_isnt_type(char *variable, char *type) {
log_error("bldit.lua: '%s' is not a %s.", variable, type);
}
-//bool is_bldit_usable() {
-// const char* bldit_version = bldit_getver();
-// if (
-// strcmp(bldit_version, "") != 0 &&
-// strcmp(bldit_version, version) == 0
-// ) return true;
-// bool prev_pass = false;
-// for (int i = 0; i < strlen(bldit_version); i++) {
-// if (bldit_version[i] == '.') continue;
-// if ((bldit_version[i] - '0') <= (version[i] - '0')) {
-// prev_pass = ((bldit_version[i] - '0') != (version[i] - '0'));
-// continue;
-// } else return prev_pass;
-// }
-// return true;
-//}
-
bool lua_try_function(lua_State *L, char *lua_file, char *fname) {
lua_getfield(L, -1, fname);
if (!lua_isfunction(L, -1)) {
@@ -170,3 +153,55 @@ bool lua_try_table(lua_State *L, char *lua_file, char *tname) {
}
return true;
}
+
+str bldit_getver(void) {
+ init_bldit_state();
+ if (!bldit_loaded) {
+ return mstr("");
+ }
+ lua_getglobal(B, "bldit_version");
+ if (!lua_isstring(B, -1)) {
+ if (flags.verbose)
+ log_warn("bldit.lua: 'bldit_version' is not a string.");
+ lua_pop(B, 1);
+ return mstr("");
+ }
+ str bldit_version = mstr(lua_tostring(B, -1));
+ lua_pop(B, 1);
+ return bldit_version;
+}
+
+str bldit_pkg_getver(void) {
+ init_bldit_state();
+ lua_getglobal(B, "package_version");
+ if (!lua_isstring(B, -1)) {
+ if (flags.verbose)
+ log_warn("bldit.lua: 'package_version' is not a string.");
+ lua_pop(B, 1);
+ return mstr("");
+ }
+ str package_version = mstr(lua_tostring(B, -1));
+ lua_pop(B, 1);
+ return package_version;
+}
+
+bool is_bldit_usable(void) {
+ str bldit_version = bldit_getver();
+ if (
+ strcmp(bldit_version.data, "") != 0 &&
+ strcmp(bldit_version.data, VERSION) == 0
+ ) return true;
+ bool prev_pass = false;
+ for (size_t i = 0; i < bldit_version.len; i++) {
+ if (bldit_version.data[i] == '.') continue;
+ if ((bldit_version.data[i] - '0') <= (VERSION[i] - '0')) {
+ prev_pass = ((bldit_version.data[i] - '0') != (VERSION[i] - '0'));
+ continue;
+ } else {
+ str_free(&bldit_version);
+ return prev_pass;
+ }
+ }
+ str_free(&bldit_version);
+ return true;
+}