[devhelp] Use g_strv_equal()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] Use g_strv_equal()
- Date: Tue, 24 Dec 2019 06:20:40 +0000 (UTC)
commit 8f832c76cfd3fc2c86cba16ac9db6cf1ad82efc4
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Dec 24 07:08:59 2019 +0100
Use g_strv_equal()
New function added in GLib 2.60.
meson.build | 2 +-
unit-tests/test-search-context.c | 25 ++++++-------------------
2 files changed, 7 insertions(+), 20 deletions(-)
---
diff --git a/meson.build b/meson.build
index 2a5ad809..cda503e2 100644
--- a/meson.build
+++ b/meson.build
@@ -34,7 +34,7 @@ LIBDEVHELP_LT_VERSION = '@0@.@1@.@2@'.format(lt_current, lt_revision, lt_age)
WEBKITGTK_DEP_STR = 'webkit2gtk-4.0'
libdevhelp_deps_array = [
- ['gio-2.0', '>= 2.56'],
+ ['gio-2.0', '>= 2.60'],
['gtk+-3.0', '>= 3.22'],
[WEBKITGTK_DEP_STR, '>= 2.24']
]
diff --git a/unit-tests/test-search-context.c b/unit-tests/test-search-context.c
index c3a1b787..6dff353a 100644
--- a/unit-tests/test-search-context.c
+++ b/unit-tests/test-search-context.c
@@ -1,32 +1,19 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/*
- * SPDX-FileCopyrightText: 2018 Sébastien Wilmet <swilmet gnome org>
+/* SPDX-FileCopyrightText: 2018-2019 Sébastien Wilmet <swilmet gnome org>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "devhelp/dh-search-context.h"
static gboolean
-strv_equal (GStrv strv1,
- GStrv strv2)
+strv_equal_nullsafe (GStrv strv1,
+ GStrv strv2)
{
- gint i1;
- gint i2;
-
if (strv1 == NULL || strv2 == NULL)
return strv1 == NULL && strv2 == NULL;
- for (i1 = 0, i2 = 0;
- strv1[i1] != NULL && strv2[i2] != NULL;
- i1++, i2++) {
- const gchar *cur_str1 = strv1[i1];
- const gchar *cur_str2 = strv2[i2];
-
- if (!g_str_equal (cur_str1, cur_str2))
- return FALSE;
- }
-
- return strv1[i1] == NULL && strv2[i2] == NULL;
+ return g_strv_equal ((const gchar * const *) strv1,
+ (const gchar * const *) strv2);
}
static void
@@ -50,7 +37,7 @@ check_process_search_string (const gchar *search_string,
g_assert_cmpstr (_dh_search_context_get_book_id (search_context), ==, expected_book_id);
g_assert_cmpstr (_dh_search_context_get_page_id (search_context), ==, expected_page_id);
- g_assert (strv_equal (_dh_search_context_get_keywords (search_context), expected_keywords));
+ g_assert (strv_equal_nullsafe (_dh_search_context_get_keywords (search_context), expected_keywords));
_dh_search_context_free (search_context);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]