Removed string length restriction of vb_echo functions.
authorDaniel Carl <danielcarl@gmx.de>
Thu, 26 Sep 2013 23:22:44 +0000 (01:22 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Thu, 26 Sep 2013 23:22:44 +0000 (01:22 +0200)
src/main.c
src/normal.c

index 0c43e54..67b1aeb 100644 (file)
@@ -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;
index 9b661d2..2b75240 100644 (file)
@@ -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 */