Branch: refs/heads/master Author: Matthew Brush matt@geany.org Committer: Matthew Brush matt@geany.org Date: Fri, 10 Aug 2012 01:21:43 Commit: e62bec43fcf31451242ea1b8c6107bebab7f9f8b https://github.com/geany/geany/commit/e62bec43fcf31451242ea1b8c6107bebab7f9f...
Log Message: ----------- Use `g_build_filename()` instead of `g_strconcat()` for paths
Modified Paths: -------------- src/editor.c src/filetypes.c src/keybindings.c src/keyfile.c src/main.c src/msgwindow.c src/plugins.c src/project.c src/symbols.c
Modified: src/editor.c 7 files changed, 3 insertions(+), 4 deletions(-) =================================================================== @@ -266,13 +266,12 @@ void editor_snippets_init(void)
snippet_offsets = g_queue_new();
- sysconfigfile = g_strconcat(app->datadir, G_DIR_SEPARATOR_S, "snippets.conf", NULL); - userconfigfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "snippets.conf", NULL); + sysconfigfile = g_build_filename(app->datadir, "snippets.conf", NULL); + userconfigfile = g_build_filename(app->configdir, "snippets.conf", NULL);
/* check for old autocomplete.conf files (backwards compatibility) */ if (! g_file_test(userconfigfile, G_FILE_TEST_IS_REGULAR)) - SETPTR(userconfigfile, - g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "autocomplete.conf", NULL)); + SETPTR(userconfigfile, g_build_filename(app->configdir, "autocomplete.conf", NULL));
/* load the actual config files */ g_key_file_load_from_file(sysconfig, sysconfigfile, G_KEY_FILE_NONE, NULL);
Modified: src/filetypes.c 18 files changed, 9 insertions(+), 9 deletions(-) =================================================================== @@ -1270,16 +1270,18 @@ static void add_keys(GKeyFile *dest, const gchar *group, GKeyFile *src) static gchar *filetypes_get_filename(GeanyFiletype *ft, gboolean user) { gchar *ext = filetypes_get_conf_extension(ft); - gchar *f; + gchar *base_name = g_strconcat("filetypes.", ext, NULL); + gchar *file_name;
if (user) - f = g_strconcat(app->configdir, G_DIR_SEPARATOR_S - GEANY_FILEDEFS_SUBDIR G_DIR_SEPARATOR_S, "filetypes.", ext, NULL); + file_name = g_build_filename(app->configdir, GEANY_FILEDEFS_SUBDIR, base_name, NULL); else - f = g_strconcat(app->datadir, G_DIR_SEPARATOR_S "filetypes.", ext, NULL); + file_name = g_build_filename(app->datadir, base_name, NULL);
g_free(ext); - return f; + g_free(base_name); + + return file_name; }
@@ -1688,10 +1690,8 @@ static void read_groups(GKeyFile *config)
static void read_filetype_config(void) { - gchar *sysconfigfile = g_strconcat(app->datadir, G_DIR_SEPARATOR_S, - "filetype_extensions.conf", NULL); - gchar *userconfigfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, - "filetype_extensions.conf", NULL); + gchar *sysconfigfile = g_build_filename(app->datadir, "filetype_extensions.conf", NULL); + gchar *userconfigfile = g_build_filename(app->configdir, "filetype_extensions.conf", NULL); GKeyFile *sysconfig = g_key_file_new(); GKeyFile *userconfig = g_key_file_new();
Modified: src/keybindings.c 6 files changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -662,13 +662,13 @@ static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_dat
static void load_user_kb(void) { - gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "keybindings.conf", NULL); + gchar *configfile = g_build_filename(app->configdir, "keybindings.conf", NULL); GKeyFile *config = g_key_file_new();
/* backwards compatibility with Geany 0.21 defaults */ if (!g_file_test(configfile, G_FILE_TEST_EXISTS)) { - gchar *geanyconf = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL); + gchar *geanyconf = g_build_filename(app->configdir, "geany.conf", NULL); const gchar data[] = "[Bindings]\n" "popup_gototagdefinition=\n" "edit_transposeline=<Control>t\n" @@ -771,7 +771,7 @@ static void set_keyfile_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer u /* just write the content of the keys array to the config file */ void keybindings_write_to_file(void) { - gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "keybindings.conf", NULL); + gchar *configfile = g_build_filename(app->configdir, "keybindings.conf", NULL); gchar *data; GKeyFile *config = g_key_file_new();
Modified: src/keyfile.c 4 files changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -576,7 +576,7 @@ static void save_ui_prefs(GKeyFile *config) void configuration_save(void) { GKeyFile *config = g_key_file_new(); - gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL); + gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL); gchar *data;
g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); @@ -984,7 +984,7 @@ static void load_ui_prefs(GKeyFile *config) */ void configuration_save_default_session(void) { - gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL); + gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL); gchar *data; GKeyFile *config = g_key_file_new();
Modified: src/main.c 10 files changed, 5 insertions(+), 5 deletions(-) =================================================================== @@ -375,13 +375,13 @@ static void setup_paths(void) * documentation and data files */ gchar *install_dir = win32_get_installation_dir();
- data_dir = g_strconcat(install_dir, "\data", NULL); /* e.g. C:\Program Files\geany\data */ - doc_dir = g_strconcat(install_dir, "\doc", NULL); + data_dir = g_build_filename(install_dir, "data", NULL); /* e.g. C:\Program Files\geany\data */ + doc_dir = g_build_filename(install_dir, "doc", NULL);
g_free(install_dir); #else - data_dir = g_strconcat(GEANY_DATADIR, "/geany", NULL); /* e.g. /usr/share/geany */ - doc_dir = g_strconcat(GEANY_DOCDIR, "/html", NULL); + data_dir = g_build_filename(GEANY_DATADIR, "geany", NULL); /* e.g. /usr/share/geany */ + doc_dir = g_build_filename(GEANY_DOCDIR, "html", NULL); #endif
/* convert path names to locale encoding */ @@ -449,7 +449,7 @@ void main_locale_init(const gchar *locale_dir, const gchar *package) { gchar *install_dir = win32_get_installation_dir(); /* e.g. C:\Program Files\geany\lib\locale */ - l_locale_dir = g_strconcat(install_dir, "\share\locale", NULL); + l_locale_dir = g_build_filename(install_dir, "share", "locale", NULL); g_free(install_dir); } #else
Modified: src/msgwindow.c 3 files changed, 1 insertions(+), 2 deletions(-) =================================================================== @@ -744,8 +744,7 @@ static void make_absolute(gchar **filename, const gchar *dir)
/* add directory */ if (! utils_is_absolute_path(*filename)) - SETPTR(*filename, g_strconcat(dir, G_DIR_SEPARATOR_S, - *filename + skip_dot_slash, NULL)); + SETPTR(*filename, g_build_filename(dir, *filename + skip_dot_slash, NULL)); }
Modified: src/plugins.c 10 files changed, 5 insertions(+), 5 deletions(-) =================================================================== @@ -883,7 +883,7 @@ static gboolean check_plugin_path(const gchar *fname) gchar *plugin_path_custom; gboolean ret = FALSE;
- plugin_path_config = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", NULL); + plugin_path_config = g_build_filename(app->configdir, "plugins", NULL); if (g_str_has_prefix(fname, plugin_path_config)) ret = TRUE;
@@ -942,7 +942,7 @@ static gboolean check_plugin_path(const gchar *fname) if (tmp == NULL || utils_str_casecmp(tmp, "." G_MODULE_SUFFIX) != 0) continue;
- fname = g_strconcat(path, G_DIR_SEPARATOR_S, item->data, NULL); + fname = g_build_filename(path, item->data, NULL); if (plugin_new(fname, FALSE, TRUE)) count++; g_free(fname); @@ -962,12 +962,12 @@ static gchar *get_plugin_path(void) gchar *path; gchar *install_dir = win32_get_installation_dir();
- path = g_strconcat(install_dir, "\lib", NULL); + path = g_build_filename(install_dir, "lib", NULL); g_free(install_dir);
return path; #else - return g_strconcat(GEANY_LIBDIR, G_DIR_SEPARATOR_S "geany", NULL); + return g_build_filename(GEANY_LIBDIR, "geany", NULL); #endif }
@@ -979,7 +979,7 @@ static void load_all_plugins(void) gchar *plugin_path_system; gchar *plugin_path_custom;
- plugin_path_config = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", NULL); + plugin_path_config = g_build_filename(app->configdir, "plugins", NULL); plugin_path_system = get_plugin_path();
/* first load plugins in ~/.config/geany/plugins/ */
Modified: src/project.c 9 files changed, 4 insertions(+), 5 deletions(-) =================================================================== @@ -675,7 +675,7 @@ static gboolean update_config(const PropertyDialogElements *e, gboolean new_proj if (! g_path_is_absolute(locale_path)) { /* relative base path, so add base dir of project file name */ gchar *dir = g_path_get_dirname(locale_filename); - SETPTR(locale_path, g_strconcat(dir, G_DIR_SEPARATOR_S, locale_path, NULL)); + SETPTR(locale_path, g_strconcat(dir, locale_path, NULL)); g_free(dir); }
@@ -1097,8 +1097,8 @@ gchar *project_get_base_path(void)
if (utils_str_equal(project->base_path, "./")) return dir; - else - path = g_strconcat(dir, G_DIR_SEPARATOR_S, project->base_path, NULL); + + path = g_build_filename(dir, project->base_path, NULL); g_free(dir); return path; } @@ -1135,8 +1135,7 @@ void project_load_prefs(GKeyFile *config) "project_file_path", NULL); if (local_prefs.project_file_path == NULL) { - local_prefs.project_file_path = g_strconcat(g_get_home_dir(), - G_DIR_SEPARATOR_S, PROJECT_DIR, NULL); + local_prefs.project_file_path = g_build_filename(g_get_home_dir(), PROJECT_DIR, NULL); } }
Modified: src/symbols.c 8 files changed, 4 insertions(+), 4 deletions(-) =================================================================== @@ -114,7 +114,7 @@ enum /* Geany tag files */ * Also works for reloading. */ static void load_c_ignore_tags(void) { - gchar *path = g_strconcat(app->configdir, G_DIR_SEPARATOR_S "ignore.tags", NULL); + gchar *path = g_build_filename(app->configdir, "ignore.tags", NULL); gchar *content;
if (g_file_get_contents(path, &content, NULL, NULL)) @@ -209,7 +209,7 @@ void symbols_global_tags_loaded(guint file_type_idx)
if (! tfi->tags_loaded) { - gchar *fname = g_strconcat(app->datadir, G_DIR_SEPARATOR_S, tfi->tag_file, NULL); + gchar *fname = g_build_filename(app->datadir, tfi->tag_file, NULL);
symbols_load_global_tags(fname, filetypes[file_type_idx]); tfi->tags_loaded = TRUE; @@ -229,7 +229,7 @@ static void html_tags_loaded(void) tfi = &tag_file_info[GTF_HTML_ENTITIES]; if (! tfi->tags_loaded) { - gchar *file = g_strconcat(app->datadir, G_DIR_SEPARATOR_S, tfi->tag_file, NULL); + gchar *file = g_build_filename(app->datadir, tfi->tag_file, NULL);
html_entities = utils_read_file_in_array(file); tfi->tags_loaded = TRUE; @@ -548,7 +548,7 @@ static GdkPixbuf *get_tag_icon(const gchar *icon_name) if (G_UNLIKELY(icon_theme == NULL)) { #ifndef G_OS_WIN32 - gchar *path = g_strconcat(GEANY_DATADIR, "/icons", NULL); + gchar *path = g_build_filename(GEANY_DATADIR, "icons", NULL); #endif gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &x, &y); icon_theme = gtk_icon_theme_get_default();
@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).