1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 15:53:26 +01:00

some code cleanup

This commit is contained in:
Jfreegman 2014-07-06 23:08:36 -04:00
parent 00e6546f0c
commit 74b84c4252
3 changed files with 8 additions and 8 deletions

View File

@ -171,8 +171,8 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
}
++path;
path[strlen(path) - 1] = L'\0';
int path_len = strlen(path);
int path_len = strlen(path) - 1;
path[path_len] = '\0';
if (path_len > MAX_STR_SIZE) {
errmsg = "File path exceeds character limit.";

View File

@ -156,7 +156,7 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
}
++temp;
temp[strlen(temp) - 1] = L'\0';
temp[strlen(temp) - 1] = '\0';
snprintf(msg, sizeof(msg), "%s", temp);
} else {
char selfname[TOX_MAX_NAME_LENGTH];
@ -377,8 +377,8 @@ void cmd_note(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
}
++msg;
msg[strlen(msg) - 1] = '\0';
int len = strlen(msg);
int len = strlen(msg) - 1;
msg[len] = '\0';
tox_set_status_message(m, (uint8_t *) msg, (uint16_t) len);
prompt_update_statusmessage(prompt, msg);
}
@ -434,8 +434,8 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
if (msg != NULL) {
++msg;
msg[strlen(msg) - 1] = L'\0'; /* remove opening and closing quotes */
int len = strlen(msg);
int len = strlen(msg) - 1;
msg[len] = '\0'; /* remove opening and closing quotes */
tox_set_status_message(m, (uint8_t *) msg, (uint16_t) len);
prompt_update_statusmessage(prompt, msg);
}

View File

@ -270,7 +270,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum
ChatContext *ctx = self->chatwin;
char nick[TOX_MAX_NAME_LENGTH];
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);