From 0e54c2c120a4b9553c9572f080a915fea1aa75f5 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Fri, 27 Sep 2013 01:22:44 +0200 Subject: [PATCH] Removed string length restriction of vb_echo functions. --- src/main.c | 63 +++++++++++++++++++++++++++------------------------- src/normal.c | 10 +-------- 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/src/main.c b/src/main.c index 0c43e54..67b1aeb 100644 --- a/src/main.c +++ b/src/main.c @@ -82,26 +82,47 @@ static void input_print(gboolean force, const MessageType type, gboolean hide, c void vb_echo_force(const MessageType type, gboolean hide, const char *error, ...) { - char message[BUF_SIZE]; - va_list arg_list; + char *buffer; + va_list args; - va_start(arg_list, error); - vsnprintf(message, BUF_SIZE, error, arg_list); - va_end(arg_list); + va_start(args, error); + buffer = g_strdup_vprintf(error, args); + va_end(args); - input_print(true, type, hide, message); + input_print(true, type, hide, buffer); + g_free(buffer); } void vb_echo(const MessageType type, gboolean hide, const char *error, ...) { - char message[BUF_SIZE]; - va_list arg_list; + char *buffer; + va_list args; - va_start(arg_list, error); - vsnprintf(message, BUF_SIZE, error, arg_list); - va_end(arg_list); + va_start(args, error); + buffer = g_strdup_vprintf(error, args); + va_end(args); - input_print(false, type, hide, message); + input_print(false, type, hide, buffer); + g_free(buffer); +} + +static void input_print(gboolean force, const MessageType type, gboolean hide, + const char *message) +{ + /* don't print message if the input is focussed */ + if (!force && gtk_widget_is_focus(GTK_WIDGET(vb.gui.input))) { + return; + } + + /* apply input style only if the message type was changed */ + if (type != vb.state.input_type) { + vb.state.input_type = type; + vb_update_input_style(); + } + vb_set_input_text(message); + if (hide) { + g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)hide_message, NULL); + } } /** @@ -525,24 +546,6 @@ static void set_status(const StatusType status) } } -static void input_print(gboolean force, const MessageType type, gboolean hide, const char *message) -{ - /* don't print message if the input is focussed */ - if (!force && gtk_widget_is_focus(GTK_WIDGET(vb.gui.input))) { - return; - } - - /* apply input style only if the message type was changed */ - if (type != vb.state.input_type) { - vb.state.input_type = type; - vb_update_input_style(); - } - vb_set_input_text(message); - if (hide) { - g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)hide_message, NULL); - } -} - static void run_user_script(WebKitWebFrame *frame) { char *js = NULL, *value = NULL; diff --git a/src/normal.c b/src/normal.c index 9b661d2..2b75240 100644 --- a/src/normal.c +++ b/src/normal.c @@ -535,15 +535,7 @@ static VbResult normal_input_open(const NormalCmdInfo *info) if (strchr("ot", info->cmd)) { vb_set_input_text(info->cmd == 't' ? ":tabopen " : ":open "); } else { - /* use vb_set_input_text because this is not restricted to BUF_SIZE - * wich could be to small for some uri */ - char *str = g_strconcat( - info->cmd == 'T' ? ":tabopen " : ":open ", - GET_URI(), - NULL - ); - vb_set_input_text(str); - g_free(str); + vb_echo(VB_MSG_NORMAL, false, ":%s %s", info->cmd == 'T' ? "open" : "tabopen", GET_URI()); } /* switch mode after setting the input text to not trigger the * commands modes input change handler */ -- 2.20.1