Update for SDL3 coding style (#6717)

I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
This commit is contained in:
Sam Lantinga
2022-11-30 12:51:59 -08:00
committed by GitHub
parent 14b902faca
commit 5750bcb174
781 changed files with 51659 additions and 55763 deletions

View File

@@ -24,7 +24,6 @@
#include "../libm/math_libm.h"
double
SDL_atan(double x)
{
@@ -35,8 +34,7 @@ SDL_atan(double x)
#endif
}
float
SDL_atanf(float x)
float SDL_atanf(float x)
{
#if defined(HAVE_ATANF)
return atanf(x);
@@ -55,8 +53,7 @@ SDL_atan2(double y, double x)
#endif
}
float
SDL_atan2f(float y, float x)
float SDL_atan2f(float y, float x)
{
#if defined(HAVE_ATAN2F)
return atan2f(y, x);
@@ -76,8 +73,7 @@ SDL_acos(double val)
result = SDL_PI_D;
} else {
result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
if (result < 0.0)
{
if (result < 0.0) {
result += SDL_PI_D;
}
}
@@ -85,8 +81,7 @@ SDL_acos(double val)
#endif
}
float
SDL_acosf(float val)
float SDL_acosf(float val)
{
#if defined(HAVE_ACOSF)
return acosf(val);
@@ -111,8 +106,7 @@ SDL_asin(double val)
#endif
}
float
SDL_asinf(float val)
float SDL_asinf(float val)
{
#if defined(HAVE_ASINF)
return asinf(val);
@@ -136,8 +130,7 @@ SDL_ceil(double x)
#endif /* HAVE_CEIL */
}
float
SDL_ceilf(float x)
float SDL_ceilf(float x)
{
#if defined(HAVE_CEILF)
return ceilf(x);
@@ -155,8 +148,8 @@ SDL_copysign(double x, double y)
return _copysign(x, y);
#elif defined(__WATCOMC__) && defined(__386__)
/* this is nasty as hell, but it works.. */
unsigned int *xi = (unsigned int *) &x,
*yi = (unsigned int *) &y;
unsigned int *xi = (unsigned int *)&x,
*yi = (unsigned int *)&y;
xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
return x;
#else
@@ -164,8 +157,7 @@ SDL_copysign(double x, double y)
#endif /* HAVE_COPYSIGN */
}
float
SDL_copysignf(float x, float y)
float SDL_copysignf(float x, float y)
{
#if defined(HAVE_COPYSIGNF)
return copysignf(x, y);
@@ -184,8 +176,7 @@ SDL_cos(double x)
#endif
}
float
SDL_cosf(float x)
float SDL_cosf(float x)
{
#if defined(HAVE_COSF)
return cosf(x);
@@ -204,8 +195,7 @@ SDL_exp(double x)
#endif
}
float
SDL_expf(float x)
float SDL_expf(float x)
{
#if defined(HAVE_EXPF)
return expf(x);
@@ -224,8 +214,7 @@ SDL_fabs(double x)
#endif
}
float
SDL_fabsf(float x)
float SDL_fabsf(float x)
{
#if defined(HAVE_FABSF)
return fabsf(x);
@@ -244,8 +233,7 @@ SDL_floor(double x)
#endif
}
float
SDL_floorf(float x)
float SDL_floorf(float x)
{
#if defined(HAVE_FLOORF)
return floorf(x);
@@ -268,8 +256,7 @@ SDL_trunc(double x)
#endif
}
float
SDL_truncf(float x)
float SDL_truncf(float x)
{
#if defined(HAVE_TRUNCF)
return truncf(x);
@@ -288,8 +275,7 @@ SDL_fmod(double x, double y)
#endif
}
float
SDL_fmodf(float x, float y)
float SDL_fmodf(float x, float y)
{
#if defined(HAVE_FMODF)
return fmodf(x, y);
@@ -308,8 +294,7 @@ SDL_log(double x)
#endif
}
float
SDL_logf(float x)
float SDL_logf(float x)
{
#if defined(HAVE_LOGF)
return logf(x);
@@ -328,8 +313,7 @@ SDL_log10(double x)
#endif
}
float
SDL_log10f(float x)
float SDL_log10f(float x)
{
#if defined(HAVE_LOG10F)
return log10f(x);
@@ -348,8 +332,7 @@ SDL_pow(double x, double y)
#endif
}
float
SDL_powf(float x, float y)
float SDL_powf(float x, float y)
{
#if defined(HAVE_POWF)
return powf(x, y);
@@ -372,8 +355,7 @@ SDL_round(double arg)
#endif
}
float
SDL_roundf(float arg)
float SDL_roundf(float arg)
{
#if defined HAVE_ROUNDF
return roundf(arg);
@@ -382,8 +364,7 @@ SDL_roundf(float arg)
#endif
}
long
SDL_lround(double arg)
long SDL_lround(double arg)
{
#if defined HAVE_LROUND
return lround(arg);
@@ -392,8 +373,7 @@ SDL_lround(double arg)
#endif
}
long
SDL_lroundf(float arg)
long SDL_lroundf(float arg)
{
#if defined HAVE_LROUNDF
return lroundf(arg);
@@ -410,16 +390,15 @@ SDL_scalbn(double x, int n)
#elif defined(HAVE__SCALB)
return _scalb(x, n);
#elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2)
/* from scalbn(3): If FLT_RADIX equals 2 (which is
* usual), then scalbn() is equivalent to ldexp(3). */
/* from scalbn(3): If FLT_RADIX equals 2 (which is
* usual), then scalbn() is equivalent to ldexp(3). */
return ldexp(x, n);
#else
return SDL_uclibc_scalbn(x, n);
#endif
}
float
SDL_scalbnf(float x, int n)
float SDL_scalbnf(float x, int n)
{
#if defined(HAVE_SCALBNF)
return scalbnf(x, n);
@@ -438,8 +417,7 @@ SDL_sin(double x)
#endif
}
float
SDL_sinf(float x)
float SDL_sinf(float x)
{
#if defined(HAVE_SINF)
return sinf(x);
@@ -458,8 +436,7 @@ SDL_sqrt(double x)
#endif
}
float
SDL_sqrtf(float x)
float SDL_sqrtf(float x)
{
#if defined(HAVE_SQRTF)
return sqrtf(x);
@@ -478,8 +455,7 @@ SDL_tan(double x)
#endif
}
float
SDL_tanf(float x)
float SDL_tanf(float x)
{
#if defined(HAVE_TANF)
return tanf(x);
@@ -498,7 +474,10 @@ int SDL_abs(int x)
}
#if defined(HAVE_CTYPE_H)
int SDL_isalpha(int x) { return isalpha(x); }
int SDL_isalpha(int x)
{
return isalpha(x);
}
int SDL_isalnum(int x) { return isalnum(x); }
int SDL_isdigit(int x) { return isdigit(x); }
int SDL_isxdigit(int x) { return isxdigit(x); }
@@ -512,7 +491,10 @@ int SDL_iscntrl(int x) { return iscntrl(x); }
int SDL_toupper(int x) { return toupper(x); }
int SDL_tolower(int x) { return tolower(x); }
#else
int SDL_isalpha(int x) { return (SDL_isupper(x)) || (SDL_islower(x)); }
int SDL_isalpha(int x)
{
return (SDL_isupper(x)) || (SDL_islower(x));
}
int SDL_isalnum(int x) { return (SDL_isalpha(x)) || (SDL_isdigit(x)); }
int SDL_isdigit(int x) { return ((x) >= '0') && ((x) <= '9'); }
int SDL_isxdigit(int x) { return (((x) >= 'A') && ((x) <= 'F')) || (((x) >= 'a') && ((x) <= 'f')) || (SDL_isdigit(x)); }
@@ -523,8 +505,8 @@ int SDL_islower(int x) { return ((x) >= 'a') && ((x) <= 'z'); }
int SDL_isprint(int x) { return ((x) >= ' ') && ((x) < '\x7f'); }
int SDL_isgraph(int x) { return (SDL_isprint(x)) && ((x) != ' '); }
int SDL_iscntrl(int x) { return (((x) >= '\0') && ((x) <= '\x1f')) || ((x) == '\x7f'); }
int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A' + ((x) - 'a')) : (x); }
int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a' + ((x) - 'A')) : (x); }
#endif
/* This file contains a portable memcpy manipulation function for SDL */
@@ -560,15 +542,15 @@ SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src,
Uint32 *srcp4, *dstp4;
Uint8 *srcp1, *dstp1;
srcp4 = (Uint32 *) src;
dstp4 = (Uint32 *) dst;
srcp4 = (Uint32 *)src;
dstp4 = (Uint32 *)dst;
len /= 4;
while (len--) {
*dstp4++ = *srcp4++;
}
srcp1 = (Uint8 *) srcp4;
dstp1 = (Uint8 *) dstp4;
srcp1 = (Uint8 *)srcp4;
dstp1 = (Uint8 *)dstp4;
switch (left) {
case 3:
*dstp1++ = *srcp1++;
@@ -590,7 +572,7 @@ SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
#else
size_t left;
Uint32 *dstp4;
Uint8 *dstp1 = (Uint8 *) dst;
Uint8 *dstp1 = (Uint8 *)dst;
Uint8 value1;
Uint32 value4;
@@ -610,14 +592,14 @@ SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
}
value4 = ((Uint32)c | ((Uint32)c << 8) | ((Uint32)c << 16) | ((Uint32)c << 24));
dstp4 = (Uint32 *) dstp1;
dstp4 = (Uint32 *)dstp1;
left = (len % 4);
len /= 4;
while (len--) {
*dstp4++ = value4;
}
dstp1 = (Uint8 *) dstp4;
dstp1 = (Uint8 *)dstp4;
switch (left) {
case 3:
*dstp1++ = value1;
@@ -639,13 +621,12 @@ SDL_memset4(void *dst, Uint32 val, size_t dwords)
memset_pattern4(dst, &val, dwords * 4);
#elif defined(__GNUC__) && defined(__i386__)
int u0, u1, u2;
__asm__ __volatile__ (
__asm__ __volatile__(
"cld \n\t"
"rep ; stosl \n\t"
: "=&D" (u0), "=&a" (u1), "=&c" (u2)
: "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords))
: "memory"
);
: "=&D"(u0), "=&a"(u1), "=&c"(u2)
: "0"(dst), "1"(val), "2"(SDL_static_cast(Uint32, dwords))
: "memory");
#else
size_t _n = (dwords + 3) / 4;
Uint32 *_p = SDL_static_cast(Uint32 *, dst);
@@ -654,20 +635,34 @@ SDL_memset4(void *dst, Uint32 val, size_t dwords)
return dst;
}
switch (dwords % 4) {
case 0: do { *_p++ = _val; SDL_FALLTHROUGH;
case 3: *_p++ = _val; SDL_FALLTHROUGH;
case 2: *_p++ = _val; SDL_FALLTHROUGH;
case 1: *_p++ = _val;
} while ( --_n );
case 0:
do {
*_p++ = _val;
SDL_FALLTHROUGH;
case 3:
*_p++ = _val;
SDL_FALLTHROUGH;
case 2:
*_p++ = _val;
SDL_FALLTHROUGH;
case 1:
*_p++ = _val;
} while (--_n);
}
#endif
return dst;
}
#if defined(HAVE_CTYPE_H) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
int SDL_isblank(int x) { return isblank(x); }
int SDL_isblank(int x)
{
return isblank(x);
}
#else
int SDL_isblank(int x) { return ((x) == ' ') || ((x) == '\t'); }
int SDL_isblank(int x)
{
return ((x) == ' ') || ((x) == '\t');
}
#endif
/* vi: set ts=4 sw=4 expandtab: */