forked from Green-Sky/tomato
Merge commit '852f2a6343518919e5ca8d3c1bbcab9f493e3cd8'
This commit is contained in:
26
external/sdl/SDL/test/testime.c
vendored
26
external/sdl/SDL/test/testime.c
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -97,7 +97,7 @@ static Uint8 validate_hex(const char *cp, size_t len, Uint32 *np)
|
||||
}
|
||||
n = (n << 4) | c;
|
||||
}
|
||||
if (np != NULL) {
|
||||
if (np) {
|
||||
*np = n;
|
||||
}
|
||||
return 1;
|
||||
@ -116,7 +116,7 @@ static int unifont_init(const char *fontname)
|
||||
|
||||
/* Allocate memory for the glyph data so the file can be closed after initialization. */
|
||||
unifontGlyph = (struct UnifontGlyph *)SDL_malloc(unifontGlyphSize);
|
||||
if (unifontGlyph == NULL) {
|
||||
if (!unifontGlyph) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for glyph data.\n", (int)(unifontGlyphSize + 1023) / 1024);
|
||||
return -1;
|
||||
}
|
||||
@ -124,20 +124,20 @@ static int unifont_init(const char *fontname)
|
||||
|
||||
/* Allocate memory for texture pointers for all renderers. */
|
||||
unifontTexture = (SDL_Texture **)SDL_malloc(unifontTextureSize);
|
||||
if (unifontTexture == NULL) {
|
||||
if (!unifontTexture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for texture pointer data.\n", (int)(unifontTextureSize + 1023) / 1024);
|
||||
return -1;
|
||||
}
|
||||
SDL_memset(unifontTexture, 0, unifontTextureSize);
|
||||
|
||||
filename = GetResourceFilename(NULL, fontname);
|
||||
if (filename == NULL) {
|
||||
if (!filename) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
hexFile = SDL_RWFromFile(filename, "rb");
|
||||
SDL_free(filename);
|
||||
if (hexFile == NULL) {
|
||||
if (!hexFile) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to open font file: %s\n", fontname);
|
||||
return -1;
|
||||
}
|
||||
@ -279,7 +279,7 @@ static int unifont_load_texture(Uint32 textureID)
|
||||
}
|
||||
|
||||
textureRGBA = (Uint8 *)SDL_malloc(UNIFONT_TEXTURE_SIZE);
|
||||
if (textureRGBA == NULL) {
|
||||
if (!textureRGBA) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d MiB for a texture.\n", UNIFONT_TEXTURE_SIZE / 1024 / 1024);
|
||||
return -1;
|
||||
}
|
||||
@ -334,7 +334,7 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_FRect *ds
|
||||
}
|
||||
}
|
||||
texture = unifontTexture[UNIFONT_NUM_TEXTURES * rendererID + textureID];
|
||||
if (texture != NULL) {
|
||||
if (texture) {
|
||||
const Uint32 cInTex = codepoint % UNIFONT_GLYPHS_IN_TEXTURE;
|
||||
srcrect.x = (float)(cInTex % UNIFONT_GLYPHS_IN_ROW * 16);
|
||||
srcrect.y = (float)(cInTex / UNIFONT_GLYPHS_IN_ROW * 16);
|
||||
@ -348,12 +348,12 @@ static void unifont_cleanup(void)
|
||||
int i, j;
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
SDL_Renderer *renderer = state->renderers[i];
|
||||
if (state->windows[i] == NULL || renderer == NULL) {
|
||||
if (state->windows[i] == NULL || !renderer) {
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j < UNIFONT_NUM_TEXTURES; j++) {
|
||||
SDL_Texture *tex = unifontTexture[UNIFONT_NUM_TEXTURES * i + j];
|
||||
if (tex != NULL) {
|
||||
if (tex) {
|
||||
SDL_DestroyTexture(tex);
|
||||
}
|
||||
}
|
||||
@ -538,7 +538,7 @@ static void _Redraw(int rendererID)
|
||||
if (cursor) {
|
||||
char *p = utf8_advance(markedText, cursor);
|
||||
char c = 0;
|
||||
if (p == NULL) {
|
||||
if (!p) {
|
||||
p = &markedText[SDL_strlen(markedText)];
|
||||
}
|
||||
|
||||
@ -639,7 +639,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -677,7 +677,7 @@ int main(int argc, char *argv[])
|
||||
TTF_Init();
|
||||
|
||||
font = TTF_OpenFont(fontname, DEFAULT_PTSIZE);
|
||||
if (font == NULL) {
|
||||
if (!font) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user