summaryrefslogtreecommitdiffhomepage
path: root/patches/sdl2/u16.patch
blob: 0a8966b4d796e16b7a11c8ef092a052ed07bc285 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
diff -ru SDL2-2.0.8.orig/src/video/windows/SDL_windowsmessagebox.c SDL2-2.0.8/src/video/windows/SDL_windowsmessagebox.c
--- SDL2-2.0.8.orig/src/video/windows/SDL_windowsmessagebox.c   2018-03-01 17:34:42.000000000 +0100
+++ SDL2-2.0.8/src/video/windows/SDL_windowsmessagebox.c        2020-10-05 12:51:31.389436939 +0200
@@ -350,7 +350,11 @@
     HFONT DialogFont;
     SIZE Size;
     RECT TextSize;
+#ifdef __midipix__
+    uint16_t *wmessage;
+#else
     wchar_t* wmessage;
+#endif
     TEXTMETRIC TM;

     HWND ParentWindow = NULL;

diff -ru SDL2-2.0.12.orig/src/stdlib/SDL_string.c SDL2-2.0.12/src/stdlib/SDL_string.c
--- SDL2-2.0.12.orig/src/stdlib/SDL_string.c	2020-03-11 02:36:18.000000000 +0100
+++ SDL2-2.0.12/src/stdlib/SDL_string.c	2020-10-07 13:40:28.237747292 +0200
@@ -421,6 +421,63 @@
 #endif /* HAVE_STRLEN */
 }
 
+#ifdef __midipix__
+#include <u16ports/u16ports.h>
+
+size_t
+SDL_wcslen(const uint16_t * string)
+{
+    return u16_wcslen(string);
+}
+
+size_t
+SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) uint16_t *dst, const uint16_t *src, size_t maxlen)
+{
+    size_t srclen = u16_wcslen(src);
+    if(maxlen > 0) {
+        size_t len = SDL_min(srclen, maxlen - 1);
+        SDL_memcpy(dst, src, len * sizeof(uint16_t));
+        dst[len] = '\0';
+    }
+    return srclen;
+}
+
+size_t
+SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) uint16_t *dst, const uint16_t *src, size_t maxlen)
+{
+    size_t dstlen = u16_wcslen(dst);
+    size_t srclen = u16_wcslen(src);
+    if (dstlen < maxlen) {
+        SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
+    }
+    return dstlen + srclen;
+}
+
+uint16_t *
+SDL_wcsdup(const uint16_t *string)
+{
+    return u16_wcsdup(string);
+}
+
+uint16_t *
+SDL_wcsstr(const uint16_t *haystack, const uint16_t *needle)
+{
+    return SDL_const_cast(uint16_t*,u16_wcsstr(haystack, needle));
+}
+
+int
+SDL_wcscmp(const uint16_t *str1, const uint16_t *str2)
+{
+    return u16_wcscmp(str1, str2);
+}
+
+int
+SDL_wcsncmp(const uint16_t *str1, const uint16_t *str2, size_t maxlen)
+{
+    return u16_wcsncmp(str1, str2, maxlen);
+}
+
+#else /* !__MIDIPIX__ */
 size_t
 SDL_wcslen(const wchar_t * string)
 {
@@ -525,6 +582,7 @@
     return (int)(*str1 - *str2);
 #endif /* HAVE_WCSNCMP */
 }
+#endif /* !__MIDIPIX__ */
 
 size_t
 SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)