Minor tidying up

This commit is contained in:
Arnavion 2014-12-08 21:24:59 -08:00
parent 65da34f19e
commit c1831cb19d
9 changed files with 21 additions and 35 deletions

View File

@ -308,9 +308,7 @@ get_xdir (void)
if (portable_mode () || SHGetKnownFolderPath (&FOLDERID_RoamingAppData, 0, NULL, &roaming_path_wide) != S_OK) if (portable_mode () || SHGetKnownFolderPath (&FOLDERID_RoamingAppData, 0, NULL, &roaming_path_wide) != S_OK)
{ {
char *path; char *path = g_win32_get_package_installation_directory_of_module (NULL);
path = g_win32_get_package_installation_directory_of_module (NULL);
if (path) if (path)
{ {
xdir = g_build_filename (path, "config", NULL); xdir = g_build_filename (path, "config", NULL);

View File

@ -393,9 +393,7 @@ log_close (session *sess)
static void static void
mkdir_p (char *filename) mkdir_p (char *filename)
{ {
char *dirname; char *dirname = g_path_get_dirname (filename);
dirname = g_path_get_dirname (filename);
g_mkdir_with_parents (dirname, 0700); g_mkdir_with_parents (dirname, 0700);
@ -711,15 +709,13 @@ log_write (session *sess, char *text, time_t ts)
log_open (sess); log_open (sess);
/* change to a different log file? */ /* change to a different log file? */
file = log_create_pathname (sess->server->servername, sess->channel, file = log_create_pathname (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE));
server_get_network (sess->server, FALSE));
if (file) if (file)
{ {
if (g_access (file, F_OK) != 0) if (g_access (file, F_OK) != 0)
{ {
close (sess->logfd); close (sess->logfd);
sess->logfd = log_open_file (sess->server->servername, sess->channel, sess->logfd = log_open_file (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE));
server_get_network (sess->server, FALSE));
} }
g_free (file); g_free (file);
} }
@ -905,7 +901,8 @@ PrintTextTimeStamp (session *sess, char *text, time_t timestamp)
{ {
text = "\n"; text = "\n";
conv = NULL; conv = NULL;
} else }
else
{ {
int len = -1; int len = -1;
conv = text_validate ((char **)&text, &len); conv = text_validate ((char **)&text, &len);

View File

@ -587,13 +587,9 @@ re_url (void)
if (uri[i].flags & URI_PATH) if (uri[i].flags & URI_PATH)
{ {
char *sep_escaped; char *sep_escaped = g_regex_escape_string (uri[i].path_sep, strlen(uri[i].path_sep));
sep_escaped = g_regex_escape_string (uri[i].path_sep, g_string_append_printf (grist_gstr, "(" "%s" PATH ")?", sep_escaped);
strlen(uri[i].path_sep));
g_string_append_printf(grist_gstr, "(" "%s" PATH ")?",
sep_escaped);
g_free (sep_escaped); g_free (sep_escaped);
} }

View File

@ -882,11 +882,10 @@ fe_confirm (const char *message, void (*yesproc)(void *), void (*noproc)(void *)
{ {
/* warning, assuming fe_confirm is used by DCC only! */ /* warning, assuming fe_confirm is used by DCC only! */
struct DCC *dcc = ud; struct DCC *dcc = ud;
char *filepath;
if (dcc->file) 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, gtkutil_file_req (message, dcc_saveas_cb, ud, filepath, NULL,
FRF_WRITE|FRF_NOASKOVERWRITE|FRF_FILTERISINITIAL); FRF_WRITE|FRF_NOASKOVERWRITE|FRF_FILTERISINITIAL);
g_free (filepath); g_free (filepath);

View File

@ -596,7 +596,8 @@ key_dialog_save (GtkWidget *wid, gpointer userdata)
else else
keybind_list = g_slist_append (keybind_list, kb); 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) if (key_save_kbs () == 0)

View File

@ -403,12 +403,11 @@ toggle_cb (GtkWidget *item, char *pref_name)
static int static int
is_in_path (char *cmd) is_in_path (char *cmd)
{ {
char *prog = g_strdup (cmd + 1); /* 1st char is "!" */ char *orig = g_strdup (cmd + 1); /* 1st char is "!" */
char *path, *orig; char *prog = orig;
char **argv; char **argv;
int argc; int argc;
orig = prog; /* save for free()ing */
/* special-case these default entries. */ /* special-case these default entries. */
/* 123456789012345678 */ /* 123456789012345678 */
if (strncmp (prog, "gnome-terminal -x ", 18) == 0) 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)) 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) if (path)
{ {
g_free (path); g_free (path);
g_free (orig); g_free (orig);
g_strfreev (argv);
return 1; return 1;
} }
g_strfreev (argv);
} }
g_free (orig); g_free (orig);

View File

@ -87,10 +87,9 @@ pixmap_load_from_file (char *filename)
static GdkPixbuf * static GdkPixbuf *
load_pixmap (const char *filename) load_pixmap (const char *filename)
{ {
gchar *path;
GdkPixbuf *pixbuf; 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); pixbuf = gdk_pixbuf_new_from_file (path, 0);
g_free (path); g_free (path);

View File

@ -156,9 +156,7 @@ plugingui_load_cb (session *sess, char *file)
void void
plugingui_load (void) plugingui_load (void)
{ {
char *sub_dir; char *sub_dir = g_build_filename (get_xdir(), "addons", NULL);
sub_dir = g_build_filename (get_xdir(), "addons", NULL);
gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb, current_sess, 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); sub_dir, "*."G_MODULE_SUFFIX";*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS);