From 16f1e3088ddb51a2f99a94ea0d5d7755ab47a644 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Fri, 30 Jun 2023 14:35:28 +0300
Subject: [PATCH] sync SDL2 headers, tests and the testlib with current SDL2
branch.
---
include/SDL2/SDL_hints.h | 69 +++++++++++++++++++++---------------
include/SDL2/SDL_keycode.h | 2 +-
include/SDL2/SDL_stdinc.h | 11 +++++-
include/SDL2/SDL_version.h | 2 +-
include/SDL2/SDL_video.h | 29 ++++++++++++++-
src/test/SDL_test_common.c | 12 +++----
src/test/SDL_test_fuzzer.c | 48 +++++++++----------------
src/test/SDL_test_harness.c | 3 +-
src/test/SDL_test_log.c | 3 +-
test/testautomation_guid.c | 24 ++++++++++---
test/testautomation_stdlib.c | 12 +++++++
11 files changed, 134 insertions(+), 81 deletions(-)
diff --git a/include/SDL2/SDL_hints.h b/include/SDL2/SDL_hints.h
index 825de4b..ad3b403 100644
--- a/include/SDL2/SDL_hints.h
+++ b/include/SDL2/SDL_hints.h
@@ -92,7 +92,7 @@ extern "C" {
* By default this hint is not set and the APK expansion files are not searched.
*/
#define SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"
-
+
/**
* \brief Android APK expansion patch file version. Should be a string number like "1", "2" etc.
*
@@ -132,13 +132,13 @@ extern "C" {
* \brief A variable to control whether we trap the Android back button to handle it manually.
* This is necessary for the right mouse button to work on some Android devices, or
* to be able to trap the back button for use in your code reliably. If set to true,
- * the back button will show up as an SDL_KEYDOWN / SDL_KEYUP pair with a keycode of
+ * the back button will show up as an SDL_KEYDOWN / SDL_KEYUP pair with a keycode of
* SDL_SCANCODE_AC_BACK.
*
* The variable can be set to the following values:
* "0" - Back button will be handled as usual for system. (default)
* "1" - Back button will be trapped, allowing you to handle the key press
- * manually. (This will also let right mouse click work on systems
+ * manually. (This will also let right mouse click work on systems
* where the right mouse button functions as back.)
*
* The value of this hint is used at runtime, so it can be changed at any time.
@@ -147,7 +147,7 @@ extern "C" {
/**
* \brief Specify an application name.
- *
+ *
* This hint lets you specify the application name sent to the OS when
* required. For example, this will often appear in volume control applets for
* audio streams, and in lists of applications which are inhibiting the
@@ -377,6 +377,17 @@ extern "C" {
*/
#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"
+/**
+ * \brief A variable that controls whether the on-screen keyboard should be shown when text input is active
+ *
+ * The variable can be set to the following values:
+ * "0" - Do not show the on-screen keyboard
+ * "1" - Show the on-screen keyboard
+ *
+ * The default value is "1". This hint must be set before text input is activated.
+ */
+#define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD"
+
/**
* \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs
*
@@ -507,7 +518,7 @@ extern "C" {
/**
* \brief If set, game controller face buttons report their values according to their labels instead of their positional layout.
- *
+ *
* For example, on Nintendo Switch controllers, normally you'd get:
*
* (Y)
@@ -569,9 +580,9 @@ extern "C" {
*
* The variable can be set to the following values:
* "0" - SDL_TEXTEDITING events are sent, and it is the application's
- * responsibility to render the text from these events and
+ * responsibility to render the text from these events and
* differentiate it somehow from committed text. (default)
- * "1" - If supported by the IME then SDL_TEXTEDITING events are not sent,
+ * "1" - If supported by the IME then SDL_TEXTEDITING events are not sent,
* and text that is being composed will be rendered in its own UI.
*/
#define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING"
@@ -1310,6 +1321,8 @@ extern "C" {
*
* This variable can be one of the following values:
* "primary" (default), "portrait", "landscape", "inverted-portrait", "inverted-landscape"
+ *
+ * Since SDL 2.0.22 this variable accepts a comma-separated list of values above.
*/
#define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION "SDL_QTWAYLAND_CONTENT_ORIENTATION"
@@ -1495,7 +1508,7 @@ extern "C" {
* disabled. You should use a string that describes what your program is doing
* (and, therefore, why the screensaver is disabled). For example, "Playing a
* game" or "Watching a video".
- *
+ *
* Setting this to "" or leaving it unset will have SDL use a reasonable
* default: "Playing a game" or something similar.
*
@@ -1509,13 +1522,13 @@ extern "C" {
* On some platforms, like Linux, a realtime priority thread may be subject to restrictions
* that require special handling by the application. This hint exists to let SDL know that
* the app is prepared to handle said restrictions.
- *
+ *
* On Linux, SDL will apply the following configuration to any thread that becomes realtime:
* * The SCHED_RESET_ON_FORK bit will be set on the scheduling policy,
* * An RLIMIT_RTTIME budget will be configured to the rtkit specified limit.
* * Exceeding this limit will result in the kernel sending SIGKILL to the app,
* * Refer to the man pages for more information.
- *
+ *
* This variable can be set to the following values:
* "0" - default platform specific behaviour
* "1" - Force SDL_THREAD_PRIORITY_TIME_CRITICAL to a realtime scheduling policy
@@ -1603,7 +1616,7 @@ extern "C" {
#define SDL_HINT_TV_REMOTE_AS_JOYSTICK "SDL_TV_REMOTE_AS_JOYSTICK"
/**
- * \brief A variable controlling whether the screensaver is enabled.
+ * \brief A variable controlling whether the screensaver is enabled.
*
* This variable can be set to the following values:
* "0" - Disable screensaver
@@ -1616,7 +1629,7 @@ extern "C" {
/**
* \brief Tell the video driver that we only want a double buffer.
*
- * By default, most lowlevel 2D APIs will use a triple buffer scheme that
+ * By default, most lowlevel 2D APIs will use a triple buffer scheme that
* wastes no CPU time on waiting for vsync after issuing a flip, but
* introduces a frame of latency. On the other hand, using a double buffer
* scheme instead is recommended for cases where low latency is an important
@@ -1747,9 +1760,9 @@ extern "C" {
/**
* \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p").
-*
+*
* If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has
-* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly
+* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly
* created SDL_Window:
*
* 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is
@@ -1815,13 +1828,13 @@ extern "C" {
/**
* \brief A variable controlling whether the X11 _NET_WM_BYPASS_COMPOSITOR hint should be used.
- *
+ *
* This variable can be set to the following values:
* "0" - Disable _NET_WM_BYPASS_COMPOSITOR
* "1" - Enable _NET_WM_BYPASS_COMPOSITOR
- *
+ *
* By default SDL will use _NET_WM_BYPASS_COMPOSITOR
- *
+ *
*/
#define SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR "SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR"
@@ -1977,7 +1990,7 @@ extern "C" {
#define SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS "SDL_WINDOWS_ENABLE_MENU_MNEMONICS"
/**
- * \brief A variable controlling whether the windows message loop is processed by SDL
+ * \brief A variable controlling whether the windows message loop is processed by SDL
*
* This variable can be set to the following values:
* "0" - The window message loop is not run
@@ -2018,7 +2031,7 @@ extern "C" {
#define SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL "SDL_WINDOWS_FORCE_SEMAPHORE_KERNEL"
/**
- * \brief A variable to specify custom icon resource id from RC file on Windows platform
+ * \brief A variable to specify custom icon resource id from RC file on Windows platform
*/
#define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON"
#define SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL "SDL_WINDOWS_INTRESOURCE_ICON_SMALL"
@@ -2057,16 +2070,16 @@ extern "C" {
*
* This hint must be set before initializing the video subsystem.
*
- * The main purpose of declaring DPI awareness is to disable OS bitmap scaling of SDL windows on monitors with
+ * The main purpose of declaring DPI awareness is to disable OS bitmap scaling of SDL windows on monitors with
* a DPI scale factor.
- *
+ *
* This hint is equivalent to requesting DPI awareness via external means (e.g. calling SetProcessDpiAwarenessContext)
* and does not cause SDL to use a virtualized coordinate system, so it will generally give you 1 SDL coordinate = 1 pixel
* even on high-DPI displays.
- *
+ *
* For more information, see:
* https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows
- *
+ *
* This variable can be set to the following values:
* "" - Do not change the DPI awareness (default).
* "unaware" - Declare the process as DPI unaware. (Windows 8.1 and later).
@@ -2084,16 +2097,16 @@ extern "C" {
/**
* \brief Uses DPI-scaled points as the SDL coordinate system on Windows.
- *
+ *
* This changes the SDL coordinate system units to be DPI-scaled points, rather than pixels everywhere.
* This means windows will be appropriately sized, even when created on high-DPI displays with scaling.
- *
+ *
* e.g. requesting a 640x480 window from SDL, on a display with 125% scaling in Windows display settings,
* will create a window with an 800x600 client area (in pixels).
*
* Setting this to "1" implicitly requests process DPI awareness (setting SDL_WINDOWS_DPI_AWARENESS is unnecessary),
* and forces SDL_WINDOW_ALLOW_HIGHDPI on all windows.
- *
+ *
* This variable can be set to the following values:
* "0" - SDL coordinates equal Windows coordinates. No automatic window resizing when dragging
* between monitors with different scale factors (unless this is performed by
@@ -2104,7 +2117,7 @@ extern "C" {
#define SDL_HINT_WINDOWS_DPI_SCALING "SDL_WINDOWS_DPI_SCALING"
/**
- * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden
+ * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden
*
* This variable can be set to the following values:
* "0" - The window frame is not interactive when the cursor is hidden (no move, resize, etc)
@@ -2115,7 +2128,7 @@ extern "C" {
#define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN"
/**
-* \brief A variable controlling whether the window is activated when the SDL_ShowWindow function is called
+* \brief A variable controlling whether the window is activated when the SDL_ShowWindow function is called
*
* This variable can be set to the following values:
* "0" - The window is activated when the SDL_ShowWindow function is called
diff --git a/include/SDL2/SDL_keycode.h b/include/SDL2/SDL_keycode.h
index 2523506..7106223 100644
--- a/include/SDL2/SDL_keycode.h
+++ b/include/SDL2/SDL_keycode.h
@@ -40,7 +40,7 @@
* an SDLK_* constant for those keys that do not generate characters.
*
* A special exception is the number keys at the top of the keyboard which
- * always map to SDLK_0...SDLK_9, regardless of layout.
+ * map to SDLK_0...SDLK_9 on AZERTY layouts.
*/
typedef Sint32 SDL_Keycode;
diff --git a/include/SDL2/SDL_stdinc.h b/include/SDL2/SDL_stdinc.h
index 0f903f8..182ed86 100644
--- a/include/SDL2/SDL_stdinc.h
+++ b/include/SDL2/SDL_stdinc.h
@@ -688,7 +688,7 @@ extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
size_t * outbytesleft);
/**
- * This function converts a string between encodings in one pass, returning a
+ * This function converts a buffer or string between encodings in one pass, returning a
* string that must be freed with SDL_free() or NULL on error.
*
* \since This function is available since SDL 2.0.0.
@@ -716,10 +716,19 @@ size_t strlcpy(char* dst, const char* src, size_t size);
size_t strlcat(char* dst, const char* src, size_t size);
#endif
+#ifndef HAVE_WCSLCPY
+size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
+#endif
+
+#ifndef HAVE_WCSLCAT
+size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
+#endif
+
/* Starting LLVM 16, the analyser errors out if these functions do not have
their prototype defined (clang-diagnostic-implicit-function-declaration) */
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
#define SDL_malloc malloc
#define SDL_calloc calloc
diff --git a/include/SDL2/SDL_version.h b/include/SDL2/SDL_version.h
index 73fc755..782a7ff 100644
--- a/include/SDL2/SDL_version.h
+++ b/include/SDL2/SDL_version.h
@@ -58,7 +58,7 @@ typedef struct SDL_version
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
#define SDL_MAJOR_VERSION 2
-#define SDL_MINOR_VERSION 27
+#define SDL_MINOR_VERSION 28
#define SDL_PATCHLEVEL 0
/**
diff --git a/include/SDL2/SDL_video.h b/include/SDL2/SDL_video.h
index 599b563..c8b2d7a 100644
--- a/include/SDL2/SDL_video.h
+++ b/include/SDL2/SDL_video.h
@@ -1275,6 +1275,17 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window);
extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
Uint32 flags);
+/**
+ * Return whether the window has a surface associated with it.
+ *
+ * \returns SDL_TRUE if there is a surface associated with the window, or SDL_FALSE otherwise.
+ *
+ * \since This function is available since SDL 2.28.0.
+ *
+ * \sa SDL_GetWindowSurface
+ */
+extern DECLSPEC SDL_bool SDLCALL SDL_HasWindowSurface(SDL_Window *window);
+
/**
* Get the SDL surface associated with the window.
*
@@ -1295,6 +1306,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
*
* \since This function is available since SDL 2.0.0.
*
+ * \sa SDL_DestroyWindowSurface
+ * \sa SDL_HasWindowSurface
* \sa SDL_UpdateWindowSurface
* \sa SDL_UpdateWindowSurfaceRects
*/
@@ -1329,7 +1342,7 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window);
*
* \param window the window to update
* \param rects an array of SDL_Rect structures representing areas of the
- * surface to copy
+ * surface to copy, in pixels
* \param numrects the number of rectangles
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
@@ -1343,6 +1356,20 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
const SDL_Rect * rects,
int numrects);
+/**
+ * Destroy the surface associated with the window.
+ *
+ * \param window the window to update
+ * \returns 0 on success or a negative error code on failure; call
+ * SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 2.28.0.
+ *
+ * \sa SDL_GetWindowSurface
+ * \sa SDL_HasWindowSurface
+ */
+extern DECLSPEC int SDLCALL SDL_DestroyWindowSurface(SDL_Window *window);
+
/**
* Set a window's input grab mode.
*
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index b06ca72..8781cc5 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -58,8 +58,7 @@ static void SDL_snprintfcat(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL
va_end(ap);
}
-SDLTest_CommonState *
-SDLTest_CommonCreateState(char **argv, Uint32 flags)
+SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags)
{
int i;
SDLTest_CommonState *state;
@@ -630,8 +629,7 @@ static char *common_usage_video = NULL;
static char *common_usage_audio = NULL;
static char *common_usage_videoaudio = NULL;
-const char *
-SDLTest_CommonUsage(SDLTest_CommonState *state)
+const char *SDLTest_CommonUsage(SDLTest_CommonState *state)
{
switch (state->flags & (SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
@@ -646,8 +644,7 @@ SDLTest_CommonUsage(SDLTest_CommonState *state)
}
}
-SDL_bool
-SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv)
+SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv)
{
int i = 1;
while (i < argc) {
@@ -1052,8 +1049,7 @@ static SDL_HitTestResult SDLCALL SDLTest_ExampleHitTestCallback(SDL_Window *win,
return SDL_HITTEST_NORMAL;
}
-SDL_bool
-SDLTest_CommonInit(SDLTest_CommonState *state)
+SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
{
int i, j, m, n, w, h;
SDL_DisplayMode fullscreen_mode;
diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c
index 1c79b99..b59cbb3 100644
--- a/src/test/SDL_test_fuzzer.c
+++ b/src/test/SDL_test_fuzzer.c
@@ -87,40 +87,35 @@ Sint8 SDLTest_RandomSint8()
return (Sint8)SDLTest_RandomInt(&rndContext) & 0x000000FF;
}
-Uint16
-SDLTest_RandomUint16()
+Uint16 SDLTest_RandomUint16()
{
fuzzerInvocationCounter++;
return (Uint16)SDLTest_RandomInt(&rndContext) & 0x0000FFFF;
}
-Sint16
-SDLTest_RandomSint16()
+Sint16 SDLTest_RandomSint16()
{
fuzzerInvocationCounter++;
return (Sint16)SDLTest_RandomInt(&rndContext) & 0x0000FFFF;
}
-Sint32
-SDLTest_RandomSint32()
+Sint32 SDLTest_RandomSint32()
{
fuzzerInvocationCounter++;
return (Sint32)SDLTest_RandomInt(&rndContext);
}
-Uint32
-SDLTest_RandomUint32()
+Uint32 SDLTest_RandomUint32()
{
fuzzerInvocationCounter++;
return (Uint32)SDLTest_RandomInt(&rndContext);
}
-Uint64
-SDLTest_RandomUint64()
+Uint64 SDLTest_RandomUint64()
{
union
{
@@ -137,8 +132,7 @@ SDLTest_RandomUint64()
return value.v64;
}
-Sint64
-SDLTest_RandomSint64()
+Sint64 SDLTest_RandomSint64()
{
union
{
@@ -155,8 +149,7 @@ SDLTest_RandomSint64()
return (Sint64)value.v64;
}
-Sint32
-SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
+Sint32 SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
{
Sint64 min = pMin;
Sint64 max = pMax;
@@ -270,8 +263,7 @@ Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_boo
validDomain);
}
-Uint16
-SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain)
+Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain)
{
/* max value for Uint16 */
const Uint64 maxValue = USHRT_MAX;
@@ -280,8 +272,7 @@ SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool v
validDomain);
}
-Uint32
-SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain)
+Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain)
{
/* max value for Uint32 */
#if ((ULONG_MAX) == (UINT_MAX))
@@ -294,8 +285,7 @@ SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool v
validDomain);
}
-Uint64
-SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain)
+Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain)
{
/* max value for Uint64 */
const Uint64 maxValue = UINT64_MAX;
@@ -400,8 +390,7 @@ Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_boo
validDomain);
}
-Sint16
-SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain)
+Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain)
{
/* min & max values for Sint16 */
const Sint64 maxValue = SHRT_MAX;
@@ -411,8 +400,7 @@ SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool v
validDomain);
}
-Sint32
-SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain)
+Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain)
{
/* min & max values for Sint32 */
#if ((ULONG_MAX) == (UINT_MAX))
@@ -427,8 +415,7 @@ SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool v
validDomain);
}
-Sint64
-SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain)
+Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain)
{
/* min & max values for Sint64 */
const Sint64 maxValue = INT64_MAX;
@@ -469,14 +456,12 @@ SDLTest_RandomDouble()
return r;
}
-char *
-SDLTest_RandomAsciiString()
+char *SDLTest_RandomAsciiString()
{
return SDLTest_RandomAsciiStringWithMaximumLength(255);
}
-char *
-SDLTest_RandomAsciiStringWithMaximumLength(int maxLength)
+char *SDLTest_RandomAsciiStringWithMaximumLength(int maxLength)
{
int size;
@@ -490,8 +475,7 @@ SDLTest_RandomAsciiStringWithMaximumLength(int maxLength)
return SDLTest_RandomAsciiStringOfSize(size);
}
-char *
-SDLTest_RandomAsciiStringOfSize(int size)
+char *SDLTest_RandomAsciiStringOfSize(int size)
{
char *string;
int counter;
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index 2ce1c16..6141513 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -50,8 +50,7 @@ static Uint32 SDLTest_TestCaseTimeout = 3600;
*
* \returns The generated seed string
*/
-char *
-SDLTest_GenerateRunSeed(const int length)
+char *SDLTest_GenerateRunSeed(const int length)
{
char *seed = NULL;
SDLTest_RandomContext randomContext;
diff --git a/src/test/SDL_test_log.c b/src/test/SDL_test_log.c
index fd48b3c..d69e3da 100644
--- a/src/test/SDL_test_log.c
+++ b/src/test/SDL_test_log.c
@@ -43,8 +43,7 @@
/* work around compiler warning on older GCCs. */
#if (defined(__GNUC__) && (__GNUC__ <= 2))
-static size_t
-strftime_gcc2_workaround(char *s, size_t max, const char *fmt, const struct tm *tm)
+static size_t strftime_gcc2_workaround(char *s, size_t max, const char *fmt, const struct tm *tm)
{
return strftime(s, max, fmt, tm);
}
diff --git a/test/testautomation_guid.c b/test/testautomation_guid.c
index 593b7fb..cf99dea 100644
--- a/test/testautomation_guid.c
+++ b/test/testautomation_guid.c
@@ -5,12 +5,26 @@
#include "SDL.h"
#include "SDL_test.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
/* ================= Test Case Implementation ================== */
/* Helper functions */
#define NUM_TEST_GUIDS 5
+#ifndef UINT64_C
+#ifdef _MSC_VER
+#define UINT64_C(x) x##ui64
+#elif defined(_LP64)
+#define UINT64_C(x) x##UL
+#else
+#define UINT64_C(x) x##ULL
+#endif
+#endif
+
static struct
{
char *str;
@@ -18,19 +32,19 @@ static struct
} test_guids[NUM_TEST_GUIDS] = {
{ "0000000000000000"
"ffffffffffffffff",
- 0x0000000000000000, 0xfffffffffffffffflu },
+ UINT64_C(0x0000000000000000), UINT64_C(0xffffffffffffffff) },
{ "0011223344556677"
"8091a2b3c4d5e6f0",
- 0x0011223344556677lu, 0x8091a2b3c4d5e6f0lu },
+ UINT64_C(0x0011223344556677), UINT64_C(0x8091a2b3c4d5e6f0) },
{ "a011223344556677"
"8091a2b3c4d5e6f0",
- 0xa011223344556677lu, 0x8091a2b3c4d5e6f0lu },
+ UINT64_C(0xa011223344556677), UINT64_C(0x8091a2b3c4d5e6f0) },
{ "a011223344556677"
"8091a2b3c4d5e6f1",
- 0xa011223344556677lu, 0x8091a2b3c4d5e6f1lu },
+ UINT64_C(0xa011223344556677), UINT64_C(0x8091a2b3c4d5e6f1) },
{ "a011223344556677"
"8191a2b3c4d5e6f0",
- 0xa011223344556677lu, 0x8191a2b3c4d5e6f0lu },
+ UINT64_C(0xa011223344556677), UINT64_C(0x8191a2b3c4d5e6f0) },
};
static void
diff --git a/test/testautomation_stdlib.c b/test/testautomation_stdlib.c
index 3f45cbf..ba7ba88 100644
--- a/test/testautomation_stdlib.c
+++ b/test/testautomation_stdlib.c
@@ -62,6 +62,18 @@ int stdlib_snprintf(void *arg)
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int)SDL_strlen(text), result);
+ result = SDL_snprintf(text, sizeof(text), "%S", L"foo");
+ expected = "foo";
+ SDLTest_AssertPass("Call to SDL_snprintf(\"%%S\", \"foo\")");
+ SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
+ SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int)SDL_strlen(text), result);
+
+ result = SDL_snprintf(text, sizeof(text), "%ls", L"foo");
+ expected = "foo";
+ SDLTest_AssertPass("Call to SDL_snprintf(\"%%ls\", \"foo\")");
+ SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
+ SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int)SDL_strlen(text), result);
+
result = SDL_snprintf(text, 2, "%s", "foo");
expected = "f";
SDLTest_AssertPass("Call to SDL_snprintf(\"%%s\", \"foo\") with buffer size 2");