diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-09-06 15:27:58 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-09-07 04:02:25 +0000 |
commit | 46e71f9a7c17e6aec5dd9d7c5829ac8bc684d90e (patch) | |
tree | 7434de7482c0eac9ca70f4761b0ba11f5b64d562 /epan | |
parent | a1fac65d8e9135014ff8cb9dfe9841e8b8267efb (diff) |
wslua: fix source argument in debug info for luacov
The source argument should start with a '@', otherwise it is treated as
actual source code instead of a filename. This is needed for luacov. See
https://www.lua.org/manual/5.2/manual.html#lua_Debug
https://github.com/keplerproject/luacov/issues/55
Change-Id: I0a3e2da65fb6b4aaabb9173a07fdea18a788f3e3
Reviewed-on: https://code.wireshark.org/review/29447
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/wslua/init_wslua.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c index caf05626cf..302aa82571 100644 --- a/epan/wslua/init_wslua.c +++ b/epan/wslua/init_wslua.c @@ -524,11 +524,13 @@ static gboolean lua_load_script(const gchar* filename, const gchar* dirname, con lua_settop(L,0); lua_pushcfunction(L,lua_main_error_handler); + /* The source argument should start with with '@' to indicate a file. */ + lua_pushfstring(L, "@%s", filename); #if LUA_VERSION_NUM >= 502 - error = lua_load(L,getF,file,filename,NULL); + error = lua_load(L, getF, file, lua_tostring(L, -1), NULL); #else - error = lua_load(L,getF,file,filename); + error = lua_load(L, getF, file, lua_tostring(L, -1)); #endif switch (error) { @@ -540,23 +542,23 @@ static gboolean lua_load_script(const gchar* filename, const gchar* dirname, con numargs = lua_script_push_args(file_count); } error = lua_pcall(L,numargs,0,1); - fclose(file); - lua_pop(L,1); /* pop the error handler */ - return error ? FALSE : TRUE; - case LUA_ERRSYNTAX: { + break; + + case LUA_ERRSYNTAX: report_failure("Lua: syntax error during precompilation of `%s':\n%s",filename,lua_tostring(L,-1)); - fclose(file); - return FALSE; - } + break; + case LUA_ERRMEM: report_failure("Lua: memory allocation error during precompilation of %s",filename); - fclose(file); - return FALSE; + break; + default: report_failure("Lua: unknown error during precompilation of %s: %d",filename,error); - fclose(file); - return FALSE; + break; } + fclose(file); + lua_pop(L, 2); /* pop the filename and error handler */ + return error == 0; } /* This one is used to load the init.lua scripts, or anything else |