Blame patches/sdl2/u16.patch

d7cf18
diff -ru SDL2-2.0.8.orig/src/video/windows/SDL_windowsmessagebox.c SDL2-2.0.8/src/video/windows/SDL_windowsmessagebox.c
d7cf18
--- SDL2-2.0.8.orig/src/video/windows/SDL_windowsmessagebox.c   2018-03-01 17:34:42.000000000 +0100
d7cf18
+++ SDL2-2.0.8/src/video/windows/SDL_windowsmessagebox.c        2020-10-05 12:51:31.389436939 +0200
d7cf18
@@ -350,7 +350,11 @@
d7cf18
     HFONT DialogFont;
d7cf18
     SIZE Size;
d7cf18
     RECT TextSize;
213fe0
+#ifdef __midipix__
d7cf18
+    uint16_t *wmessage;
213fe0
+#else
d7cf18
     wchar_t* wmessage;
213fe0
+#endif
d7cf18
     TEXTMETRIC TM;
d7cf18
d7cf18
     HWND ParentWindow = NULL;
d7cf18
d7cf18
diff -ru SDL2-2.0.12.orig/src/stdlib/SDL_string.c SDL2-2.0.12/src/stdlib/SDL_string.c
d7cf18
--- SDL2-2.0.12.orig/src/stdlib/SDL_string.c	2020-03-11 02:36:18.000000000 +0100
d7cf18
+++ SDL2-2.0.12/src/stdlib/SDL_string.c	2020-10-07 13:40:28.237747292 +0200
d7cf18
@@ -421,6 +421,63 @@
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
+
d7cf18
+uint16_t *
d7cf18
+SDL_wcsdup(const uint16_t *string)
d7cf18
+{
d7cf18
+    return u16_wcsdup(string);
d7cf18
+}
d7cf18
+
d7cf18
+uint16_t *
d7cf18
+SDL_wcsstr(const uint16_t *haystack, const uint16_t *needle)
d7cf18
+{
d7cf18
+    return SDL_const_cast(uint16_t*,u16_wcsstr(haystack, needle));
d7cf18
+}
d7cf18
+
213fe0
+int
213fe0
+SDL_wcscmp(const uint16_t *str1, const uint16_t *str2)
213fe0
+{
213fe0
+    return u16_wcscmp(str1, str2);
213fe0
+}
d7cf18
+
d7cf18
+int
d7cf18
+SDL_wcsncmp(const uint16_t *str1, const uint16_t *str2, size_t maxlen)
d7cf18
+{
d7cf18
+    return u16_wcsncmp(str1, str2, maxlen);
d7cf18
+}
d7cf18
+
d7cf18
+#else /* !__MIDIPIX__ */
213fe0
 size_t
213fe0
 SDL_wcslen(const wchar_t * string)
213fe0
 {
d7cf18
@@ -525,6 +582,7 @@
213fe0
     return (int)(*str1 - *str2);
d7cf18
 #endif /* HAVE_WCSNCMP */
213fe0
 }
d7cf18
+#endif /* !__MIDIPIX__ */
213fe0
 
213fe0
 size_t
213fe0
 SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)