[gedit] Utils: deprecate make_valid_utf8(), use g_utf8_make_valid()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Utils: deprecate make_valid_utf8(), use g_utf8_make_valid()
- Date: Mon, 11 Nov 2019 03:01:07 +0000 (UTC)
commit 9377d2311b841168010b21bb142e89655afdb572
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Nov 6 10:12:45 2019 +0100
Utils: deprecate make_valid_utf8(), use g_utf8_make_valid()
g_utf8_make_valid() has been added in GLib 2.52.
gedit/gedit-utils.c | 47 ++++++++---------------------------------------
gedit/gedit-utils.h | 1 +
meson.build | 2 +-
3 files changed, 10 insertions(+), 40 deletions(-)
---
diff --git a/gedit/gedit-utils.c b/gedit/gedit-utils.c
index 58adac0f3..defb565e7 100644
--- a/gedit/gedit-utils.c
+++ b/gedit/gedit-utils.c
@@ -245,48 +245,17 @@ gedit_utils_str_end_truncate (const gchar *string,
return tepl_utils_str_end_truncate (string, truncate_length);
}
+/**
+ * gedit_utils_make_valid_utf8:
+ * @name:
+ *
+ * Returns:
+ * Deprecated: 3.36: Use g_utf8_make_valid() instead.
+ */
gchar *
gedit_utils_make_valid_utf8 (const char *name)
{
- GString *string;
- const char *remainder, *invalid;
- int remaining_bytes, valid_bytes;
-
- g_return_val_if_fail (name != NULL, NULL);
-
- string = NULL;
- remainder = name;
- remaining_bytes = strlen (name);
-
- while (remaining_bytes != 0) {
- if (g_utf8_validate (remainder, remaining_bytes, &invalid))
- {
- break;
- }
- valid_bytes = invalid - remainder;
-
- if (string == NULL)
- {
- string = g_string_sized_new (remaining_bytes);
- }
- g_string_append_len (string, remainder, valid_bytes);
- /* append U+FFFD REPLACEMENT CHARACTER */
- g_string_append (string, "\357\277\275");
-
- remaining_bytes -= valid_bytes + 1;
- remainder = invalid + 1;
- }
-
- if (string == NULL)
- {
- return g_strdup (name);
- }
-
- g_string_append (string, remainder);
-
- g_assert (g_utf8_validate (string->str, -1, NULL));
-
- return g_string_free (string, FALSE);
+ return g_utf8_make_valid (name, -1);
}
static gchar *
diff --git a/gedit/gedit-utils.h b/gedit/gedit-utils.h
index ab8456f99..32f97e57e 100644
--- a/gedit/gedit-utils.h
+++ b/gedit/gedit-utils.h
@@ -66,6 +66,7 @@ void gedit_utils_set_atk_relation (G
void gedit_warning (GtkWindow *parent,
const gchar *format,
...) G_GNUC_PRINTF(2, 3);
+G_DEPRECATED_FOR (g_utf8_make_valid)
gchar *gedit_utils_make_valid_utf8 (const char *name);
diff --git a/meson.build b/meson.build
index ddb591e60..c62271637 100644
--- a/meson.build
+++ b/meson.build
@@ -60,7 +60,7 @@ libgd_sp = subproject(
)
# Dependencies
-glib_req = '>= 2.44.0'
+glib_req = '>= 2.52'
gtk_req = '>= 3.22.0'
gtksourceview_req = '>= 4.0.2'
tepl_req = '>= 4.3'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]