diff options
author | sfan5 <sfan5@live.de> | 2022-03-23 10:11:03 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-03-23 21:09:53 +0100 |
commit | 84821dbcb6d9e16b8f11da2135208e4f3e66fcd0 (patch) | |
tree | 955d779d786e1e8ac9f355a06c1814248fa4876f /player | |
parent | fcc81cd940dc721773a91301c60755aa11010a86 (diff) | |
download | mpv-84821dbcb6d9e16b8f11da2135208e4f3e66fcd0.tar.bz2 mpv-84821dbcb6d9e16b8f11da2135208e4f3e66fcd0.tar.xz |
lua: use correct chunkname when loading script files
This was brought up in #10007 and it turned out mpv did not follow Lua conventions.
Diffstat (limited to 'player')
-rw-r--r-- | player/lua.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/player/lua.c b/player/lua.c index 64c5d33e6e..a2d4d766d8 100644 --- a/player/lua.c +++ b/player/lua.c @@ -248,13 +248,16 @@ static void load_file(lua_State *L, const char *fname) { struct script_ctx *ctx = get_ctx(L); MP_DBG(ctx, "loading file %s\n", fname); - struct bstr s = stream_read_file(fname, ctx, ctx->mpctx->global, 100000000); + void *tmp = talloc_new(ctx); + // according to Lua manaual chunkname should be '@' plus the filename + char *dispname = talloc_asprintf(tmp, "@%s", fname); + struct bstr s = stream_read_file(fname, tmp, ctx->mpctx->global, 100000000); if (!s.start) luaL_error(L, "Could not read file.\n"); - if (luaL_loadbuffer(L, s.start, s.len, fname)) + if (luaL_loadbuffer(L, s.start, s.len, dispname)) lua_error(L); lua_call(L, 0, 1); - talloc_free(s.start); + talloc_free(tmp); } static int load_builtin(lua_State *L) |