early-access version 2835
This commit is contained in:
2
externals/SDL/src/stdlib/SDL_crc32.c
vendored
2
externals/SDL/src/stdlib/SDL_crc32.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
16
externals/SDL/src/stdlib/SDL_getenv.c
vendored
16
externals/SDL/src/stdlib/SDL_getenv.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -48,7 +48,7 @@ int
|
||||
SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ int
|
||||
SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
char *new_variable;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
char *new_variable;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ SDL_getenv(const char *name)
|
||||
#endif
|
||||
|
||||
/* Input validation */
|
||||
if (!name || !*name) {
|
||||
if (!name || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ SDL_getenv(const char *name)
|
||||
size_t bufferlen;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name)==0) {
|
||||
if (!name || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ SDL_getenv(const char *name)
|
||||
char *value;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name)==0) {
|
||||
if (!name || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
27
externals/SDL/src/stdlib/SDL_iconv.c
vendored
27
externals/SDL/src/stdlib/SDL_iconv.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -36,18 +36,6 @@
|
||||
#define LIBICONV_PLUG 1
|
||||
#endif
|
||||
#include <iconv.h>
|
||||
|
||||
/* Depending on which standard the iconv() was implemented with,
|
||||
iconv() may or may not use const char ** for the inbuf param.
|
||||
If we get this wrong, it's just a warning, so no big deal.
|
||||
*/
|
||||
#if defined(_XGP6) || defined(__APPLE__) || defined(__RISCOS__) || defined(__FREEBSD__) || \
|
||||
defined(__EMSCRIPTEN__) || \
|
||||
(defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) || \
|
||||
(defined(_NEWLIB_VERSION)))
|
||||
#define ICONV_INBUF_NONCONST
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(iconv_t, sizeof (iconv_t) <= sizeof (SDL_iconv_t));
|
||||
@@ -69,12 +57,9 @@ SDL_iconv(SDL_iconv_t cd,
|
||||
const char **inbuf, size_t * inbytesleft,
|
||||
char **outbuf, size_t * outbytesleft)
|
||||
{
|
||||
size_t retCode;
|
||||
#ifdef ICONV_INBUF_NONCONST
|
||||
retCode = iconv((iconv_t) ((uintptr_t) cd), (char **) inbuf, inbytesleft, outbuf, outbytesleft);
|
||||
#else
|
||||
retCode = iconv((iconv_t) ((uintptr_t) cd), inbuf, inbytesleft, outbuf, outbytesleft);
|
||||
#endif
|
||||
/* iconv's second parameter may or may not be `const char const *` depending on the
|
||||
C runtime's whims. Casting to void * seems to make everyone happy, though. */
|
||||
const size_t retCode = iconv((iconv_t) ((uintptr_t) cd), (void *) inbuf, inbytesleft, outbuf, outbytesleft);
|
||||
if (retCode == (size_t) - 1) {
|
||||
switch (errno) {
|
||||
case E2BIG:
|
||||
@@ -141,7 +126,7 @@ static struct
|
||||
const char *name;
|
||||
int format;
|
||||
} encodings[] = {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
{ "ASCII", ENCODING_ASCII },
|
||||
{ "US-ASCII", ENCODING_ASCII },
|
||||
{ "8859-1", ENCODING_LATIN1 },
|
||||
@@ -175,7 +160,7 @@ static struct
|
||||
{ "UCS-4LE", ENCODING_UCS4LE },
|
||||
{ "UCS-4BE", ENCODING_UCS4BE },
|
||||
{ "UCS-4-INTERNAL", ENCODING_UCS4NATIVE },
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
};
|
||||
|
||||
static const char *
|
||||
|
18
externals/SDL/src/stdlib/SDL_malloc.c
vendored
18
externals/SDL/src/stdlib/SDL_malloc.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -733,7 +733,7 @@ extern "C"
|
||||
maximum supported value of n differs across systems, but is in all
|
||||
cases less than the maximum representable value of a size_t.
|
||||
*/
|
||||
void *dlmalloc(size_t);
|
||||
void * SDLCALL dlmalloc(size_t);
|
||||
|
||||
/*
|
||||
free(void* p)
|
||||
@@ -742,14 +742,14 @@ extern "C"
|
||||
It has no effect if p is null. If p was not malloced or already
|
||||
freed, free(p) will by default cause the current program to abort.
|
||||
*/
|
||||
void dlfree(void *);
|
||||
void SDLCALL dlfree(void *);
|
||||
|
||||
/*
|
||||
calloc(size_t n_elements, size_t element_size);
|
||||
Returns a pointer to n_elements * element_size bytes, with all locations
|
||||
set to zero.
|
||||
*/
|
||||
void *dlcalloc(size_t, size_t);
|
||||
void * SDLCALL dlcalloc(size_t, size_t);
|
||||
|
||||
/*
|
||||
realloc(void* p, size_t n)
|
||||
@@ -774,7 +774,7 @@ extern "C"
|
||||
to be used as an argument to realloc is not supported.
|
||||
*/
|
||||
|
||||
void *dlrealloc(void *, size_t);
|
||||
void * SDLCALL dlrealloc(void *, size_t);
|
||||
|
||||
/*
|
||||
memalign(size_t alignment, size_t n);
|
||||
@@ -5305,10 +5305,10 @@ History:
|
||||
#endif /* !HAVE_MALLOC */
|
||||
|
||||
#ifdef HAVE_MALLOC
|
||||
#define real_malloc malloc
|
||||
#define real_calloc calloc
|
||||
#define real_realloc realloc
|
||||
#define real_free free
|
||||
static void* SDLCALL real_malloc(size_t s) { return malloc(s); }
|
||||
static void* SDLCALL real_calloc(size_t n, size_t s) { return calloc(n, s); }
|
||||
static void* SDLCALL real_realloc(void *p, size_t s) { return realloc(p,s); }
|
||||
static void SDLCALL real_free(void *p) { free(p); }
|
||||
#else
|
||||
#define real_malloc dlmalloc
|
||||
#define real_calloc dlcalloc
|
||||
|
79
externals/SDL/src/stdlib/SDL_memcpy.c
vendored
Executable file
79
externals/SDL/src/stdlib/SDL_memcpy.c
vendored
Executable file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
/* This file contains a portable memcpy manipulation function for SDL */
|
||||
|
||||
void *
|
||||
SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
/* Presumably this is well tuned for speed.
|
||||
On my machine this is twice as fast as the C code below.
|
||||
*/
|
||||
return __builtin_memcpy(dst, src, len);
|
||||
#elif defined(HAVE_MEMCPY)
|
||||
return memcpy(dst, src, len);
|
||||
#elif defined(HAVE_BCOPY)
|
||||
bcopy(src, dst, len);
|
||||
return dst;
|
||||
#else
|
||||
/* GCC 4.9.0 with -O3 will generate movaps instructions with the loop
|
||||
using Uint32* pointers, so we need to make sure the pointers are
|
||||
aligned before we loop using them.
|
||||
*/
|
||||
if (((uintptr_t)src & 0x3) || ((uintptr_t)dst & 0x3)) {
|
||||
/* Do an unaligned byte copy */
|
||||
Uint8 *srcp1 = (Uint8 *)src;
|
||||
Uint8 *dstp1 = (Uint8 *)dst;
|
||||
|
||||
while (len--) {
|
||||
*dstp1++ = *srcp1++;
|
||||
}
|
||||
} else {
|
||||
size_t left = (len % 4);
|
||||
Uint32 *srcp4, *dstp4;
|
||||
Uint8 *srcp1, *dstp1;
|
||||
|
||||
srcp4 = (Uint32 *) src;
|
||||
dstp4 = (Uint32 *) dst;
|
||||
len /= 4;
|
||||
while (len--) {
|
||||
*dstp4++ = *srcp4++;
|
||||
}
|
||||
|
||||
srcp1 = (Uint8 *) srcp4;
|
||||
dstp1 = (Uint8 *) dstp4;
|
||||
switch (left) {
|
||||
case 3:
|
||||
*dstp1++ = *srcp1++;
|
||||
case 2:
|
||||
*dstp1++ = *srcp1++;
|
||||
case 1:
|
||||
*dstp1++ = *srcp1++;
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
#endif /* __GNUC__ */
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
75
externals/SDL/src/stdlib/SDL_memset.c
vendored
Executable file
75
externals/SDL/src/stdlib/SDL_memset.c
vendored
Executable file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
/* This file contains a portable memset manipulation function for SDL */
|
||||
|
||||
void *
|
||||
SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
|
||||
{
|
||||
#if defined(HAVE_MEMSET)
|
||||
return memset(dst, c, len);
|
||||
#else
|
||||
size_t left;
|
||||
Uint32 *dstp4;
|
||||
Uint8 *dstp1 = (Uint8 *) dst;
|
||||
Uint8 value1;
|
||||
Uint32 value4;
|
||||
|
||||
/* The value used in memset() is a byte, passed as an int */
|
||||
c &= 0xff;
|
||||
|
||||
/* The destination pointer needs to be aligned on a 4-byte boundary to
|
||||
* execute a 32-bit set. Set first bytes manually if needed until it is
|
||||
* aligned. */
|
||||
value1 = (Uint8)c;
|
||||
while ((uintptr_t)dstp1 & 0x3) {
|
||||
if (len--) {
|
||||
*dstp1++ = value1;
|
||||
} else {
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
|
||||
value4 = ((Uint32)c | ((Uint32)c << 8) | ((Uint32)c << 16) | ((Uint32)c << 24));
|
||||
dstp4 = (Uint32 *) dstp1;
|
||||
left = (len % 4);
|
||||
len /= 4;
|
||||
while (len--) {
|
||||
*dstp4++ = value4;
|
||||
}
|
||||
|
||||
dstp1 = (Uint8 *) dstp4;
|
||||
switch (left) {
|
||||
case 3:
|
||||
*dstp1++ = value1;
|
||||
case 2:
|
||||
*dstp1++ = value1;
|
||||
case 1:
|
||||
*dstp1++ = value1;
|
||||
}
|
||||
|
||||
return dst;
|
||||
#endif /* HAVE_MEMSET */
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
35
externals/SDL/src/stdlib/SDL_qsort.c
vendored
35
externals/SDL/src/stdlib/SDL_qsort.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -534,5 +534,38 @@ extern void qsortG(void *base, size_t nmemb, size_t size,
|
||||
|
||||
#endif /* HAVE_QSORT */
|
||||
|
||||
void *
|
||||
SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *))
|
||||
{
|
||||
#if defined(HAVE_BSEARCH)
|
||||
return bsearch(key, base, nmemb, size, compare);
|
||||
#else
|
||||
/* SDL's replacement: Taken from the Public Domain C Library (PDCLib):
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
const void *pivot;
|
||||
size_t corr;
|
||||
int rc;
|
||||
|
||||
while (nmemb) {
|
||||
/* algorithm needs -1 correction if remaining elements are an even number. */
|
||||
corr = nmemb % 2;
|
||||
nmemb /= 2;
|
||||
pivot = (const char *)base + (nmemb * size);
|
||||
rc = compare(key, pivot);
|
||||
|
||||
if (rc > 0) {
|
||||
base = (const char *)pivot + size;
|
||||
/* applying correction */
|
||||
nmemb -= (1 - corr);
|
||||
} else if (rc == 0) {
|
||||
return (void *)pivot;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
#endif /* HAVE_BSEARCH */
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
|
9
externals/SDL/src/stdlib/SDL_stdlib.c
vendored
9
externals/SDL/src/stdlib/SDL_stdlib.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -549,8 +549,9 @@ int SDL_isblank(int x) { return ((x) == ' ') || ((x) == '\t'); }
|
||||
__declspec(selectany) int _fltused = 1;
|
||||
#endif
|
||||
|
||||
/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls */
|
||||
#if _MSC_VER >= 1400
|
||||
/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls.
|
||||
Always provide it for the SDL2 DLL, but skip it when building static lib w/ static runtime. */
|
||||
#if (_MSC_VER >= 1400) && (!defined(_MT) || defined(DLL_EXPORT))
|
||||
extern void *memcpy(void* dst, const void* src, size_t len);
|
||||
#pragma intrinsic(memcpy)
|
||||
|
||||
@@ -570,7 +571,7 @@ memset(void *dst, int c, size_t len)
|
||||
{
|
||||
return SDL_memset(dst, c, len);
|
||||
}
|
||||
#endif /* _MSC_VER >= 1400 */
|
||||
#endif /* (_MSC_VER >= 1400) && (!defined(_MT) || defined(DLL_EXPORT)) */
|
||||
|
||||
#ifdef _M_IX86
|
||||
|
||||
|
202
externals/SDL/src/stdlib/SDL_string.c
vendored
202
externals/SDL/src/stdlib/SDL_string.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -27,12 +27,7 @@
|
||||
/* This file contains portable string manipulation functions for SDL */
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1800
|
||||
/* Visual Studio 2013 tries to link with _vacopy in the C runtime. Newer versions do an inline assignment */
|
||||
#undef va_copy
|
||||
#define va_copy(dst, src) dst = src
|
||||
#endif
|
||||
#include "SDL_vacopy.h"
|
||||
|
||||
#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOL) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD) || !defined(HAVE_STRTOLL) || !defined(HAVE_STRTOULL)
|
||||
#define SDL_isupperhex(X) (((X) >= 'A') && ((X) <= 'F'))
|
||||
@@ -42,7 +37,7 @@
|
||||
#define UTF8_IsLeadByte(c) ((c) >= 0xC0 && (c) <= 0xF4)
|
||||
#define UTF8_IsTrailingByte(c) ((c) >= 0x80 && (c) <= 0xBF)
|
||||
|
||||
static int UTF8_TrailingBytes(unsigned char c)
|
||||
static unsigned UTF8_TrailingBytes(unsigned char c)
|
||||
{
|
||||
if (c >= 0xC0 && c <= 0xDF)
|
||||
return 1;
|
||||
@@ -268,108 +263,6 @@ SDL_ScanFloat(const char *text, double *valuep)
|
||||
}
|
||||
#endif
|
||||
|
||||
void *
|
||||
SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
|
||||
{
|
||||
#if defined(HAVE_MEMSET)
|
||||
return memset(dst, c, len);
|
||||
#else
|
||||
size_t left;
|
||||
Uint32 *dstp4;
|
||||
Uint8 *dstp1 = (Uint8 *) dst;
|
||||
Uint8 value1;
|
||||
Uint32 value4;
|
||||
|
||||
/* The value used in memset() is a byte, passed as an int */
|
||||
c &= 0xff;
|
||||
|
||||
/* The destination pointer needs to be aligned on a 4-byte boundary to
|
||||
* execute a 32-bit set. Set first bytes manually if needed until it is
|
||||
* aligned. */
|
||||
value1 = (Uint8)c;
|
||||
while ((uintptr_t)dstp1 & 0x3) {
|
||||
if (len--) {
|
||||
*dstp1++ = value1;
|
||||
} else {
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
|
||||
value4 = (c | (c << 8) | (c << 16) | (c << 24));
|
||||
dstp4 = (Uint32 *) dstp1;
|
||||
left = (len % 4);
|
||||
len /= 4;
|
||||
while (len--) {
|
||||
*dstp4++ = value4;
|
||||
}
|
||||
|
||||
dstp1 = (Uint8 *) dstp4;
|
||||
switch (left) {
|
||||
case 3:
|
||||
*dstp1++ = value1;
|
||||
case 2:
|
||||
*dstp1++ = value1;
|
||||
case 1:
|
||||
*dstp1++ = value1;
|
||||
}
|
||||
|
||||
return dst;
|
||||
#endif /* HAVE_MEMSET */
|
||||
}
|
||||
|
||||
void *
|
||||
SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
/* Presumably this is well tuned for speed.
|
||||
On my machine this is twice as fast as the C code below.
|
||||
*/
|
||||
return __builtin_memcpy(dst, src, len);
|
||||
#elif defined(HAVE_MEMCPY)
|
||||
return memcpy(dst, src, len);
|
||||
#elif defined(HAVE_BCOPY)
|
||||
bcopy(src, dst, len);
|
||||
return dst;
|
||||
#else
|
||||
/* GCC 4.9.0 with -O3 will generate movaps instructions with the loop
|
||||
using Uint32* pointers, so we need to make sure the pointers are
|
||||
aligned before we loop using them.
|
||||
*/
|
||||
if (((uintptr_t)src & 0x3) || ((uintptr_t)dst & 0x3)) {
|
||||
/* Do an unaligned byte copy */
|
||||
Uint8 *srcp1 = (Uint8 *)src;
|
||||
Uint8 *dstp1 = (Uint8 *)dst;
|
||||
|
||||
while (len--) {
|
||||
*dstp1++ = *srcp1++;
|
||||
}
|
||||
} else {
|
||||
size_t left = (len % 4);
|
||||
Uint32 *srcp4, *dstp4;
|
||||
Uint8 *srcp1, *dstp1;
|
||||
|
||||
srcp4 = (Uint32 *) src;
|
||||
dstp4 = (Uint32 *) dst;
|
||||
len /= 4;
|
||||
while (len--) {
|
||||
*dstp4++ = *srcp4++;
|
||||
}
|
||||
|
||||
srcp1 = (Uint8 *) srcp4;
|
||||
dstp1 = (Uint8 *) dstp4;
|
||||
switch (left) {
|
||||
case 3:
|
||||
*dstp1++ = *srcp1++;
|
||||
case 2:
|
||||
*dstp1++ = *srcp1++;
|
||||
case 1:
|
||||
*dstp1++ = *srcp1++;
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
#endif /* __GNUC__ */
|
||||
}
|
||||
|
||||
void *
|
||||
SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
|
||||
{
|
||||
@@ -638,20 +531,17 @@ SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_
|
||||
size_t src_bytes = SDL_strlen(src);
|
||||
size_t bytes = SDL_min(src_bytes, dst_bytes - 1);
|
||||
size_t i = 0;
|
||||
char trailing_bytes = 0;
|
||||
if (bytes)
|
||||
{
|
||||
unsigned char trailing_bytes = 0;
|
||||
|
||||
if (bytes) {
|
||||
unsigned char c = (unsigned char)src[bytes - 1];
|
||||
if (UTF8_IsLeadByte(c))
|
||||
if (UTF8_IsLeadByte(c)) {
|
||||
--bytes;
|
||||
else if (UTF8_IsTrailingByte(c))
|
||||
{
|
||||
for (i = bytes - 1; i != 0; --i)
|
||||
{
|
||||
} else if (UTF8_IsTrailingByte(c)) {
|
||||
for (i = bytes - 1; i != 0; --i) {
|
||||
c = (unsigned char)src[i];
|
||||
trailing_bytes = UTF8_TrailingBytes(c);
|
||||
if (trailing_bytes)
|
||||
{
|
||||
if (trailing_bytes) {
|
||||
if (bytes - i != trailing_bytes + 1)
|
||||
bytes = i;
|
||||
|
||||
@@ -662,6 +552,7 @@ SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_
|
||||
SDL_memcpy(dst, src, bytes);
|
||||
}
|
||||
dst[bytes] = '\0';
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@@ -670,7 +561,7 @@ SDL_utf8strlen(const char *str)
|
||||
{
|
||||
size_t retval = 0;
|
||||
const char *p = str;
|
||||
char ch;
|
||||
unsigned char ch;
|
||||
|
||||
while ((ch = *(p++)) != 0) {
|
||||
/* if top two bits are 1 and 0, it's a continuation byte. */
|
||||
@@ -682,6 +573,23 @@ SDL_utf8strlen(const char *str)
|
||||
return retval;
|
||||
}
|
||||
|
||||
size_t
|
||||
SDL_utf8strnlen(const char *str, size_t bytes)
|
||||
{
|
||||
size_t retval = 0;
|
||||
const char *p = str;
|
||||
unsigned char ch;
|
||||
|
||||
while ((ch = *(p++)) != 0 && bytes-- > 0) {
|
||||
/* if top two bits are 1 and 0, it's a continuation byte. */
|
||||
if ((ch & 0xc0) != 0x80) {
|
||||
retval++;
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
size_t
|
||||
SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
|
||||
{
|
||||
@@ -1070,13 +978,16 @@ SDL_strcmp(const char *str1, const char *str2)
|
||||
#if defined(HAVE_STRCMP)
|
||||
return strcmp(str1, str2);
|
||||
#else
|
||||
while (*str1 && *str2) {
|
||||
if (*str1 != *str2)
|
||||
int result;
|
||||
|
||||
while(1) {
|
||||
result = (int)((unsigned char) *str1 - (unsigned char) *str2);
|
||||
if (result != 0 || (*str1 == '\0'/* && *str2 == '\0'*/))
|
||||
break;
|
||||
++str1;
|
||||
++str2;
|
||||
}
|
||||
return (int)((unsigned char) *str1 - (unsigned char) *str2);
|
||||
return result;
|
||||
#endif /* HAVE_STRCMP */
|
||||
}
|
||||
|
||||
@@ -1086,17 +997,20 @@ SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
|
||||
#if defined(HAVE_STRNCMP)
|
||||
return strncmp(str1, str2, maxlen);
|
||||
#else
|
||||
while (*str1 && *str2 && maxlen) {
|
||||
if (*str1 != *str2)
|
||||
int result;
|
||||
|
||||
while (maxlen) {
|
||||
result = (int) (unsigned char) *str1 - (unsigned char) *str2;
|
||||
if (result != 0 || *str1 == '\0'/* && *str2 == '\0'*/)
|
||||
break;
|
||||
++str1;
|
||||
++str2;
|
||||
--maxlen;
|
||||
}
|
||||
if (!maxlen) {
|
||||
return 0;
|
||||
result = 0;
|
||||
}
|
||||
return (int) ((unsigned char) *str1 - (unsigned char) *str2);
|
||||
return result;
|
||||
#endif /* HAVE_STRNCMP */
|
||||
}
|
||||
|
||||
@@ -1108,19 +1022,18 @@ SDL_strcasecmp(const char *str1, const char *str2)
|
||||
#elif defined(HAVE__STRICMP)
|
||||
return _stricmp(str1, str2);
|
||||
#else
|
||||
char a = 0;
|
||||
char b = 0;
|
||||
while (*str1 && *str2) {
|
||||
int a, b, result;
|
||||
|
||||
while (1) {
|
||||
a = SDL_toupper((unsigned char) *str1);
|
||||
b = SDL_toupper((unsigned char) *str2);
|
||||
if (a != b)
|
||||
result = a - b;
|
||||
if (result != 0 || a == 0 /*&& b == 0*/)
|
||||
break;
|
||||
++str1;
|
||||
++str2;
|
||||
}
|
||||
a = SDL_toupper(*str1);
|
||||
b = SDL_toupper(*str2);
|
||||
return (int) ((unsigned char) a - (unsigned char) b);
|
||||
return result;
|
||||
#endif /* HAVE_STRCASECMP */
|
||||
}
|
||||
|
||||
@@ -1132,24 +1045,21 @@ SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen)
|
||||
#elif defined(HAVE__STRNICMP)
|
||||
return _strnicmp(str1, str2, maxlen);
|
||||
#else
|
||||
char a = 0;
|
||||
char b = 0;
|
||||
while (*str1 && *str2 && maxlen) {
|
||||
int a, b, result;
|
||||
|
||||
while (maxlen) {
|
||||
a = SDL_tolower((unsigned char) *str1);
|
||||
b = SDL_tolower((unsigned char) *str2);
|
||||
if (a != b)
|
||||
result = a - b;
|
||||
if (result != 0 || a == 0 /*&& b == 0*/)
|
||||
break;
|
||||
++str1;
|
||||
++str2;
|
||||
--maxlen;
|
||||
}
|
||||
if (maxlen == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
a = SDL_tolower((unsigned char) *str1);
|
||||
b = SDL_tolower((unsigned char) *str2);
|
||||
return (int) ((unsigned char) a - (unsigned char) b);
|
||||
}
|
||||
if (maxlen == 0)
|
||||
result = 0;
|
||||
return result;
|
||||
#endif /* HAVE_STRNCASECMP */
|
||||
}
|
||||
|
||||
|
2
externals/SDL/src/stdlib/SDL_strtokr.c
vendored
2
externals/SDL/src/stdlib/SDL_strtokr.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
36
externals/SDL/src/stdlib/SDL_vacopy.h
vendored
Executable file
36
externals/SDL/src/stdlib/SDL_vacopy.h
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* Do our best to make sure va_copy is working */
|
||||
#if defined(__NGAGE__)
|
||||
#undef va_copy
|
||||
#define va_copy(dst, src) dst = src
|
||||
|
||||
#elif defined(_MSC_VER) && _MSC_VER <= 1800
|
||||
/* Visual Studio 2013 tries to link with _vacopy in the C runtime. Newer versions do an inline assignment */
|
||||
#undef va_copy
|
||||
#define va_copy(dst, src) dst = src
|
||||
|
||||
#elif defined(__GNUC__) && (__GNUC__ < 3)
|
||||
#define va_copy(dst, src) __va_copy(dst, src)
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
Reference in New Issue
Block a user