From 07c9c4c7eb3a8a04a2edee501cba90648fb7dd18 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 17 Sep 2014 20:46:47 +0200 Subject: [PATCH] luainstance: Fix default parameter for config file getXXX functions - Revert commit 'Fix default parameter for config file setXXX functions' Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b2945b1a1ae946788a6ea50749bfde81062dbf3a Author: Michael Liebmann Date: 2014-09-17 (Wed, 17 Sep 2014) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 95a0d2ba0..e37527a25 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -2385,10 +2385,13 @@ int CLuaInstance::LuaConfigFileGetString(lua_State *L) { CLuaConfigFile *c = LuaConfigFileCheck(L, 1); if (!c) return 0; + int numargs = lua_gettop(L); std::string ret; const char *key = luaL_checkstring(L, 2); - const char *defaultVal = luaL_checkstring(L, 3); + const char *defaultVal = ""; + if (numargs > 2) + defaultVal = luaL_checkstring(L, 3); ret = c->c->getString(key, defaultVal); lua_pushstring(L, ret.c_str()); return 1; @@ -2398,12 +2401,9 @@ int CLuaInstance::LuaConfigFileSetString(lua_State *L) { CLuaConfigFile *c = LuaConfigFileCheck(L, 1); if (!c) return 0; - int numargs = lua_gettop(L); const char *key = luaL_checkstring(L, 2); - const char *val = ""; - if (numargs > 2) - val = luaL_checkstring(L, 3); + const char *val = luaL_checkstring(L, 3); c->c->setString(key, val); return 0; } @@ -2412,10 +2412,13 @@ int CLuaInstance::LuaConfigFileGetInt32(lua_State *L) { CLuaConfigFile *c = LuaConfigFileCheck(L, 1); if (!c) return 0; + int numargs = lua_gettop(L); int ret; const char *key = luaL_checkstring(L, 2); - int defaultVal = luaL_checkint(L, 3); + int defaultVal = 0; + if (numargs > 2) + defaultVal = luaL_checkint(L, 3); ret = c->c->getInt32(key, defaultVal); lua_pushinteger(L, ret); return 1; @@ -2425,12 +2428,9 @@ int CLuaInstance::LuaConfigFileSetInt32(lua_State *L) { CLuaConfigFile *c = LuaConfigFileCheck(L, 1); if (!c) return 0; - int numargs = lua_gettop(L); const char *key = luaL_checkstring(L, 2); - int val = 0; - if (numargs > 2) - val = luaL_checkint(L, 3); + int val = luaL_checkint(L, 3); c->c->setInt32(key, val); return 0; } @@ -2439,10 +2439,13 @@ int CLuaInstance::LuaConfigFileGetBool(lua_State *L) { CLuaConfigFile *c = LuaConfigFileCheck(L, 1); if (!c) return 0; + int numargs = lua_gettop(L); bool ret; const char *key = luaL_checkstring(L, 2); - bool defaultVal = _luaL_checkbool(L, 3); + bool defaultVal = false; + if (numargs > 2) + defaultVal = _luaL_checkbool(L, 3); ret = c->c->getBool(key, defaultVal); lua_pushboolean(L, ret); return 1; @@ -2452,12 +2455,9 @@ int CLuaInstance::LuaConfigFileSetBool(lua_State *L) { CLuaConfigFile *c = LuaConfigFileCheck(L, 1); if (!c) return 0; - int numargs = lua_gettop(L); const char *key = luaL_checkstring(L, 2); - bool val = false; - if (numargs > 2) - val = _luaL_checkbool(L, 3); + bool val = _luaL_checkbool(L, 3); c->c->setBool(key, val); return 0; }