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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
781 changed files with 51659 additions and 55763 deletions

View file

@ -28,80 +28,80 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent filesystem routines */
char *
SDL_GetBasePath(void)
{
char *retval;
size_t len;
char cwd[FILENAME_MAX];
char *retval;
size_t len;
char cwd[FILENAME_MAX];
getcwd(cwd, sizeof(cwd));
len = SDL_strlen(cwd) + 1;
retval = (char *) SDL_malloc(len);
if (retval) {
SDL_memcpy(retval, cwd, len);
}
getcwd(cwd, sizeof(cwd));
len = SDL_strlen(cwd) + 1;
retval = (char *)SDL_malloc(len);
if (retval) {
SDL_memcpy(retval, cwd, len);
}
return retval;
return retval;
}
/* Do a recursive mkdir of parents folders */
static void recursive_mkdir(const char *dir) {
char tmp[FILENAME_MAX];
char *base = SDL_GetBasePath();
char *p = NULL;
size_t len;
static void recursive_mkdir(const char *dir)
{
char tmp[FILENAME_MAX];
char *base = SDL_GetBasePath();
char *p = NULL;
size_t len;
snprintf(tmp, sizeof(tmp),"%s",dir);
len = strlen(tmp);
if (tmp[len - 1] == '/') {
tmp[len - 1] = 0;
}
for (p = tmp + 1; *p; p++) {
if (*p == '/') {
*p = 0;
// Just creating subfolders from current path
if (strstr(tmp, base) != NULL) {
mkdir(tmp, S_IRWXU);
}
*p = '/';
snprintf(tmp, sizeof(tmp), "%s", dir);
len = strlen(tmp);
if (tmp[len - 1] == '/') {
tmp[len - 1] = 0;
}
}
free(base);
mkdir(tmp, S_IRWXU);
for (p = tmp + 1; *p; p++) {
if (*p == '/') {
*p = 0;
// Just creating subfolders from current path
if (strstr(tmp, base) != NULL) {
mkdir(tmp, S_IRWXU);
}
*p = '/';
}
}
free(base);
mkdir(tmp, S_IRWXU);
}
char *
SDL_GetPrefPath(const char *org, const char *app)
{
char *retval = NULL;
size_t len;
char *base = SDL_GetBasePath();
if (app == NULL) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
org = "";
}
char *retval = NULL;
size_t len;
char *base = SDL_GetBasePath();
if (app == NULL) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
org = "";
}
len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
retval = (char *) SDL_malloc(len);
len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
retval = (char *)SDL_malloc(len);
if (*org) {
SDL_snprintf(retval, len, "%s%s/%s/", base, org, app);
} else {
SDL_snprintf(retval, len, "%s%s/", base, app);
}
free(base);
if (*org) {
SDL_snprintf(retval, len, "%s%s/%s/", base, org, app);
} else {
SDL_snprintf(retval, len, "%s%s/", base, app);
}
free(base);
recursive_mkdir(retval);
return retval;
recursive_mkdir(retval);
return retval;
}
#endif /* SDL_FILESYSTEM_PS2 */