[gnome-builder] meson: namespace the parse_languages() function



commit 24f6dd7e2966daffdac123e761747b6090b4329d
Author: Christian Hergert <chergert redhat com>
Date:   Tue Oct 12 17:23:56 2021 -0700

    meson: namespace the parse_languages() function

 src/plugins/meson/gbp-meson-build-system.c  |  4 ++--
 src/plugins/meson/test-meson-build-system.c | 35 +++++++++++++----------------
 2 files changed, 18 insertions(+), 21 deletions(-)
---
diff --git a/src/plugins/meson/gbp-meson-build-system.c b/src/plugins/meson/gbp-meson-build-system.c
index ddf787a3c..71914b263 100644
--- a/src/plugins/meson/gbp-meson-build-system.c
+++ b/src/plugins/meson/gbp-meson-build-system.c
@@ -778,7 +778,7 @@ split_language (gchar *raw_language_string)
  * 4) 'projectname', ['c', 'c++'] with an list as languages
  */
 char **
-parse_languages (const gchar *raw_language_string)
+_gbp_meson_build_system_parse_languages (const gchar *raw_language_string)
 {
   g_autofree gchar *language_string = NULL;
   gchar *cur = (gchar *) raw_language_string;
@@ -870,7 +870,7 @@ extract_metadata (GbpMesonBuildSystem *self,
   while (g_match_info_matches (match_info))
     {
       const gchar *str = g_match_info_fetch (match_info, 1);
-      self->languages = parse_languages (str);
+      self->languages = _gbp_meson_build_system_parse_languages (str);
 
       g_match_info_next (match_info, NULL);
     }
diff --git a/src/plugins/meson/test-meson-build-system.c b/src/plugins/meson/test-meson-build-system.c
index 07117749d..f864e8ce1 100644
--- a/src/plugins/meson/test-meson-build-system.c
+++ b/src/plugins/meson/test-meson-build-system.c
@@ -1,24 +1,24 @@
 #include <glib.h>
 
-const gchar **parse_languages (gchar *language_string);
+char **_gbp_meson_build_system_parse_languages (const char *language_string);
 
 static void
 meson_test_parse_languages (void)
 {
-  struct {
-    gchar *input;
-    gchar **expected;
+  const struct {
+    const char *input;
+    const char **expected;
   } cases[] = {
-      { .input = "'testproject', 'rust'", .expected = (gchar*[]){ "rust", NULL } },
-      { .input = "'testproject', 'rust', 'c'", .expected = (gchar*[]){ "rust", "c", NULL } },
-      { .input = "'testproject', 'rust', version: '3.0'", .expected = (gchar*[]){ "rust", NULL } },
-      { .input = "testproject, rust, version: 3.0, default_options: ['warning_level=2']", .expected = 
(gchar*[]){ "rust", NULL } },
-      { .input = "testproject\n\n,\n rust, \nversion: 3.0, default_options: ['warning_level=2']", .expected 
= (gchar*[]){ "rust", NULL } },
-      { .input = "testproject\n\n,\n ['rust'], \nversion: 3.0, default_options: ['warning_level=2']", 
.expected = (gchar*[]){ "rust", NULL } },
-      { .input = "testproject\n\n,\n ['rust']", .expected = (gchar*[]){ "rust", NULL } },
-      { .input = "testproject\n\n,\n ['c', 'c++'], \nversion: 3.0, default_options: ['warning_level=2']", 
.expected = (gchar*[]){ "c", "c++", NULL } },
+      { .input = "'testproject', 'rust'", .expected = (const char *[]){ "rust", NULL } },
+      { .input = "'testproject', 'rust', 'c'", .expected = (const char *[]){ "rust", "c", NULL } },
+      { .input = "'testproject', 'rust', version: '3.0'", .expected = (const char *[]){ "rust", NULL } },
+      { .input = "testproject, rust, version: 3.0, default_options: ['warning_level=2']", .expected = (const 
char *[]){ "rust", NULL } },
+      { .input = "testproject\n\n,\n rust, \nversion: 3.0, default_options: ['warning_level=2']", .expected 
= (const char *[]){ "rust", NULL } },
+      { .input = "testproject\n\n,\n ['rust'], \nversion: 3.0, default_options: ['warning_level=2']", 
.expected = (const char *[]){ "rust", NULL } },
+      { .input = "testproject\n\n,\n ['rust']", .expected = (const char *[]){ "rust", NULL } },
+      { .input = "testproject\n\n,\n ['c', 'c++'], \nversion: 3.0, default_options: ['warning_level=2']", 
.expected = (const char *[]){ "c", "c++", NULL } },
       { .input = "testproject\n\n,\n ['c', 'c++', \nversion: 3.0", .expected = NULL},
-      { .input = "testproject\n\n,\n 'c', 'c++', \nversion: 3.0", .expected = (gchar*[]){ "c", "c++", NULL } 
},
+      { .input = "testproject\n\n,\n 'c', 'c++', \nversion: 3.0", .expected = (const char *[]){ "c", "c++", 
NULL } },
       { .input = "testproject\n\n,\n 'c', 'c++'], \nversion: 3.0", .expected = NULL },
       { .input = "'testproject',\nversion: 3.0", .expected = NULL },
       { .input = "'projectname'", .expected = NULL },
@@ -28,19 +28,16 @@ meson_test_parse_languages (void)
 
   for (guint i = 0; i < n_cases; i++)
     {
-      const gchar **languages = parse_languages (cases[i].input);
-
+      g_auto(GStrv) languages = _gbp_meson_build_system_parse_languages (cases[i].input);
       g_assert_cmpstrv (cases[i].expected, languages);
     }
 }
 
 gint
-main (gint   argc,
-      gchar *argv[])
+main (gint  argc,
+      char *argv[])
 {
   g_test_init (&argc, &argv, NULL);
-
   g_test_add_func("/meson/parse_languages", meson_test_parse_languages);
-
   return g_test_run ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]