summaryrefslogtreecommitdiffstats
path: root/player/lua.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-01 00:50:59 +0100
committerwm4 <wm4@nowhere>2014-03-01 00:50:59 +0100
commit32d18d77cd3afd49f8d221db50ab8fc23dbdd340 (patch)
tree9ce6dd4e86e7a5788037cc71848cd40ff693cc43 /player/lua.c
parentd706f8181a5c9f135d6167fd1a2b4c1921c08a86 (diff)
downloadmpv-32d18d77cd3afd49f8d221db50ab8fc23dbdd340.tar.bz2
mpv-32d18d77cd3afd49f8d221db50ab8fc23dbdd340.tar.xz
lua: set a proper chunk name for builtin modules
luaL_loadstring(), which was used until now, uses the start of the Lua code itself as chunk name. Since the chunk name shows up even with runtime errors triggered by e.g. Lua code loaded from user scripts, this looks a but ugly. Switch to luaL_loadbuffer(), which is almost the same as luaL_loadstring(), but allows setting a chunk name.
Diffstat (limited to 'player/lua.c')
-rw-r--r--player/lua.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/player/lua.c b/player/lua.c
index 5c1eb03493..67c9fb459f 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -164,7 +164,8 @@ static int load_builtin(lua_State *L)
const char *name = luaL_checkstring(L, 1);
for (int n = 0; builtin_lua_scripts[n][0]; n++) {
if (strcmp(name, builtin_lua_scripts[n][0]) == 0) {
- if (luaL_loadstring(L, builtin_lua_scripts[n][1]))
+ const char *script = builtin_lua_scripts[n][1];
+ if (luaL_loadbuffer(L, script, strlen(script), name))
lua_error(L);
lua_call(L, 0, 1);
return 1;