diff --git a/src/gettext.cpp b/src/gettext.cpp index 49eb0981a..68b6f728a 100644 --- a/src/gettext.cpp +++ b/src/gettext.cpp @@ -20,15 +20,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include -#include #include "gettext.h" #include "util/string.h" +#include "porting.h" #include "log.h" -#ifdef _WIN32 -#define setenv(n,v,o) _putenv_s(n,v) -#endif - #if USE_GETTEXT && defined(_MSC_VER) #include #include diff --git a/src/porting.h b/src/porting.h index cd710d191..ad707cebe 100644 --- a/src/porting.h +++ b/src/porting.h @@ -23,6 +23,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once +#if (defined(__linux__) || defined(__GNU__)) && !defined(_GNU_SOURCE) + #define _GNU_SOURCE +#endif + #include #include #include "irrlicht.h" @@ -43,12 +47,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #define sleep_ms(x) Sleep(x) #define sleep_us(x) Sleep((x)/1000) + + #define setenv(n,v,o) _putenv_s(n,v) + #define unsetenv(n) _putenv_s(n,"") #else #include - - #if (defined(__linux__) || defined(__GNU__)) && !defined(_GNU_SOURCE) - #define _GNU_SOURCE - #endif + #include // setenv #define sleep_ms(x) usleep((x)*1000) #define sleep_us(x) usleep(x) diff --git a/src/unittest/test_servermodmanager.cpp b/src/unittest/test_servermodmanager.cpp index e9f10b2c1..30b02f184 100644 --- a/src/unittest/test_servermodmanager.cpp +++ b/src/unittest/test_servermodmanager.cpp @@ -67,15 +67,7 @@ void TestServerModManager::runTests(IGameDef *gamedef) ofs2 << "-- intentionally empty\n"; } -#ifdef WIN32 - { - std::string mod_path("MINETEST_MOD_PATH="); - mod_path.append(test_mods); - _putenv(mod_path.c_str()); - } -#else setenv("MINETEST_MOD_PATH", test_mods.c_str(), 1); -#endif m_worlddir = getTestTempDirectory().append(DIR_DELIM "world"); fs::CreateDir(m_worlddir);