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:
@@ -47,8 +47,8 @@ print_string(char **text, size_t *maxlen, const char *fmt, ...)
|
||||
len = SDL_vsnprintf(*text, *maxlen, fmt, ap);
|
||||
if (len > 0) {
|
||||
*text += len;
|
||||
if ( ((size_t) len) < *maxlen ) {
|
||||
*maxlen -= (size_t) len;
|
||||
if (((size_t)len) < *maxlen) {
|
||||
*maxlen -= (size_t)len;
|
||||
} else {
|
||||
*maxlen = 0;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ PrintModifierState()
|
||||
}
|
||||
|
||||
static void
|
||||
PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
|
||||
PrintKey(SDL_Keysym *sym, SDL_bool pressed, SDL_bool repeat)
|
||||
{
|
||||
char message[512];
|
||||
char *spot;
|
||||
@@ -131,17 +131,17 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
|
||||
/* Print the keycode, name and state */
|
||||
if (sym->sym) {
|
||||
print_string(&spot, &left,
|
||||
"Key %s: scancode %d = %s, keycode 0x%08X = %s ",
|
||||
pressed ? "pressed " : "released",
|
||||
sym->scancode,
|
||||
SDL_GetScancodeName(sym->scancode),
|
||||
sym->sym, SDL_GetKeyName(sym->sym));
|
||||
"Key %s: scancode %d = %s, keycode 0x%08X = %s ",
|
||||
pressed ? "pressed " : "released",
|
||||
sym->scancode,
|
||||
SDL_GetScancodeName(sym->scancode),
|
||||
sym->sym, SDL_GetKeyName(sym->sym));
|
||||
} else {
|
||||
print_string(&spot, &left,
|
||||
"Unknown Key (scancode %d = %s) %s ",
|
||||
sym->scancode,
|
||||
SDL_GetScancodeName(sym->scancode),
|
||||
pressed ? "pressed " : "released");
|
||||
"Unknown Key (scancode %d = %s) %s ",
|
||||
sym->scancode,
|
||||
SDL_GetScancodeName(sym->scancode),
|
||||
pressed ? "pressed " : "released");
|
||||
}
|
||||
print_modifiers(&spot, &left);
|
||||
if (repeat) {
|
||||
@@ -157,15 +157,14 @@ PrintText(const char *eventtype, const char *text)
|
||||
char expanded[1024];
|
||||
|
||||
expanded[0] = '\0';
|
||||
for ( spot = text; *spot; ++spot ) {
|
||||
for (spot = text; *spot; ++spot) {
|
||||
size_t length = SDL_strlen(expanded);
|
||||
SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot);
|
||||
}
|
||||
SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text);
|
||||
}
|
||||
|
||||
void
|
||||
loop()
|
||||
void loop()
|
||||
{
|
||||
SDL_Event event;
|
||||
/* Check for events */
|
||||
@@ -247,8 +246,7 @@ loop()
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
@@ -271,14 +269,14 @@ main(int argc, char *argv[])
|
||||
640, 480, 0);
|
||||
if (window == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
|
||||
SDL_GetError());
|
||||
SDL_GetError());
|
||||
quit(2);
|
||||
}
|
||||
|
||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||
if (renderer == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n",
|
||||
SDL_GetError());
|
||||
SDL_GetError());
|
||||
quit(2);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user