From 2bb31556caad644db0ce6d1c7dd55fcbca174e0e Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sun, 25 May 2014 00:08:10 -0700 Subject: Fixing a few warnings and errors. --- src/BLua.cc | 31 +++++++++++++++++++++++++++++++ src/LuaHandle.cc | 3 +-- src/LuaTask.cc | 4 ++-- 3 files changed, 34 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/BLua.cc b/src/BLua.cc index 7e3a1d2..d3e50b6 100644 --- a/src/BLua.cc +++ b/src/BLua.cc @@ -1,3 +1,7 @@ +#ifdef _WIN32 +#include +#endif + #include #include #include "BLua.h" @@ -167,12 +171,28 @@ int Balau::LuaStatics::getenv(lua_State * __L) { L.error("Incorrect arguments to function `getenv'"); #ifdef _WIN32 +#ifdef UNICODE + wchar_t wbuffer[BUFSIZ + 1]; + String varStr = L.tostring(1).iconv("UTF-8", "UNICODE"); + if (GetEnvironmentVariable((wchar_t *)varStr.to_charp(), wbuffer, BUFSIZ)) { + char buffer[BUFSIZ + 1]; + const wchar_t * pwbuffer = wbuffer; + mbstate_t mbs; + mbrlen(NULL, 0, &mbs); + memset(buffer, 0, BUFSIZ + 1); + wcsrtombs(buffer, &pwbuffer, BUFSIZ, &mbs); + L.push(buffer); + } else { + L.push(); + } +#else char buffer[BUFSIZ + 1]; if (GetEnvironmentVariable(L.tostring(1).to_charp(), buffer, BUFSIZ)) { L.push(buffer); } else { L.push(); } +#endif #else char * var = ::getenv(L.tostring(1).to_charp()); if (var) { @@ -194,7 +214,13 @@ int Balau::LuaStatics::setenv(lua_State * __L) { } #ifdef _WIN32 +#ifdef UNICODE + String varStr = L.tostring(1).iconv("UTF-8", "UNICODE"); + String valStr = L.tostring(2).iconv("UTF-8", "UNICODE"); + SetEnvironmentVariable((wchar_t *)varStr.to_charp(), (wchar_t *)valStr.to_charp()); +#else SetEnvironmentVariable(L.tostring(1).to_charp(), L.tostring(2).to_charp()); +#endif #else ::setenv(L.tostring(1).to_charp(), L.tostring(2).to_charp(), 1); #endif @@ -210,7 +236,12 @@ int Balau::LuaStatics::unsetenv(lua_State * __L) { L.error("Incorrect arguments to function `unsetenv'"); #ifdef _WIN32 +#ifdef UNICODE + String varStr = L.tostring(1).iconv("UTF-8", "UNICODE"); + SetEnvironmentVariable((wchar_t *)varStr.to_charp(), NULL); +#else SetEnvironmentVariable(L.tostring(1).to_charp(), NULL); +#endif #else ::unsetenv(L.tostring(1).to_charp()); #endif diff --git a/src/LuaHandle.cc b/src/LuaHandle.cc index de9e7e2..67a1496 100644 --- a/src/LuaHandle.cc +++ b/src/LuaHandle.cc @@ -262,7 +262,6 @@ int sLua_IOInput::IOInput_proceed_static(Balau::Lua & L, int n, int caller) { } int sLua_IOInput::IOInput_proceed(Balau::Lua & L, int n, IOInput * obj, int caller) { - int r; Balau::IO h = *obj; switch (caller) { @@ -271,7 +270,7 @@ int sLua_IOInput::IOInput_proceed(Balau::Lua & L, int n, IOInput * obj, int call break; } - return r; + return 0; } void Balau::LuaInputFactory::pushStatics(Balau::Lua & L) { diff --git a/src/LuaTask.cc b/src/LuaTask.cc index c22cb68..0835765 100644 --- a/src/LuaTask.cc +++ b/src/LuaTask.cc @@ -52,7 +52,7 @@ void Balau::LuaMainTask::Do() { try { cell = m_queue.pop(); } - catch (Balau::EAgain & e) { + catch (Balau::EAgain &) { taskSwitch(); } Printer::elog(E_TASK, "LuaMainTask at %p popped %p", this, cell); @@ -81,7 +81,7 @@ void Balau::LuaTask::Do() { else m_cell->run(L); } - catch (EAgain & e) { + catch (EAgain &) { } catch (GeneralException & e) { m_cell->m_exception = new GeneralException(e); -- cgit v1.2.3