From c1831cb19dc1a95bfe96c808aaf5ee42f7401995 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Mon, 8 Dec 2014 21:24:59 -0800 Subject: [PATCH] Minor tidying up --- src/common/cfgfiles.c | 4 +--- src/common/text.c | 15 ++++++--------- src/common/url.c | 12 ++++-------- src/fe-gtk/fe-gtk.c | 3 +-- src/fe-gtk/fkeys.c | 3 ++- src/fe-gtk/maingui.c | 2 +- src/fe-gtk/menu.c | 10 ++++------ src/fe-gtk/pixmaps.c | 3 +-- src/fe-gtk/plugingui.c | 4 +--- 9 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 020e3bc1..069ca70b 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -308,9 +308,7 @@ get_xdir (void) if (portable_mode () || SHGetKnownFolderPath (&FOLDERID_RoamingAppData, 0, NULL, &roaming_path_wide) != S_OK) { - char *path; - - path = g_win32_get_package_installation_directory_of_module (NULL); + char *path = g_win32_get_package_installation_directory_of_module (NULL); if (path) { xdir = g_build_filename (path, "config", NULL); diff --git a/src/common/text.c b/src/common/text.c index 6a6b65e7..5af98073 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -393,9 +393,7 @@ log_close (session *sess) static void mkdir_p (char *filename) { - char *dirname; - - dirname = g_path_get_dirname (filename); + char *dirname = g_path_get_dirname (filename); g_mkdir_with_parents (dirname, 0700); @@ -582,7 +580,7 @@ log_create_pathname (char *servname, char *channame, char *netname) /* create all the subdirectories */ mkdir_p (fname); - return g_strdup(fname); + return g_strdup (fname); } static int @@ -711,15 +709,13 @@ log_write (session *sess, char *text, time_t ts) log_open (sess); /* change to a different log file? */ - file = log_create_pathname (sess->server->servername, sess->channel, - server_get_network (sess->server, FALSE)); + file = log_create_pathname (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE)); if (file) { if (g_access (file, F_OK) != 0) { close (sess->logfd); - sess->logfd = log_open_file (sess->server->servername, sess->channel, - server_get_network (sess->server, FALSE)); + sess->logfd = log_open_file (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE)); } g_free (file); } @@ -905,7 +901,8 @@ PrintTextTimeStamp (session *sess, char *text, time_t timestamp) { text = "\n"; conv = NULL; - } else + } + else { int len = -1; conv = text_validate ((char **)&text, &len); diff --git a/src/common/url.c b/src/common/url.c index 5fbeb6c8..732449a4 100644 --- a/src/common/url.c +++ b/src/common/url.c @@ -587,18 +587,14 @@ re_url (void) if (uri[i].flags & URI_PATH) { - char *sep_escaped; - - sep_escaped = g_regex_escape_string (uri[i].path_sep, - strlen(uri[i].path_sep)); + char *sep_escaped = g_regex_escape_string (uri[i].path_sep, strlen(uri[i].path_sep)); - g_string_append_printf(grist_gstr, "(" "%s" PATH ")?", - sep_escaped); + g_string_append_printf (grist_gstr, "(" "%s" PATH ")?", sep_escaped); - g_free(sep_escaped); + g_free (sep_escaped); } - g_string_append(grist_gstr, ")"); + g_string_append (grist_gstr, ")"); } grist = g_string_free (grist_gstr, FALSE); diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 4b7d916f..962e9785 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -882,11 +882,10 @@ fe_confirm (const char *message, void (*yesproc)(void *), void (*noproc)(void *) { /* warning, assuming fe_confirm is used by DCC only! */ struct DCC *dcc = ud; - char *filepath; if (dcc->file) { - filepath = g_build_filename (prefs.hex_dcc_dir, dcc->file, NULL); + char *filepath = g_build_filename (prefs.hex_dcc_dir, dcc->file, NULL); gtkutil_file_req (message, dcc_saveas_cb, ud, filepath, NULL, FRF_WRITE|FRF_NOASKOVERWRITE|FRF_FILTERISINITIAL); g_free (filepath); diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c index b8391b9c..2f020311 100644 --- a/src/fe-gtk/fkeys.c +++ b/src/fe-gtk/fkeys.c @@ -596,7 +596,8 @@ key_dialog_save (GtkWidget *wid, gpointer userdata) else keybind_list = g_slist_append (keybind_list, kb); - } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter)); + } + while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter)); } if (key_save_kbs () == 0) diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index d8a538ed..a04f20dc 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -2287,7 +2287,7 @@ mg_word_clicked (GtkWidget *xtext, char *word, GdkEventButton *even) case WORD_EMAIL: word[end] = 0; word += start; - tmp = g_strdup_printf("mailto:%s", word + (ispunct (*word)? 1: 0)); + tmp = g_strdup_printf ("mailto:%s", word + (ispunct (*word) ? 1 : 0)); menu_urlmenu (even, tmp); g_free (tmp); break; diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 945f6360..63607bed 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -403,12 +403,11 @@ toggle_cb (GtkWidget *item, char *pref_name) static int is_in_path (char *cmd) { - char *prog = g_strdup (cmd + 1); /* 1st char is "!" */ - char *path, *orig; + char *orig = g_strdup (cmd + 1); /* 1st char is "!" */ + char *prog = orig; char **argv; int argc; - orig = prog; /* save for free()ing */ /* special-case these default entries. */ /* 123456789012345678 */ if (strncmp (prog, "gnome-terminal -x ", 18) == 0) @@ -417,15 +416,14 @@ is_in_path (char *cmd) if (g_shell_parse_argv (prog, &argc, &argv, NULL)) { - path = g_find_program_in_path (argv[0]); + char *path = g_find_program_in_path (argv[0]); + g_strfreev (argv); if (path) { g_free (path); g_free (orig); - g_strfreev (argv); return 1; } - g_strfreev (argv); } g_free (orig); diff --git a/src/fe-gtk/pixmaps.c b/src/fe-gtk/pixmaps.c index cbec6f71..053afaaf 100644 --- a/src/fe-gtk/pixmaps.c +++ b/src/fe-gtk/pixmaps.c @@ -87,10 +87,9 @@ pixmap_load_from_file (char *filename) static GdkPixbuf * load_pixmap (const char *filename) { - gchar *path; GdkPixbuf *pixbuf; - path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "icons" G_DIR_SEPARATOR_S "%s.png", get_xdir (), filename); + gchar *path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "icons" G_DIR_SEPARATOR_S "%s.png", get_xdir (), filename); pixbuf = gdk_pixbuf_new_from_file (path, 0); g_free (path); diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c index 9b3186a6..05d697f8 100644 --- a/src/fe-gtk/plugingui.c +++ b/src/fe-gtk/plugingui.c @@ -156,9 +156,7 @@ plugingui_load_cb (session *sess, char *file) void plugingui_load (void) { - char *sub_dir; - - sub_dir = g_build_filename (get_xdir(), "addons", NULL); + char *sub_dir = g_build_filename (get_xdir(), "addons", NULL); gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb, current_sess, sub_dir, "*."G_MODULE_SUFFIX";*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS);