[gtksourceview/wip/chergert/gsv-gtk4] fix const'ness of search-path usage in various managers



commit 98d7af34ed47b2e5ce3540077748ed2fbd7612fa
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 29 08:31:42 2020 -0800

    fix const'ness of search-path usage in various managers
    
    These should be "const gchar * const *" since we're breakin API/ABI
    anyway. This is not an ABI break, but it will cause warnings in existing
    code that was passing "gchar**". This is more correct however since we
    do not take any references or mutate the strings, or pointer to strings.

 gtksourceview/gtksourcelanguagemanager.c    | 10 +++++-----
 gtksourceview/gtksourcelanguagemanager.h    |  4 ++--
 gtksourceview/gtksourcestyleschememanager.c | 11 ++++++-----
 gtksourceview/gtksourcestyleschememanager.h |  2 +-
 testsuite/test-buffer.c                     |  2 +-
 testsuite/test-language.c                   |  3 ++-
 testsuite/test-languagemanager.c            |  2 +-
 testsuite/test-search-context.c             |  2 +-
 testsuite/test-stylescheme.c                |  2 +-
 9 files changed, 20 insertions(+), 18 deletions(-)
---
diff --git a/gtksourceview/gtksourcelanguagemanager.c b/gtksourceview/gtksourcelanguagemanager.c
index 2405b047..9b62e6ba 100644
--- a/gtksourceview/gtksourcelanguagemanager.c
+++ b/gtksourceview/gtksourcelanguagemanager.c
@@ -229,8 +229,8 @@ notify_search_path (GtkSourceLanguageManager *mgr)
 /**
  * gtk_source_language_manager_set_search_path:
  * @lm: a #GtkSourceLanguageManager.
- * @dirs: (nullable) (array zero-terminated=1):
- * a %NULL-terminated array of strings or %NULL.
+ * @dirs: (nullable) (array zero-terminated=1): a %NULL-terminated array of
+ *   strings or %NULL.
  *
  * Sets the list of directories where the @lm looks for
  * language files.
@@ -246,8 +246,8 @@ notify_search_path (GtkSourceLanguageManager *mgr)
  * </note>
  */
 void
