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

@@ -29,8 +29,8 @@
#include "testutils.h"
static SDL_AudioSpec spec;
static Uint8 *sound = NULL; /* Pointer to wave data */
static Uint32 soundlen = 0; /* Length of wave data */
static Uint8 *sound = NULL; /* Pointer to wave data */
static Uint32 soundlen = 0; /* Length of wave data */
static int posindex = 0;
static Uint32 positions[64];
@@ -44,9 +44,9 @@ quit(int rc)
}
void SDLCALL
fillerup(void *_pos, Uint8 * stream, int len)
fillerup(void *_pos, Uint8 *stream, int len)
{
Uint32 pos = *((Uint32 *) _pos);
Uint32 pos = *((Uint32 *)_pos);
Uint8 *waveptr;
int waveleft;
@@ -65,17 +65,16 @@ fillerup(void *_pos, Uint8 * stream, int len)
}
SDL_memcpy(stream, waveptr, len);
pos += len;
*((Uint32 *) _pos) = pos;
*((Uint32 *)_pos) = pos;
}
static int done = 0;
void
poked(int sig)
void poked(int sig)
{
done = 1;
}
static const char*
static const char *
devtypestr(int iscapture)
{
return iscapture ? "capture" : "output";
@@ -98,10 +97,10 @@ iteration()
int iscapture = e.adevice.iscapture;
const char *name = SDL_GetAudioDeviceName(index, iscapture);
if (name != NULL)
SDL_Log("New %s audio device at index %u: %s\n", devtypestr(iscapture), (unsigned int) index, name);
SDL_Log("New %s audio device at index %u: %s\n", devtypestr(iscapture), (unsigned int)index, name);
else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Got new %s device at index %u, but failed to get the name: %s\n",
devtypestr(iscapture), (unsigned int) index, SDL_GetError());
devtypestr(iscapture), (unsigned int)index, SDL_GetError());
continue;
}
if (!iscapture) {
@@ -112,21 +111,20 @@ iteration()
if (!dev) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open '%s': %s\n", name, SDL_GetError());
} else {
SDL_Log("Opened '%s' as %u\n", name, (unsigned int) dev);
SDL_Log("Opened '%s' as %u\n", name, (unsigned int)dev);
SDL_PauseAudioDevice(dev, 0);
}
}
} else if (e.type == SDL_AUDIODEVICEREMOVED) {
dev = (SDL_AudioDeviceID) e.adevice.which;
SDL_Log("%s device %u removed.\n", devtypestr(e.adevice.iscapture), (unsigned int) dev);
dev = (SDL_AudioDeviceID)e.adevice.which;
SDL_Log("%s device %u removed.\n", devtypestr(e.adevice.iscapture), (unsigned int)dev);
SDL_CloseAudioDevice(dev);
}
}
}
#ifdef __EMSCRIPTEN__
void
loop()
void loop()
{
if (done)
emscripten_cancel_main_loop();
@@ -135,8 +133,7 @@ loop()
}
#endif
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
int i;
char *filename = NULL;