make functions fall more inline with the standard structure of raylib functions

This commit is contained in:
DissolveDZ 2023-09-30 19:00:58 +02:00
parent beab63887c
commit 4a6b24f729

View File

@ -1345,7 +1345,12 @@ Rectangle GetGlyphAtlasRec(Font font, int codepoint)
unsigned int TextLength(const char *text) unsigned int TextLength(const char *text)
{ {
// use strlen since it uses vector operations // use strlen since it uses vector operations
return text ? strlen(text) : 0; bool result = false;
if (text && strlen(text))
result = true;
return result;
} }
// Formatting of text with variables to 'embed' // Formatting of text with variables to 'embed'
@ -1424,7 +1429,12 @@ int TextCopy(char *dst, const char *src)
// REQUIRES: strcmp() // REQUIRES: strcmp()
bool TextIsEqual(const char *text1, const char *text2) bool TextIsEqual(const char *text1, const char *text2)
{ {
return text1 && text2 ? !strcmp(text1, text2) : 0; bool result = false;
if (text1 && text2 && !strcmp(text1, text2))
result = true;
return result;
} }
// Get a piece of a text string // Get a piece of a text string
@ -1432,16 +1442,21 @@ const char *TextSubtext(const char *text, int position, int length)
{ {
if (!length || !text) if (!length || !text)
return ""; return "";
int textLength = TextLength(text); int textLength = TextLength(text);
if (position >= textLength) if (position >= textLength)
{ {
position = textLength - 1; position = textLength - 1;
length = 0; length = 0;
} }
if (length > textLength) length = textLength; if (length > textLength) length = textLength;
char *buffer = malloc(length + 1); char *buffer = malloc(length + 1);
memcpy(buffer, text + position, length); memcpy(buffer, text + position, length);
buffer[length] = '\0'; buffer[length] = '\0';
return buffer; return buffer;
} }