From cfccb8fa616297582c66de1b787b09e7b96dd758 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Tue, 11 Nov 2014 15:33:36 -0500 Subject: [PATCH] Correctly report syntax errors in loaded scripts Syntax errors were getting reported as "file not found" errors instead. Correctly pass through the right error code and message. --- src/host/lua_auxlib.c | 2 +- src/host/premake.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/host/lua_auxlib.c b/src/host/lua_auxlib.c index 84b91a63..27883a3e 100644 --- a/src/host/lua_auxlib.c +++ b/src/host/lua_auxlib.c @@ -75,7 +75,7 @@ LUALIB_API int luaL_loadfile (lua_State* L, const char* filename) if (z == OKAY) { lua_pushcclosure(L, chunk_wrapper, 2); } - else { + else if (z == LUA_YIELD) { lua_pushstring(L, "cannot open "); lua_pushstring(L, filename); lua_pushstring(L, ": No such file or directory"); diff --git a/src/host/premake.c b/src/host/premake.c index 51f7f32b..ecba9fa7 100644 --- a/src/host/premake.c +++ b/src/host/premake.c @@ -332,11 +332,5 @@ int premake_load_embedded_script(lua_State* L, const char* filename) lua_concat(L, 2); /* Load the chunk */ - i = luaL_loadbuffer(L, chunk, strlen(chunk), filename); - if (i != OKAY) { - lua_pop(L, 1); - printf("Failed to load embedded script '%s': %s\n", filename, lua_tostring(L, -1)); - } - - return i; + return luaL_loadbuffer(L, chunk, strlen(chunk), filename); }