Skip to content

Commit 30577cd

Browse files
authored
glib: remove deprecated/unused GRegex via patch (#30)
See lovell/sharp-libvips#106
1 parent 18a99a0 commit 30577cd

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c
2+
index ec0caf655..c6799a2ba 100644
3+
--- a/gio/gsettingsschema.c
4+
+++ b/gio/gsettingsschema.c
5+
@@ -551,58 +551,7 @@ start_element (GMarkupParseContext *context,
6+
static gchar *
7+
normalise_whitespace (const gchar *orig)
8+
{
9+
- /* We normalise by the same rules as in intltool:
10+
- *
11+
- * sub cleanup {
12+
- * s/^\s+//;
13+
- * s/\s+$//;
14+
- * s/\s+/ /g;
15+
- * return $_;
16+
- * }
17+
- *
18+
- * $message = join "\n\n", map &cleanup, split/\n\s*\n+/, $message;
19+
- *
20+
- * Where \s is an ascii space character.
21+
- *
22+
- * We aim for ease of implementation over efficiency -- this code is
23+
- * not run in normal applications.
24+
- */
25+
- static GRegex *cleanup[3];
26+
- static GRegex *splitter;
27+
- gchar **lines;
28+
- gchar *result;
29+
- gint i;
30+
-
31+
- if (g_once_init_enter (&splitter))
32+
- {
33+
- GRegex *s;
34+
-
35+
- cleanup[0] = g_regex_new ("^\\s+", 0, 0, 0);
36+
- cleanup[1] = g_regex_new ("\\s+$", 0, 0, 0);
37+
- cleanup[2] = g_regex_new ("\\s+", 0, 0, 0);
38+
- s = g_regex_new ("\\n\\s*\\n+", 0, 0, 0);
39+
-
40+
- g_once_init_leave (&splitter, s);
41+
- }
42+
-
43+
- lines = g_regex_split (splitter, orig, 0);
44+
- for (i = 0; lines[i]; i++)
45+
- {
46+
- gchar *a, *b, *c;
47+
-
48+
- a = g_regex_replace_literal (cleanup[0], lines[i], -1, 0, "", 0, 0);
49+
- b = g_regex_replace_literal (cleanup[1], a, -1, 0, "", 0, 0);
50+
- c = g_regex_replace_literal (cleanup[2], b, -1, 0, " ", 0, 0);
51+
- g_free (lines[i]);
52+
- g_free (a);
53+
- g_free (b);
54+
- lines[i] = c;
55+
- }
56+
-
57+
- result = g_strjoinv ("\n\n", lines);
58+
- g_strfreev (lines);
59+
-
60+
- return result;
61+
+ return orig;
62+
}
63+
64+
static void
65+
diff --git a/glib/glib-autocleanups.h b/glib/glib-autocleanups.h
66+
index 6457eaff8..f72031fb1 100644
67+
--- a/glib/glib-autocleanups.h
68+
+++ b/glib/glib-autocleanups.h
69+
@@ -71,8 +71,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPatternSpec, g_pattern_spec_free)
70+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GQueue, g_queue_free)
71+
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GQueue, g_queue_clear)
72+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRand, g_rand_free)
73+
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRegex, g_regex_unref)
74+
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMatchInfo, g_match_info_unref)
75+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GScanner, g_scanner_destroy)
76+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSequence, g_sequence_free)
77+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSList, g_slist_free)
78+
diff --git a/glib/glib.h b/glib/glib.h
79+
index e72c09da5..d639e645e 100644
80+
--- a/glib/glib.h
81+
+++ b/glib/glib.h
82+
@@ -72,7 +72,6 @@
83+
#include <glib/grcbox.h>
84+
#include <glib/grefcount.h>
85+
#include <glib/grefstring.h>
86+
-#include <glib/gregex.h>
87+
#include <glib/gscanner.h>
88+
#include <glib/gsequence.h>
89+
#include <glib/gshell.h>
90+
diff --git a/glib/meson.build b/glib/meson.build
91+
index 93600b29e..3ebcbeb02 100644
92+
--- a/glib/meson.build
93+
+++ b/glib/meson.build
94+
@@ -187,7 +187,6 @@ glib_sub_headers = files(
95+
'grcbox.h',
96+
'grefcount.h',
97+
'grefstring.h',
98+
- 'gregex.h',
99+
'gscanner.h',
100+
'gsequence.h',
101+
'gshell.h',
102+
diff --git a/gobject/gboxed.c b/gobject/gboxed.c
103+
index ae48df566..9f1ca04c8 100644
104+
--- a/gobject/gboxed.c
105+
+++ b/gobject/gboxed.c
106+
@@ -147,9 +147,6 @@ G_DEFINE_BOXED_TYPE (GByteArray, g_byte_array, g_byte_array_ref, g_byte_array_un
107+
G_DEFINE_BOXED_TYPE (GBytes, g_bytes, g_bytes_ref, g_bytes_unref)
108+
G_DEFINE_BOXED_TYPE (GTree, g_tree, g_tree_ref, g_tree_unref)
109+
110+
-G_DEFINE_BOXED_TYPE (GRegex, g_regex, g_regex_ref, g_regex_unref)
111+
-G_DEFINE_BOXED_TYPE (GMatchInfo, g_match_info, g_match_info_ref, g_match_info_unref)
112+
-
113+
#define g_variant_type_get_type g_variant_type_get_gtype
114+
G_DEFINE_BOXED_TYPE (GVariantType, g_variant_type, g_variant_type_copy, g_variant_type_free)
115+
#undef g_variant_type_get_type

0 commit comments

Comments
 (0)