mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-26 01:04:17 +00:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
This commit is contained in:
@@ -2765,5 +2765,5 @@ static const CaseFoldHashBucket3_16 case_fold_hash3_16[] = {
|
||||
{ case_fold3_16_003, SDL_arraysize(case_fold3_16_003) },
|
||||
};
|
||||
|
||||
#endif /* SDL_casefolding_h_ */
|
||||
#endif // SDL_casefolding_h_
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ static Uint16 crc16_for_byte(Uint8 r)
|
||||
|
||||
Uint16 SDL_crc16(Uint16 crc, const void *data, size_t len)
|
||||
{
|
||||
/* As an optimization we can precalculate a 256 entry table for each byte */
|
||||
// As an optimization we can precalculate a 256 entry table for each byte
|
||||
size_t i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
crc = crc16_for_byte((Uint8)crc ^ ((const Uint8 *)data)[i]) ^ crc >> 8;
|
||||
|
||||
@@ -41,7 +41,7 @@ static Uint32 crc32_for_byte(Uint32 r)
|
||||
|
||||
Uint32 SDL_crc32(Uint32 crc, const void *data, size_t len)
|
||||
{
|
||||
/* As an optimization we can precalculate a 256 entry table for each byte */
|
||||
// As an optimization we can precalculate a 256 entry table for each byte
|
||||
size_t i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
crc = crc32_for_byte((Uint8)crc ^ ((const Uint8 *)data)[i]) ^ crc >> 8;
|
||||
|
||||
@@ -40,37 +40,37 @@
|
||||
#define HAVE_LOCAL_ENVIRONMENT
|
||||
#endif
|
||||
|
||||
/* Put a variable into the environment */
|
||||
/* Note: Name may not contain a '=' character. (Reference: http://www.unix.com/man-page/Linux/3/setenv/) */
|
||||
// Put a variable into the environment
|
||||
// Note: Name may not contain a '=' character. (Reference: http://www.unix.com/man-page/Linux/3/setenv/)
|
||||
#ifdef HAVE_LIBC_ENVIRONMENT
|
||||
#if defined(HAVE_SETENV)
|
||||
int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return setenv(name, value, overwrite);
|
||||
}
|
||||
/* We have a real environment table, but no real setenv? Fake it w/ putenv. */
|
||||
// We have a real environment table, but no real setenv? Fake it w/ putenv.
|
||||
#else
|
||||
int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
char *new_variable;
|
||||
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (getenv(name) != NULL) {
|
||||
if (!overwrite) {
|
||||
return 0; /* leave the existing one there. */
|
||||
return 0; // leave the existing one there.
|
||||
}
|
||||
}
|
||||
|
||||
/* This leaks. Sorry. Get a better OS so we don't have to do this. */
|
||||
// This leaks. Sorry. Get a better OS so we don't have to do this.
|
||||
SDL_asprintf(&new_variable, "%s=%s", name, value);
|
||||
if (!new_variable) {
|
||||
return -1;
|
||||
@@ -81,14 +81,14 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
#elif defined(HAVE_WIN32_ENVIRONMENT)
|
||||
int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!overwrite) {
|
||||
if (GetEnvironmentVariableA(name, NULL, 0) > 0) {
|
||||
return 0; /* asked not to overwrite existing value. */
|
||||
return 0; // asked not to overwrite existing value.
|
||||
}
|
||||
}
|
||||
if (!SetEnvironmentVariableA(name, value)) {
|
||||
@@ -96,9 +96,9 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#else /* roll our own */
|
||||
#else // roll our own
|
||||
|
||||
/* We'll leak this, as environment variables are intended to persist past SDL_Quit() */
|
||||
// We'll leak this, as environment variables are intended to persist past SDL_Quit()
|
||||
static char **SDL_env;
|
||||
|
||||
int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
@@ -108,17 +108,17 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
char **new_env;
|
||||
char *new_variable;
|
||||
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See if it already exists */
|
||||
// See if it already exists
|
||||
if (!overwrite && SDL_getenv(name)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allocate memory for the variable */
|
||||
// Allocate memory for the variable
|
||||
len = SDL_strlen(name) + SDL_strlen(value) + 2;
|
||||
new_variable = (char *)SDL_malloc(len);
|
||||
if (!new_variable) {
|
||||
@@ -129,15 +129,15 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
value = new_variable + SDL_strlen(name) + 1;
|
||||
name = new_variable;
|
||||
|
||||
/* Actually put it into the environment */
|
||||
// Actually put it into the environment
|
||||
added = 0;
|
||||
i = 0;
|
||||
if (SDL_env) {
|
||||
/* Check to see if it's already there... */
|
||||
// Check to see if it's already there...
|
||||
len = (value - name);
|
||||
for (; SDL_env[i]; ++i) {
|
||||
if (SDL_strncmp(SDL_env[i], name, len) == 0) {
|
||||
/* If we found it, just replace the entry */
|
||||
// If we found it, just replace the entry
|
||||
SDL_free(SDL_env[i]);
|
||||
SDL_env[i] = new_variable;
|
||||
added = 1;
|
||||
@@ -146,7 +146,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
}
|
||||
}
|
||||
|
||||
/* Didn't find it in the environment, expand and add */
|
||||
// Didn't find it in the environment, expand and add
|
||||
if (!added) {
|
||||
new_env = SDL_realloc(SDL_env, (i + 2) * sizeof(char *));
|
||||
if (new_env) {
|
||||
@@ -166,18 +166,18 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
#if defined(HAVE_UNSETENV)
|
||||
int SDL_unsetenv(const char *name)
|
||||
{
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return unsetenv(name);
|
||||
}
|
||||
/* We have a real environment table, but no unsetenv? Fake it w/ putenv. */
|
||||
// We have a real environment table, but no unsetenv? Fake it w/ putenv.
|
||||
#else
|
||||
int SDL_unsetenv(const char *name)
|
||||
{
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL) {
|
||||
return -1;
|
||||
}
|
||||
@@ -189,7 +189,7 @@ int SDL_unsetenv(const char *name)
|
||||
#elif defined(HAVE_WIN32_ENVIRONMENT)
|
||||
int SDL_unsetenv(const char *name)
|
||||
{
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL) {
|
||||
return -1;
|
||||
}
|
||||
@@ -204,7 +204,7 @@ int SDL_unsetenv(const char *name)
|
||||
{
|
||||
size_t len, i;
|
||||
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL) {
|
||||
return -1;
|
||||
}
|
||||
@@ -214,7 +214,7 @@ int SDL_unsetenv(const char *name)
|
||||
for (i = 0; SDL_env[i]; ++i) {
|
||||
if ((SDL_strncmp(SDL_env[i], name, len) == 0) &&
|
||||
(SDL_env[i][len] == '=')) {
|
||||
/* Just clear out this entry for now */
|
||||
// Just clear out this entry for now
|
||||
*SDL_env[i] = '\0';
|
||||
break;
|
||||
}
|
||||
@@ -224,16 +224,16 @@ int SDL_unsetenv(const char *name)
|
||||
}
|
||||
#endif // HAVE_LIBC_ENVIRONMENT
|
||||
|
||||
/* Retrieve a variable named "name" from the environment */
|
||||
// Retrieve a variable named "name" from the environment
|
||||
#ifdef HAVE_LIBC_ENVIRONMENT
|
||||
const char *SDL_getenv(const char *name)
|
||||
{
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
/* Make sure variables from the application manifest are available */
|
||||
// Make sure variables from the application manifest are available
|
||||
Android_JNI_GetManifestEnvironmentVariables();
|
||||
#endif
|
||||
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ const char *SDL_getenv(const char *name)
|
||||
char *string = NULL;
|
||||
const char *retval = NULL;
|
||||
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ const char *SDL_getenv(const char *name)
|
||||
size_t len, i;
|
||||
char *value;
|
||||
|
||||
/* Input validation */
|
||||
// Input validation
|
||||
if (!name || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This file contains portable iconv functions for SDL */
|
||||
// This file contains portable iconv functions for SDL
|
||||
|
||||
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
|
||||
#ifndef SDL_USE_LIBICONV
|
||||
/* Define LIBICONV_PLUG to use iconv from the base instead of ports and avoid linker errors. */
|
||||
// Define LIBICONV_PLUG to use iconv from the base instead of ports and avoid linker errors.
|
||||
#define LIBICONV_PLUG 1
|
||||
#endif
|
||||
#include <iconv.h>
|
||||
@@ -87,10 +87,10 @@ enum
|
||||
ENCODING_ASCII,
|
||||
ENCODING_LATIN1,
|
||||
ENCODING_UTF8,
|
||||
ENCODING_UTF16, /* Needs byte order marker */
|
||||
ENCODING_UTF16, // Needs byte order marker
|
||||
ENCODING_UTF16BE,
|
||||
ENCODING_UTF16LE,
|
||||
ENCODING_UTF32, /* Needs byte order marker */
|
||||
ENCODING_UTF32, // Needs byte order marker
|
||||
ENCODING_UTF32BE,
|
||||
ENCODING_UTF32LE,
|
||||
ENCODING_UCS2BE,
|
||||
@@ -121,7 +121,7 @@ static struct
|
||||
const char *name;
|
||||
int format;
|
||||
} encodings[] = {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
{ "ASCII", ENCODING_ASCII },
|
||||
{ "US-ASCII", ENCODING_ASCII },
|
||||
{ "8859-1", ENCODING_LATIN1 },
|
||||
@@ -155,7 +155,7 @@ static struct
|
||||
{ "UCS-4LE", ENCODING_UCS4LE },
|
||||
{ "UCS-4BE", ENCODING_UCS4BE },
|
||||
{ "UCS-4-INTERNAL", ENCODING_UCS4NATIVE },
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
};
|
||||
|
||||
static const char *getlocale(char *buffer, size_t bufsize)
|
||||
@@ -177,7 +177,7 @@ static const char *getlocale(char *buffer, size_t bufsize)
|
||||
lang = "ASCII";
|
||||
}
|
||||
|
||||
/* We need to trim down strings like "en_US.UTF-8@blah" to "UTF-8" */
|
||||
// We need to trim down strings like "en_US.UTF-8@blah" to "UTF-8"
|
||||
ptr = SDL_strchr(lang, '.');
|
||||
if (ptr) {
|
||||
lang = ptr + 1;
|
||||
@@ -186,7 +186,7 @@ static const char *getlocale(char *buffer, size_t bufsize)
|
||||
SDL_strlcpy(buffer, lang, bufsize);
|
||||
ptr = SDL_strchr(buffer, '@');
|
||||
if (ptr) {
|
||||
*ptr = '\0'; /* chop end of string. */
|
||||
*ptr = '\0'; // chop end of string.
|
||||
}
|
||||
|
||||
return buffer;
|
||||
@@ -235,7 +235,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
const char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft)
|
||||
{
|
||||
/* For simplicity, we'll convert everything to and from UCS-4 */
|
||||
// For simplicity, we'll convert everything to and from UCS-4
|
||||
const char *src;
|
||||
char *dst;
|
||||
size_t srclen, dstlen;
|
||||
@@ -246,7 +246,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
return SDL_ICONV_ERROR;
|
||||
}
|
||||
if (!inbuf || !*inbuf) {
|
||||
/* Reset the context */
|
||||
// Reset the context
|
||||
return 0;
|
||||
}
|
||||
if (!outbuf || !*outbuf || !outbytesleft || !*outbytesleft) {
|
||||
@@ -259,7 +259,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
|
||||
switch (cd->src_fmt) {
|
||||
case ENCODING_UTF16:
|
||||
/* Scan for a byte order marker */
|
||||
// Scan for a byte order marker
|
||||
{
|
||||
Uint8 *p = (Uint8 *)src;
|
||||
size_t n = srclen / 2;
|
||||
@@ -275,13 +275,13 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
--n;
|
||||
}
|
||||
if (n == 0) {
|
||||
/* We can't tell, default to host order */
|
||||
// We can't tell, default to host order
|
||||
cd->src_fmt = ENCODING_UTF16NATIVE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ENCODING_UTF32:
|
||||
/* Scan for a byte order marker */
|
||||
// Scan for a byte order marker
|
||||
{
|
||||
Uint8 *p = (Uint8 *)src;
|
||||
size_t n = srclen / 4;
|
||||
@@ -299,7 +299,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
--n;
|
||||
}
|
||||
if (n == 0) {
|
||||
/* We can't tell, default to host order */
|
||||
// We can't tell, default to host order
|
||||
cd->src_fmt = ENCODING_UTF32NATIVE;
|
||||
}
|
||||
}
|
||||
@@ -308,7 +308,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
|
||||
switch (cd->dst_fmt) {
|
||||
case ENCODING_UTF16:
|
||||
/* Default to host order, need to add byte order marker */
|
||||
// Default to host order, need to add byte order marker
|
||||
if (dstlen < 2) {
|
||||
return SDL_ICONV_E2BIG;
|
||||
}
|
||||
@@ -318,7 +318,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
cd->dst_fmt = ENCODING_UTF16NATIVE;
|
||||
break;
|
||||
case ENCODING_UTF32:
|
||||
/* Default to host order, need to add byte order marker */
|
||||
// Default to host order, need to add byte order marker
|
||||
if (dstlen < 4) {
|
||||
return SDL_ICONV_E2BIG;
|
||||
}
|
||||
@@ -331,7 +331,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
|
||||
total = 0;
|
||||
while (srclen > 0) {
|
||||
/* Decode a character */
|
||||
// Decode a character
|
||||
switch (cd->src_fmt) {
|
||||
case ENCODING_ASCII:
|
||||
{
|
||||
@@ -347,7 +347,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
++src;
|
||||
--srclen;
|
||||
} break;
|
||||
case ENCODING_UTF8: /* RFC 3629 */
|
||||
case ENCODING_UTF8: // RFC 3629
|
||||
{
|
||||
Uint8 *p = (Uint8 *)src;
|
||||
size_t left = 0;
|
||||
@@ -434,7 +434,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
ch = UNKNOWN_UNICODE;
|
||||
}
|
||||
} break;
|
||||
case ENCODING_UTF16BE: /* RFC 2781 */
|
||||
case ENCODING_UTF16BE: // RFC 2781
|
||||
{
|
||||
Uint8 *p = (Uint8 *)src;
|
||||
Uint16 W1, W2;
|
||||
@@ -473,7 +473,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
(Uint32)(W2 & 0x3FF)) +
|
||||
0x10000;
|
||||
} break;
|
||||
case ENCODING_UTF16LE: /* RFC 2781 */
|
||||
case ENCODING_UTF16LE: // RFC 2781
|
||||
{
|
||||
Uint8 *p = (Uint8 *)src;
|
||||
Uint16 W1, W2;
|
||||
@@ -560,7 +560,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
} break;
|
||||
}
|
||||
|
||||
/* Encode a character */
|
||||
// Encode a character
|
||||
switch (cd->dst_fmt) {
|
||||
case ENCODING_ASCII:
|
||||
{
|
||||
@@ -590,7 +590,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
++dst;
|
||||
--dstlen;
|
||||
} break;
|
||||
case ENCODING_UTF8: /* RFC 3629 */
|
||||
case ENCODING_UTF8: // RFC 3629
|
||||
{
|
||||
Uint8 *p = (Uint8 *)dst;
|
||||
if (ch > 0x10FFFF) {
|
||||
@@ -632,7 +632,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
dstlen -= 4;
|
||||
}
|
||||
} break;
|
||||
case ENCODING_UTF16BE: /* RFC 2781 */
|
||||
case ENCODING_UTF16BE: // RFC 2781
|
||||
{
|
||||
Uint8 *p = (Uint8 *)dst;
|
||||
if (ch > 0x10FFFF) {
|
||||
@@ -662,7 +662,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
dstlen -= 4;
|
||||
}
|
||||
} break;
|
||||
case ENCODING_UTF16LE: /* RFC 2781 */
|
||||
case ENCODING_UTF16LE: // RFC 2781
|
||||
{
|
||||
Uint8 *p = (Uint8 *)dst;
|
||||
if (ch > 0x10FFFF) {
|
||||
@@ -766,7 +766,7 @@ size_t SDL_iconv(SDL_iconv_t cd,
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update state */
|
||||
// Update state
|
||||
*inbuf = src;
|
||||
*inbytesleft = srclen;
|
||||
*outbuf = dst;
|
||||
@@ -785,7 +785,7 @@ int SDL_iconv_close(SDL_iconv_t cd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !HAVE_ICONV */
|
||||
#endif // !HAVE_ICONV
|
||||
|
||||
char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)
|
||||
{
|
||||
@@ -838,17 +838,17 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb
|
||||
continue;
|
||||
}
|
||||
case SDL_ICONV_EILSEQ:
|
||||
/* Try skipping some input data - not perfect, but... */
|
||||
// Try skipping some input data - not perfect, but...
|
||||
++inbuf;
|
||||
--inbytesleft;
|
||||
break;
|
||||
case SDL_ICONV_EINVAL:
|
||||
case SDL_ICONV_ERROR:
|
||||
/* We can't continue... */
|
||||
// We can't continue...
|
||||
inbytesleft = 0;
|
||||
break;
|
||||
}
|
||||
/* Avoid infinite loops when nothing gets converted */
|
||||
// Avoid infinite loops when nothing gets converted
|
||||
if (oldinbytesleft == inbytesleft) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ void *SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void
|
||||
aligned before we loop using them.
|
||||
*/
|
||||
if (((uintptr_t)src & 0x3) || ((uintptr_t)dst & 0x3)) {
|
||||
/* Do an unaligned byte copy */
|
||||
// Do an unaligned byte copy
|
||||
Uint8 *srcp1 = (Uint8 *)src;
|
||||
Uint8 *dstp1 = (Uint8 *)dst;
|
||||
|
||||
@@ -78,13 +78,13 @@ void *SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
#endif /* HAVE_MEMCPY */
|
||||
#endif // HAVE_MEMCPY
|
||||
}
|
||||
|
||||
/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls.
|
||||
We will provide our own implementation if we're not building with a C runtime. */
|
||||
#ifndef HAVE_LIBC
|
||||
/* NOLINTNEXTLINE(readability-redundant-declaration) */
|
||||
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||
extern void *memcpy(void *dst, const void *src, size_t len);
|
||||
#if defined(_MSC_VER) && !defined(__INTEL_LLVM_COMPILER)
|
||||
#pragma intrinsic(memcpy)
|
||||
@@ -93,9 +93,9 @@ extern void *memcpy(void *dst, const void *src, size_t len);
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#pragma function(memcpy)
|
||||
#endif
|
||||
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
|
||||
// NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name)
|
||||
void *memcpy(void *dst, const void *src, size_t len)
|
||||
{
|
||||
return SDL_memcpy(dst, src, len);
|
||||
}
|
||||
#endif /* !HAVE_LIBC */
|
||||
#endif // !HAVE_LIBC
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
void *SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
|
||||
{
|
||||
#if defined(__GNUC__) && (defined(HAVE_LIBC) && HAVE_LIBC)
|
||||
/* Presumably this is well tuned for speed. */
|
||||
// Presumably this is well tuned for speed.
|
||||
return __builtin_memmove(dst, src, len);
|
||||
#elif defined(HAVE_MEMMOVE)
|
||||
return memmove(dst, src, len);
|
||||
@@ -50,12 +50,12 @@ void *SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
#endif /* HAVE_MEMMOVE */
|
||||
#endif // HAVE_MEMMOVE
|
||||
}
|
||||
|
||||
|
||||
#ifndef HAVE_LIBC
|
||||
/* NOLINTNEXTLINE(readability-redundant-declaration) */
|
||||
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||
extern void *memmove(void *dst, const void *src, size_t len);
|
||||
#if defined(_MSC_VER) && !defined(__INTEL_LLVM_COMPILER)
|
||||
#pragma intrinsic(memmove)
|
||||
@@ -64,10 +64,10 @@ extern void *memmove(void *dst, const void *src, size_t len);
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#pragma function(memmove)
|
||||
#endif
|
||||
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
|
||||
// NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name)
|
||||
void *memmove(void *dst, const void *src, size_t len)
|
||||
{
|
||||
return SDL_memmove(dst, src, len);
|
||||
}
|
||||
#endif /* !HAVE_LIBC */
|
||||
#endif // !HAVE_LIBC
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ void *SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
|
||||
Uint8 value1;
|
||||
Uint32 value4;
|
||||
|
||||
/* The value used in memset() is a byte, passed as an int */
|
||||
// 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
|
||||
@@ -76,10 +76,10 @@ void *SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
|
||||
}
|
||||
|
||||
return dst;
|
||||
#endif /* HAVE_MEMSET */
|
||||
#endif // HAVE_MEMSET
|
||||
}
|
||||
|
||||
/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */
|
||||
// Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent.
|
||||
void *SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
||||
{
|
||||
#if defined(__APPLE__) && defined(HAVE_STRING_H)
|
||||
@@ -121,7 +121,7 @@ void *SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
||||
/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls.
|
||||
We will provide our own implementation if we're not building with a C runtime. */
|
||||
#ifndef HAVE_LIBC
|
||||
/* NOLINTNEXTLINE(readability-redundant-declaration) */
|
||||
// NOLINTNEXTLINE(readability-redundant-declaration)
|
||||
extern void *memset(void *dst, int c, size_t len);
|
||||
#if defined(_MSC_VER) && !defined(__INTEL_LLVM_COMPILER)
|
||||
#pragma intrinsic(memset)
|
||||
@@ -130,10 +130,10 @@ extern void *memset(void *dst, int c, size_t len);
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#pragma function(memset)
|
||||
#endif
|
||||
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
|
||||
// NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name)
|
||||
void *memset(void *dst, int c, size_t len)
|
||||
{
|
||||
return SDL_memset(dst, c, len);
|
||||
}
|
||||
#endif /* !HAVE_LIBC */
|
||||
#endif // !HAVE_LIBC
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This file contains SDL replacements for functions in the C library */
|
||||
// This file contains SDL replacements for functions in the C library
|
||||
|
||||
#if !defined(HAVE_LIBC) && !defined(SDL_STATIC_LIB)
|
||||
|
||||
/* These are some C runtime intrinsics that need to be defined */
|
||||
// These are some C runtime intrinsics that need to be defined
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
@@ -35,7 +35,7 @@ __declspec(selectany) int _fltused = 1;
|
||||
|
||||
#ifdef _M_IX86
|
||||
|
||||
/* Float to long */
|
||||
// Float to long
|
||||
void __declspec(naked) _ftol()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
@@ -95,7 +95,7 @@ void _ftol2()
|
||||
_ftol();
|
||||
}
|
||||
|
||||
/* 64-bit math operators for 32-bit systems */
|
||||
// 64-bit math operators for 32-bit systems
|
||||
void __declspec(naked) _allmul()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
@@ -726,7 +726,7 @@ void __declspec(naked) _alloca_probe_16(void)
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
#endif /* _M_IX86 */
|
||||
#endif // _M_IX86
|
||||
|
||||
#ifdef _M_ARM64
|
||||
|
||||
@@ -736,7 +736,7 @@ void __chkstk() {
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* MSC_VER */
|
||||
#endif // MSC_VER
|
||||
|
||||
#ifdef __ICL
|
||||
/* The classic Intel compiler generates calls to _intel_fast_memcpy
|
||||
@@ -751,4 +751,4 @@ void *_intel_fast_memset(void *dst, int c, size_t len)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !HAVE_LIBC && !SDL_STATIC_LIB */
|
||||
#endif // !HAVE_LIBC && !SDL_STATIC_LIB
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This file contains portable random functions for SDL */
|
||||
// This file contains portable random functions for SDL
|
||||
|
||||
static Uint64 SDL_rand_state;
|
||||
static SDL_bool SDL_rand_initialized = SDL_FALSE;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This file contains portable stdlib functions for SDL */
|
||||
// This file contains portable stdlib functions for SDL
|
||||
|
||||
#include "../libm/math_libm.h"
|
||||
|
||||
@@ -122,7 +122,7 @@ double SDL_ceil(double x)
|
||||
integer += 1.0;
|
||||
}
|
||||
return integer;
|
||||
#endif /* HAVE_CEIL */
|
||||
#endif // HAVE_CEIL
|
||||
}
|
||||
|
||||
float SDL_ceilf(float x)
|
||||
@@ -141,14 +141,14 @@ double SDL_copysign(double x, double y)
|
||||
#elif defined(HAVE__COPYSIGN)
|
||||
return _copysign(x, y);
|
||||
#elif defined(__WATCOMC__) && defined(__386__)
|
||||
/* this is nasty as hell, but it works.. */
|
||||
// this is nasty as hell, but it works..
|
||||
unsigned int *xi = (unsigned int *)&x,
|
||||
*yi = (unsigned int *)&y;
|
||||
xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
|
||||
return x;
|
||||
#else
|
||||
return SDL_uclibc_copysign(x, y);
|
||||
#endif /* HAVE_COPYSIGN */
|
||||
#endif // HAVE_COPYSIGN
|
||||
}
|
||||
|
||||
float SDL_copysignf(float x, float y)
|
||||
@@ -544,13 +544,13 @@ void *SDL_aligned_alloc(size_t alignment, size_t size)
|
||||
SDL_size_add_overflow(size, padding, &size) == 0) {
|
||||
void *original = SDL_malloc(size);
|
||||
if (original) {
|
||||
/* Make sure we have enough space to store the original pointer */
|
||||
// Make sure we have enough space to store the original pointer
|
||||
retval = (Uint8 *)original + sizeof(original);
|
||||
|
||||
/* Align the pointer we're going to return */
|
||||
// Align the pointer we're going to return
|
||||
retval += alignment - (((size_t)retval) % alignment);
|
||||
|
||||
/* Store the original pointer right before the returned value */
|
||||
// Store the original pointer right before the returned value
|
||||
SDL_memcpy(retval - sizeof(original), &original, sizeof(original));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This file contains portable string manipulation functions for SDL */
|
||||
// This file contains portable string manipulation functions for SDL
|
||||
|
||||
#include "SDL_vacopy.h"
|
||||
|
||||
@@ -628,7 +628,7 @@ int SDL_memcmp(const void *s1, const void *s2, size_t len)
|
||||
++s2p;
|
||||
}
|
||||
return 0;
|
||||
#endif /* HAVE_MEMCMP */
|
||||
#endif // HAVE_MEMCMP
|
||||
}
|
||||
|
||||
size_t SDL_strlen(const char *string)
|
||||
@@ -641,7 +641,7 @@ size_t SDL_strlen(const char *string)
|
||||
++len;
|
||||
}
|
||||
return len;
|
||||
#endif /* HAVE_STRLEN */
|
||||
#endif // HAVE_STRLEN
|
||||
}
|
||||
|
||||
size_t SDL_strnlen(const char *string, size_t maxlen)
|
||||
@@ -654,7 +654,7 @@ size_t SDL_strnlen(const char *string, size_t maxlen)
|
||||
++len;
|
||||
}
|
||||
return len;
|
||||
#endif /* HAVE_STRNLEN */
|
||||
#endif // HAVE_STRNLEN
|
||||
}
|
||||
|
||||
size_t SDL_wcslen(const wchar_t *string)
|
||||
@@ -667,7 +667,7 @@ size_t SDL_wcslen(const wchar_t *string)
|
||||
++len;
|
||||
}
|
||||
return len;
|
||||
#endif /* HAVE_WCSLEN */
|
||||
#endif // HAVE_WCSLEN
|
||||
}
|
||||
|
||||
size_t SDL_wcsnlen(const wchar_t *string, size_t maxlen)
|
||||
@@ -680,7 +680,7 @@ size_t SDL_wcsnlen(const wchar_t *string, size_t maxlen)
|
||||
++len;
|
||||
}
|
||||
return len;
|
||||
#endif /* HAVE_WCSNLEN */
|
||||
#endif // HAVE_WCSNLEN
|
||||
}
|
||||
|
||||
size_t SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
|
||||
@@ -695,7 +695,7 @@ size_t SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_
|
||||
dst[len] = '\0';
|
||||
}
|
||||
return srclen;
|
||||
#endif /* HAVE_WCSLCPY */
|
||||
#endif // HAVE_WCSLCPY
|
||||
}
|
||||
|
||||
size_t SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
|
||||
@@ -709,7 +709,7 @@ size_t SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, siz
|
||||
SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
|
||||
}
|
||||
return dstlen + srclen;
|
||||
#endif /* HAVE_WCSLCAT */
|
||||
#endif // HAVE_WCSLCAT
|
||||
}
|
||||
|
||||
wchar_t *SDL_wcsdup(const wchar_t *string)
|
||||
@@ -744,7 +744,7 @@ wchar_t *SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle)
|
||||
return SDL_const_cast(wchar_t *, wcsstr(haystack, needle));
|
||||
#else
|
||||
return SDL_wcsnstr(haystack, needle, SDL_wcslen(haystack));
|
||||
#endif /* HAVE_WCSSTR */
|
||||
#endif // HAVE_WCSSTR
|
||||
}
|
||||
|
||||
int SDL_wcscmp(const wchar_t *str1, const wchar_t *str2)
|
||||
@@ -760,7 +760,7 @@ int SDL_wcscmp(const wchar_t *str1, const wchar_t *str2)
|
||||
++str2;
|
||||
}
|
||||
return *str1 - *str2;
|
||||
#endif /* HAVE_WCSCMP */
|
||||
#endif // HAVE_WCSCMP
|
||||
}
|
||||
|
||||
int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
|
||||
@@ -781,7 +781,7 @@ int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
|
||||
}
|
||||
return *str1 - *str2;
|
||||
|
||||
#endif /* HAVE_WCSNCMP */
|
||||
#endif // HAVE_WCSNCMP
|
||||
}
|
||||
|
||||
int SDL_wcscasecmp(const wchar_t *wstr1, const wchar_t *wstr2)
|
||||
@@ -840,7 +840,7 @@ long SDL_wcstol(const wchar_t *string, wchar_t **endp, int base)
|
||||
*endp = (wchar_t *)string + len;
|
||||
}
|
||||
return value;
|
||||
#endif /* HAVE_WCSTOL */
|
||||
#endif // HAVE_WCSTOL
|
||||
}
|
||||
|
||||
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
|
||||
@@ -855,7 +855,7 @@ size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxl
|
||||
dst[len] = '\0';
|
||||
}
|
||||
return srclen;
|
||||
#endif /* HAVE_STRLCPY */
|
||||
#endif // HAVE_STRLCPY
|
||||
}
|
||||
|
||||
size_t SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes)
|
||||
@@ -918,7 +918,7 @@ size_t SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t ma
|
||||
SDL_strlcpy(dst + dstlen, src, maxlen - dstlen);
|
||||
}
|
||||
return dstlen + srclen;
|
||||
#endif /* HAVE_STRLCAT */
|
||||
#endif // HAVE_STRLCAT
|
||||
}
|
||||
|
||||
char *SDL_strdup(const char *string)
|
||||
@@ -952,12 +952,12 @@ char *SDL_strrev(char *string)
|
||||
char *b = &string[len - 1];
|
||||
len /= 2;
|
||||
while (len--) {
|
||||
const char c = *a; /* NOLINT(clang-analyzer-core.uninitialized.Assign) */
|
||||
const char c = *a; // NOLINT(clang-analyzer-core.uninitialized.Assign)
|
||||
*a++ = *b;
|
||||
*b-- = c;
|
||||
}
|
||||
return string;
|
||||
#endif /* HAVE__STRREV */
|
||||
#endif // HAVE__STRREV
|
||||
}
|
||||
|
||||
char *SDL_strupr(char *string)
|
||||
@@ -997,7 +997,7 @@ char *SDL_strchr(const char *string, int c)
|
||||
return (char *)string;
|
||||
}
|
||||
return NULL;
|
||||
#endif /* HAVE_STRCHR */
|
||||
#endif // HAVE_STRCHR
|
||||
}
|
||||
|
||||
char *SDL_strrchr(const char *string, int c)
|
||||
@@ -1015,7 +1015,7 @@ char *SDL_strrchr(const char *string, int c)
|
||||
--bufp;
|
||||
}
|
||||
return NULL;
|
||||
#endif /* HAVE_STRRCHR */
|
||||
#endif // HAVE_STRRCHR
|
||||
}
|
||||
|
||||
char *SDL_strnstr(const char *haystack, const char *needle, size_t maxlen)
|
||||
@@ -1035,7 +1035,7 @@ char *SDL_strnstr(const char *haystack, const char *needle, size_t maxlen)
|
||||
--maxlen;
|
||||
}
|
||||
return NULL;
|
||||
#endif /* HAVE_STRSTR */
|
||||
#endif // HAVE_STRSTR
|
||||
}
|
||||
|
||||
char *SDL_strstr(const char *haystack, const char *needle)
|
||||
@@ -1044,7 +1044,7 @@ char *SDL_strstr(const char *haystack, const char *needle)
|
||||
return SDL_const_cast(char *, strstr(haystack, needle));
|
||||
#else
|
||||
return SDL_strnstr(haystack, needle, SDL_strlen(haystack));
|
||||
#endif /* HAVE_STRSTR */
|
||||
#endif // HAVE_STRSTR
|
||||
}
|
||||
|
||||
char *SDL_strcasestr(const char *haystack, const char *needle)
|
||||
@@ -1067,7 +1067,7 @@ static const char ntoa_table[] = {
|
||||
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
|
||||
'U', 'V', 'W', 'X', 'Y', 'Z'
|
||||
};
|
||||
#endif /* ntoa() conversion table */
|
||||
#endif // ntoa() conversion table
|
||||
|
||||
char *SDL_itoa(int value, char *string, int radix)
|
||||
{
|
||||
@@ -1075,7 +1075,7 @@ char *SDL_itoa(int value, char *string, int radix)
|
||||
return itoa(value, string, radix);
|
||||
#else
|
||||
return SDL_ltoa((long)value, string, radix);
|
||||
#endif /* HAVE_ITOA */
|
||||
#endif // HAVE_ITOA
|
||||
}
|
||||
|
||||
char *SDL_uitoa(unsigned int value, char *string, int radix)
|
||||
@@ -1084,7 +1084,7 @@ char *SDL_uitoa(unsigned int value, char *string, int radix)
|
||||
return _uitoa(value, string, radix);
|
||||
#else
|
||||
return SDL_ultoa((unsigned long)value, string, radix);
|
||||
#endif /* HAVE__UITOA */
|
||||
#endif // HAVE__UITOA
|
||||
}
|
||||
|
||||
char *SDL_ltoa(long value, char *string, int radix)
|
||||
@@ -1102,7 +1102,7 @@ char *SDL_ltoa(long value, char *string, int radix)
|
||||
}
|
||||
|
||||
return string;
|
||||
#endif /* HAVE__LTOA */
|
||||
#endif // HAVE__LTOA
|
||||
}
|
||||
|
||||
char *SDL_ultoa(unsigned long value, char *string, int radix)
|
||||
@@ -1122,11 +1122,11 @@ char *SDL_ultoa(unsigned long value, char *string, int radix)
|
||||
}
|
||||
*bufp = '\0';
|
||||
|
||||
/* The numbers went into the string backwards. :) */
|
||||
// The numbers went into the string backwards. :)
|
||||
SDL_strrev(string);
|
||||
|
||||
return string;
|
||||
#endif /* HAVE__ULTOA */
|
||||
#endif // HAVE__ULTOA
|
||||
}
|
||||
|
||||
char *SDL_lltoa(Sint64 value, char *string, int radix)
|
||||
@@ -1144,7 +1144,7 @@ char *SDL_lltoa(Sint64 value, char *string, int radix)
|
||||
}
|
||||
|
||||
return string;
|
||||
#endif /* HAVE__I64TOA */
|
||||
#endif // HAVE__I64TOA
|
||||
}
|
||||
|
||||
char *SDL_ulltoa(Uint64 value, char *string, int radix)
|
||||
@@ -1164,11 +1164,11 @@ char *SDL_ulltoa(Uint64 value, char *string, int radix)
|
||||
}
|
||||
*bufp = '\0';
|
||||
|
||||
/* The numbers went into the string backwards. :) */
|
||||
// The numbers went into the string backwards. :)
|
||||
SDL_strrev(string);
|
||||
|
||||
return string;
|
||||
#endif /* HAVE__UI64TOA */
|
||||
#endif // HAVE__UI64TOA
|
||||
}
|
||||
|
||||
int SDL_atoi(const char *string)
|
||||
@@ -1177,7 +1177,7 @@ int SDL_atoi(const char *string)
|
||||
return atoi(string);
|
||||
#else
|
||||
return SDL_strtol(string, NULL, 10);
|
||||
#endif /* HAVE_ATOI */
|
||||
#endif // HAVE_ATOI
|
||||
}
|
||||
|
||||
double SDL_atof(const char *string)
|
||||
@@ -1186,7 +1186,7 @@ double SDL_atof(const char *string)
|
||||
return atof(string);
|
||||
#else
|
||||
return SDL_strtod(string, NULL);
|
||||
#endif /* HAVE_ATOF */
|
||||
#endif // HAVE_ATOF
|
||||
}
|
||||
|
||||
long SDL_strtol(const char *string, char **endp, int base)
|
||||
@@ -1210,7 +1210,7 @@ long SDL_strtol(const char *string, char **endp, int base)
|
||||
*endp = (char *)string + len;
|
||||
}
|
||||
return value;
|
||||
#endif /* HAVE_STRTOL */
|
||||
#endif // HAVE_STRTOL
|
||||
}
|
||||
|
||||
unsigned long
|
||||
@@ -1235,7 +1235,7 @@ SDL_strtoul(const char *string, char **endp, int base)
|
||||
*endp = (char *)string + len;
|
||||
}
|
||||
return value;
|
||||
#endif /* HAVE_STRTOUL */
|
||||
#endif // HAVE_STRTOUL
|
||||
}
|
||||
|
||||
Sint64 SDL_strtoll(const char *string, char **endp, int base)
|
||||
@@ -1259,7 +1259,7 @@ Sint64 SDL_strtoll(const char *string, char **endp, int base)
|
||||
*endp = (char *)string + len;
|
||||
}
|
||||
return value;
|
||||
#endif /* HAVE_STRTOLL */
|
||||
#endif // HAVE_STRTOLL
|
||||
}
|
||||
|
||||
Uint64 SDL_strtoull(const char *string, char **endp, int base)
|
||||
@@ -1283,7 +1283,7 @@ Uint64 SDL_strtoull(const char *string, char **endp, int base)
|
||||
*endp = (char *)string + len;
|
||||
}
|
||||
return value;
|
||||
#endif /* HAVE_STRTOULL */
|
||||
#endif // HAVE_STRTOULL
|
||||
}
|
||||
|
||||
double SDL_strtod(const char *string, char **endp)
|
||||
@@ -1299,7 +1299,7 @@ double SDL_strtod(const char *string, char **endp)
|
||||
*endp = (char *)string + len;
|
||||
}
|
||||
return value;
|
||||
#endif /* HAVE_STRTOD */
|
||||
#endif // HAVE_STRTOD
|
||||
}
|
||||
|
||||
int SDL_strcmp(const char *str1, const char *str2)
|
||||
@@ -1318,7 +1318,7 @@ int SDL_strcmp(const char *str1, const char *str2)
|
||||
++str2;
|
||||
}
|
||||
return result;
|
||||
#endif /* HAVE_STRCMP */
|
||||
#endif // HAVE_STRCMP
|
||||
}
|
||||
|
||||
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
|
||||
@@ -1338,7 +1338,7 @@ int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
|
||||
--maxlen;
|
||||
}
|
||||
return result;
|
||||
#endif /* HAVE_STRNCMP */
|
||||
#endif // HAVE_STRNCMP
|
||||
}
|
||||
|
||||
int SDL_strcasecmp(const char *str1, const char *str2)
|
||||
@@ -1402,7 +1402,7 @@ static SDL_bool CharacterMatchesSet(char c, const char *set, size_t set_len)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* NOLINTNEXTLINE(readability-non-const-parameter) */
|
||||
// NOLINTNEXTLINE(readability-non-const-parameter)
|
||||
int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap)
|
||||
{
|
||||
int retval = 0;
|
||||
@@ -1471,7 +1471,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li
|
||||
++text;
|
||||
}
|
||||
|
||||
/* FIXME: implement more of the format specifiers */
|
||||
// FIXME: implement more of the format specifiers
|
||||
while (!done) {
|
||||
switch (*fmt) {
|
||||
case '*':
|
||||
@@ -1555,7 +1555,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li
|
||||
} break;
|
||||
case DO_LONGLONG:
|
||||
case DO_SIZE_T:
|
||||
/* Handled above */
|
||||
// Handled above
|
||||
break;
|
||||
}
|
||||
++retval;
|
||||
@@ -1616,7 +1616,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li
|
||||
} break;
|
||||
case DO_LONGLONG:
|
||||
case DO_SIZE_T:
|
||||
/* Handled above */
|
||||
// Handled above
|
||||
break;
|
||||
}
|
||||
++retval;
|
||||
@@ -1726,13 +1726,13 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li
|
||||
++fmt;
|
||||
continue;
|
||||
}
|
||||
/* Text didn't match format specifier */
|
||||
// Text didn't match format specifier
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif /* HAVE_VSSCANF */
|
||||
#endif // HAVE_VSSCANF
|
||||
|
||||
int SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
{
|
||||
@@ -1759,7 +1759,7 @@ int SDL_swprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_
|
||||
}
|
||||
|
||||
#if defined(HAVE_LIBC) && defined(__WATCOMC__)
|
||||
/* _vsnprintf() doesn't ensure nul termination */
|
||||
// _vsnprintf() doesn't ensure nul termination
|
||||
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||
{
|
||||
int retval;
|
||||
@@ -1786,7 +1786,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *f
|
||||
#else
|
||||
#define TEXT_AND_LEN_ARGS (length < maxlen) ? &text[length] : NULL, (length < maxlen) ? (maxlen - length) : 0
|
||||
|
||||
/* FIXME: implement more of the format specifiers */
|
||||
// FIXME: implement more of the format specifiers
|
||||
typedef enum
|
||||
{
|
||||
SDL_CASE_NOCHANGE,
|
||||
@@ -1798,7 +1798,7 @@ typedef struct
|
||||
{
|
||||
SDL_bool left_justify;
|
||||
SDL_bool force_sign;
|
||||
SDL_bool force_type; /* for now: used only by float printer, ignored otherwise. */
|
||||
SDL_bool force_type; // for now: used only by float printer, ignored otherwise.
|
||||
SDL_bool pad_zeroes;
|
||||
SDL_letter_case force_case;
|
||||
int width;
|
||||
@@ -1876,7 +1876,7 @@ static size_t SDL_PrintStringW(char *text, size_t maxlen, SDL_FormatInfo *info,
|
||||
}
|
||||
|
||||
static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *info)
|
||||
{ /* left-pad num with zeroes. */
|
||||
{ // left-pad num with zeroes.
|
||||
size_t sz, pad, have_sign;
|
||||
|
||||
if (!info) {
|
||||
@@ -1892,23 +1892,23 @@ static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *inf
|
||||
sz = SDL_strlen(num);
|
||||
if (info->precision > 0 && sz < (size_t)info->precision) {
|
||||
pad = (size_t)info->precision - sz;
|
||||
if (pad + sz + 1 <= maxlen) { /* otherwise ignore the precision */
|
||||
if (pad + sz + 1 <= maxlen) { // otherwise ignore the precision
|
||||
SDL_memmove(num + pad, num, sz + 1);
|
||||
SDL_memset(num, '0', pad);
|
||||
}
|
||||
}
|
||||
info->precision = -1; /* so that SDL_PrintString() doesn't make a mess. */
|
||||
info->precision = -1; // so that SDL_PrintString() doesn't make a mess.
|
||||
|
||||
if (info->pad_zeroes && info->width > 0 && (size_t)info->width > sz + have_sign) {
|
||||
/* handle here: spaces are added before the sign
|
||||
but zeroes must be placed _after_ the sign. */
|
||||
/* sz hasn't changed: we ignore pad_zeroes if a precision is given. */
|
||||
// sz hasn't changed: we ignore pad_zeroes if a precision is given.
|
||||
pad = (size_t)info->width - sz - have_sign;
|
||||
if (pad + sz + 1 <= maxlen) {
|
||||
SDL_memmove(num + pad, num, sz + 1);
|
||||
SDL_memset(num, '0', pad);
|
||||
}
|
||||
info->width = 0; /* so that SDL_PrintString() doesn't make a mess. */
|
||||
info->width = 0; // so that SDL_PrintString() doesn't make a mess.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1963,7 +1963,7 @@ static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, do
|
||||
size_t integer_length;
|
||||
int precision = info->precision;
|
||||
|
||||
/* This isn't especially accurate, but hey, it's easy. :) */
|
||||
// This isn't especially accurate, but hey, it's easy. :)
|
||||
Uint64 value;
|
||||
|
||||
if (arg < 0) {
|
||||
@@ -1980,7 +1980,7 @@ static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, do
|
||||
precision = 6;
|
||||
}
|
||||
if (g) {
|
||||
/* The precision includes the integer portion */
|
||||
// The precision includes the integer portion
|
||||
precision -= SDL_min((int)integer_length, precision);
|
||||
}
|
||||
if (info->force_type || precision > 0) {
|
||||
@@ -2000,7 +2000,7 @@ static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, do
|
||||
arg *= 10.0;
|
||||
integer_value = SDL_round(arg);
|
||||
if (integer_value == 10.0) {
|
||||
/* Carry the one... */
|
||||
// Carry the one...
|
||||
size_t i;
|
||||
|
||||
for (i = length; i--; ) {
|
||||
@@ -2029,7 +2029,7 @@ static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, do
|
||||
}
|
||||
|
||||
if (g) {
|
||||
/* Trim trailing zeroes and decimal separator */
|
||||
// Trim trailing zeroes and decimal separator
|
||||
size_t i;
|
||||
|
||||
for (i = length - 1; num[i] != decimal_separator; --i) {
|
||||
@@ -2077,7 +2077,7 @@ static size_t SDL_PrintPointer(char *text, size_t maxlen, SDL_FormatInfo *info,
|
||||
return length + SDL_PrintString(TEXT_AND_LEN_ARGS, info, num);
|
||||
}
|
||||
|
||||
/* NOLINTNEXTLINE(readability-non-const-parameter) */
|
||||
// NOLINTNEXTLINE(readability-non-const-parameter)
|
||||
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
|
||||
{
|
||||
size_t length = 0;
|
||||
@@ -2159,7 +2159,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
case 'c':
|
||||
/* char is promoted to int when passed through (...) */
|
||||
// char is promoted to int when passed through (...)
|
||||
if (length < maxlen) {
|
||||
text[length] = (char)va_arg(ap, int);
|
||||
}
|
||||
@@ -2167,7 +2167,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
case 'h':
|
||||
/* short is promoted to int when passed through (...) */
|
||||
// short is promoted to int when passed through (...)
|
||||
break;
|
||||
case 'l':
|
||||
if (inttype < DO_LONGLONG) {
|
||||
@@ -2300,7 +2300,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO
|
||||
}
|
||||
|
||||
#undef TEXT_AND_LEN_ARGS
|
||||
#endif /* HAVE_VSNPRINTF */
|
||||
#endif // HAVE_VSNPRINTF
|
||||
|
||||
int SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, const wchar_t *fmt, va_list ap)
|
||||
{
|
||||
@@ -2315,7 +2315,7 @@ int SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, const wcha
|
||||
}
|
||||
|
||||
if (!maxlen) {
|
||||
/* We still need to generate the text to find the final text length */
|
||||
// We still need to generate the text to find the final text length
|
||||
maxlen = 1024;
|
||||
}
|
||||
text_utf8 = (char *)SDL_malloc(maxlen * 4);
|
||||
@@ -2360,7 +2360,7 @@ int SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
int SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
|
||||
{
|
||||
int retval;
|
||||
int size = 100; /* Guess we need no more than 100 bytes */
|
||||
int size = 100; // Guess we need no more than 100 bytes
|
||||
char *p, *np;
|
||||
va_list aq;
|
||||
|
||||
@@ -2372,25 +2372,25 @@ int SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list
|
||||
}
|
||||
|
||||
while (1) {
|
||||
/* Try to print in the allocated space */
|
||||
// Try to print in the allocated space
|
||||
va_copy(aq, ap);
|
||||
retval = SDL_vsnprintf(p, size, fmt, aq);
|
||||
va_end(aq);
|
||||
|
||||
/* Check error code */
|
||||
// Check error code
|
||||
if (retval < 0) {
|
||||
SDL_free(p);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* If that worked, return the string */
|
||||
// If that worked, return the string
|
||||
if (retval < size) {
|
||||
*strp = p;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Else try again with more space */
|
||||
size = retval + 1; /* Precisely what is needed */
|
||||
// Else try again with more space
|
||||
size = retval + 1; // Precisely what is needed
|
||||
|
||||
np = (char *)SDL_realloc(p, size);
|
||||
if (!np) {
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* Do our best to make sure va_copy is working */
|
||||
// Do our best to make sure va_copy is working
|
||||
#ifdef SDL_PLATFORM_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 */
|
||||
// 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user