summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@redhat.com>2022-02-08 14:39:09 -0600
committerMichael Catanzaro <mcatanzaro@redhat.com>2022-02-08 14:39:53 -0600
commit25e6d1c57a6002b081f6f225e5abd953fbe13768 (patch)
tree5acfb0cd42548d6afce9c34cfd2230ea8e334956
parentf7272f6d6be1abebe63ae4c81d09bc9ce592f2cd (diff)
downloadepiphany-gnome-3-36.tar.gz
output-encoding: fix build with older GLibgnome-3-36
-rw-r--r--lib/ephy-output-encoding.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/ephy-output-encoding.c b/lib/ephy-output-encoding.c
index 2a7c1d0a8..1263b25e8 100644
--- a/lib/ephy-output-encoding.c
+++ b/lib/ephy-output-encoding.c
@@ -23,6 +23,49 @@
#include <glib.h>
+#if !GLIB_CHECK_VERSION(2, 68, 0)
+static guint
+g_string_replace (GString *string,
+ const gchar *find,
+ const gchar *replace,
+ guint limit)
+{
+ gsize f_len, r_len, pos;
+ gchar *cur, *next;
+ guint n = 0;
+
+ g_return_val_if_fail (string != NULL, 0);
+ g_return_val_if_fail (find != NULL, 0);
+ g_return_val_if_fail (replace != NULL, 0);
+
+ f_len = strlen (find);
+ r_len = strlen (replace);
+ cur = string->str;
+
+ while ((next = strstr (cur, find)) != NULL)
+ {
+ pos = next - string->str;
+ g_string_erase (string, pos, f_len);
+ g_string_insert (string, pos, replace);
+ cur = string->str + pos + r_len;
+ n++;
+ /* Only match the empty string once at any given position, to
+ * avoid infinite loops */
+ if (f_len == 0)
+ {
+ if (cur[0] == '\0')
+ break;
+ else
+ cur++;
+ }
+ if (n == limit)
+ break;
+ }
+
+ return n;
+}
+#endif
+
char *
ephy_encode_for_html_entity (const char *input)
{