Blame patches/sdl2/u16.patch

213fe0
diff -ru SDL2-2.0.8.orig/include/SDL_stdinc.h SDL2-2.0.8/include/SDL_stdinc.h
213fe0
--- SDL2-2.0.8.orig/include/SDL_stdinc.h	2018-03-01 17:34:41.000000000 +0100
213fe0
+++ SDL2-2.0.8/include/SDL_stdinc.h	2020-10-05 12:29:51.927442178 +0200
213fe0
@@ -451,10 +451,17 @@
213fe0
 extern DECLSPEC void *SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
213fe0
 extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
213fe0
 
213fe0
+#ifdef __midipix__
213fe0
+extern DECLSPEC size_t SDLCALL SDL_wcslen(const uint16_t *wstr);
213fe0
+extern DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) uint16_t *dst, const uint16_t *src, size_t maxlen);
213fe0
+extern DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) uint16_t *dst, const uint16_t *src, size_t maxlen);
213fe0
+extern DECLSPEC int SDLCALL SDL_wcscmp(const uint16_t *str, const uint16_t *str2);
213fe0
+#else
213fe0
 extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr);
213fe0
 extern DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
213fe0
 extern DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
213fe0
 extern DECLSPEC int SDLCALL SDL_wcscmp(const wchar_t *str1, const wchar_t *str2);
213fe0
+#endif /* !__midipix__ */
213fe0
 
213fe0
 extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str);
213fe0
 extern DECLSPEC size_t SDLCALL SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen);
213fe0
diff -ru SDL2-2.0.8.orig/src/dynapi/SDL_dynapi_procs.h SDL2-2.0.8/src/dynapi/SDL_dynapi_procs.h
213fe0
--- SDL2-2.0.8.orig/src/dynapi/SDL_dynapi_procs.h	2018-03-01 17:34:42.000000000 +0100
213fe0
+++ SDL2-2.0.8/src/dynapi/SDL_dynapi_procs.h	2020-10-05 12:41:07.154180772 +0200
213fe0
@@ -418,9 +418,15 @@
213fe0
 SDL_DYNAPI_PROC(void*,SDL_memcpy,(SDL_OUT_BYTECAP(c) void *a, SDL_IN_BYTECAP(c) const void *b, size_t c),(a,b,c),return)
213fe0
 SDL_DYNAPI_PROC(void*,SDL_memmove,(SDL_OUT_BYTECAP(c) void *a, SDL_IN_BYTECAP(c) const void *b, size_t c),(a,b,c),return)
213fe0
 SDL_DYNAPI_PROC(int,SDL_memcmp,(const void *a, const void *b, size_t c),(a,b,c),return)
213fe0
+#ifdef __midipix__
213fe0
+SDL_DYNAPI_PROC(size_t,SDL_wcslen,(const uint16_t *a),(a),return)
213fe0
+SDL_DYNAPI_PROC(size_t,SDL_wcslcpy,(SDL_OUT_Z_CAP(c) uint16_t *a, const uint16_t *b, size_t c),(a,b,c),return)
213fe0
+SDL_DYNAPI_PROC(size_t,SDL_wcslcat,(SDL_INOUT_Z_CAP(c) uint16_t *a, const uint16_t *b, size_t c),(a,b,c),return)
213fe0
+#else
213fe0
 SDL_DYNAPI_PROC(size_t,SDL_wcslen,(const wchar_t *a),(a),return)