-gtk_source_language_manager_set_search_path (GtkSourceLanguageManager  *lm,
-                                             gchar                    **dirs)
+gtk_source_language_manager_set_search_path (GtkSourceLanguageManager *lm,
+                                             const gchar * const      *dirs)
 {
        gchar **tmp;
 
@@ -262,7 +262,7 @@ gtk_source_language_manager_set_search_path (GtkSourceLanguageManager  *lm,
        if (dirs == NULL)
                lm->lang_dirs = _gtk_source_utils_get_default_dirs (LANGUAGE_DIR);
        else
-               lm->lang_dirs = g_strdupv (dirs);
+               lm->lang_dirs = g_strdupv ((gchar **)dirs);
 
        g_strfreev (tmp);
 
diff --git a/gtksourceview/gtksourcelanguagemanager.h b/gtksourceview/gtksourcelanguagemanager.h
index 186ff288..b3c7782c 100644
--- a/gtksourceview/gtksourcelanguagemanager.h
+++ b/gtksourceview/gtksourcelanguagemanager.h
@@ -41,8 +41,8 @@ GtkSourceLanguageManager *gtk_source_language_manager_get_default      (void);
 GTK_SOURCE_AVAILABLE_IN_ALL
 const gchar * const      *gtk_source_language_manager_get_search_path  (GtkSourceLanguageManager  *lm);
 GTK_SOURCE_AVAILABLE_IN_ALL
-void                      gtk_source_language_manager_set_search_path  (GtkSourceLanguageManager  *lm,
-                                                                        gchar                    **dirs);
+void                      gtk_source_language_manager_set_search_path  (GtkSourceLanguageManager *lm,
+                                                                        const gchar * const      *dirs);
 GTK_SOURCE_AVAILABLE_IN_ALL
 const gchar * const      *gtk_source_language_manager_get_language_ids (GtkSourceLanguageManager  *lm);
 GTK_SOURCE_AVAILABLE_IN_ALL
diff --git a/gtksourceview/gtksourcestyleschememanager.c b/gtksourceview/gtksourcestyleschememanager.c
index 8d6c937b..1c333f00 100644
--- a/gtksourceview/gtksourcestyleschememanager.c
+++ b/gtksourceview/gtksourcestyleschememanager.c
@@ -404,16 +404,17 @@ notify_search_path (GtkSourceStyleSchemeManager *mgr)
 /**
  * gtk_source_style_scheme_manager_set_search_path:
  * @manager: a #GtkSourceStyleSchemeManager.
- * @path: (array zero-terminated=1) (nullable):
- * a %NULL-terminated array of strings or %NULL.
+ * @path: (array zero-terminated=1) (nullable): a %NULL-terminated array of
+ *   strings or %NULL.
  *
  * Sets the list of directories where the @manager looks for
  * style scheme files.
+ *
  * If @path is %NULL, the search path is reset to default.
  */
 void
-gtk_source_style_scheme_manager_set_search_path (GtkSourceStyleSchemeManager  *manager,
-                                                 gchar                       **path)
+gtk_source_style_scheme_manager_set_search_path (GtkSourceStyleSchemeManager *manager,
+                                                 const gchar * const         *path)
 {
        gchar **tmp;
 
@@ -424,7 +425,7 @@ gtk_source_style_scheme_manager_set_search_path (GtkSourceStyleSchemeManager  *m
        if (path == NULL)
                manager->search_path = _gtk_source_utils_get_default_dirs (STYLES_DIR);
        else
-               manager->search_path = g_strdupv (path);
+               manager->search_path = g_strdupv ((gchar **)path);
 
        g_strfreev (tmp);
 
diff --git a/gtksourceview/gtksourcestyleschememanager.h b/gtksourceview/gtksourcestyleschememanager.h
index 1c32b432..f4ce397e 100644
--- a/gtksourceview/gtksourcestyleschememanager.h
+++ b/gtksourceview/gtksourcestyleschememanager.h
@@ -40,7 +40,7 @@ GTK_SOURCE_AVAILABLE_IN_ALL
 GtkSourceStyleSchemeManager *gtk_source_style_scheme_manager_get_default         (void);
 GTK_SOURCE_AVAILABLE_IN_ALL
 void                         gtk_source_style_scheme_manager_set_search_path     
(GtkSourceStyleSchemeManager  *manager,
-                                                                                  gchar                      
 **path);
+                                                                                  const gchar * const        
  *path);
 GTK_SOURCE_AVAILABLE_IN_ALL
 void                         gtk_source_style_scheme_manager_append_search_path  
(GtkSourceStyleSchemeManager  *manager,
                                                                                   const gchar                
  *path);
diff --git a/testsuite/test-buffer.c b/testsuite/test-buffer.c
index a38835b7..fa3fe017 100644
--- a/testsuite/test-buffer.c
+++ b/testsuite/test-buffer.c
@@ -52,7 +52,7 @@ init_default_manager (void)
        if (g_file_test (dir, G_FILE_TEST_IS_DIR))
        {
                GtkSourceLanguageManager *lm = gtk_source_language_manager_get_default ();
-               gchar *lang_dirs[2] = {dir, NULL};
+               const gchar *lang_dirs[2] = {dir, NULL};
 
                gtk_source_language_manager_set_search_path (lm, lang_dirs);
        }
diff --git a/testsuite/test-language.c b/testsuite/test-language.c
index 10b7bbc7..b1b7eeb9 100644
--- a/testsuite/test-language.c
+++ b/testsuite/test-language.c
@@ -67,7 +67,8 @@ test_fixture_setup (TestFixture   *fixture,
                lang_dirs[i] = g_test_build_filename (G_TEST_DIST, "language-specs", NULL);
        }
 
-       gtk_source_language_manager_set_search_path (fixture->manager, lang_dirs);
+       gtk_source_language_manager_set_search_path (fixture->manager,
+                                                    (const gchar * const *)lang_dirs);
        g_strfreev (lang_dirs);
 }
 
diff --git a/testsuite/test-languagemanager.c b/testsuite/test-languagemanager.c
index 7b98b5c5..d61711f7 100644
--- a/testsuite/test-languagemanager.c
+++ b/testsuite/test-languagemanager.c
@@ -43,7 +43,7 @@ init_default_manager (void)
                lang_dirs = g_new0 (gchar *, 2);
                lang_dirs[0] = dir;
 
-               gtk_source_language_manager_set_search_path (lm, lang_dirs);
+               gtk_source_language_manager_set_search_path (lm, (const gchar * const *)lang_dirs);
                g_strfreev (lang_dirs);
        }
        else
diff --git a/testsuite/test-search-context.c b/testsuite/test-search-context.c
index 488691f4..d7de8270 100644
--- a/testsuite/test-search-context.c
+++ b/testsuite/test-search-context.c
@@ -70,7 +70,7 @@ init_style_scheme_manager (void)
                dirs = g_new0 (gchar *, 2);
                dirs[0] = dir;
 
-               gtk_source_style_scheme_manager_set_search_path (manager, dirs);
+               gtk_source_style_scheme_manager_set_search_path (manager, (const gchar * const *)dirs);
                g_strfreev (dirs);
        }
        else
diff --git a/testsuite/test-stylescheme.c b/testsuite/test-stylescheme.c
index 651c2c62..be7fe443 100644
--- a/testsuite/test-stylescheme.c
+++ b/testsuite/test-stylescheme.c
@@ -68,7 +68,7 @@ test_fixture_setup (TestFixture   *fixture,
                style_dirs[i] = g_test_build_filename (G_TEST_DIST, "styles", NULL);
        }
 
-       gtk_source_style_scheme_manager_set_search_path (fixture->manager, style_dirs);
+       gtk_source_style_scheme_manager_set_search_path (fixture->manager, (const gchar * const *)style_dirs);
        g_strfreev (style_dirs);
 }
 


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