static bool luaA_loadrc(const char *confpath, bool run) { lua_State *L = globalconf_get_lua_State(); if(!luaL_loadfile(L, confpath)) { if(run) { /* Set the conffile right now so it can be used inside the * configuration file. */ conffile = a_strdup(confpath); /* Move error handling function before function */ lua_pushcfunction(L, luaA_dofunction_on_error); lua_insert(L, -2); if(lua_pcall(L, 0, LUA_MULTRET, -2)) { const char *err = lua_tostring(L, -1); luaA_startup_error(err); fprintf(stderr, "%s\n", err); /* An error happened, so reset this. */ conffile = NULL; } else return true; } else { lua_pop(L, 1); return true; } } else { const char *err = lua_tostring(L, -1); luaA_startup_error(err); fprintf(stderr, "%s\n", err); } return false; }
static bool luaA_loadrc(const char *confpath, bool run) { if(!luaL_loadfile(globalconf.L, confpath)) { if(run) { /* Set the conffile right now so it can be used inside the * configuration file. */ globalconf.conffile = a_strdup(confpath); if(lua_pcall(globalconf.L, 0, LUA_MULTRET, 0)) { const char *err = lua_tostring(globalconf.L, -1); luaA_startup_error(err); fprintf(stderr, "%s\n", err); /* An error happened, so reset this. */ globalconf.conffile = NULL; } else return true; } else { lua_pop(globalconf.L, 1); return true; } } else { const char *err = lua_tostring(globalconf.L, -1); luaA_startup_error(err); fprintf(stderr, "%s\n", err); } return false; }