From: tcely Date: Tue, 1 Aug 2017 00:58:05 +0000 (-0400) Subject: Add "PREFIX-" when checking for isEmpty X-Git-Tag: dnsdist-1.4.0-rc3~42^2~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96097f3552940ff863f63afc5f3a9e80bd7e6ffc;p=thirdparty%2Fpdns.git Add "PREFIX-" when checking for isEmpty This appears to have been a hack that got out-of-sync. Adding a proper isEmpty() to the API is probably a better approach. --- diff --git a/modules/luabackend/lua_functions.cc b/modules/luabackend/lua_functions.cc index c33ba5c031..2d48cfb3d0 100644 --- a/modules/luabackend/lua_functions.cc +++ b/modules/luabackend/lua_functions.cc @@ -91,7 +91,7 @@ int l_arg_get (lua_State *lua) { string a = lua_tostring(lua, 1); - if (::arg().isEmpty(a)) + if (lb->my_isEmpty(a)) lua_pushnil(lua); else lua_pushstring(lua, lb->my_getArg(a).c_str()); @@ -109,7 +109,7 @@ int l_arg_mustdo (lua_State *lua) { string a = lua_tostring(lua, 1); - if (::arg().isEmpty(a)) + if (lb->my_isEmpty(a)) lua_pushnil(lua); else lua_pushboolean(lua, lb->my_mustDo(a)); diff --git a/modules/luabackend/luabackend.hh b/modules/luabackend/luabackend.hh index 308c194eb7..9f335db5f0 100644 --- a/modules/luabackend/luabackend.hh +++ b/modules/luabackend/luabackend.hh @@ -30,6 +30,7 @@ #include using std::string; +#define LUABACKEND_PREFIX "lua" class LUAException { public: @@ -107,6 +108,7 @@ public: //private.cc string my_getArg(string a); bool my_mustDo(string a); + bool my_isEmpty(string a); private: diff --git a/modules/luabackend/minimal.cc b/modules/luabackend/minimal.cc index cf3545ee80..29fab4d83e 100644 --- a/modules/luabackend/minimal.cc +++ b/modules/luabackend/minimal.cc @@ -32,7 +32,7 @@ LUABackend::LUABackend(const string &suffix) { - setArgPrefix("lua"+suffix); + setArgPrefix(LUABACKEND_PREFIX+suffix); try { diff --git a/modules/luabackend/private.cc b/modules/luabackend/private.cc index 78b2b5427a..a23e5d20c6 100644 --- a/modules/luabackend/private.cc +++ b/modules/luabackend/private.cc @@ -36,6 +36,10 @@ bool LUABackend::my_mustDo(string a) { return mustDo(a); } +bool LUABackend::my_isEmpty(string a) { + return ::arg().isEmpty(LUABACKEND_PREFIX+"-"+a); +} + bool LUABackend::domaininfo_from_table(DomainInfo *di) { di->backend = NULL; diff --git a/modules/luabackend/reload.cc b/modules/luabackend/reload.cc index 2bc2696ac7..18288f5f5c 100644 --- a/modules/luabackend/reload.cc +++ b/modules/luabackend/reload.cc @@ -41,7 +41,7 @@ void LUABackend::get_lua_function(lua_State *lua, const char *name, int *functio f.append(name); string arg = ""; - if (!::arg().isEmpty(f)) + if (!::arg().isEmpty(LUABACKEND_PREFIX+"-"+f)) arg = getArg(f); lua_getglobal(lua, arg == "" ? name : arg.c_str());