Updates SDL to 2.0.12

This commit is contained in:
Areloch 2020-08-12 11:56:18 -05:00
parent 3108a08650
commit a526029f2f
861 changed files with 25596 additions and 8904 deletions

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -421,17 +421,6 @@ SDL_strlen(const char *string)
#endif /* HAVE_STRLEN */
}
wchar_t *
SDL_wcsdup(const wchar_t *string)
{
size_t len = ((SDL_wcslen(string) + 1) * sizeof(wchar_t));
wchar_t *newstr = (wchar_t *)SDL_malloc(len);
if (newstr) {
SDL_memcpy(newstr, string, len);
}
return newstr;
}
size_t
SDL_wcslen(const wchar_t * string)
{
@ -477,6 +466,34 @@ SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t max
#endif /* HAVE_WCSLCAT */
}
wchar_t *
SDL_wcsdup(const wchar_t *string)
{
size_t len = ((SDL_wcslen(string) + 1) * sizeof(wchar_t));
wchar_t *newstr = (wchar_t *)SDL_malloc(len);
if (newstr) {
SDL_memcpy(newstr, string, len);
}
return newstr;
}
wchar_t *
SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle)
{
#if defined(HAVE_WCSSTR)
return SDL_const_cast(wchar_t*,wcsstr(haystack, needle));
#else
size_t length = SDL_wcslen(needle);
while (*haystack) {
if (SDL_wcsncmp(haystack, needle, length) == 0) {
return (wchar_t *)haystack;
}
++haystack;
}
return NULL;
#endif /* HAVE_WCSSTR */
}
int
SDL_wcscmp(const wchar_t *str1, const wchar_t *str2)
{
@ -493,6 +510,22 @@ SDL_wcscmp(const wchar_t *str1, const wchar_t *str2)
#endif /* HAVE_WCSCMP */
}
int
SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
{
#if defined(HAVE_WCSNCMP)
return wcsncmp(str1, str2, maxlen);
#else
while (*str1 && *str2) {
if (*str1 != *str2)
break;
++str1;
++str2;
}
return (int)(*str1 - *str2);
#endif /* HAVE_WCSNCMP */
}
size_t
SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
{
@ -549,7 +582,7 @@ SDL_utf8strlen(const char *str)
const char *p = str;
char ch;
while ((ch = *(p++))) {
while ((ch = *(p++)) != 0) {
/* if top two bits are 1 and 0, it's a continuation byte. */
if ((ch & 0xc0) != 0x80) {
retval++;
@ -818,7 +851,7 @@ int SDL_atoi(const char *string)
double SDL_atof(const char *string)
{
#ifdef HAVE_ATOF
return (double) atof(string);
return atof(string);
#else
return SDL_strtod(string, NULL);
#endif /* HAVE_ATOF */
@ -1387,15 +1420,18 @@ SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *str
sz = SDL_strlen(string);
if (info && info->width > 0 && (size_t)info->width > sz) {
char fill = info->pad_zeroes ? '0' : ' ';
const char fill = info->pad_zeroes ? '0' : ' ';
size_t width = info->width - sz;
size_t filllen;
if (info->precision >= 0 && (size_t)info->precision < sz)
width += sz - (size_t)info->precision;
while (width-- > 0 && maxlen > 0) {
*text++ = fill;
++length;
--maxlen;
}
filllen = SDL_min(width, maxlen);
SDL_memset(text, fill, filllen);
text += filllen;
length += filllen;
maxlen -= filllen;
}
slen = SDL_strlcpy(text, string, maxlen);
@ -1580,7 +1616,7 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
width = info->width - (int)(text - textstart);
if (width > 0) {
char fill = info->pad_zeroes ? '0' : ' ';
const char fill = info->pad_zeroes ? '0' : ' ';
char *end = text+left-1;
len = (text - textstart);
for (len = (text - textstart); len--; ) {
@ -1596,10 +1632,10 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
text += len;
left -= len;
}
while (len--) {
if (textstart+len < end) {
textstart[len] = fill;
}
if (end != textstart) {
const size_t filllen = SDL_min(len, ((size_t) (end - textstart)) - 1);
SDL_memset(textstart, fill, filllen);
}
}