From 5ce116861971c55b106bf827bff17752b87ba45e Mon Sep 17 00:00:00 2001
From: Cameron Gutman <[EMAIL REDACTED]>
Date: Sat, 15 Feb 2025 15:16:42 -0600
Subject: [PATCH] init: replace usage of SDL3_strrchr() function during init
---
src/sdl2_compat.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 4dc7472..bb921d9 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -282,6 +282,19 @@ static bool SDL2Compat_strequal(const char *a, const char *b)
return true;
}
+/* you can use SDL3_strrchr once we're past startup. */
+static char *SDL2Compat_strrchr(const char *string, int c)
+{
+ const char *bufp = string + SDL2Compat_strlen(string);
+ while (bufp >= string) {
+ if (*bufp == c) {
+ return (char *)bufp;
+ }
+ --bufp;
+ }
+ return NULL;
+}
+
/* log a string using platform-specific code for before SDL3 is fully available. */
static void SDL2Compat_LogAtStartup(const char *str)
{
@@ -548,7 +561,7 @@ SDL2Compat_GetExeName(void)
static char *base_path;
bool use_base_path = true;
OS_GetExeName(path_buf, SDL2COMPAT_MAXPATH, &use_base_path);
- base_path = SDL3_strrchr(path_buf, *DIRSEP);
+ base_path = SDL2Compat_strrchr(path_buf, *DIRSEP);
if (base_path && use_base_path) {
/* We have a '\\' component. */
exename = base_path + 1;