mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-12 17:42:50 +00:00
RENAMED: Variable names for consistency, textLength (length in bytes) vs textSize (measure in pixels)
This commit is contained in:
@@ -2770,9 +2770,9 @@ static const char *GetFileNameWithoutExt(const char *filePath)
|
|||||||
|
|
||||||
if (filePath != NULL) strncpy(fileName, GetFileName(filePath), MAX_FILENAMEWITHOUTEXT_LENGTH - 1); // Get filename with extension
|
if (filePath != NULL) strncpy(fileName, GetFileName(filePath), MAX_FILENAMEWITHOUTEXT_LENGTH - 1); // Get filename with extension
|
||||||
|
|
||||||
int size = (int)strlen(fileName); // Get size in bytes
|
int fileNameLength = (int)strlen(fileName); // Get size in bytes
|
||||||
|
|
||||||
for (int i = 0; (i < size) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++)
|
for (int i = 0; (i < fileNameLength) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++)
|
||||||
{
|
{
|
||||||
if (fileName[i] == '.')
|
if (fileName[i] == '.')
|
||||||
{
|
{
|
||||||
|
|||||||
46
src/rcore.c
46
src/rcore.c
@@ -2009,10 +2009,10 @@ bool IsFileExtension(const char *fileName, const char *ext)
|
|||||||
|
|
||||||
if (fileExt != NULL)
|
if (fileExt != NULL)
|
||||||
{
|
{
|
||||||
int fileExtLen = (int)strlen(fileExt);
|
int fileExtLength = (int)strlen(fileExt);
|
||||||
char fileExtLower[16] = { 0 };
|
char fileExtLower[16] = { 0 };
|
||||||
char *fileExtLowerPtr = fileExtLower;
|
char *fileExtLowerPtr = fileExtLower;
|
||||||
for (int i = 0; (i < fileExtLen) && (i < 16); i++)
|
for (int i = 0; (i < fileExtLength) && (i < 16); i++)
|
||||||
{
|
{
|
||||||
// Copy and convert to lower-case
|
// Copy and convert to lower-case
|
||||||
if ((fileExt[i] >= 'A') && (fileExt[i] <= 'Z')) fileExtLower[i] = fileExt[i] + 32;
|
if ((fileExt[i] >= 'A') && (fileExt[i] <= 'Z')) fileExtLower[i] = fileExt[i] + 32;
|
||||||
@@ -2020,13 +2020,13 @@ bool IsFileExtension(const char *fileName, const char *ext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int extCount = 1;
|
int extCount = 1;
|
||||||
int extLen = (int)strlen(ext);
|
int extLength = (int)strlen(ext);
|
||||||
char *extList = (char *)RL_CALLOC(extLen + 1, 1);
|
char *extList = (char *)RL_CALLOC(extLength + 1, 1);
|
||||||
char *extListPtrs[MAX_FILE_EXTENSIONS] = { 0 };
|
char *extListPtrs[MAX_FILE_EXTENSIONS] = { 0 };
|
||||||
strncpy(extList, ext, extLen);
|
strncpy(extList, ext, extLength);
|
||||||
extListPtrs[0] = extList;
|
extListPtrs[0] = extList;
|
||||||
|
|
||||||
for (int i = 0; i < extLen; i++)
|
for (int i = 0; i < extLength; i++)
|
||||||
{
|
{
|
||||||
// Convert to lower-case if extension is upper-case
|
// Convert to lower-case if extension is upper-case
|
||||||
if ((extList[i] >= 'A') && (extList[i] <= 'Z')) extList[i] += 32;
|
if ((extList[i] >= 'A') && (extList[i] <= 'Z')) extList[i] += 32;
|
||||||
@@ -2163,9 +2163,9 @@ const char *GetFileNameWithoutExt(const char *filePath)
|
|||||||
if (filePath != NULL)
|
if (filePath != NULL)
|
||||||
{
|
{
|
||||||
strncpy(fileName, GetFileName(filePath), MAX_FILENAME_LENGTH - 1); // Get filename.ext without path
|
strncpy(fileName, GetFileName(filePath), MAX_FILENAME_LENGTH - 1); // Get filename.ext without path
|
||||||
int size = (int)strlen(fileName); // Get size in bytes
|
int fileNameLenght = (int)strlen(fileName); // Get size in bytes
|
||||||
|
|
||||||
for (int i = size; i > 0; i--) // Reverse search '.'
|
for (int i = fileNameLenght; i > 0; i--) // Reverse search '.'
|
||||||
{
|
{
|
||||||
if (fileName[i] == '.')
|
if (fileName[i] == '.')
|
||||||
{
|
{
|
||||||
@@ -2232,11 +2232,11 @@ const char *GetPrevDirectoryPath(const char *dirPath)
|
|||||||
{
|
{
|
||||||
static char prevDirPath[MAX_FILEPATH_LENGTH] = { 0 };
|
static char prevDirPath[MAX_FILEPATH_LENGTH] = { 0 };
|
||||||
memset(prevDirPath, 0, MAX_FILEPATH_LENGTH);
|
memset(prevDirPath, 0, MAX_FILEPATH_LENGTH);
|
||||||
int pathLen = (int)strlen(dirPath);
|
int dirPathLength = (int)strlen(dirPath);
|
||||||
|
|
||||||
if (pathLen <= 3) strncpy(prevDirPath, dirPath, MAX_FILEPATH_LENGTH - 1);
|
if (dirPathLength <= 3) strncpy(prevDirPath, dirPath, MAX_FILEPATH_LENGTH - 1);
|
||||||
|
|
||||||
for (int i = (pathLen - 1); (i >= 0) && (pathLen > 3); i--)
|
for (int i = (dirPathLength - 1); (i >= 0) && (dirPathLength > 3); i--)
|
||||||
{
|
{
|
||||||
if ((dirPath[i] == '\\') || (dirPath[i] == '/'))
|
if ((dirPath[i] == '\\') || (dirPath[i] == '/'))
|
||||||
{
|
{
|
||||||
@@ -2323,8 +2323,8 @@ const char *GetApplicationDirectory(void)
|
|||||||
|
|
||||||
if (_NSGetExecutablePath(appDir, &size) == 0)
|
if (_NSGetExecutablePath(appDir, &size) == 0)
|
||||||
{
|
{
|
||||||
int len = strlen(appDir);
|
int appDirLength = (int)strlen(appDir);
|
||||||
for (int i = len; i >= 0; --i)
|
for (int i = appDirLength; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (appDir[i] == '/')
|
if (appDir[i] == '/')
|
||||||
{
|
{
|
||||||
@@ -2346,8 +2346,8 @@ const char *GetApplicationDirectory(void)
|
|||||||
|
|
||||||
if (sysctl(mib, 4, appDir, &size, NULL, 0) == 0)
|
if (sysctl(mib, 4, appDir, &size, NULL, 0) == 0)
|
||||||
{
|
{
|
||||||
int len = strlen(appDir);
|
int appDirLength = (int)strlen(appDir);
|
||||||
for (int i = len; i >= 0; --i)
|
for (int i = appDirLength; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (appDir[i] == '/')
|
if (appDir[i] == '/')
|
||||||
{
|
{
|
||||||
@@ -2442,12 +2442,12 @@ int MakeDirectory(const char *dirPath)
|
|||||||
if (DirectoryExists(dirPath)) return 0; // Path already exists (is valid)
|
if (DirectoryExists(dirPath)) return 0; // Path already exists (is valid)
|
||||||
|
|
||||||
// Copy path string to avoid modifying original
|
// Copy path string to avoid modifying original
|
||||||
int len = (int)strlen(dirPath) + 1;
|
int dirPathLength = (int)strlen(dirPath) + 1;
|
||||||
char *pathcpy = (char *)RL_CALLOC(len, 1);
|
char *pathcpy = (char *)RL_CALLOC(dirPathLength, 1);
|
||||||
memcpy(pathcpy, dirPath, len);
|
memcpy(pathcpy, dirPath, dirPathLength);
|
||||||
|
|
||||||
// Iterate over pathcpy, create each subdirectory as needed
|
// Iterate over pathcpy, create each subdirectory as needed
|
||||||
for (int i = 0; (i < len) && (pathcpy[i] != '\0'); i++)
|
for (int i = 0; (i < dirPathLength) && (pathcpy[i] != '\0'); i++)
|
||||||
{
|
{
|
||||||
if (pathcpy[i] == ':') i++;
|
if (pathcpy[i] == ':') i++;
|
||||||
else
|
else
|
||||||
@@ -2499,10 +2499,10 @@ bool IsFileNameValid(const char *fileName)
|
|||||||
|
|
||||||
if ((fileName != NULL) && (fileName[0] != '\0'))
|
if ((fileName != NULL) && (fileName[0] != '\0'))
|
||||||
{
|
{
|
||||||
int length = (int)strlen(fileName);
|
int fileNameLength = (int)strlen(fileName);
|
||||||
bool allPeriods = true;
|
bool allPeriods = true;
|
||||||
|
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < fileNameLength; i++)
|
||||||
{
|
{
|
||||||
// Check invalid characters
|
// Check invalid characters
|
||||||
if ((fileName[i] == '<') ||
|
if ((fileName[i] == '<') ||
|
||||||
@@ -2528,7 +2528,7 @@ bool IsFileNameValid(const char *fileName)
|
|||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
// Check invalid DOS names
|
// Check invalid DOS names
|
||||||
if (length >= 3)
|
if (fileNameLength >= 3)
|
||||||
{
|
{
|
||||||
if (((fileName[0] == 'C') && (fileName[1] == 'O') && (fileName[2] == 'N')) || // CON
|
if (((fileName[0] == 'C') && (fileName[1] == 'O') && (fileName[2] == 'N')) || // CON
|
||||||
((fileName[0] == 'P') && (fileName[1] == 'R') && (fileName[2] == 'N')) || // PRN
|
((fileName[0] == 'P') && (fileName[1] == 'R') && (fileName[2] == 'N')) || // PRN
|
||||||
@@ -2536,7 +2536,7 @@ bool IsFileNameValid(const char *fileName)
|
|||||||
((fileName[0] == 'N') && (fileName[1] == 'U') && (fileName[2] == 'L'))) valid = false; // NUL
|
((fileName[0] == 'N') && (fileName[1] == 'U') && (fileName[2] == 'L'))) valid = false; // NUL
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length >= 4)
|
if (fileNameLength >= 4)
|
||||||
{
|
{
|
||||||
if (((fileName[0] == 'C') && (fileName[1] == 'O') && (fileName[2] == 'M') && ((fileName[3] >= '0') && (fileName[3] <= '9'))) || // COM0-9
|
if (((fileName[0] == 'C') && (fileName[1] == 'O') && (fileName[2] == 'M') && ((fileName[3] >= '0') && (fileName[3] <= '9'))) || // COM0-9
|
||||||
((fileName[0] == 'L') && (fileName[1] == 'P') && (fileName[2] == 'T') && ((fileName[3] >= '0') && (fileName[3] <= '9')))) valid = false; // LPT0-9
|
((fileName[0] == 'L') && (fileName[1] == 'P') && (fileName[2] == 'T') && ((fileName[3] >= '0') && (fileName[3] <= '9')))) valid = false; // LPT0-9
|
||||||
|
|||||||
@@ -2496,12 +2496,12 @@ void rlLoadExtensions(void *loader)
|
|||||||
const char *extensions = (const char *)glGetString(GL_EXTENSIONS); // One big const string
|
const char *extensions = (const char *)glGetString(GL_EXTENSIONS); // One big const string
|
||||||
|
|
||||||
// NOTE: We have to duplicate string because glGetString() returns a const string
|
// NOTE: We have to duplicate string because glGetString() returns a const string
|
||||||
int extSize = (int)strlen(extensions); // Get extensions string size in bytes
|
int extensionsLength = (int)strlen(extensions); // Get extensions string size in bytes
|
||||||
char *extensionsDup = (char *)RL_CALLOC(extSize + 1, sizeof(char)); // Allocate space for copy with additional EOL byte
|
char *extensionsDup = (char *)RL_CALLOC(extensionsLength + 1, sizeof(char)); // Allocate space for copy with additional EOL byte
|
||||||
strncpy(extensionsDup, extensions, extSize);
|
strncpy(extensionsDup, extensions, extensionsLength);
|
||||||
extList[numExt] = extensionsDup;
|
extList[numExt] = extensionsDup;
|
||||||
|
|
||||||
for (int i = 0; i < extSize; i++)
|
for (int i = 0; i < extensionsLength; i++)
|
||||||
{
|
{
|
||||||
if (extensionsDup[i] == ' ')
|
if (extensionsDup[i] == ' ')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1449,17 +1449,17 @@ char **LoadTextLines(const char *text, int *count)
|
|||||||
|
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
int textSize = TextLength(text);
|
int textLength = TextLength(text);
|
||||||
lineCount = 1;
|
lineCount = 1;
|
||||||
|
|
||||||
// First text scan pass to get required line count
|
// First text scan pass to get required line count
|
||||||
for (int i = 0; i < textSize; i++)
|
for (int i = 0; i < textLength; i++)
|
||||||
{
|
{
|
||||||
if (text[i] == '\n') lineCount++;
|
if (text[i] == '\n') lineCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
lines = (char **)RL_CALLOC(lineCount, sizeof(char *));
|
lines = (char **)RL_CALLOC(lineCount, sizeof(char *));
|
||||||
for (int i = 0, l = 0, lineLen = 0; i <= textSize; i++)
|
for (int i = 0, l = 0, lineLen = 0; i <= textLength; i++)
|
||||||
{
|
{
|
||||||
if ((text[i] == '\n') || (text[i] == '\0'))
|
if ((text[i] == '\n') || (text[i] == '\0'))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1488,7 +1488,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
|
|||||||
#if defined(SUPPORT_MODULE_RTEXT)
|
#if defined(SUPPORT_MODULE_RTEXT)
|
||||||
if (text == NULL) return imText;
|
if (text == NULL) return imText;
|
||||||
|
|
||||||
int size = (int)strlen(text); // Get size in bytes of text
|
int textLength = (int)strlen(text); // Get length of text in bytes
|
||||||
int textOffsetX = 0; // Image drawing position X
|
int textOffsetX = 0; // Image drawing position X
|
||||||
int textOffsetY = 0; // Offset between lines (on linebreak '\n')
|
int textOffsetY = 0; // Offset between lines (on linebreak '\n')
|
||||||
|
|
||||||
@@ -1499,7 +1499,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
|
|||||||
// Create image to store text
|
// Create image to store text
|
||||||
imText = GenImageColor((int)imSize.x, (int)imSize.y, BLANK);
|
imText = GenImageColor((int)imSize.x, (int)imSize.y, BLANK);
|
||||||
|
|
||||||
for (int i = 0; i < size;)
|
for (int i = 0; i < textLength;)
|
||||||
{
|
{
|
||||||
// Get next codepoint from byte string and glyph index in font
|
// Get next codepoint from byte string and glyph index in font
|
||||||
int codepointByteCount = 0;
|
int codepointByteCount = 0;
|
||||||
|
|||||||
@@ -142,8 +142,8 @@ void TraceLog(int logType, const char *text, ...)
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int textSize = (unsigned int)strlen(text);
|
unsigned int textLength = (unsigned int)strlen(text);
|
||||||
memcpy(buffer + strlen(buffer), text, (textSize < (MAX_TRACELOG_MSG_LENGTH - 12))? textSize : (MAX_TRACELOG_MSG_LENGTH - 12));
|
memcpy(buffer + strlen(buffer), text, (textLength < (MAX_TRACELOG_MSG_LENGTH - 12))? textLength : (MAX_TRACELOG_MSG_LENGTH - 12));
|
||||||
strcat(buffer, "\n");
|
strcat(buffer, "\n");
|
||||||
vprintf(buffer, args);
|
vprintf(buffer, args);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|||||||
Reference in New Issue
Block a user