parent
28fb58f0ea
commit
61af8e7631
1 changed files with 8 additions and 9 deletions
|
|
@ -1371,14 +1371,14 @@ const char *TextFormat(const char *text, ...)
|
|||
|
||||
va_list args;
|
||||
va_start(args, text);
|
||||
int charCountRequired = vsnprintf(currentBuffer, MAX_TEXT_BUFFER_LENGTH, text, args);
|
||||
int requiredByteCount = vsnprintf(currentBuffer, MAX_TEXT_BUFFER_LENGTH, text, args);
|
||||
va_end(args);
|
||||
|
||||
// If charCountRequired is larger than the MAX_TEXT_BUFFER_LENGTH, then overflow occured
|
||||
if(charCountRequired > MAX_TEXT_BUFFER_LENGTH)
|
||||
// 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; // 7 = six letters + '\0'
|
||||
char *truncBuffer = buffers[index] + MAX_TEXT_BUFFER_LENGTH - 7; // Adding 7 bytes = six chars + '\0'
|
||||
sprintf(truncBuffer, "[TRUN]");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue