1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 21:53:05 +01:00
This commit is contained in:
Jfreegman 2014-10-03 19:29:12 -04:00
parent 40f70fc1e3
commit 5c66f5c161
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
2 changed files with 9 additions and 6 deletions

View File

@ -116,14 +116,17 @@ static void set_self_typingstatus(ToxWindow *self, Tox *m, uint8_t is_typing)
ctx->self_is_typing = is_typing;
}
static void chat_set_window_name(ToxWindow *self, char *nick, int len)
{
static void chat_set_window_name(ToxWindow *self, const char *nick, int len)
{
char nick_cpy[TOXIC_MAX_NAME_LENGTH + 1];
snprintf(nick_cpy, sizeof(nick_cpy), "%s", nick);
if (len > MAX_WINDOW_NAME_LENGTH) {
strcpy(&nick[MAX_WINDOW_NAME_LENGTH - 3], "...");
nick[MAX_WINDOW_NAME_LENGTH] = '\0';
strcpy(&nick_cpy[MAX_WINDOW_NAME_LENGTH - 3], "...");
nick_cpy[MAX_WINDOW_NAME_LENGTH] = '\0';
}
snprintf(self->name, sizeof(self->name), "%s", nick);
snprintf(self->name, sizeof(self->name), "%s", nick_cpy);
}
static void close_all_file_receivers(Tox *m, int friendnum);

View File

@ -250,7 +250,7 @@ void str_to_lower(char *str)
int get_nick_truncate(Tox *m, char *buf, int friendnum)
{
int len = tox_get_name(m, friendnum, (uint8_t *) buf);
len = MIN(len, TOXIC_MAX_NAME_LENGTH);
len = MIN(len, TOXIC_MAX_NAME_LENGTH - 1);
buf[len] = '\0';
return len;
}