Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/sdl/patches/0006-fix-cs-environ.patch
9898 views
1
diff --git a/thirdparty/sdl/stdlib/SDL_getenv.c b/thirdparty/sdl/stdlib/SDL_getenv.c
2
index b4a19224655..e23f8a0ea0d 100644
3
--- a/thirdparty/sdl/stdlib/SDL_getenv.c
4
+++ b/thirdparty/sdl/stdlib/SDL_getenv.c
5
@@ -50,6 +50,9 @@ extern char **environ;
6
static char **environ;
7
#endif
8
9
+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_FREEBSD)
10
+#include <stdlib.h>
11
+#endif
12
13
struct SDL_Environment
14
{
15
@@ -149,6 +152,9 @@ SDL_Environment *SDL_CreateEnvironment(bool populated)
16
17
const char *SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name)
18
{
19
+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_FREEBSD)
20
+ return getenv(name);
21
+#else
22
const char *result = NULL;
23
24
if (!env) {
25
@@ -168,6 +174,7 @@ const char *SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name)
26
SDL_UnlockMutex(env->lock);
27
28
return result;
29
+#endif
30
}
31
32
typedef struct CountEnvStringsData
33
@@ -246,6 +253,9 @@ char **SDL_GetEnvironmentVariables(SDL_Environment *env)
34
35
bool SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const char *value, bool overwrite)
36
{
37
+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_FREEBSD)
38
+ return setenv(name, value, overwrite);
39
+#else
40
bool result = false;
41
42
if (!env) {
43
@@ -281,10 +291,14 @@ bool SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const ch
44
SDL_UnlockMutex(env->lock);
45
46
return result;
47
+#endif
48
}
49
50
bool SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name)
51
{
52
+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_FREEBSD)
53
+ return unsetenv(name);
54
+#else
55
bool result = false;
56
57
if (!env) {
58
@@ -305,6 +319,7 @@ bool SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name)
59
SDL_UnlockMutex(env->lock);
60
61
return result;
62
+#endif
63
}
64
65
void SDL_DestroyEnvironment(SDL_Environment *env)
66
67