summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-29 21:10:41 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-29 21:10:41 +0300
commitf025e205790527804e2781fd56e99097be27a3a6 (patch)
tree3664620d0c69c80fb8dd4378e503739cfb646ab7
parentb1e1038b7f755138999865af1ffd53047e06b853 (diff)
downloadplus-f025e205790527804e2781fd56e99097be27a3a6.tar.gz
plus-f025e205790527804e2781fd56e99097be27a3a6.tar.bz2
plus-f025e205790527804e2781fd56e99097be27a3a6.tar.xz
plus-f025e205790527804e2781fd56e99097be27a3a6.zip
Replace most putenv to setenv.
-rw-r--r--src/client.cpp20
-rw-r--r--src/client.h2
2 files changed, 16 insertions, 6 deletions
diff --git a/src/client.cpp b/src/client.cpp
index a47b16388..d80943802 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -337,8 +337,8 @@ void Client::gameInit()
#else
if (!lang.empty())
{
- putenv(const_cast<char*>(("LANG=" + lang).c_str()));
- putenv(const_cast<char*>(("LANGUAGE=" + lang).c_str()));
+ setEnv("LANG", lang.c_str());
+ setEnv("LANGUAGE", lang.c_str());
logger->log("set lang: " + lang);
}
logger->log("lang1=%s", getenv("LANG"));
@@ -384,15 +384,15 @@ void Client::gameInit()
#if defined(WIN32) || defined(__APPLE__)
if (config.getBoolValue("centerwindow"))
- putenv("SDL_VIDEO_CENTERED=1");
+ setEnv("SDL_VIDEO_CENTERED", "1");
else
- putenv("SDL_VIDEO_CENTERED=0");
+ setEnv("SDL_VIDEO_CENTERED", "0");
#endif
if (config.getBoolValue("allowscreensaver"))
- putenv(const_cast<char*>("SDL_VIDEO_ALLOW_SCREENSAVER=1"));
+ setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "1");
else
- putenv(const_cast<char*>("SDL_VIDEO_ALLOW_SCREENSAVER=0"));
+ setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "0");
chatLogger = new ChatLogger;
if (mOptions.chatLogDir == "")
@@ -711,6 +711,14 @@ void Client::bindTextDomain(const char *const name, const char *const path)
logger->log("bindtextdomain failed");
}
+void Client::setEnv(const char *const name, const char *const value)
+{
+ if (!name || !value)
+ return;
+ if (setenv(name, value, 1))
+ logger->log("setenv failed: %s=%s", name, value);
+}
+
void Client::testsClear()
{
if (!mOptions.test.empty())
diff --git a/src/client.h b/src/client.h
index d684904af..fb33b4d4c 100644
--- a/src/client.h
+++ b/src/client.h
@@ -354,6 +354,8 @@ private:
static void bindTextDomain(const char *const name, const char *const path);
+ static void setEnv(const char *const name, const char *const value);
+
Options mOptions;
std::string mPackageDir;