sharklinux / shark

We're building a better performance management system
http://www.sharkly.io
GNU Lesser General Public License v2.1
79 stars 13 forks source link

An issue in main function in core/shark.c #22

Open NanXiao opened 9 years ago

NanXiao commented 9 years ago

Hi Shark,

I am reading the main function in core/shark.c, and have some confusions:

Line 320 ~ 332

 {
    if((ret = luaL_loadfile(ls, argv[script]))) {
    ret = lua_report(ls, ret);
    goto out;
}

base = lua_gettop(ls) - 1;
lua_pushcfunction(ls, lua_traceback);
lua_insert(ls, base);

if (lua_pcall(ls, 0, 0, base)) {
    fprintf(stderr, "%s\n", lua_tostring(ls, -1));
    exit(EXIT_FAILURE);
}

}

Before executing "lua_pcall(ls, 0, 0, base)", the Lua stack is like this:

script                               (-1)
Last parameter                 (-2)
lua_traceback                  (-3)
penultimate parameter      (-4)

So the "lua_pcall(ls, 0, 0, base)" can't process any parameters, right?

If you have time. please check whether it is right, thanks!

Best Regards Nan Xiao