aboutsummaryrefslogtreecommitdiffstats
path: root/luaing.c
diff options
context:
space:
mode:
Diffstat (limited to 'luaing.c')
-rw-r--r--luaing.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/luaing.c b/luaing.c
new file mode 100644
index 0000000..ac08668
--- /dev/null
+++ b/luaing.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <string.h>
+#include <lua.h>
+#include <lauxlib.h>
+#include <lualib.h>
+
+int main(int argc, char **argv)
+{
+ char buffer[256];
+ int error;
+ lua_State *L = luaL_newstate();
+ luaL_openlibs(L);
+
+ while (fgets(buffer, sizeof(buffer), stdin) != NULL) {
+ error = luaL_loadbuffer(L, buffer, strlen(buffer), "line")
+ || lua_pcall(L, 0, 0, 0);
+ if (error) {
+ fprintf(stderr, "%s", lua_tostring(L, -1));
+ lua_pop(L, 1);
+ }
+ }
+
+ lua_close(L);
+ return 0;
+}