From 3f1221a7f99b927ed12f595f8627937e9538c3ed Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 26 Aug 2013 00:53:14 -0300 Subject: [PATCH] Reverted commit bcb6336 --- src/modules/system/wrap_System.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/modules/system/wrap_System.cpp b/src/modules/system/wrap_System.cpp index c99a84f2f..3048a94dc 100644 --- a/src/modules/system/wrap_System.cpp +++ b/src/modules/system/wrap_System.cpp @@ -57,17 +57,24 @@ int w_getClipboardText(lua_State *L) int w_getPowerInfo(lua_State *L) { int seconds = -1, percent = -1; - const char *statestr; + const char *str; System::PowerState state = instance->getPowerInfo(seconds, percent); - if (!System::getConstant(state, statestr)) - statestr = "unknown"; + if (!System::getConstant(state, str)) + str = "unknown"; - lua_pushstring(L, statestr); + lua_pushstring(L, str); - lua_pushinteger(L, percent); - lua_pushinteger(L, seconds); + if (percent >= 0) + lua_pushinteger(L, percent); + else + lua_pushnil(L); + + if (seconds >= 0) + lua_pushinteger(L, seconds); + else + lua_pushnil(L); return 3; }