If possible use g_strconcat instead of g_strdup_printf.
authorDaniel Carl <danielcarl@gmx.de>
Thu, 26 Sep 2013 23:08:21 +0000 (01:08 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Thu, 26 Sep 2013 23:08:21 +0000 (01:08 +0200)
src/completion.c
src/hints.c
src/main.c
src/setting.c

index d3e10df..b8ef9bf 100644 (file)
@@ -273,7 +273,7 @@ static gboolean tree_selection_func(GtkTreeSelection *selection,
         if (comp.count) {
             comp.text = g_strdup_printf("%s%d%s", comp.prefix, comp.count, value);
         } else {
-            comp.text = g_strdup_printf("%s%s", comp.prefix, value);
+            comp.text = g_strconcat(comp.prefix, value, NULL);
         }
         /* print the text also into inputbox */
         vb_set_input_text(comp.text);
index 7831e38..d49c687 100644 (file)
@@ -95,7 +95,7 @@ void hints_clear(void)
     if (vb.mode->flags & FLAG_HINTING) {
         vb.mode->flags &= ~FLAG_HINTING;
         vb_set_input_text("");
-        js = g_strdup_printf("%s.clear();", HINT_VAR);
+        js = g_strconcat(HINT_VAR, ".clear();", NULL);
         vb_eval_script(webkit_web_view_get_main_frame(vb.gui.webview), js, HINT_FILE, &value);
         g_free(value);
         g_free(js);
@@ -145,7 +145,7 @@ void hints_focus_next(const gboolean back)
 
 void hints_fire(void)
 {
-    char *js = g_strdup_printf("%s.fire();", HINT_VAR);
+    char *js = g_strconcat(HINT_VAR, ".fire();", NULL);
     run_script(js);
     g_free(js);
 }
index a4a5baa..0c43e54 100644 (file)
@@ -159,12 +159,12 @@ gboolean vb_load_uri(const Arg *arg)
         path = vb.config.home_page;
     }
 
-    if (g_strrstr(path, "://") || !strncmp(path, "about:", 6)) {
+    if (strstr(path, "://") || !strncmp(path, "about:", 6)) {
         uri = g_strdup(path);
     } else if (stat(path, &st) == 0) {
         /* check if the path is a file path */
         rp  = realpath(path, NULL);
-        uri = g_strdup_printf("file://%s", rp);
+        uri = g_strconcat("file://", rp, NULL);
         free(rp);
     } else if (strchr(path, ' ') || !strchr(path, '.')) {
         /* use a shortcut if path contains spaces or no dot */
@@ -172,7 +172,7 @@ gboolean vb_load_uri(const Arg *arg)
     }
 
     if (!uri) {
-        uri = g_strdup_printf("http://%s", path);
+        uri = g_strconcat("http://", path, NULL);
     }
 
     if (arg->i == VB_TARGET_NEW) {
@@ -874,7 +874,7 @@ static void hover_link_cb(WebKitWebView *webview, const char *title, const char
 {
     char *message;
     if (link) {
-        message = g_strdup_printf("Link: %s", link);
+        message = g_strconcat("Link: ", link, NULL);
         gtk_label_set_text(GTK_LABEL(vb.gui.statusbar.left), message);
         g_free(message);
     } else {
index 46834bd..cfe8d63 100644 (file)
@@ -624,9 +624,9 @@ static gboolean proxy(const Setting *s, const SettingType type)
     if (enabled) {
         proxy = (char *)g_getenv("http_proxy");
         if (proxy != NULL && strlen(proxy)) {
-            proxy_new = g_strrstr(proxy, "http://")
+            proxy_new = g_str_has_prefix(proxy, "http://")
                 ? g_strdup(proxy)
-                : g_strdup_printf("http://%s", proxy);
+                : g_strconcat("http://", proxy, NULL);
             proxy_uri = soup_uri_new(proxy_new);
 
             g_object_set(vb.session, "proxy-uri", proxy_uri, NULL);