From 68354eb3b11c149c54099e5522808330694a9327 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Fri, 27 Sep 2013 01:08:21 +0200 Subject: [PATCH] If possible use g_strconcat instead of g_strdup_printf. --- src/completion.c | 2 +- src/hints.c | 4 ++-- src/main.c | 8 ++++---- src/setting.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/completion.c b/src/completion.c index d3e10df..b8ef9bf 100644 --- a/src/completion.c +++ b/src/completion.c @@ -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); diff --git a/src/hints.c b/src/hints.c index 7831e38..d49c687 100644 --- a/src/hints.c +++ b/src/hints.c @@ -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); } diff --git a/src/main.c b/src/main.c index a4a5baa..0c43e54 100644 --- a/src/main.c +++ b/src/main.c @@ -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 { diff --git a/src/setting.c b/src/setting.c index 46834bd..cfe8d63 100644 --- a/src/setting.c +++ b/src/setting.c @@ -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); -- 2.20.1