From b98ea6f69b812788c09e87bbe10efb9aff1f318a Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Sat, 25 Jul 2026 11:24:34 -0400 Subject: [PATCH 1/2] strcasecmp compatability thing configure --- compat/configure.sh | 11 ++++++++ src/android/main.c | 2 +- src/audio/miniaudio/ma_audio_system.c | 2 +- src/audio/openal/al_audio_system.c | 2 +- src/audio/ps2/ps2_audio_system.c | 2 +- src/audio/web/web_audio_system.c | 2 +- src/binary_reader.c | 2 +- src/binary_utils.h | 2 +- src/data_win.c | 2 +- src/data_win.h | 2 +- src/data_win_print.c | 2 +- src/desktop/backends/glfw3.c | 2 +- src/desktop/backends/sdl1.c | 2 +- src/desktop/main.c | 16 +---------- src/event_table.c | 2 +- src/gl/gl_renderer.c | 2 +- src/gl_common/gl_common.c | 2 +- src/gl_legacy/gl_legacy_renderer.c | 2 +- src/gml_array.c | 2 +- src/image/image_decoder.c | 2 +- src/ini.c | 2 +- src/input_recording.c | 2 +- src/instance.c | 2 +- src/int_int_hashmap.c | 2 +- src/int_rvalue_hashmap.c | 2 +- src/json_reader.c | 2 +- src/json_writer.c | 2 +- src/matrix_math.h | 2 +- src/noop_file_system.c | 2 +- src/overlay_file_system.c | 2 +- src/profiler.c | 2 +- src/ps2/debug_font_renderer.c | 2 +- src/ps2/gs_renderer.c | 2 +- src/ps2/ps2_file_system.c | 2 +- src/ps2/ps2_gamepad.c | 2 +- src/ps2/ps2_utils.c | 2 +- src/ps3/main.c | 2 +- src/ps3/ps3_overlay.c | 2 +- src/ps3/ps3_textures.c | 2 +- src/runner.c | 2 +- src/runner_gamepad.c | 2 +- src/runner_keyboard.c | 2 +- src/runner_mouse.c | 2 +- src/rvalue.h | 2 +- src/string_builder.c | 2 +- src/string_compat.h | 38 +++++++++++++++++++++++++++ src/text_utils.h | 2 +- src/utils.h | 2 +- src/vm.c | 2 +- src/vm_builtins.c | 2 +- src/web-meta/main.c | 2 +- src/web/main.c | 2 +- 52 files changed, 99 insertions(+), 64 deletions(-) create mode 100644 src/string_compat.h diff --git a/compat/configure.sh b/compat/configure.sh index cc7145ddb..cdcef5014 100644 --- a/compat/configure.sh +++ b/compat/configure.sh @@ -408,6 +408,17 @@ if ! check 'for strtok_r'; then define 'NO_STRTOK_R' fi +printf '%s' "\ +#include +int main(void){ + return strcasecmp(\"\", \"\"); +} +" > tmp/test.c + +if ! check 'for strcasecmp'; then + define 'NO_STRCASECMP' +fi + printf '%s' "\ #include int main(int argc,char *argv[]){ diff --git a/src/android/main.c b/src/android/main.c index 4b5caa293..ec44c2ae7 100644 --- a/src/android/main.c +++ b/src/android/main.c @@ -1,7 +1,7 @@ #include #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include #include #include diff --git a/src/audio/miniaudio/ma_audio_system.c b/src/audio/miniaudio/ma_audio_system.c index 07522dfd6..3a71dc230 100644 --- a/src/audio/miniaudio/ma_audio_system.c +++ b/src/audio/miniaudio/ma_audio_system.c @@ -24,7 +24,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "stb_ds.h" // ===[ Helpers ]=== diff --git a/src/audio/openal/al_audio_system.c b/src/audio/openal/al_audio_system.c index 70953259b..228adf4e3 100644 --- a/src/audio/openal/al_audio_system.c +++ b/src/audio/openal/al_audio_system.c @@ -12,7 +12,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "stb_ds.h" // ===[ Helpers ]=== diff --git a/src/audio/ps2/ps2_audio_system.c b/src/audio/ps2/ps2_audio_system.c index 10a615a04..d1cc6249c 100644 --- a/src/audio/ps2/ps2_audio_system.c +++ b/src/audio/ps2/ps2_audio_system.c @@ -4,7 +4,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include #include diff --git a/src/audio/web/web_audio_system.c b/src/audio/web/web_audio_system.c index cb14f42d1..e9741e8a5 100644 --- a/src/audio/web/web_audio_system.c +++ b/src/audio/web/web_audio_system.c @@ -8,7 +8,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "stb_ds.h" // ===[ Helpers ]=== diff --git a/src/binary_reader.c b/src/binary_reader.c index 6490c0884..1810141c1 100644 --- a/src/binary_reader.c +++ b/src/binary_reader.c @@ -3,7 +3,7 @@ #include "utils.h" #include -#include +#include "string_compat.h" BinaryReader BinaryReader_create(FILE* file, size_t fileSize) { BinaryReader br = {0}; diff --git a/src/binary_utils.h b/src/binary_utils.h index 7e071f168..7d1373d6c 100644 --- a/src/binary_utils.h +++ b/src/binary_utils.h @@ -4,7 +4,7 @@ #include "common.h" #include #include -#include +#include "string_compat.h" // Binary reads/writes from a raw byte buffer. // When IS_BIG_ENDIAN is defined, reads are byte-swapped to interpret serialized little-endian data. diff --git a/src/data_win.c b/src/data_win.c index a8c995186..86cd1f743 100644 --- a/src/data_win.c +++ b/src/data_win.c @@ -4,7 +4,7 @@ #include #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "math_compat.h" #include "stb_ds.h" diff --git a/src/data_win.h b/src/data_win.h index c38f784eb..1717f3bf6 100644 --- a/src/data_win.h +++ b/src/data_win.h @@ -6,7 +6,7 @@ #include #include #include "stdio_compat.h" -#include +#include "string_compat.h" #include "utils.h" diff --git a/src/data_win_print.c b/src/data_win_print.c index 768b61a07..b8d44aad8 100644 --- a/src/data_win_print.c +++ b/src/data_win_print.c @@ -1,7 +1,7 @@ #include "data_win.h" #include "stdio_compat.h" -#include +#include "string_compat.h" #include "utils.h" diff --git a/src/desktop/backends/glfw3.c b/src/desktop/backends/glfw3.c index 6d85924d8..a2ce53517 100644 --- a/src/desktop/backends/glfw3.c +++ b/src/desktop/backends/glfw3.c @@ -1,4 +1,4 @@ -#include +#include "string_compat.h" #include "stdio_compat.h" #include #include "math_compat.h" diff --git a/src/desktop/backends/sdl1.c b/src/desktop/backends/sdl1.c index 766cc0c8d..c008c7b9a 100644 --- a/src/desktop/backends/sdl1.c +++ b/src/desktop/backends/sdl1.c @@ -1,5 +1,5 @@ #include -#include +#include "string_compat.h" #include "stdio_compat.h" #include #include diff --git a/src/desktop/main.c b/src/desktop/main.c index 01f7828e5..d29308795 100644 --- a/src/desktop/main.c +++ b/src/desktop/main.c @@ -7,7 +7,7 @@ #include #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include #include #ifdef _WIN32 @@ -345,20 +345,6 @@ static void resolveWindowSize(const CommandLineArgs* args, uint32_t gen8Width, u } } -#ifdef NO_STRTOK_R - -static char *strtok_r(char *s, const char *sep, char **p) { - if (!s && !(s = *p)) return NULL; - s += strspn(s, sep); - if (!*s) return *p = 0; - *p = s + strcspn(s, sep); - if (**p) *(*p)++ = 0; - else *p = 0; - return s; -} - -#endif - // Extracts the Runner arguments from a string, returning the values on stb_ds array // The "Runner arguments" is used for the "--game-args" and for the game_change GML function // Returns the modified array diff --git a/src/event_table.c b/src/event_table.c index b3ae4e499..04066a871 100644 --- a/src/event_table.c +++ b/src/event_table.c @@ -2,7 +2,7 @@ #include "utils.h" #include "stdio_compat.h" #include -#include +#include "string_compat.h" // ===[ EventSlotMap ]=== diff --git a/src/gl/gl_renderer.c b/src/gl/gl_renderer.c index 48b0b4480..3ee52a901 100644 --- a/src/gl/gl_renderer.c +++ b/src/gl/gl_renderer.c @@ -9,7 +9,7 @@ #endif #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "math_compat.h" #include "stb_image.h" diff --git a/src/gl_common/gl_common.c b/src/gl_common/gl_common.c index a13b4e52e..e774174c2 100644 --- a/src/gl_common/gl_common.c +++ b/src/gl_common/gl_common.c @@ -2,7 +2,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "runner.h" #include "utils.h" diff --git a/src/gl_legacy/gl_legacy_renderer.c b/src/gl_legacy/gl_legacy_renderer.c index 26ba2c531..62cd1d3b9 100644 --- a/src/gl_legacy/gl_legacy_renderer.c +++ b/src/gl_legacy/gl_legacy_renderer.c @@ -35,7 +35,7 @@ extern GLint gPalettedUPaletteVLoc; #endif #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "math_compat.h" // Next power-of-two, used for FBO texture dimensions on older GPUs (Intel 82865G etc.) diff --git a/src/gml_array.c b/src/gml_array.c index 555e0d66d..1c3272f4a 100644 --- a/src/gml_array.c +++ b/src/gml_array.c @@ -3,7 +3,7 @@ #include "utils.h" #include "stdio_compat.h" #include -#include +#include "string_compat.h" static void ensureLegacyRowCapacity(GMLArray* arr, int32_t minRows) { require(arr->type == GML_LEGACY_ARRAY); diff --git a/src/image/image_decoder.c b/src/image/image_decoder.c index 3956a4955..5ae40d050 100644 --- a/src/image/image_decoder.c +++ b/src/image/image_decoder.c @@ -2,7 +2,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include #include "stb_image.h" diff --git a/src/ini.c b/src/ini.c index b3d14ec8e..7787726ca 100644 --- a/src/ini.c +++ b/src/ini.c @@ -3,7 +3,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "text_utils.h" diff --git a/src/input_recording.c b/src/input_recording.c index 50289ef4e..55146349d 100644 --- a/src/input_recording.c +++ b/src/input_recording.c @@ -6,7 +6,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "stb_ds.h" diff --git a/src/instance.c b/src/instance.c index 2fc8d4e63..871d3726f 100644 --- a/src/instance.c +++ b/src/instance.c @@ -1,7 +1,7 @@ #include "instance.h" #include -#include +#include "string_compat.h" #include "math_compat.h" #include "stb_ds.h" diff --git a/src/int_int_hashmap.c b/src/int_int_hashmap.c index ded85ff6f..06331e251 100644 --- a/src/int_int_hashmap.c +++ b/src/int_int_hashmap.c @@ -1,7 +1,7 @@ #include "int_int_hashmap.h" #include -#include +#include "string_compat.h" #define INITIAL_CAPACITY 16 diff --git a/src/int_rvalue_hashmap.c b/src/int_rvalue_hashmap.c index 03ae46a6a..edd429777 100644 --- a/src/int_rvalue_hashmap.c +++ b/src/int_rvalue_hashmap.c @@ -1,7 +1,7 @@ #include "int_rvalue_hashmap.h" #include -#include +#include "string_compat.h" #define INITIAL_CAPACITY 8 diff --git a/src/json_reader.c b/src/json_reader.c index 8d3c51e2d..a1bdb85b3 100644 --- a/src/json_reader.c +++ b/src/json_reader.c @@ -2,7 +2,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "utils.h" diff --git a/src/json_writer.c b/src/json_writer.c index 890176b49..c0854ddcd 100644 --- a/src/json_writer.c +++ b/src/json_writer.c @@ -3,7 +3,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" // ===[ Internal Helpers ]=== diff --git a/src/matrix_math.h b/src/matrix_math.h index be7a38e2a..9f3399836 100644 --- a/src/matrix_math.h +++ b/src/matrix_math.h @@ -2,7 +2,7 @@ #define _BS_MATRIX_MATH_H_ #include "common.h" #include "math_compat.h" -#include +#include "string_compat.h" // ===[ Matrix4f Type ]=== diff --git a/src/noop_file_system.c b/src/noop_file_system.c index ad39ace76..b3e1fe21c 100644 --- a/src/noop_file_system.c +++ b/src/noop_file_system.c @@ -2,7 +2,7 @@ #include "utils.h" #include -#include +#include "string_compat.h" #include "stb_ds.h" diff --git a/src/overlay_file_system.c b/src/overlay_file_system.c index ee2621d52..7e0e89b6b 100644 --- a/src/overlay_file_system.c +++ b/src/overlay_file_system.c @@ -4,7 +4,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include #include diff --git a/src/profiler.c b/src/profiler.c index 5a26c83b6..9cf0df710 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -1,7 +1,7 @@ #include "profiler.h" #include -#include +#include "string_compat.h" #include "stdio_compat.h" #include "utils.h" diff --git a/src/ps2/debug_font_renderer.c b/src/ps2/debug_font_renderer.c index e2036596e..225a8cb41 100644 --- a/src/ps2/debug_font_renderer.c +++ b/src/ps2/debug_font_renderer.c @@ -10,7 +10,7 @@ #include #include "stdio_compat.h" #include -#include +#include "string_compat.h" #define DEBUGFONT_LINE_HEIGHT_SCALE 0.80f diff --git a/src/ps2/gs_renderer.c b/src/ps2/gs_renderer.c index 388b5a1ca..13fb2c15d 100644 --- a/src/ps2/gs_renderer.c +++ b/src/ps2/gs_renderer.c @@ -6,7 +6,7 @@ #pragma GCC diagnostic pop #include -#include +#include "string_compat.h" #include "stdio_compat.h" #include #include diff --git a/src/ps2/ps2_file_system.c b/src/ps2/ps2_file_system.c index 9e9cddf0b..09496ac54 100644 --- a/src/ps2/ps2_file_system.c +++ b/src/ps2/ps2_file_system.c @@ -5,7 +5,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include #include "stb_ds.h" diff --git a/src/ps2/ps2_gamepad.c b/src/ps2/ps2_gamepad.c index b7527a0f1..c0c6210b7 100644 --- a/src/ps2/ps2_gamepad.c +++ b/src/ps2/ps2_gamepad.c @@ -3,7 +3,7 @@ #include #include "stdio_compat.h" -#include +#include "string_compat.h" // Track DualShock-mode handshake completion per port so poll() can lazily kick it off if it hasn't run yet. static bool analogModeReady[2] = {false, false}; diff --git a/src/ps2/ps2_utils.c b/src/ps2/ps2_utils.c index 2f0778339..5ffcd1f64 100644 --- a/src/ps2/ps2_utils.c +++ b/src/ps2/ps2_utils.c @@ -1,5 +1,5 @@ #include "stdio_compat.h" -#include +#include "string_compat.h" #include #include #include diff --git a/src/ps3/main.c b/src/ps3/main.c index bb657ba39..693ba648c 100644 --- a/src/ps3/main.c +++ b/src/ps3/main.c @@ -5,7 +5,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include #include diff --git a/src/ps3/ps3_overlay.c b/src/ps3/ps3_overlay.c index fc1c37064..b6a8a1864 100644 --- a/src/ps3/ps3_overlay.c +++ b/src/ps3/ps3_overlay.c @@ -8,7 +8,7 @@ #include #include "stdio_compat.h" #include -#include +#include "string_compat.h" #define OVERLAY_LINE_HEIGHT_SCALE 0.80f #define PROFILER_WINDOW_FRAMES 60 diff --git a/src/ps3/ps3_textures.c b/src/ps3/ps3_textures.c index 0c33b8e00..ef594c12b 100644 --- a/src/ps3/ps3_textures.c +++ b/src/ps3/ps3_textures.c @@ -2,7 +2,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" // We stream the texture pages on demand from the file instead of loading everything in RAM. diff --git a/src/runner.c b/src/runner.c index f53e27252..c8e2524bc 100644 --- a/src/runner.c +++ b/src/runner.c @@ -10,7 +10,7 @@ #include #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "math_compat.h" #include "debug_overlay.h" diff --git a/src/runner_gamepad.c b/src/runner_gamepad.c index 99bb795f0..afb4047d7 100644 --- a/src/runner_gamepad.c +++ b/src/runner_gamepad.c @@ -2,7 +2,7 @@ #include "utils.h" #include -#include +#include "string_compat.h" #include "math_compat.h" //DELTARUNE HACK diff --git a/src/runner_keyboard.c b/src/runner_keyboard.c index 646414667..b8e5a0c87 100644 --- a/src/runner_keyboard.c +++ b/src/runner_keyboard.c @@ -2,7 +2,7 @@ #include "utils.h" #include -#include +#include "string_compat.h" static bool isValidKey(int32_t key) { return key >= 0 && GML_KEY_COUNT > key; diff --git a/src/runner_mouse.c b/src/runner_mouse.c index 973d177ab..4a10a3560 100644 --- a/src/runner_mouse.c +++ b/src/runner_mouse.c @@ -4,7 +4,7 @@ #include #include "stdio_compat.h" #include -#include +#include "string_compat.h" static bool isValidButtonVirtual(int32_t button) { return button >= -1 && GML_MOUSE_BUTTONS > button; diff --git a/src/rvalue.h b/src/rvalue.h index c76307063..20b5a5093 100644 --- a/src/rvalue.h +++ b/src/rvalue.h @@ -4,7 +4,7 @@ #include "common.h" #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "real_type.h" #include "stb_ds.h" diff --git a/src/string_builder.c b/src/string_builder.c index 26a0c6ab8..ffdb44de1 100644 --- a/src/string_builder.c +++ b/src/string_builder.c @@ -3,7 +3,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include #define STRING_BUILDER_MIN_CAPACITY 16 diff --git a/src/string_compat.h b/src/string_compat.h new file mode 100644 index 000000000..aca09f67c --- /dev/null +++ b/src/string_compat.h @@ -0,0 +1,38 @@ +#ifndef _BS_STRING_COMPAT_H_ +#define _BS_STRING_COMPAT_H_ + +#include + +#ifdef NO_STRCASECMP + +#include + +static int strcasecmp(const char *_s1, const char *_s2) { + const unsigned char *s1 = (void *)_s1, *s2 = (void *)_s2; + + while (*s1 && *s2) { + if (*s1 != *s2 && tolower(*s1) != tolower(*s2)) + break; + ++s1; + ++s2; + } + return tolower(*s1) - tolower(*s2); +} + +#endif + +#ifdef NO_STRTOK_R + +static char *strtok_r(char *s, const char *sep, char **p) { + if (!s && !(s = *p)) return NULL; + s += strspn(s, sep); + if (!*s) return *p = 0; + *p = s + strcspn(s, sep); + if (**p) *(*p)++ = 0; + else *p = 0; + return s; +} + +#endif + +#endif /* _BS_STRING_COMPAT_H_ */ diff --git a/src/text_utils.h b/src/text_utils.h index f10fdc31d..eabd43291 100644 --- a/src/text_utils.h +++ b/src/text_utils.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include "string_compat.h" #include "data_win.h" #include "runner.h" #include "utils.h" diff --git a/src/utils.h b/src/utils.h index dc8c804b0..af64a4bfa 100644 --- a/src/utils.h +++ b/src/utils.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include "string_compat.h" #include "math_compat.h" #include "real_type.h" diff --git a/src/vm.c b/src/vm.c index e3827f142..7b5895fe7 100644 --- a/src/vm.c +++ b/src/vm.c @@ -10,7 +10,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "math_compat.h" #include "stb_ds.h" diff --git a/src/vm_builtins.c b/src/vm_builtins.c index 66e1ebde0..ce013bc5b 100644 --- a/src/vm_builtins.c +++ b/src/vm_builtins.c @@ -12,7 +12,7 @@ #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "math_compat.h" #include #include diff --git a/src/web-meta/main.c b/src/web-meta/main.c index 351a5125c..6abb5c2d5 100644 --- a/src/web-meta/main.c +++ b/src/web-meta/main.c @@ -1,7 +1,7 @@ #include "common.h" #include "stdio_compat.h" #include -#include +#include "string_compat.h" #include "data_win.h" DataWin* parseDataWin(const char* path) { diff --git a/src/web/main.c b/src/web/main.c index 986092f97..4da43e201 100644 --- a/src/web/main.c +++ b/src/web/main.c @@ -1,5 +1,5 @@ #include "stdio_compat.h" -#include +#include "string_compat.h" #include #include #include From bc208e83c3d500b5b306267af2fbe6eb9d80ca6c Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Sat, 25 Jul 2026 11:35:56 -0400 Subject: [PATCH 2/2] fix --- src/string_compat.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/string_compat.h b/src/string_compat.h index aca09f67c..e41d8a0b9 100644 --- a/src/string_compat.h +++ b/src/string_compat.h @@ -8,7 +8,8 @@ #include static int strcasecmp(const char *_s1, const char *_s2) { - const unsigned char *s1 = (void *)_s1, *s2 = (void *)_s2; + const unsigned char *s1 = (const unsigned char *)_s1; + const unsigned char *s2 = (const unsigned char *)_s2; while (*s1 && *s2) { if (*s1 != *s2 && tolower(*s1) != tolower(*s2))