From d99c815fccdfa98b207a611488e5b5cd4f2897e9 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 12 Jan 2016 20:07:55 +0000 Subject: Adding named chunks also for the embedded scripts. This uses an array that runs in parallel with the builtin_scripts. --HG-- branch : WDS-build --- src/host/premake.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/host/premake.c b/src/host/premake.c index df4d004..e096bbc 100755 --- a/src/host/premake.c +++ b/src/host/premake.c @@ -363,7 +363,7 @@ static int load_file_scripts(lua_State* L) extern const char* builtin_script_fnames[]; #define luaL_dobuffer(L, s, n) \ - (luaL_loadbuffer(L, s, strlen(s), n) || lua_pcall(L, 0, LUA_MULTRET, 0)) + (luaL_loadbuffer(L, s, strlen(s), n) || lua_pcall(L, 0, LUA_MULTRET, 0)) /** * When running in release mode, the scripts are loaded from a static data @@ -375,16 +375,27 @@ static int load_builtin_scripts(lua_State* L) int i; for (i = 0; builtin_scripts[i]; ++i) { - if (luaL_dostring(L, builtin_scripts[i]) != OKAY) + if (builtin_script_fnames[i]) { - printf(ERROR_MESSAGE, lua_tostring(L, -1)); - return !OKAY; + if (luaL_dobuffer(L, builtin_scripts[i], builtin_script_fnames[i]) != OKAY) + { + printf(ERROR_MESSAGE, lua_tostring(L, -1)); + return !OKAY; + } + } + else + { + if (luaL_dostring(L, builtin_scripts[i]) != OKAY) + { + printf(ERROR_MESSAGE, lua_tostring(L, -1)); + return !OKAY; + } } } - /* in release mode, also show full traceback on all errors */ - lua_getglobal(L, "debug"); - lua_getfield(L, -1, "traceback"); + /* in release mode, also show full traceback on all errors */ + lua_getglobal(L, "debug"); + lua_getfield(L, -1, "traceback"); /* hand off control to the scripts */ lua_getglobal(L, "_premake_main"); -- cgit v1.2.3