1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-03 01:06:44 +02:00

wrap tox_get_name in function that truncates name if it's too long

This commit is contained in:
Jfreegman
2014-07-08 14:31:59 -04:00
parent e74212cb9e
commit 442f68cd31
5 changed files with 29 additions and 40 deletions

View File

@ -270,16 +270,11 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum
ChatContext *ctx = self->chatwin;
char nick[TOX_MAX_NAME_LENGTH] = {0};
int n_len = tox_get_name(m, friendnum, (uint8_t *) nick);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1);
char nick[TOX_MAX_NAME_LENGTH] = {0}; /* stop removing this initiation */
get_nick_truncate(m, nick, friendnum);
if (!nick[0]) {
if (!nick[0])
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
n_len = strlen(UNKNOWN_NAME);
}
nick[n_len] = '\0';
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));