some debug for lua that got me to where I don't think I need lua.

- thanks to debugging and seeing variables internally
This commit is contained in:
Howland Owl 2017-04-25 23:45:13 +03:00
parent f164ada948
commit 2da61079de
2 changed files with 26 additions and 2 deletions

View file

@ -1,9 +1,9 @@
-- Lua test file
function ithecolors( c )
a = 5
b = 7
io.write("some shit from lua\n")
-- io.write(c)
io.write("\n")
end
ithecolors()

24
st.c
View file

@ -589,6 +589,11 @@ int dothatLua(void) {
luaL_openlibs(L); /* Load Lua libraries */
if (luaL_loadfile(L, "color.lua")) /* Load but don't run the Lua script */
bail(L, "luaL_loadfile() failed"); /* Error out if file can't be read */
// for (int i = 0; i < sizeof(colorname); ++i) {
// lua_pushstring(L,colorname[i]);
// }
printf("In C, calling Lua\n");
if (lua_pcall(L, 0, 0, 0)) /* Run the loaded Lua script */
bail(L, "lua_pcall() failed"); /* Error out if Lua file has an error */
@ -597,6 +602,24 @@ int dothatLua(void) {
return 0;
}
int luaInterpreter(void) {
char buff[256];
int error;
lua_State *L = luaL_newstate(); /* opens Lua */
luaL_openlibs(L); /* opens the standard libraries */
while (fgets(buff, sizeof(buff), stdin) != NULL) {
error = luaL_loadstring(L, buff) || lua_pcall(L, 0, 0, 0);
if (error) {
fprintf(stderr, "%s\n", lua_tostring(L, -1));
lua_pop(L, 1); /* pop error message from the stack */
}
}
lua_close(L);
return 0;
}
ssize_t
xwrite(int fd, const char *s, size_t len)
@ -4529,6 +4552,7 @@ run:
opt_title = basename(xstrdup(argv[0]));
}
dothatLua();
// luaInterpreter();
setlocale(LC_CTYPE, "");
XSetLocaleModifiers("");
tnew(MAX(cols, 1), MAX(rows, 1));