--- a/gplugin/gplugin-manager.c Wed Aug 26 03:12:40 2020 -0500
+++ b/gplugin/gplugin-manager.c Sat Aug 29 03:48:20 2020 -0500
@@ -254,6 +254,33 @@
+gplugin_manager_normalize_path(const gchar *path) + if(g_str_has_suffix(path, G_DIR_SEPARATOR_S)) { + return g_strdup_printf("%s%s", path, G_DIR_SEPARATOR_S); +gplugin_manager_compare_paths(gconstpointer a, gconstpointer b) + gchar *keya = NULL, *keyb = NULL; + keya = g_utf8_collate_key_for_filename((const gchar *)a, -1); + keyb = g_utf8_collate_key_for_filename((const gchar *)b, -1); + r = strcmp(keya, keyb); /******************************************************************************
*****************************************************************************/
@@ -261,53 +288,74 @@
gplugin_manager_real_append_path(GPluginManager *manager, const gchar *path)
+ gchar *normalized = NULL;
+ normalized = gplugin_manager_normalize_path(path); - for(l = manager->paths->head; l; l = l->next)
- if(strcmp(l->data, path) == 0)
- g_queue_push_tail(manager->paths, g_strdup(path));
+ l = g_queue_find_custom( + gplugin_manager_compare_paths); + g_queue_push_tail(manager->paths, normalized); gplugin_manager_real_prepend_path(GPluginManager *manager, const gchar *path)
+ gchar *normalized = NULL;
+ normalized = gplugin_manager_normalize_path(path); - for(l = manager->paths->head; l; l = l->next)
- if(strcmp(l->data, path) == 0)
- g_queue_push_head(manager->paths, g_strdup(path));
+ l = g_queue_find_custom( + gplugin_manager_compare_paths); + g_queue_push_head(manager->paths, normalized); gplugin_manager_real_remove_path(GPluginManager *manager, const gchar *path)
- GList *l = NULL, *link = NULL;
+ gchar *normalized = NULL; g_return_if_fail(path != NULL);
- for(l = manager->paths->head; l; l = l->next)
- if(strcmp(l->data, path) == 0) {
+ normalized = gplugin_manager_normalize_path(path);
- g_queue_delete_link(manager->paths, link);
+ l = g_queue_find_custom( + gplugin_manager_compare_paths); + g_queue_delete_link(manager->paths, l); gplugin_manager_real_remove_paths(GPluginManager *manager)
- g_queue_clear(manager->paths);
+ g_queue_clear_full(manager->paths, g_free); --- a/gplugin/tests/test-option-group.c Wed Aug 26 03:12:40 2020 -0500
+++ b/gplugin/tests/test-option-group.c Sat Aug 29 03:48:20 2020 -0500
@@ -1,5 +1,5 @@
- * Copyright (C) 2011-2014 Gary Kramlich <grim@reaperworld.com>
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -69,10 +69,14 @@
- path = g_build_filename(PREFIX, LIBDIR, "gplugin", NULL);
+ path = g_build_filename(PREFIX, LIBDIR, "gplugin", G_DIR_SEPARATOR_S, NULL); paths = g_list_prepend(paths, path);
- path = g_build_filename(g_get_user_config_dir(), "gplugin", NULL);
+ path = g_build_filename( + g_get_user_config_dir(), paths = g_list_prepend(paths, path);
@@ -96,7 +100,7 @@
gchar *args = "test-option-group,-p,foo";
expected = test_gplugin_manager_default_paths();
- expected = g_list_prepend(expected, g_strdup("foo"));
+ expected = g_list_prepend(expected, g_strdup("foo/")); test_gplugin_option_group_paths(args, expected);
@@ -108,9 +112,9 @@
gchar *args = "test-option-group,-p,foo,-p,bar,-p,baz";
expected = test_gplugin_manager_default_paths();
- expected = g_list_prepend(expected, g_strdup("foo"));
- expected = g_list_prepend(expected, g_strdup("bar"));
- expected = g_list_prepend(expected, g_strdup("baz"));
+ expected = g_list_prepend(expected, g_strdup("foo/")); + expected = g_list_prepend(expected, g_strdup("bar/")); + expected = g_list_prepend(expected, g_strdup("baz/")); test_gplugin_option_group_paths(args, expected);
@@ -137,7 +141,7 @@
gchar *args = "test-option-group,-D,-p,foo";
- expected = g_list_prepend(expected, g_strdup("foo"));
+ expected = g_list_prepend(expected, g_strdup("foo/")); test_gplugin_option_group_paths(args, expected);
@@ -148,9 +152,9 @@
gchar *args = "test-option-group,-D,-p,foo,-p,bar,-p,baz";
- expected = g_list_prepend(expected, g_strdup("foo"));
- expected = g_list_prepend(expected, g_strdup("bar"));
- expected = g_list_prepend(expected, g_strdup("baz"));
+ expected = g_list_prepend(expected, g_strdup("foo/")); + expected = g_list_prepend(expected, g_strdup("bar/")); + expected = g_list_prepend(expected, g_strdup("baz/")); test_gplugin_option_group_paths(args, expected);
@@ -158,7 +162,7 @@
test_gplugin_option_group_add_path_short(void)
- GList *expected = g_list_prepend(NULL, g_strdup("foo"));
+ GList *expected = g_list_prepend(NULL, g_strdup("foo/")); gchar *args = "test-option-group,-D,-p,foo";
test_gplugin_option_group_paths(args, expected);
@@ -167,7 +171,7 @@
test_gplugin_option_group_add_path_long(void)
- GList *expected = g_list_prepend(NULL, g_strdup("foo"));
+ GList *expected = g_list_prepend(NULL, g_strdup("foo/")); gchar *args = "test-option-group,-D,--path,foo";
test_gplugin_option_group_paths(args, expected);
--- a/gplugin/tests/test-plugin-manager-paths.c Wed Aug 26 03:12:40 2020 -0500
+++ b/gplugin/tests/test-plugin-manager-paths.c Sat Aug 29 03:48:20 2020 -0500
@@ -89,6 +89,42 @@
+test_gplugin_manager_paths_unicode(void) + gplugin_manager_append_path("/home/🐦/.plugins"); + gplugin_manager_append_path("/home/user/.plugins"); + gplugin_manager_remove_path("/home/🐦/.plugins"); + gplugin_manager_remove_path("/home/user/.plugins"); +test_gplugin_manager_add_multiple_mixed_trailing_slashes(void) + gplugin_manager_append_path("/home/user1/.plugins"); + gplugin_manager_append_path("/home/user2/.plugins/"); + gplugin_manager_remove_path("/home/user1/.plugins/"); + gplugin_manager_remove_path("/home/user2/.plugins"); test_gplugin_manager_add_default_paths(void)
@@ -100,10 +136,14 @@
req = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
/* create and add the paths we are expecting to the table */
- path = g_build_filename(PREFIX, LIBDIR, "gplugin", NULL);
+ path = g_build_filename(PREFIX, LIBDIR, "gplugin", G_DIR_SEPARATOR_S, NULL); g_hash_table_insert(req, path, GINT_TO_POINTER(FALSE));
- path = g_build_filename(g_get_user_config_dir(), "gplugin", NULL);
+ path = g_build_filename( + g_get_user_config_dir(), g_hash_table_insert(req, path, GINT_TO_POINTER(FALSE));
/* now tell the plugin manager to add the default paths */
@@ -135,10 +175,15 @@
/* build our table of required paths */
req = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
- path = g_build_filename(prefix, LIBDIR, appname, NULL);
+ path = g_build_filename(prefix, LIBDIR, appname, G_DIR_SEPARATOR_S, NULL); g_hash_table_insert(req, path, GINT_TO_POINTER(FALSE));
- path = g_build_filename(g_get_user_config_dir(), appname, "plugins", NULL);
+ path = g_build_filename( + g_get_user_config_dir(), g_hash_table_insert(req, path, GINT_TO_POINTER(FALSE));
/* now add the app paths */
@@ -186,6 +231,14 @@
test_gplugin_manager_paths_multiple_filo);
+ "/plugins/paths/add_multiple_unicode", + test_gplugin_manager_paths_unicode); + "/plugins/paths/add_multiple_mixed_trailing_slashes", + test_gplugin_manager_add_multiple_mixed_trailing_slashes); "/plugins/paths/add_default_paths",
test_gplugin_manager_add_default_paths);