diff options
author | Oliver Schneider <oliver@assarbad.net> | 2016-01-12 23:07:55 +0300 |
---|---|---|
committer | Oliver Schneider <oliver@assarbad.net> | 2016-01-12 23:07:55 +0300 |
commit | d99c815fccdfa98b207a611488e5b5cd4f2897e9 (patch) | |
tree | 8e4a0e58f1da6f72666a56cc42cbabb272dcd293 | |
parent | 32dbee7029ba110af841e67b0816b747bdf3c0c2 (diff) |
Adding named chunks also for the embedded scripts. This uses an array that runs in parallel with the builtin_scripts.
--HG--
branch : WDS-build
-rwxr-xr-x | src/host/premake.c | 25 |
1 files 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"); |