xdg-desktop-portal/SOURCES/0001-Don-t-use-g_strv_equals.patch
2021-09-10 05:57:10 +00:00

119 lines
3.5 KiB
Diff

From 72fa3eca32d764f35b46642337c46ecc9b851177 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Mon, 25 May 2020 21:31:07 +0200
Subject: [PATCH] Don't use g_strv_equals
---
tests/backend/email.c | 25 ++++++++++++++++++++++---
tests/filechooser.c | 23 +++++++++++++++++++++--
2 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/tests/backend/email.c b/tests/backend/email.c
index 7d8844f..bab4ac6 100644
--- a/tests/backend/email.c
+++ b/tests/backend/email.c
@@ -31,6 +31,25 @@ email_handle_free (EmailHandle *handle)
g_free (handle);
}
+static gboolean
+strv_equal (const gchar * const *strv1,
+ const gchar * const *strv2)
+{
+ g_return_val_if_fail (strv1 != NULL, FALSE);
+ g_return_val_if_fail (strv2 != NULL, FALSE);
+
+ if (strv1 == strv2)
+ return TRUE;
+
+ for (; *strv1 != NULL && *strv2 != NULL; strv1++, strv2++)
+ {
+ if (!g_str_equal (*strv1, *strv2))
+ return FALSE;
+ }
+
+ return (*strv1 == NULL && *strv2 == NULL);
+}
+
static gboolean
send_response (gpointer data)
{
@@ -70,7 +89,7 @@ send_response (gpointer data)
if (strv)
{
g_assert (addresses != NULL);
- g_assert_true (g_strv_equal ((const char * const *)strv, addresses));
+ g_assert_true (strv_equal ((const char * const *)strv, addresses));
g_strfreev (strv);
}
@@ -78,7 +97,7 @@ send_response (gpointer data)
if (strv)
{
g_assert (addresses != NULL);
- g_assert_true (g_strv_equal ((const char * const *)strv, cc));
+ g_assert_true (strv_equal ((const char * const *)strv, cc));
g_strfreev (strv);
}
@@ -86,7 +105,7 @@ send_response (gpointer data)
if (strv)
{
g_assert (addresses != NULL);
- g_assert_true (g_strv_equal ((const char * const *)strv, bcc));
+ g_assert_true (strv_equal ((const char * const *)strv, bcc));
g_strfreev (strv);
}
diff --git a/tests/filechooser.c b/tests/filechooser.c
index a5f9b2c..a1a17cd 100644
--- a/tests/filechooser.c
+++ b/tests/filechooser.c
@@ -12,6 +12,25 @@ extern char outdir[];
static int got_info;
+static gboolean
+strv_equal (const gchar * const *strv1,
+ const gchar * const *strv2)
+{
+ g_return_val_if_fail (strv1 != NULL, FALSE);
+ g_return_val_if_fail (strv2 != NULL, FALSE);
+
+ if (strv1 == strv2)
+ return TRUE;
+
+ for (; *strv1 != NULL && *strv2 != NULL; strv1++, strv2++)
+ {
+ if (!g_str_equal (*strv1, *strv2))
+ return FALSE;
+ }
+
+ return (*strv1 == NULL && *strv2 == NULL);
+}
+
static void
open_file_cb (GObject *obj,
GAsyncResult *result,
@@ -41,7 +60,7 @@ open_file_cb (GObject *obj,
g_variant_lookup (ret, "uris", "^a&s", &uris);
expected_uris = g_key_file_get_string_list (keyfile, "result", "uris", NULL, NULL);
- g_assert (g_strv_equal (uris, (const char * const *)expected_uris));
+ g_assert (strv_equal (uris, (const char * const *)expected_uris));
expected_choices = g_key_file_get_string (keyfile, "result", "choices", NULL);
g_variant_lookup (ret, "choices", "@a(ss)", &choices);
@@ -670,7 +689,7 @@ save_file_cb (GObject *obj,
g_variant_lookup (ret, "uris", "^a&s", &uris);
expected = g_key_file_get_string_list (keyfile, "result", "uris", NULL, NULL);
- g_assert (g_strv_equal (uris, (const char * const *)expected));
+ g_assert (strv_equal (uris, (const char * const *)expected));
}
else if (response == 1)
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
--
2.26.2