sdl2-compat: Quirks need to persist past SDL_Quit()

From 6981f82329870e15833045e0bb8b607408290aae Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 15 Sep 2024 11:51:42 -0700
Subject: [PATCH] Quirks need to persist past SDL_Quit()

---
 src/sdl2_compat.c | 12 ++++++------
 src/sdl3_syms.h   |  3 ---
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index ffb1a56..43d9909 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -530,15 +530,15 @@ SDL2Compat_ApplyQuirks(SDL_bool force_x11)
 
     /* if you change this, update also SDL2_to_SDL3_hint() */
     for (i = 0; i < SDL_arraysize(renamed_hints); ++i) {
-        old_env = SDL3_GetEnvironmentVariable(SDL3_GetEnvironment(), renamed_hints[i].old_hint);
+        old_env = SDL3_getenv(renamed_hints[i].old_hint);
         if (old_env) {
-            SDL3_SetEnvironmentVariable(SDL3_GetEnvironment(), renamed_hints[i].new_hint, old_env, SDL_TRUE);
+            SDL3_setenv_unsafe(renamed_hints[i].new_hint, old_env, 1);
         }
     }
 
     #ifdef __linux__
     if (force_x11) {
-        const char *videodriver_env = SDL3_GetEnvironmentVariable(SDL3_GetEnvironment(), "SDL_VIDEODRIVER");
+        const char *videodriver_env = SDL3_getenv("SDL_VIDEODRIVER");
         if (videodriver_env && (SDL3_strcmp(videodriver_env, "x11") != 0)) {
             if (WantDebugLogging) {
                 SDL3_Log("This app looks like it requires X11, but the SDL_VIDEODRIVER environment variable is set to \"%s\". If you have issues, try setting SDL_VIDEODRIVER=x11", videodriver_env);
@@ -547,7 +547,7 @@ SDL2Compat_ApplyQuirks(SDL_bool force_x11)
             if (WantDebugLogging) {
                 SDL3_Log("sdl2-compat: We are forcing this app to use X11, because it probably talks to an X server directly, outside of SDL. If possible, this app should be fixed, to be compatible with Wayland, etc.");
             }
-            SDL3_SetEnvironmentVariable(SDL3_GetEnvironment(), "SDL_VIDEO_DRIVER", "x11", SDL_TRUE);
+            SDL3_setenv_unsafe("SDL_VIDEO_DRIVER", "x11", 1);
         }
     }
     #endif
@@ -557,12 +557,12 @@ SDL2Compat_ApplyQuirks(SDL_bool force_x11)
     }
     for (i = 0; i < SDL_arraysize(quirks); i++) {
         if (!SDL3_strcmp(exe_name, quirks[i].exe_name)) {
-            const char *var = SDL3_GetEnvironmentVariable(SDL3_GetEnvironment(), quirks[i].hint_name);
+            const char *var = SDL3_getenv(quirks[i].hint_name);
             if (!var) {
                 if (WantDebugLogging) {
                     SDL3_Log("Applying compatibility quirk %s=\"%s\" for \"%s\"", quirks[i].hint_name, quirks[i].hint_value, exe_name);
                 }
-                SDL3_SetEnvironmentVariable(SDL3_GetEnvironment(), quirks[i].hint_name, quirks[i].hint_value, SDL_TRUE);
+                SDL3_setenv_unsafe(quirks[i].hint_name, quirks[i].hint_value, 1);
             } else {
                 if (WantDebugLogging) {
                     SDL3_Log("Not applying compatibility quirk %s=\"%s\" for \"%s\" due to environment variable override (\"%s\")\n",
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index d974d4d..6531b5d 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -274,8 +274,6 @@ SDL3_SYM(SDL_DisplayID,GetDisplayForWindow,(SDL_Window *a),(a),return)
 SDL3_SYM(const char*,GetDisplayName,(SDL_DisplayID a),(a),return)
 SDL3_SYM(SDL_bool,GetDisplayUsableBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
 SDL3_SYM(SDL_DisplayID*,GetDisplays,(int *a),(a),return)
-SDL3_SYM(SDL_Environment*,GetEnvironment,(void),(),return)
-SDL3_SYM(const char*,GetEnvironmentVariable,(SDL_Environment *a, const char *b),(a,b),return)
 SDL3_SYM_PASSTHROUGH(const char*,GetError,(void),(),return)
 SDL3_SYM(SDL_bool,GetEventFilter,(SDL_EventFilter *a, void **b),(a,b),)
 SDL3_SYM(float,GetFloatProperty,(SDL_PropertiesID a, const char *b, float c),(a,b,c),return)
@@ -608,7 +606,6 @@ SDL3_SYM(SDL_bool,SetAudioStreamPutCallback,(SDL_AudioStream *a, SDL_AudioStream
 SDL3_SYM(SDL_bool,SetBooleanProperty,(SDL_PropertiesID a, const char *b, SDL_bool c),(a,b,c),return)
 SDL3_SYM_PASSTHROUGH_RETCODE(SDL_bool,SetClipboardText,(const char *a),(a),return)
 SDL3_SYM(SDL_bool,SetCursor,(SDL_Cursor *a),(a),return)
-SDL3_SYM(SDL_bool,SetEnvironmentVariable,(SDL_Environment *a, const char *b, const char *c, SDL_bool d),(a,b,c,d),return)
 SDL3_SYM(void,SetEventEnabled,(Uint32 a, SDL_bool b),(a,b),)
 SDL3_SYM(void,SetEventFilter,(SDL_EventFilter a, void *b),(a,b),)
 SDL3_SYM(void,SetGamepadEventsEnabled,(SDL_bool a),(a),)