Remove newlines from log messages

This commit is contained in:
nightmareci
2025-01-22 12:59:57 -08:00
committed by Sam Lantinga
parent 17625e20df
commit 718034f5fa
123 changed files with 1143 additions and 1118 deletions

View File

@@ -1092,12 +1092,12 @@ static void SDLTest_PrintRenderer(SDL_Renderer *renderer)
name = SDL_GetRendererName(renderer);
SDL_Log(" Renderer %s:\n", name);
SDL_Log(" Renderer %s:", name);
if (SDL_strcmp(name, "gpu") == 0) {
SDL_GPUDevice *device = SDL_GetPointerProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_GPU_DEVICE_POINTER, NULL);
SDL_Log(" Driver: %s\n", SDL_GetGPUDeviceDriver(device));
SDL_Log(" Driver: %s", SDL_GetGPUDeviceDriver(device));
}
SDL_Log(" VSync: %d\n", (int)SDL_GetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_VSYNC_NUMBER, 0));
SDL_Log(" VSync: %d", (int)SDL_GetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_VSYNC_NUMBER, 0));
texture_formats = (const SDL_PixelFormat *)SDL_GetPointerProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER, NULL);
if (texture_formats) {
@@ -1108,12 +1108,12 @@ static void SDLTest_PrintRenderer(SDL_Renderer *renderer)
}
SDLTest_PrintPixelFormat(text, sizeof(text), texture_formats[i]);
}
SDL_Log("%s\n", text);
SDL_Log("%s", text);
}
max_texture_size = (int)SDL_GetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, 0);
if (max_texture_size) {
SDL_Log(" Max Texture Size: %dx%d\n", max_texture_size, max_texture_size);
SDL_Log(" Max Texture Size: %dx%d", max_texture_size, max_texture_size);
}
}
@@ -1124,7 +1124,7 @@ static SDL_Surface *SDLTest_LoadIcon(const char *file)
/* Load the icon surface */
icon = SDL_LoadBMP(file);
if (!icon) {
SDL_Log("Couldn't load %s: %s\n", file, SDL_GetError());
SDL_Log("Couldn't load %s: %s", file, SDL_GetError());
return NULL;
}
@@ -1142,40 +1142,40 @@ static SDL_HitTestResult SDLCALL SDLTest_ExampleHitTestCallback(SDL_Window *win,
const int RESIZE_BORDER = 8;
const int DRAGGABLE_TITLE = 32;
/*SDL_Log("Hit test point %d,%d\n", area->x, area->y);*/
/*SDL_Log("Hit test point %d,%d", area->x, area->y);*/
SDL_GetWindowSize(win, &w, &h);
if (area->x < RESIZE_BORDER) {
if (area->y < RESIZE_BORDER) {
SDL_Log("SDL_HITTEST_RESIZE_TOPLEFT\n");
SDL_Log("SDL_HITTEST_RESIZE_TOPLEFT");
return SDL_HITTEST_RESIZE_TOPLEFT;
} else if (area->y >= (h - RESIZE_BORDER)) {
SDL_Log("SDL_HITTEST_RESIZE_BOTTOMLEFT\n");
SDL_Log("SDL_HITTEST_RESIZE_BOTTOMLEFT");
return SDL_HITTEST_RESIZE_BOTTOMLEFT;
} else {
SDL_Log("SDL_HITTEST_RESIZE_LEFT\n");
SDL_Log("SDL_HITTEST_RESIZE_LEFT");
return SDL_HITTEST_RESIZE_LEFT;
}
} else if (area->x >= (w - RESIZE_BORDER)) {
if (area->y < RESIZE_BORDER) {
SDL_Log("SDL_HITTEST_RESIZE_TOPRIGHT\n");
SDL_Log("SDL_HITTEST_RESIZE_TOPRIGHT");
return SDL_HITTEST_RESIZE_TOPRIGHT;
} else if (area->y >= (h - RESIZE_BORDER)) {
SDL_Log("SDL_HITTEST_RESIZE_BOTTOMRIGHT\n");
SDL_Log("SDL_HITTEST_RESIZE_BOTTOMRIGHT");
return SDL_HITTEST_RESIZE_BOTTOMRIGHT;
} else {
SDL_Log("SDL_HITTEST_RESIZE_RIGHT\n");
SDL_Log("SDL_HITTEST_RESIZE_RIGHT");
return SDL_HITTEST_RESIZE_RIGHT;
}
} else if (area->y >= (h - RESIZE_BORDER)) {
SDL_Log("SDL_HITTEST_RESIZE_BOTTOM\n");
SDL_Log("SDL_HITTEST_RESIZE_BOTTOM");
return SDL_HITTEST_RESIZE_BOTTOM;
} else if (area->y < RESIZE_BORDER) {
SDL_Log("SDL_HITTEST_RESIZE_TOP\n");
SDL_Log("SDL_HITTEST_RESIZE_TOP");
return SDL_HITTEST_RESIZE_TOP;
} else if (area->y < DRAGGABLE_TITLE) {
SDL_Log("SDL_HITTEST_DRAGGABLE\n");
SDL_Log("SDL_HITTEST_DRAGGABLE");
return SDL_HITTEST_DRAGGABLE;
}
return SDL_HITTEST_NORMAL;
@@ -1190,7 +1190,7 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
if (state->verbose & VERBOSE_VIDEO) {
n = SDL_GetNumVideoDrivers();
if (n == 0) {
SDL_Log("No built-in video drivers\n");
SDL_Log("No built-in video drivers");
} else {
(void)SDL_snprintf(text, sizeof(text), "Built-in video drivers:");
for (i = 0; i < n; ++i) {
@@ -1199,16 +1199,16 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
}
SDL_snprintfcat(text, sizeof(text), " %s", SDL_GetVideoDriver(i));
}
SDL_Log("%s\n", text);
SDL_Log("%s", text);
}
}
if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) {
SDL_Log("Couldn't initialize video driver: %s\n",
SDL_Log("Couldn't initialize video driver: %s",
SDL_GetError());
return false;
}
if (state->verbose & VERBOSE_VIDEO) {
SDL_Log("Video driver: %s\n",
SDL_Log("Video driver: %s",
SDL_GetCurrentVideoDriver());
}
@@ -1257,10 +1257,10 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
int outputIndex = 0;
#endif
displays = SDL_GetDisplays(&n);
SDL_Log("Number of displays: %d\n", n);
SDL_Log("Number of displays: %d", n);
for (i = 0; i < n; ++i) {
SDL_DisplayID displayID = displays[i];
SDL_Log("Display %" SDL_PRIu32 ": %s\n", displayID, SDL_GetDisplayName(displayID));
SDL_Log("Display %" SDL_PRIu32 ": %s", displayID, SDL_GetDisplayName(displayID));
SDL_zero(bounds);
SDL_GetDisplayBounds(displayID, &bounds);
@@ -1268,46 +1268,46 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_zero(usablebounds);
SDL_GetDisplayUsableBounds(displayID, &usablebounds);
SDL_Log("Bounds: %dx%d at %d,%d\n", bounds.w, bounds.h, bounds.x, bounds.y);
SDL_Log("Usable bounds: %dx%d at %d,%d\n", usablebounds.w, usablebounds.h, usablebounds.x, usablebounds.y);
SDL_Log("Bounds: %dx%d at %d,%d", bounds.w, bounds.h, bounds.x, bounds.y);
SDL_Log("Usable bounds: %dx%d at %d,%d", usablebounds.w, usablebounds.h, usablebounds.x, usablebounds.y);
mode = SDL_GetDesktopDisplayMode(displayID);
SDL_GetMasksForPixelFormat(mode->format, &bpp, &Rmask, &Gmask,
&Bmask, &Amask);
SDL_Log(" Desktop mode: %dx%d@%gx %gHz, %d bits-per-pixel (%s)\n",
SDL_Log(" Desktop mode: %dx%d@%gx %gHz, %d bits-per-pixel (%s)",
mode->w, mode->h, mode->pixel_density, mode->refresh_rate, bpp,
SDL_GetPixelFormatName(mode->format));
if (Rmask || Gmask || Bmask) {
SDL_Log(" Red Mask = 0x%.8" SDL_PRIx32 "\n", Rmask);
SDL_Log(" Green Mask = 0x%.8" SDL_PRIx32 "\n", Gmask);
SDL_Log(" Blue Mask = 0x%.8" SDL_PRIx32 "\n", Bmask);
SDL_Log(" Red Mask = 0x%.8" SDL_PRIx32, Rmask);
SDL_Log(" Green Mask = 0x%.8" SDL_PRIx32, Gmask);
SDL_Log(" Blue Mask = 0x%.8" SDL_PRIx32, Bmask);
if (Amask) {
SDL_Log(" Alpha Mask = 0x%.8" SDL_PRIx32 "\n", Amask);
SDL_Log(" Alpha Mask = 0x%.8" SDL_PRIx32, Amask);
}
}
/* Print available fullscreen video modes */
modes = SDL_GetFullscreenDisplayModes(displayID, &m);
if (m == 0) {
SDL_Log("No available fullscreen video modes\n");
SDL_Log("No available fullscreen video modes");
} else {
SDL_Log(" Fullscreen video modes:\n");
SDL_Log(" Fullscreen video modes:");
for (j = 0; j < m; ++j) {
mode = modes[j];
SDL_GetMasksForPixelFormat(mode->format, &bpp, &Rmask,
&Gmask, &Bmask, &Amask);
SDL_Log(" Mode %d: %dx%d@%gx %gHz, %d bits-per-pixel (%s)\n",
SDL_Log(" Mode %d: %dx%d@%gx %gHz, %d bits-per-pixel (%s)",
j, mode->w, mode->h, mode->pixel_density, mode->refresh_rate, bpp,
SDL_GetPixelFormatName(mode->format));
if (Rmask || Gmask || Bmask) {
SDL_Log(" Red Mask = 0x%.8" SDL_PRIx32 "\n",
SDL_Log(" Red Mask = 0x%.8" SDL_PRIx32,
Rmask);
SDL_Log(" Green Mask = 0x%.8" SDL_PRIx32 "\n",
SDL_Log(" Green Mask = 0x%.8" SDL_PRIx32,
Gmask);
SDL_Log(" Blue Mask = 0x%.8" SDL_PRIx32 "\n",
SDL_Log(" Blue Mask = 0x%.8" SDL_PRIx32,
Bmask);
if (Amask) {
SDL_Log(" Alpha Mask = 0x%.8" SDL_PRIx32 "\n", Amask);
SDL_Log(" Alpha Mask = 0x%.8" SDL_PRIx32, Amask);
}
}
}
@@ -1330,11 +1330,11 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
if (state->verbose & VERBOSE_RENDER) {
n = SDL_GetNumRenderDrivers();
if (n == 0) {
SDL_Log("No built-in render drivers\n");
SDL_Log("No built-in render drivers");
} else {
SDL_Log("Built-in render drivers:\n");
SDL_Log("Built-in render drivers:");
for (i = 0; i < n; ++i) {
SDL_Log(" %s\n", SDL_GetRenderDriver(i));
SDL_Log(" %s", SDL_GetRenderDriver(i));
}
}
}
@@ -1374,7 +1374,7 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
(SDL_Texture **)SDL_calloc(state->num_windows,
sizeof(*state->targets));
if (!state->windows || !state->renderers) {
SDL_Log("Out of memory!\n");
SDL_Log("Out of memory!");
return false;
}
for (i = 0; i < state->num_windows; ++i) {
@@ -1412,7 +1412,7 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
state->windows[i] = SDL_CreateWindowWithProperties(props);
SDL_DestroyProperties(props);
if (!state->windows[i]) {
SDL_Log("Couldn't create window: %s\n",
SDL_Log("Couldn't create window: %s",
SDL_GetError());
return false;
}
@@ -1427,7 +1427,7 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
}
SDL_GetWindowSize(state->windows[i], &w, &h);
if (!(state->window_flags & SDL_WINDOW_RESIZABLE) && (w != r.w || h != r.h)) {
SDL_Log("Window requested size %dx%d, got %dx%d\n", r.w, r.h, w, h);
SDL_Log("Window requested size %dx%d, got %dx%d", r.w, r.h, w, h);
state->window_w = w;
state->window_h = h;
}
@@ -1459,7 +1459,7 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
if (!state->skip_renderer && (state->renderdriver || !(state->window_flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)))) {
state->renderers[i] = SDL_CreateRenderer(state->windows[i], state->renderdriver);
if (!state->renderers[i]) {
SDL_Log("Couldn't create renderer: %s\n",
SDL_Log("Couldn't create renderer: %s",
SDL_GetError());
return false;
}
@@ -1471,14 +1471,14 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_SetRenderVSync(state->renderers[i], state->render_vsync);
}
if (!SDL_SetRenderLogicalPresentation(state->renderers[i], state->logical_w, state->logical_h, state->logical_presentation)) {
SDL_Log("Couldn't set logical presentation: %s\n", SDL_GetError());
SDL_Log("Couldn't set logical presentation: %s", SDL_GetError());
return false;
}
if (state->scale != 0.0f) {
SDL_SetRenderScale(state->renderers[i], state->scale, state->scale);
}
if (state->verbose & VERBOSE_RENDER) {
SDL_Log("Current renderer:\n");
SDL_Log("Current renderer:");
SDLTest_PrintRenderer(state->renderers[i]);
}
}
@@ -1494,7 +1494,7 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
if (state->verbose & VERBOSE_AUDIO) {
n = SDL_GetNumAudioDrivers();
if (n == 0) {
SDL_Log("No built-in audio drivers\n");
SDL_Log("No built-in audio drivers");
} else {
(void)SDL_snprintf(text, sizeof(text), "Built-in audio drivers:");
for (i = 0; i < n; ++i) {
@@ -1503,23 +1503,23 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
}
SDL_snprintfcat(text, sizeof(text), " %s", SDL_GetAudioDriver(i));
}
SDL_Log("%s\n", text);
SDL_Log("%s", text);
}
}
if (!SDL_InitSubSystem(SDL_INIT_AUDIO)) {
SDL_Log("Couldn't initialize audio driver: %s\n",
SDL_Log("Couldn't initialize audio driver: %s",
SDL_GetError());
return false;
}
if (state->verbose & VERBOSE_AUDIO) {
SDL_Log("Audio driver: %s\n",
SDL_Log("Audio driver: %s",
SDL_GetCurrentAudioDriver());
}
const SDL_AudioSpec spec = { state->audio_format, state->audio_channels, state->audio_freq };
state->audio_id = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec);
if (!state->audio_id) {
SDL_Log("Couldn't open audio: %s\n", SDL_GetError());
SDL_Log("Couldn't open audio: %s", SDL_GetError());
return false;
}
}
@@ -1676,7 +1676,7 @@ void SDLTest_PrintEvent(const SDL_Event *event)
SDL_Rect rect;
SDL_GetWindowSafeArea(SDL_GetWindowFromEvent(event), &rect);
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " changed safe area to: %d,%d %dx%d\n",
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " changed safe area to: %d,%d %dx%d",
event->window.windowID, rect.x, rect.y, rect.w, rect.h);
break;
}
@@ -2058,7 +2058,7 @@ static void SDLCALL SDLTest_ScreenShotClipboardCleanup(void *context)
{
SDLTest_ClipboardData *data = (SDLTest_ClipboardData *)context;
SDL_Log("Cleaning up screenshot image data\n");
SDL_Log("Cleaning up screenshot image data");
if (data->image) {
SDL_free(data->image);
@@ -2071,14 +2071,14 @@ static const void * SDLCALL SDLTest_ScreenShotClipboardProvider(void *context, c
SDLTest_ClipboardData *data = (SDLTest_ClipboardData *)context;
if (SDL_strncmp(mime_type, "text", 4) == 0) {
SDL_Log("Providing screenshot title to clipboard!\n");
SDL_Log("Providing screenshot title to clipboard!");
/* Return "Test screenshot" */
*size = 15;
return "Test screenshot (but this isn't part of it)";
}
SDL_Log("Providing screenshot image to clipboard!\n");
SDL_Log("Providing screenshot image to clipboard!");
if (!data->image) {
SDL_IOStream *file;
@@ -2089,7 +2089,7 @@ static const void * SDLCALL SDLTest_ScreenShotClipboardProvider(void *context, c
void *image = SDL_malloc(length);
if (image) {
if (SDL_ReadIO(file, image, length) != length) {
SDL_Log("Couldn't read %s: %s\n", SCREENSHOT_FILE, SDL_GetError());
SDL_Log("Couldn't read %s: %s", SCREENSHOT_FILE, SDL_GetError());
SDL_free(image);
image = NULL;
}
@@ -2101,7 +2101,7 @@ static const void * SDLCALL SDLTest_ScreenShotClipboardProvider(void *context, c
data->size = length;
}
} else {
SDL_Log("Couldn't load %s: %s\n", SCREENSHOT_FILE, SDL_GetError());
SDL_Log("Couldn't load %s: %s", SCREENSHOT_FILE, SDL_GetError());
}
}
@@ -2124,12 +2124,12 @@ static void SDLTest_CopyScreenShot(SDL_Renderer *renderer)
surface = SDL_RenderReadPixels(renderer, NULL);
if (!surface) {
SDL_Log("Couldn't read screen: %s\n", SDL_GetError());
SDL_Log("Couldn't read screen: %s", SDL_GetError());
return;
}
if (!SDL_SaveBMP(surface, SCREENSHOT_FILE)) {
SDL_Log("Couldn't save %s: %s\n", SCREENSHOT_FILE, SDL_GetError());
SDL_Log("Couldn't save %s: %s", SCREENSHOT_FILE, SDL_GetError());
SDL_DestroySurface(surface);
return;
}
@@ -2137,11 +2137,11 @@ static void SDLTest_CopyScreenShot(SDL_Renderer *renderer)
clipboard_data = (SDLTest_ClipboardData *)SDL_calloc(1, sizeof(*clipboard_data));
if (!clipboard_data) {
SDL_Log("Couldn't allocate clipboard data\n");
SDL_Log("Couldn't allocate clipboard data");
return;
}
SDL_SetClipboardData(SDLTest_ScreenShotClipboardProvider, SDLTest_ScreenShotClipboardCleanup, clipboard_data, image_formats, SDL_arraysize(image_formats));
SDL_Log("Saved screenshot to %s and clipboard\n", SCREENSHOT_FILE);
SDL_Log("Saved screenshot to %s and clipboard", SCREENSHOT_FILE);
}
static void SDLTest_PasteScreenShot(void)
@@ -2336,7 +2336,7 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
} else {
dest = displays[(current_index + num_displays + 1) % num_displays];
}
SDL_Log("Centering on display (%" SDL_PRIu32 ")\n", dest);
SDL_Log("Centering on display (%" SDL_PRIu32 ")", dest);
SDL_SetWindowPosition(window,
SDL_WINDOWPOS_CENTERED_DISPLAY(dest),
SDL_WINDOWPOS_CENTERED_DISPLAY(dest));
@@ -2365,7 +2365,7 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
x += delta;
}
SDL_Log("Setting position to (%d, %d)\n", x, y);
SDL_Log("Setting position to (%d, %d)", x, y);
SDL_SetWindowPosition(window, x, y);
}
}
@@ -2399,7 +2399,7 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
if (withAlt) {
/* Alt-C copy awesome text to the primary selection! */
SDL_SetPrimarySelectionText("SDL rocks!\nYou know it!");
SDL_Log("Copied text to primary selection\n");
SDL_Log("Copied text to primary selection");
} else if (withControl) {
if (withShift) {
@@ -2415,7 +2415,7 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
} else {
/* Ctrl-C copy awesome text! */
SDL_SetClipboardText("SDL rocks!\nYou know it!");
SDL_Log("Copied text to clipboard\n");
SDL_Log("Copied text to clipboard");
}
break;
}
@@ -2425,9 +2425,9 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
/* Alt-V paste awesome text from the primary selection! */
char *text = SDL_GetPrimarySelectionText();
if (*text) {
SDL_Log("Primary selection: %s\n", text);
SDL_Log("Primary selection: %s", text);
} else {
SDL_Log("Primary selection is empty\n");
SDL_Log("Primary selection is empty");
}
SDL_free(text);
@@ -2439,9 +2439,9 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
/* Ctrl-V paste awesome text! */
char *text = SDL_GetClipboardText();
if (*text) {
SDL_Log("Clipboard: %s\n", text);
SDL_Log("Clipboard: %s", text);
} else {
SDL_Log("Clipboard is empty\n");
SDL_Log("Clipboard is empty");
}
SDL_free(text);
}
@@ -2498,7 +2498,7 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
if (window) {
const bool shouldCapture = !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_CAPTURE);
const bool rc = SDL_CaptureMouse(shouldCapture);
SDL_Log("%sapturing mouse %s!\n", shouldCapture ? "C" : "Unc", rc ? "succeeded" : "failed");
SDL_Log("%sapturing mouse %s!", shouldCapture ? "C" : "Unc", rc ? "succeeded" : "failed");
}
}
break;