Skip to content

Commit

Permalink
REVIEWED: TextFormat(), added "..." for truncation #3366
Browse files Browse the repository at this point in the history
It seems more standard than [TRUN]
  • Loading branch information
raysan5 committed Oct 11, 2023
1 parent 6ed8acd commit 876e6b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/rcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -2946,9 +2946,9 @@ const char *TextFormat(const char *text, ...)
// If requiredByteCount is larger than the MAX_TEXT_BUFFER_LENGTH, then overflow occured
if (requiredByteCount >= MAX_TEXT_BUFFER_LENGTH)
{
// We are going to insert [TRUN] at the end of the string so the user knows what happened
char *truncBuffer = buffers[index] + MAX_TEXT_BUFFER_LENGTH - 7; // Adding 7 bytes = six char + '\0'
sprintf(truncBuffer, "[TRUN]");
// Inserting "..." at the end of the string to mark as truncated
char *truncBuffer = buffers[index] + MAX_TEXT_BUFFER_LENGTH - 4; // Adding 4 bytes = "...\0"
sprintf(truncBuffer, "...");
}

index += 1; // Move to next buffer for next function call
Expand Down
6 changes: 3 additions & 3 deletions src/rtext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1377,9 +1377,9 @@ const char *TextFormat(const char *text, ...)
// If requiredByteCount is larger than the MAX_TEXT_BUFFER_LENGTH, then overflow occured
if (requiredByteCount >= MAX_TEXT_BUFFER_LENGTH)
{
// We are going to insert [TRUN] at the end of the string so the user knows what happened
char *truncBuffer = buffers[index] + MAX_TEXT_BUFFER_LENGTH - 7; // Adding 7 bytes = six chars + '\0'
sprintf(truncBuffer, "[TRUN]");
// Inserting "..." at the end of the string to mark as truncated
char *truncBuffer = buffers[index] + MAX_TEXT_BUFFER_LENGTH - 4; // Adding 4 bytes = "...\0"
sprintf(truncBuffer, "...");
}

index += 1; // Move to next buffer for next function call
Expand Down

0 comments on commit 876e6b3

Please sign in to comment.