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

(cherry picked from commit 5750bcb174)
This commit is contained in:
Sam Lantinga 2022-11-30 12:51:59 -08:00
parent 5c4bc807f7
commit b8d85c6939
764 changed files with 50598 additions and 54407 deletions

View file

@ -32,8 +32,8 @@
#define FBASENAME1 "../Documents/sdldata1" /* this file will be created during tests */
#define FBASENAME2 "../Documents/sdldata2" /* this file should not exist before starting test */
#else
#define FBASENAME1 "sdldata1" /* this file will be created during tests */
#define FBASENAME2 "sdldata2" /* this file should not exist before starting test */
#define FBASENAME1 "sdldata1" /* this file will be created during tests */
#define FBASENAME2 "sdldata2" /* this file should not exist before starting test */
#endif
#ifndef NULL
@ -48,22 +48,19 @@ cleanup(void)
}
static void
rwops_error_quit(unsigned line, SDL_RWops * rwops)
rwops_error_quit(unsigned line, SDL_RWops *rwops)
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line);
if (rwops) {
rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */
rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */
}
cleanup();
exit(1); /* quit with rwops error (test failed) */
exit(1); /* quit with rwops error (test failed) */
}
#define RWOP_ERR_QUIT(x) rwops_error_quit( __LINE__, (x) )
#define RWOP_ERR_QUIT(x) rwops_error_quit(__LINE__, (x))
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
SDL_RWops *rwops = NULL;
char test_buf[30];
@ -73,7 +70,7 @@ main(int argc, char *argv[])
cleanup();
/* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
/* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
rwops = SDL_RWFromFile(NULL, NULL);
if (rwops) {
@ -97,16 +94,16 @@ main(int argc, char *argv[])
}
SDL_Log("test1 OK\n");
/* test 2 : check that inexistent file is not successfully opened/created when required */
/* modes : r, r+ imply that file MUST exist
modes : a, a+, w, w+ checks that it succeeds (file may not exists)
/* test 2 : check that inexistent file is not successfully opened/created when required */
/* modes : r, r+ imply that file MUST exist
modes : a, a+, w, w+ checks that it succeeds (file may not exists)
*/
rwops = SDL_RWFromFile(FBASENAME2, "rb"); /* this file doesn't exist that call must fail */
*/
rwops = SDL_RWFromFile(FBASENAME2, "rb"); /* this file doesn't exist that call must fail */
if (rwops) {
RWOP_ERR_QUIT(rwops);
}
rwops = SDL_RWFromFile(FBASENAME2, "rb+"); /* this file doesn't exist that call must fail */
rwops = SDL_RWFromFile(FBASENAME2, "rb+"); /* this file doesn't exist that call must fail */
if (rwops) {
RWOP_ERR_QUIT(rwops);
}
@ -136,10 +133,10 @@ main(int argc, char *argv[])
unlink(FBASENAME2);
SDL_Log("test2 OK\n");
/* test 3 : creation, writing , reading, seeking,
test : w mode, r mode, w+ mode
*/
rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */
/* test 3 : creation, writing , reading, seeking,
test : w mode, r mode, w+ mode
*/
rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */
if (rwops == NULL) {
RWOP_ERR_QUIT(rwops);
}
@ -157,11 +154,11 @@ main(int argc, char *argv[])
}
if (0 != rwops->read(rwops, test_buf, 1, 1)) {
RWOP_ERR_QUIT(rwops); /* we are in write only mode */
}
}
rwops->close(rwops);
rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exists */
rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exists */
if (rwops == NULL) {
RWOP_ERR_QUIT(rwops);
}
@ -198,8 +195,8 @@ main(int argc, char *argv[])
rwops->close(rwops);
/* test 3: same with w+ mode */
rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */
/* test 3: same with w+ mode */
rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */
if (rwops == NULL) {
RWOP_ERR_QUIT(rwops);
}
@ -249,8 +246,8 @@ main(int argc, char *argv[])
rwops->close(rwops);
SDL_Log("test3 OK\n");
/* test 4: same in r+ mode */
rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */
/* test 4: same in r+ mode */
rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */
if (rwops == NULL) {
RWOP_ERR_QUIT(rwops);
}
@ -300,8 +297,8 @@ main(int argc, char *argv[])
rwops->close(rwops);
SDL_Log("test4 OK\n");
/* test5 : append mode */
rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */
/* test5 : append mode */
rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */
if (rwops == NULL) {
RWOP_ERR_QUIT(rwops);
}
@ -357,5 +354,5 @@ main(int argc, char *argv[])
rwops->close(rwops);
SDL_Log("test5 OK\n");
cleanup();
return 0; /* all ok */
return 0; /* all ok */
}