make functions fall more inline with the standard structure of raylib functions
This commit is contained in:
parent
f342f11368
commit
6783b3ebd6
24
src/rtext.c
24
src/rtext.c
|
|
@ -1344,8 +1344,13 @@ Rectangle GetGlyphAtlasRec(Font font, int codepoint)
|
||||||
// Get text length in bytes, check for \0 character
|
// Get text length in bytes, check for \0 character
|
||||||
unsigned int TextLength(const char *text)
|
unsigned int TextLength(const char *text)
|
||||||
{
|
{
|
||||||
|
if (!text)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// use strlen since it uses vector operations
|
// use strlen since it uses vector operations
|
||||||
return textstrlen(text) ? 1 : 0;
|
unsigned int length = strlen(text);
|
||||||
|
|
||||||
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formatting of text with variables to 'embed'
|
// Formatting of text with variables to 'embed'
|
||||||
|
|
@ -1424,24 +1429,35 @@ 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 !strcmp(text1, text2);
|
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
|
||||||
const char *TextSubtext(const char *text, int position, int length)
|
const char *TextSubtext(const char *text, int position, int length)
|
||||||
{
|
{
|
||||||
if (!length)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user