diff options
author | Michael Catanzaro <mcatanzaro@redhat.com> | 2022-02-08 14:39:09 -0600 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@redhat.com> | 2022-02-08 14:39:09 -0600 |
commit | bbc62f3e1a7a99d6f3c402e5015479064cffbc49 (patch) | |
tree | 0d174842009363a039f198ef9c4e76b479560add | |
parent | ea0acf04820dfd7b6c61d58d1b56b67c5625480a (diff) | |
download | epiphany-gnome-3-38.tar.gz |
output-encoding: fix build with older GLibgnome-3-38
-rw-r--r-- | lib/ephy-output-encoding.c | 43 |
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) { |