From afbad7058cc41cda86472921f27d38965e61ac33 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 2 Nov 2023 01:56:40 +0300
Subject: [PATCH] update from latest SDL2 and SDL3 branches
---
src/sdl3_include_wrapper.h | 5 +++
src/test/SDL_test_fuzzer.c | 4 +-
test/testautomation_stdlib.c | 78 +++++++++++++++++++++++++++++++++++-
3 files changed, 85 insertions(+), 2 deletions(-)
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index 0771572..e509941 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -945,6 +945,7 @@
#define SDL_GetSurfaceProperties IGNORE_THIS_VERSION_OF_SDL_GetSurfaceProperties
#define SDL_GetWindowProperties IGNORE_THIS_VERSION_OF_SDL_GetWindowProperties
#define SDL_ClearProperty IGNORE_THIS_VERSION_OF_SDL_ClearProperty
+#define SDL_EnterAppMainCallbacks IGNORE_THIS_VERSION_OF_SDL_EnterAppMainCallbacks
#define SDL_FUNCTION_POINTER_IS_VOID_POINTER 1
@@ -4642,6 +4643,10 @@
#undef SDL_ClearProperty
#endif
+#ifdef SDL_EnterAppMainCallbacks
+#undef SDL_EnterAppMainCallbacks
+#endif
+
/* undefine these macros too: */
/* redefine as SDL3_xxx, if needed. */
diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c
index b59cbb3..9e2e757 100644
--- a/src/test/SDL_test_fuzzer.c
+++ b/src/test/SDL_test_fuzzer.c
@@ -471,7 +471,9 @@ char *SDLTest_RandomAsciiStringWithMaximumLength(int maxLength)
}
size = (SDLTest_RandomUint32() % (maxLength + 1));
-
+ if (size == 0) {
+ size = 1;
+ }
return SDLTest_RandomAsciiStringOfSize(size);
}
diff --git a/test/testautomation_stdlib.c b/test/testautomation_stdlib.c
index af014b7..5b681fc 100644
--- a/test/testautomation_stdlib.c
+++ b/test/testautomation_stdlib.c
@@ -351,7 +351,7 @@ int stdlib_sscanf(void *arg)
long long_output, expected_long_output;
long long long_long_output, expected_long_long_output;
size_t size_output, expected_size_output;
- char text[128];
+ char text[128], text2[128];
expected_output = output = 123;
expected_result = -1;
@@ -415,6 +415,82 @@ int stdlib_sscanf(void *arg)
SDLTest_AssertCheck(expected_size_output == size_output, "Check output, expected: %zu, got: %zu", expected_size_output, size_output);
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+ expected_result = 1;
+ text[0] = '\0';
+ result = SDL_sscanf("abc def", "%s", text);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"abc def\", \"%%s\", text)");
+ SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ expected_result = 1;
+ text[0] = '\0';
+ result = SDL_sscanf("abc,def", "%s", text);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%s\", text)");
+ SDLTest_AssertCheck(SDL_strcmp(text, "abc,def") == 0, "Check output, expected: \"abc\", got: \"%s\"", text);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ expected_result = 1;
+ text[0] = '\0';
+ result = SDL_sscanf("abc,def", "%[cba]", text);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[cba]\", text)");
+ SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ expected_result = 1;
+ text[0] = '\0';
+ result = SDL_sscanf("abc,def", "%[a-z]", text);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[z-a]\", text)");
+ SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ expected_result = 1;
+ text[0] = '\0';
+ result = SDL_sscanf("abc,def", "%[^,]", text);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[^,]\", text)");
+ SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ expected_result = 0;
+ text[0] = '\0';
+ result = SDL_sscanf("abc,def", "%[A-Z]", text);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[A-Z]\", text)");
+ SDLTest_AssertCheck(SDL_strcmp(text, "") == 0, "Check output, expected: \"\", got: \"%s\"", text);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ expected_result = 2;
+ text[0] = '\0';
+ text2[0] = '\0';
+ result = SDL_sscanf("abc,def", "%[abc],%[def]", text, text2);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[abc],%%[def]\", text)");
+ SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text);
+ SDLTest_AssertCheck(SDL_strcmp(text2, "def") == 0, "Check output, expected: \"def\", got: \"%s\"", text2);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ expected_result = 2;
+ text[0] = '\0';
+ text2[0] = '\0';
+ result = SDL_sscanf("abc,def", "%[abc]%*[,]%[def]", text, text2);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[abc]%%*[,]%%[def]\", text)");
+ SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text);
+ SDLTest_AssertCheck(SDL_strcmp(text2, "def") == 0, "Check output, expected: \"def\", got: \"%s\"", text2);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ expected_result = 2;
+ text[0] = '\0';
+ text2[0] = '\0';
+ result = SDL_sscanf("abc def", "%[abc] %[def]", text, text2);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"abc def\", \"%%[abc] %%[def]\", text)");
+ SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text);
+ SDLTest_AssertCheck(SDL_strcmp(text2, "def") == 0, "Check output, expected: \"def\", got: \"%s\"", text2);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ expected_result = 1;
+ text[0] = '\0';
+ result = SDL_sscanf("abc123XYZ", "%[a-zA-Z0-9]", text);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"abc123XYZ\", \"%%[a-zA-Z0-9]\", text)");
+ SDLTest_AssertCheck(SDL_strcmp(text, "abc123XYZ") == 0, "Check output, expected: \"abc123XYZ\", got: \"%s\"", text);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
return TEST_COMPLETED;
}