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

@@ -15,8 +15,8 @@
static int SDLCALL
num_compare(const void *_a, const void *_b)
{
const int a = *((const int *) _a);
const int b = *((const int *) _b);
const int a = *((const int *)_a);
const int b = *((const int *)_b);
return (a < b) ? -1 : ((a > b) ? 1 : 0);
}
@@ -28,7 +28,7 @@ test_sort(const char *desc, int *nums, const int arraylen)
SDL_Log("test: %s arraylen=%d", desc, arraylen);
SDL_qsort(nums, arraylen, sizeof (nums[0]), num_compare);
SDL_qsort(nums, arraylen, sizeof(nums[0]), num_compare);
prev = nums[0];
for (i = 1; i < arraylen; i++) {
@@ -41,8 +41,7 @@ test_sort(const char *desc, int *nums, const int arraylen)
}
}
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
static int nums[1024 * 100];
static const int itervals[] = { SDL_arraysize(nums), 12 };
@@ -53,9 +52,9 @@ main(int argc, char *argv[])
int success;
Uint64 seed = 0;
if (argv[1][0] == '0' && argv[1][1] == 'x')
success = SDL_sscanf(argv[1] + 2, "%"SDL_PRIx64, &seed);
success = SDL_sscanf(argv[1] + 2, "%" SDL_PRIx64, &seed);
else
success = SDL_sscanf(argv[1], "%"SDL_PRIu64, &seed);
success = SDL_sscanf(argv[1], "%" SDL_PRIu64, &seed);
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid seed. Use a decimal or hexadecimal number.\n");
return 1;
@@ -82,11 +81,11 @@ main(int argc, char *argv[])
for (i = 0; i < arraylen; i++) {
nums[i] = i;
}
nums[arraylen-1] = -1;
nums[arraylen - 1] = -1;
test_sort("already sorted except last element", nums, arraylen);
for (i = 0; i < arraylen; i++) {
nums[i] = (arraylen-1) - i;
nums[i] = (arraylen - 1) - i;
}
test_sort("reverse sorted", nums, arraylen);