213fe0
 SDL_DYNAPI_PROC(size_t,SDL_wcslcpy,(SDL_OUT_Z_CAP(c) wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return)
213fe0
 SDL_DYNAPI_PROC(size_t,SDL_wcslcat,(SDL_INOUT_Z_CAP(c) wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return)
213fe0
+#endif
213fe0
 SDL_DYNAPI_PROC(size_t,SDL_strlen,(const char *a),(a),return)
213fe0
 SDL_DYNAPI_PROC(size_t,SDL_strlcpy,(SDL_OUT_Z_CAP(c) char *a, const char *b, size_t c),(a,b,c),return)
213fe0
 SDL_DYNAPI_PROC(size_t,SDL_utf8strlcpy,(SDL_OUT_Z_CAP(c) char *a, const char *b, size_t c),(a,b,c),return)
213fe0
@@ -660,7 +666,11 @@
213fe0
 SDL_DYNAPI_PROC(SDL_JoystickID,SDL_JoystickGetDeviceInstanceID,(int a),(a),return)
213fe0
 SDL_DYNAPI_PROC(size_t,SDL_utf8strlen,(const char *a),(a),return)
213fe0
 SDL_DYNAPI_PROC(void*,SDL_LoadFile_RW,(SDL_RWops *a, size_t *b, int c),(a,b,c),return)
213fe0
+#ifdef __midipix__
213fe0
+SDL_DYNAPI_PROC(int,SDL_wcscmp,(const uint16_t *a, const uint16_t *b),(a,b),return)
213fe0
+#else
213fe0
 SDL_DYNAPI_PROC(int,SDL_wcscmp,(const wchar_t *a, const wchar_t *b),(a,b),return)
213fe0
+#endif
213fe0
 SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return)
213fe0
 SDL_DYNAPI_PROC(SDL_Surface*,SDL_DuplicateSurface,(SDL_Surface *a),(a),return)
213fe0
 SDL_DYNAPI_PROC(int,SDL_Vulkan_LoadLibrary,(const char *a),(a),return)
213fe0
diff -ru SDL2-2.0.8.orig/src/stdlib/SDL_string.c SDL2-2.0.8/src/stdlib/SDL_string.c
213fe0
--- SDL2-2.0.8.orig/src/stdlib/SDL_string.c	2018-03-01 17:34:42.000000000 +0100
213fe0
+++ SDL2-2.0.8/src/stdlib/SDL_string.c	2020-10-05 12:29:39.691442561 +0200
213fe0
@@ -416,6 +416,44 @@
213fe0
 #endif /* HAVE_STRLEN */
213fe0
 }
213fe0
 
213fe0
+#ifdef __midipix__
213fe0
+#include <u16ports/u16ports.h>
213fe0
+
213fe0
+size_t
213fe0
+SDL_wcslen(const uint16_t * string)
213fe0
+{
213fe0
+    return u16_wcslen(string);
213fe0
+}
213fe0
+
213fe0
+size_t
213fe0
+SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) uint16_t *dst, const uint16_t *src, size_t maxlen)
213fe0
+{
213fe0
+    size_t srclen = u16_wcslen(src);
213fe0
+    if(maxlen > 0) {
213fe0
+        size_t len = SDL_min(srclen, maxlen - 1);
213fe0
+        SDL_memcpy(dst, src, len * sizeof(uint16_t));
213fe0
+        dst[len] = '\0';
213fe0
+    }
213fe0
+    return srclen;
213fe0
+}
213fe0
+
213fe0
+size_t
213fe0
+SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) uint16_t *dst, const uint16_t *src, size_t maxlen)
213fe0
+{
213fe0
+    size_t dstlen = u16_wcslen(dst);
213fe0
+    size_t srclen = u16_wcslen(src);
213fe0
+    if (dstlen < maxlen) {
213fe0
+        SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
213fe0
+    }
213fe0
+    return dstlen + srclen;
213fe0
+}
213fe0
+
213fe0
+int
213fe0
+SDL_wcscmp(const uint16_t *str1, const uint16_t *str2)
213fe0
+{
213fe0
+    return u16_wcscmp(str1, str2);
213fe0
+}
213fe0
+#else
213fe0
 size_t
213fe0
 SDL_wcslen(const wchar_t * string)
213fe0
 {
213fe0
@@ -476,6 +514,7 @@
213fe0
     return (int)(*str1 - *str2);
213fe0
 #endif /* HAVE_WCSCMP */
213fe0
 }
213fe0
+#endif /* !__midipix__ */
213fe0
 
213fe0
 size_t
213fe0
 SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
213fe0
diff -ru SDL2-2.0.8.orig/src/video/windows/SDL_windowsmessagebox.c SDL2-2.0.8/src/video/windows/SDL_windowsmessagebox.c
213fe0
--- SDL2-2.0.8.orig/src/video/windows/SDL_windowsmessagebox.c	2018-03-01 17:34:42.000000000 +0100
213fe0
+++ SDL2-2.0.8/src/video/windows/SDL_windowsmessagebox.c	2020-10-05 12:51:31.389436939 +0200
213fe0
@@ -350,7 +350,11 @@
213fe0
     HFONT DialogFont;
213fe0
     SIZE Size;
213fe0
     RECT TextSize;
213fe0
+#ifdef __midipix__
213fe0
+    uint16_t *wmessage;
213fe0
+#else
213fe0
     wchar_t* wmessage;
213fe0
+#endif
213fe0
     TEXTMETRIC TM;
213fe0
 
213fe0
     HWND ParentWindow = NULL;