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

Add missing braces to if/for/while blocks.

Astyle doesn't quite catch all of them.
This commit is contained in:
iphydf 2018-07-18 15:56:21 +00:00
parent a37bf300f9
commit f2b796940e
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
5 changed files with 29 additions and 19 deletions

View File

@ -180,12 +180,13 @@ static void recv_message_helper(ToxWindow *self, Tox *m, uint32_t num, const cha
line_info_add(self, timefrmt, nick, NULL, IN_MSG, 0, 0, "%s", msg); line_info_add(self, timefrmt, nick, NULL, IN_MSG, 0, 0, "%s", msg);
write_to_log(msg, nick, ctx->log, false); write_to_log(msg, nick, ctx->log, false);
if (self->active_box != -1) if (self->active_box != -1) {
box_notify2(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message, box_notify2(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message,
self->active_box, "%s", msg); self->active_box, "%s", msg);
else } else {
box_notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message, box_notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message,
&self->active_box, nick, "%s", msg); &self->active_box, nick, "%s", msg);
}
} }
static void recv_action_helper(ToxWindow *self, Tox *m, uint32_t num, const char *action, size_t len, static void recv_action_helper(ToxWindow *self, Tox *m, uint32_t num, const char *action, size_t len,
@ -196,12 +197,13 @@ static void recv_action_helper(ToxWindow *self, Tox *m, uint32_t num, const char
line_info_add(self, timefrmt, nick, NULL, IN_ACTION, 0, 0, "%s", action); line_info_add(self, timefrmt, nick, NULL, IN_ACTION, 0, 0, "%s", action);
write_to_log(action, nick, ctx->log, true); write_to_log(action, nick, ctx->log, true);
if (self->active_box != -1) if (self->active_box != -1) {
box_notify2(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message, box_notify2(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message,
self->active_box, "* %s %s", nick, action); self->active_box, "* %s %s", nick, action);
else } else {
box_notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message, box_notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message,
&self->active_box, self->name, "* %s %s", nick, action); &self->active_box, self->name, "* %s %s", nick, action);
}
} }
static void chat_onMessage(ToxWindow *self, Tox *m, uint32_t num, TOX_MESSAGE_TYPE type, const char *msg, size_t len) static void chat_onMessage(ToxWindow *self, Tox *m, uint32_t num, TOX_MESSAGE_TYPE type, const char *msg, size_t len)
@ -648,12 +650,13 @@ static void chat_onFileRecv(ToxWindow *self, Tox *m, uint32_t friendnum, uint32_
snprintf(ft->file_name, sizeof(ft->file_name), "%s", filename); snprintf(ft->file_name, sizeof(ft->file_name), "%s", filename);
tox_file_get_file_id(m, friendnum, filenum, ft->file_id, NULL); tox_file_get_file_id(m, friendnum, filenum, ft->file_id, NULL);
if (self->active_box != -1) if (self->active_box != -1) {
box_notify2(self, transfer_pending, NT_WNDALERT_0 | NT_NOFOCUS | user_settings->bell_on_filetrans, box_notify2(self, transfer_pending, NT_WNDALERT_0 | NT_NOFOCUS | user_settings->bell_on_filetrans,
self->active_box, "Incoming file: %s", filename); self->active_box, "Incoming file: %s", filename);
else } else {
box_notify(self, transfer_pending, NT_WNDALERT_0 | NT_NOFOCUS | user_settings->bell_on_filetrans, box_notify(self, transfer_pending, NT_WNDALERT_0 | NT_NOFOCUS | user_settings->bell_on_filetrans,
&self->active_box, self->name, "Incoming file: %s", filename); &self->active_box, self->name, "Incoming file: %s", filename);
}
} }
static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, uint8_t type, const char *group_pub_key, static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, uint8_t type, const char *group_pub_key,

View File

