[gnome-software: 2/3] gs-utils: Remove unused gs_utils_parse_evr
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 2/3] gs-utils: Remove unused gs_utils_parse_evr
- Date: Thu, 2 Dec 2021 10:12:25 +0000 (UTC)
commit dfea11da302f745e0e8508c54394964f4028ae21
Author: Pablo Correa Gómez <ablocorrea hotmail com>
Date: Wed Dec 1 18:22:48 2021 +0100
gs-utils: Remove unused gs_utils_parse_evr
lib/gs-self-test.c | 73 ------------------------------------------------------
lib/gs-utils.c | 63 ----------------------------------------------
2 files changed, 136 deletions(-)
---
diff --git a/lib/gs-self-test.c b/lib/gs-self-test.c
index ee4da9ed8..9a75d5b12 100644
--- a/lib/gs-self-test.c
+++ b/lib/gs-self-test.c
@@ -169,78 +169,6 @@ gs_utils_error_func (void)
g_assert_cmpstr (error->message, ==, "failed");
}
-static void
-gs_utils_parse_evr_func (void)
-{
- gboolean ret;
-
- {
- g_autofree gchar *epoch = NULL;
- g_autofree gchar *version = NULL;
- g_autofree gchar *release = NULL;
-
- ret = gs_utils_parse_evr ("3.26.0-1.fc27", &epoch, &version, &release);
- g_assert (ret);
- g_assert_cmpstr (epoch, ==, "0");
- g_assert_cmpstr (version, ==, "3.26.0");
- g_assert_cmpstr (release, ==, "1.fc27");
- }
-
- {
- g_autofree gchar *epoch = NULL;
- g_autofree gchar *version = NULL;
- g_autofree gchar *release = NULL;
-
- ret = gs_utils_parse_evr ("1:3.26.0-1.fc27", &epoch, &version, &release);
- g_assert (ret);
- g_assert_cmpstr (epoch, ==, "1");
- g_assert_cmpstr (version, ==, "3.26.0");
- g_assert_cmpstr (release, ==, "1.fc27");
- }
-
- {
- g_autofree gchar *epoch = NULL;
- g_autofree gchar *version = NULL;
- g_autofree gchar *release = NULL;
-
- ret = gs_utils_parse_evr ("234", &epoch, &version, &release);
- g_assert (ret);
- g_assert_cmpstr (epoch, ==, "0");
- g_assert_cmpstr (version, ==, "234");
- g_assert_cmpstr (release, ==, "0");
- }
-
- {
- g_autofree gchar *epoch = NULL;
- g_autofree gchar *version = NULL;
- g_autofree gchar *release = NULL;
-
- ret = gs_utils_parse_evr ("3:1.6~git20131207+dfsg-2ubuntu1~14.04.3", &epoch, &version,
&release);
- g_assert (ret);
- g_assert_cmpstr (epoch, ==, "3");
- g_assert_cmpstr (version, ==, "1.6~git20131207+dfsg");
- g_assert_cmpstr (release, ==, "2ubuntu1~14.04.3");
- }
-
- {
- g_autofree gchar *epoch = NULL;
- g_autofree gchar *version = NULL;
- g_autofree gchar *release = NULL;
-
- ret = gs_utils_parse_evr ("1-2-3-4-5-6", &epoch, &version, &release);
- g_assert (!ret);
- }
-
- {
- g_autofree gchar *epoch = NULL;
- g_autofree gchar *version = NULL;
- g_autofree gchar *release = NULL;
-
- ret = gs_utils_parse_evr ("", &epoch, &version, &release);
- g_assert (!ret);
- }
-}
-
static void
gs_plugin_download_rewrite_func (void)
{
@@ -827,7 +755,6 @@ main (int argc, char **argv)
g_test_add_func ("/gnome-software/lib/utils{error}", gs_utils_error_func);
g_test_add_func ("/gnome-software/lib/utils{cache}", gs_utils_cache_func);
g_test_add_func ("/gnome-software/lib/utils{append-kv}", gs_utils_append_kv_func);
- g_test_add_func ("/gnome-software/lib/utils{parse-evr}", gs_utils_parse_evr_func);
g_test_add_func ("/gnome-software/lib/os-release", gs_os_release_func);
g_test_add_func ("/gnome-software/lib/app", gs_app_func);
g_test_add_func ("/gnome-software/lib/app/progress-clamping", gs_app_progress_clamping_func);
diff --git a/lib/gs-utils.c b/lib/gs-utils.c
index b88da279b..c3cf2e2cc 100644
--- a/lib/gs-utils.c
+++ b/lib/gs-utils.c
@@ -1126,69 +1126,6 @@ gs_utils_get_memory_total (void)
#endif
}
-/**
- * gs_utils_parse_evr:
- * @evr: an EVR version string
- * @out_epoch: (out): return location for the epoch string
- * @out_version: (out): return location for the version string
- * @out_release: (out): return location for the release string
- *
- * Splits EVR into epoch-version-release strings.
- *
- * Returns: %TRUE for success
- **/
-gboolean
-gs_utils_parse_evr (const gchar *evr,
- gchar **out_epoch,
- gchar **out_version,
- gchar **out_release)
-{
- const gchar *version_release;
- g_auto(GStrv) split_colon = NULL;
- g_auto(GStrv) split_dash = NULL;
-
- /* split on : to get epoch */
- split_colon = g_strsplit (evr, ":", -1);
- switch (g_strv_length (split_colon)) {
- case 1:
- /* epoch is 0 when not set */
- *out_epoch = g_strdup ("0");
- version_release = split_colon[0];
- break;
- case 2:
- /* epoch set */
- *out_epoch = g_strdup (split_colon[0]);
- version_release = split_colon[1];
- break;
- default:
- /* error */
- return FALSE;
- }
-
- /* split on - to get version and release */
- split_dash = g_strsplit (version_release, "-", -1);
- switch (g_strv_length (split_dash)) {
- case 1:
- /* all of the string is version */
- *out_version = g_strdup (split_dash[0]);
- *out_release = g_strdup ("0");
- break;
- case 2:
- /* both version and release set */
- *out_version = g_strdup (split_dash[0]);
- *out_release = g_strdup (split_dash[1]);
- break;
- default:
- /* error */
- return FALSE;
- }
-
- g_assert (*out_epoch != NULL);
- g_assert (*out_version != NULL);
- g_assert (*out_release != NULL);
- return TRUE;
-}
-
/**
* gs_utils_set_online_updates_timestamp:
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]