summaryrefslogtreecommitdiffstats
path: root/player/lua.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-05-26 23:53:29 +0200
committerwm4 <wm4@nowhere>2014-05-27 00:02:34 +0200
commit799b5e1a5df15d8004ff8030dd8f4e8b2a25e198 (patch)
treec5bdbbd5d8a613fbd81227bb30dd8a565a450fff /player/lua.c
parent9acd263542b7ceae3ad5427a7be3131fb7f9a68c (diff)
downloadmpv-799b5e1a5df15d8004ff8030dd8f4e8b2a25e198.tar.bz2
mpv-799b5e1a5df15d8004ff8030dd8f4e8b2a25e198.tar.xz
lua: slightly nicer diagnostics output
When Lua itself prints errors such as: Error: [string "mp.defaults"]:387: syntax error near 'function' It's unclear why the location is prefixed with "string ". And for some reason, it disappears if you prefix the name with '@'. I suppose this is done for the sake of luaL_loadstring. With the '@' prefix added, the output is now: Error: mp.defaults:387: syntax error near 'function'
Diffstat (limited to 'player/lua.c')
-rw-r--r--player/lua.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/player/lua.c b/player/lua.c
index a37f651857..689be1896b 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -162,10 +162,12 @@ static int load_file(struct script_ctx *ctx, const char *fname)
static int load_builtin(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
+ char dispname[80];
+ snprintf(dispname, sizeof(dispname), "@%s", name);
for (int n = 0; builtin_lua_scripts[n][0]; n++) {
if (strcmp(name, builtin_lua_scripts[n][0]) == 0) {
const char *script = builtin_lua_scripts[n][1];
- if (luaL_loadbuffer(L, script, strlen(script), name))
+ if (luaL_loadbuffer(L, script, strlen(script), dispname))
lua_error(L);
lua_call(L, 0, 1);
return 1;