diff --git a/buildaux/txt2cstr.cpp b/buildaux/txt2cstr.cpp index 0cf79219..95f96fc5 100644 --- a/buildaux/txt2cstr.cpp +++ b/buildaux/txt2cstr.cpp @@ -42,7 +42,7 @@ struct encoder } i++; } - output << out.str() << std::endl; + output << out.str(); return i; } size_t operator()() diff --git a/src/lua/Makefile b/src/lua/Makefile index d666be8e..d636ee3a 100644 --- a/src/lua/Makefile +++ b/src/lua/Makefile @@ -7,6 +7,7 @@ __all__.files: $(OBJECTS) echo >__all__.ldflags sysrc.cpp: sysrc.lua + luac -p $< ../../buildaux/txt2cstr.exe lua_sysrc_script $< >$@ sysrc.cpp.dep: sysrc.cpp diff --git a/src/lua/lua.cpp b/src/lua/lua.cpp index b57be75f..90dcd5ce 100644 --- a/src/lua/lua.cpp +++ b/src/lua/lua.cpp @@ -124,6 +124,8 @@ namespace #define TEMPORARY "LUAINTERP_INTERNAL_COMMAND_TEMPORARY" + const char* eval_sysrc_lua = "local fn = loadstring(" TEMPORARY ", \"\"); if fn then fn(); else " + "print2(\"Parse error in sysrc.lua script\"); end;"; const char* eval_lua_lua = "local fn = loadstring(" TEMPORARY "); if fn then fn(); else print(" "\"Parse error in Lua statement\"); end;"; const char* run_lua_lua = "dofile(" TEMPORARY ");"; @@ -245,7 +247,10 @@ namespace void run_sysrc_lua(lua::state& L) { - do_eval_lua(L, lua_sysrc_script); + L.pushstring(lua_sysrc_script); + L.setglobal(TEMPORARY); + luareader_fragment = eval_sysrc_lua; + run_lua_fragment(L); } void run_synchronous_paint(struct lua_render_context* ctx)