shithub: lua9

Download patch

ref: 98b14048ff38d318b446a1428a763a6b4bbb7a18
parent: e73ad64ec22095a32884c2ee187a46e0c570f477
author: telephil9 <[email protected]>
date: Sun Oct 25 16:04:27 EDT 2020

Fixed error reporting

	Errors raised from lua were never displayed. We now get the error
	from the stack and display it when the result of the call to dofile
	is not LUA_OK.

--- a/lua9.c
+++ b/lua9.c
@@ -24,7 +24,7 @@
 {
 	lua_State *L;
 	luaL_Reg *lib;
-	char *f = NULL;
+	char *s;
 	int r;
 
 	L = luaL_newstate();
@@ -34,6 +34,10 @@
 		lua_pop(L, 1);
 	}
 	r = luaL_dofile(L, argc > 1 ? argv[1] : NULL);
+	if(r != LUA_OK){
+		s = luaL_checkstring(L, lua_gettop(L));
+		fprintf(stderr, "error: %s\n", s);
+	}
 	lua_close(L);
-	return f == LUA_OK;
+	return r == LUA_OK;
 }