@ -450,23 +450,25 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, uint32_t friendnu
line_info_add(self, timefrmt, nick, NULL, CONNECTION, 0, GREEN, msg); line_info_add(self, timefrmt, nick, NULL, CONNECTION, 0, GREEN, msg);
write_to_log(msg, nick, ctx->log, true); write_to_log(msg, nick, ctx->log, true);
if (self->active_box != -1) if (self->active_box != -1) {
box_notify2(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, self->active_box, box_notify2(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, self->active_box,
"%s has come online", nick); "%s has come online", nick);
else } else {
box_notify(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, &self->active_box, box_notify(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, &self->active_box,
"Toxic", "%s has come online", nick); "Toxic", "%s has come online", nick);
}
} else if (connection_status == TOX_CONNECTION_NONE) { } else if (connection_status == TOX_CONNECTION_NONE) {
msg = "has gone offline"; msg = "has gone offline";
line_info_add(self, timefrmt, nick, NULL, DISCONNECTION, 0, RED, msg); line_info_add(self, timefrmt, nick, NULL, DISCONNECTION, 0, RED, msg);
write_to_log(msg, nick, ctx->log, true); write_to_log(msg, nick, ctx->log, true);
if (self->active_box != -1) if (self->active_box != -1) {
box_notify2(self, user_log_out, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, self->active_box, box_notify2(self, user_log_out, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, self->active_box,
"%s has gone offline", nick); "%s has gone offline", nick);
else } else {
box_notify(self, user_log_out, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, &self->active_box, box_notify(self, user_log_out, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, &self->active_box,
"Toxic", "%s has gone offline", nick); "Toxic", "%s has gone offline", nick);
}
} }
} }

View File

@ -382,8 +382,8 @@ static int password_prompt(char *buf, int size)
if (buf[--len] != '\n') { if (buf[--len] != '\n') {
int ch; int ch;
while ((ch = getchar()) != '\n' && ch > 0) while ((ch = getchar()) != '\n' && ch > 0) {
; }
return 0; return 0;
} }

View File

@ -261,18 +261,20 @@ void strsubst(char *str, char old, char new)
{ {
int i; int i;
for (i = 0; str[i] != '\0'; ++i) for (i = 0; str[i] != '\0'; ++i) {
if (str[i] == old) { if (str[i] == old) {
str[i] = new; str[i] = new;
} }
}
} }
void wstrsubst(wchar_t *str, wchar_t old, wchar_t new) void wstrsubst(wchar_t *str, wchar_t old, wchar_t new)
{ {
int i; int i;
for (i = 0; str[i] != L'\0'; ++i) for (i = 0; str[i] != L'\0'; ++i) {
if (str[i] == old) { if (str[i] == old) {
str[i] = new; str[i] = new;
} }
}
} }

View File

@ -304,9 +304,10 @@ void on_file_recv(Tox *m, uint32_t friendnumber, uint32_t filenumber, uint32_t k
size_t i; size_t i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) { for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onFileRecv != NULL) if (windows[i].onFileRecv != NULL) {
windows[i].onFileRecv(&windows[i], m, friendnumber, filenumber, file_size, (char *) filename, windows[i].onFileRecv(&windows[i], m, friendnumber, filenumber, file_size, (char *) filename,
filename_length); filename_length);
}
} }
} }
@ -534,25 +535,27 @@ static void draw_bar(void)
continue; continue;
} }
if (windows + i == active_window) if (windows + i == active_window) {
#ifdef URXVT_FIX #ifdef URXVT_FIX
attron(A_BOLD | COLOR_PAIR(GREEN)); attron(A_BOLD | COLOR_PAIR(GREEN));
else } else {
#endif #endif
attron(A_BOLD); attron(A_BOLD);
}
draw_window_tab(&windows[i]); draw_window_tab(&windows[i]);
if (windows + i == active_window) if (windows + i == active_window) {
#ifdef URXVT_FIX #ifdef URXVT_FIX
attroff(A_BOLD | COLOR_PAIR(GREEN)); attroff(A_BOLD | COLOR_PAIR(GREEN));
else } else {
#endif #endif
attroff(A_BOLD); attroff(A_BOLD);
}
} }
// restore cursor position after drawing // restore cursor position after drawing