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

@@ -24,17 +24,18 @@
#include "SDL_error.h"
#include "SDL_hints_c.h"
/* Assuming there aren't many hints set and they aren't being queried in
critical performance paths, we'll just use linked lists here.
*/
typedef struct SDL_HintWatch {
typedef struct SDL_HintWatch
{
SDL_HintCallback callback;
void *userdata;
struct SDL_HintWatch *next;
} SDL_HintWatch;
typedef struct SDL_Hint {
typedef struct SDL_Hint
{
char *name;
char *value;
SDL_HintPriority priority;
@@ -68,7 +69,7 @@ SDL_SetHintWithPriority(const char *name, const char *value,
}
if (hint->value != value &&
(value == NULL || !hint->value || SDL_strcmp(hint->value, value) != 0)) {
for (entry = hint->callbacks; entry; ) {
for (entry = hint->callbacks; entry;) {
/* Save the next entry in case this one is deleted */
SDL_HintWatch *next = entry->next;
entry->callback(entry->userdata, name, hint->value, value);
@@ -113,7 +114,7 @@ SDL_ResetHint(const char *name)
if ((env == NULL && hint->value != NULL) ||
(env != NULL && hint->value == NULL) ||
(env != NULL && SDL_strcmp(env, hint->value) != 0)) {
for (entry = hint->callbacks; entry; ) {
for (entry = hint->callbacks; entry;) {
/* Save the next entry in case this one is deleted */
SDL_HintWatch *next = entry->next;
entry->callback(entry->userdata, name, hint->value, env);
@@ -129,8 +130,7 @@ SDL_ResetHint(const char *name)
return SDL_FALSE;
}
void
SDL_ResetHints(void)
void SDL_ResetHints(void)
{
const char *env;
SDL_Hint *hint;
@@ -141,7 +141,7 @@ SDL_ResetHints(void)
if ((env == NULL && hint->value != NULL) ||
(env != NULL && hint->value == NULL) ||
(env != NULL && SDL_strcmp(env, hint->value) != 0)) {
for (entry = hint->callbacks; entry; ) {
for (entry = hint->callbacks; entry;) {
/* Save the next entry in case this one is deleted */
SDL_HintWatch *next = entry->next;
entry->callback(entry->userdata, hint->name, hint->value, env);
@@ -197,8 +197,7 @@ SDL_GetHintBoolean(const char *name, SDL_bool default_value)
return SDL_GetStringBoolean(hint, default_value);
}
void
SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
{
SDL_Hint *hint;
SDL_HintWatch *entry;
@@ -259,8 +258,7 @@ SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
callback(userdata, name, value, value);
}
void
SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
{
SDL_Hint *hint;
SDL_HintWatch *entry, *prev;
@@ -296,7 +294,7 @@ void SDL_ClearHints(void)
SDL_free(hint->name);
SDL_free(hint->value);
for (entry = hint->callbacks; entry; ) {
for (entry = hint->callbacks; entry;) {
SDL_HintWatch *freeable = entry;
entry = entry->next;
SDL_free(freeable);