1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Made usage of cons_show vargs

This commit is contained in:
James Booth 2012-10-03 22:19:46 +01:00
parent 6aa1fe5513
commit 585d3e52f7
3 changed files with 15 additions and 45 deletions

View File

@ -478,9 +478,7 @@ _cmd_connect(const char * const inp, struct cmd_help_t help)
cons_show("You are either connected already, or a login is in process."); cons_show("You are either connected already, or a login is in process.");
result = TRUE; result = TRUE;
} else if (strlen(inp) < 10) { } else if (strlen(inp) < 10) {
char usage[strlen(help.usage + 8)]; cons_show("Usage: %s", help.usage);
sprintf(usage, "Usage: %s", help.usage);
cons_show(usage);
result = TRUE; result = TRUE;
} else { } else {
char *user, *lower; char *user, *lower;
@ -622,14 +620,10 @@ _cmd_msg(const char * const inp, struct cmd_help_t help)
win_show_outgoing_msg("me", usr, msg); win_show_outgoing_msg("me", usr, msg);
} else { } else {
char usage[strlen(help.usage + 8)]; cons_show("Usage: %s", help.usage);
sprintf(usage, "Usage: %s", help.usage);
cons_show(usage);
} }
} else { } else {
char usage[strlen(help.usage + 8)]; cons_show("Usage: %s", help.usage);
sprintf(usage, "Usage: %s", help.usage);
cons_show(usage);
} }
} }
@ -670,9 +664,7 @@ _cmd_tiny(const char * const inp, struct cmd_help_t help)
free(url); free(url);
} }
} else { } else {
char usage[strlen(help.usage + 8)]; cons_show("Usage: %s", help.usage);
sprintf(usage, "Usage: %s", help.usage);
cons_show(usage);
if (win_in_chat()) { if (win_in_chat()) {
char usage[strlen(help.usage + 8)]; char usage[strlen(help.usage + 8)];
@ -739,9 +731,7 @@ static gboolean
_cmd_set_remind(const char * const inp, struct cmd_help_t help) _cmd_set_remind(const char * const inp, struct cmd_help_t help)
{ {
if ((strncmp(inp, "/remind ", 8) != 0) || (strlen(inp) < 9)) { if ((strncmp(inp, "/remind ", 8) != 0) || (strlen(inp) < 9)) {
char usage[strlen(help.usage + 8)]; cons_show("Usage: %s", help.usage);
sprintf(usage, "Usage: %s", help.usage);
cons_show(usage);
} else { } else {
// copy input // copy input
char inp_cpy[strlen(inp) + 1]; char inp_cpy[strlen(inp) + 1];
@ -821,14 +811,10 @@ _update_presence(const jabber_presence_t presence,
jabber_update_presence(presence, msg); jabber_update_presence(presence, msg);
title_bar_set_status(presence); title_bar_set_status(presence);
if (msg != NULL) { if (msg != NULL) {
char str[14 + strlen(show) + 3 + strlen(msg) + 2]; cons_show("Status set to %s, \"%s\"", show, msg);
sprintf(str, "Status set to %s, \"%s\"", show, msg);
cons_show(str);
free(msg); free(msg);
} else { } else {
char str[14 + strlen(show) + 1]; cons_show("Status set to %s", show);
sprintf(str, "Status set to %s", show);
cons_show(str);
} }
} }

View File

@ -116,11 +116,9 @@ void
prof_handle_login_success(const char *jid) prof_handle_login_success(const char *jid)
{ {
const char *msg = " logged in successfully."; const char *msg = " logged in successfully.";
char line[strlen(jid) + 1 + strlen(msg) + 1]; cons_show("%s %s", jid, msg);
sprintf(line, "%s %s", jid, msg);
title_bar_set_status(PRESENCE_ONLINE); title_bar_set_status(PRESENCE_ONLINE);
cons_show(line); log_info("%s %s", jid, msg);
log_info(line);
win_page_off(); win_page_off();
status_bar_print_message(jid); status_bar_print_message(jid);
status_bar_refresh(); status_bar_refresh();
@ -173,14 +171,10 @@ prof_handle_roster(GSList *roster)
while (roster != NULL) { while (roster != NULL) {
jabber_roster_entry *entry = roster->data; jabber_roster_entry *entry = roster->data;
if (entry->name != NULL) { if (entry->name != NULL) {
char line[strlen(entry->name) + 2 + strlen(entry->jid) + 1 + 1]; cons_show("%s (%s)", entry->name, entry->jid);
sprintf(line, "%s (%s)", entry->name, entry->jid);
cons_show(line);
} else { } else {
char line[strlen(entry->jid) + 1]; cons_show("%s", entry->jid);
sprintf(line, "%s", entry->jid);
cons_show(line);
} }
roster = g_slist_next(roster); roster = g_slist_next(roster);

View File

@ -489,11 +489,7 @@ cons_prefs(void)
else else
cons_show("Chat logging : OFF"); cons_show("Chat logging : OFF");
char remind_period[50]; cons_show("Message reminder period : %d seconds", prefs_get_remind());
sprintf(remind_period,
"Message reminder period : %d seconds", prefs_get_remind());
cons_show(remind_period);
cons_show(""); cons_show("");
@ -509,9 +505,7 @@ _cons_show_basic_help(void)
GSList *basic_helpers = cmd_get_basic_help(); GSList *basic_helpers = cmd_get_basic_help();
while (basic_helpers != NULL) { while (basic_helpers != NULL) {
struct cmd_help_t *help = (struct cmd_help_t *)basic_helpers->data; struct cmd_help_t *help = (struct cmd_help_t *)basic_helpers->data;
char line[25 + 2 + strlen(help->short_help)]; cons_show("%-25s: %s", help->usage, help->short_help);
sprintf(line, "%-25s: %s", help->usage, help->short_help);
cons_show(line);
basic_helpers = g_slist_next(basic_helpers); basic_helpers = g_slist_next(basic_helpers);
} }
@ -531,9 +525,7 @@ cons_help(void)
GSList *settings_helpers = cmd_get_settings_help(); GSList *settings_helpers = cmd_get_settings_help();
while (settings_helpers != NULL) { while (settings_helpers != NULL) {
struct cmd_help_t *help = (struct cmd_help_t *)settings_helpers->data; struct cmd_help_t *help = (struct cmd_help_t *)settings_helpers->data;
char line[25 + 2 + strlen(help->short_help)]; cons_show("%-25s: %s", help->usage, help->short_help);
sprintf(line, "%-25s: %s", help->usage, help->short_help);
cons_show(line);
settings_helpers = g_slist_next(settings_helpers); settings_helpers = g_slist_next(settings_helpers);
} }
@ -544,9 +536,7 @@ cons_help(void)
GSList *status_helpers = cmd_get_status_help(); GSList *status_helpers = cmd_get_status_help();
while (status_helpers != NULL) { while (status_helpers != NULL) {
struct cmd_help_t *help = (struct cmd_help_t *)status_helpers->data; struct cmd_help_t *help = (struct cmd_help_t *)status_helpers->data;
char line[25 + 2 + strlen(help->short_help)]; cons_show("%-25s: %s", help->usage, help->short_help);
sprintf(line, "%-25s: %s", help->usage, help->short_help);
cons_show(line);
status_helpers = g_slist_next(status_helpers); status_helpers = g_slist_next(status_helpers);
} }