aboutsummaryrefslogtreecommitdiffstats
path: root/src/lush.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lush.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/lush.c b/src/lush.c
index 49b205e..8beed6a 100644
--- a/src/lush.c
+++ b/src/lush.c
@@ -21,7 +21,7 @@ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include "lua.h"
#include "lua_api.h"
#include "lualib.h"
-#include "../lib/compat53/c-api/compat-5.3.h"
+#include "compat-5.3.h"
#include <asm-generic/ioctls.h>
#include <bits/time.h>
#include <ctype.h>
@@ -43,6 +43,10 @@ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include <time.h>
#include <unistd.h>
+// Forward declare the open functions for the compat C modules we need to preload
+int luaopen_bit32 (lua_State *L);
+int luaopen_utf8 (lua_State *L);
+
#define BUFFER_SIZE 1024
#define MAX_GLOB 512
@@ -1489,6 +1493,23 @@ int main(int argc, char *argv[]) {
// init lua state
lua_State *L = luaL_newstate();
luaL_openlibs(L);
+
+ // --- Pre-load compat modules ---
+ // This is to make C modules available to Lua
+ luaL_getglobal(L, "package");
+ luaL_getfield(L, -1, "preload");
+
+ // Preload bit32 for Lua 5.1 compatibility
+ lua_pushcfunction(L, luaopen_bit32);
+ lua_setfield(L, -2, "bit32");
+
+ // Preload utf8 for Lua 5.1/5.2 compatibility
+ lua_pushcfunction(L, luaopen_utf8);
+ lua_setfield(L, -2, "utf8");
+
+ // Pop package and preload tables
+ lua_pop(L, 2);
+ // --- End pre-loading ---
luaopen_compat53(L);
lua_register_api(L);
lua_run_init(L);
lass='deletions'>-0/+1 2024-09-13added better clarification to help menuGravatar BanceDev 1-1/+2 2024-09-13improved installation instructionsGravatar BanceDev 1-3/+3 2024-09-12v0.1.1Gravatar BanceDev 1-1/+1 2024-09-12fixed bug in input buffer handling due to misplaced printGravatar BanceDev 2-5/+8 2024-09-12Update build.yml checkout v4Gravatar Lance Borden 1-1/+1 2024-09-12Update build.yml to artifact v4Gravatar Lance Borden 1-1/+1 2024-09-12fixed exit status issue with non interative modeGravatar BanceDev 1-1/+1 2024-09-12added non interative mode for running lua scriptsGravatar BanceDev 2-4/+28 2024-09-12temporary github action fix until non-interactive mode is implementedGravatar BanceDev 1-2/+2 2024-09-12attempt to update build script to accept input into lush shellGravatar BanceDev 2-4/+6 2024-09-12prevent lush workflow from getting stuck in testsGravatar Lance Borden 1-1/+4 2024-09-12removed chsh in workflowGravatar Lance Borden 1-4/+1