Update to 2.78.3
This commit is contained in:
parent
828c0d9c23
commit
d9bc37b0d0
@ -1,39 +0,0 @@
|
|||||||
From cabc49407371800733ada202fab721c9091b6fe6 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Pavel Sobolev <paveloom@riseup.net>
|
|
||||||
Date: Thu, 14 Sep 2023 15:42:24 +0300
|
|
||||||
Subject: [PATCH] Make sure the `GTask` is freed on a graceful disconnect
|
|
||||||
|
|
||||||
This fixes the memory leak in the case the connection has been
|
|
||||||
successfully closed by the peer.
|
|
||||||
|
|
||||||
|
|
||||||
Conflict:NA
|
|
||||||
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/cabc49407371800733ada202fab721c9091b6fe6
|
|
||||||
|
|
||||||
---
|
|
||||||
gio/gtcpconnection.c | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/gio/gtcpconnection.c b/gio/gtcpconnection.c
|
|
||||||
index 422b3dea52..e0865d859b 100644
|
|
||||||
--- a/gio/gtcpconnection.c
|
|
||||||
+++ b/gio/gtcpconnection.c
|
|
||||||
@@ -206,6 +206,8 @@ async_close_finish (GTask *task,
|
|
||||||
g_task_return_error (task, error);
|
|
||||||
else
|
|
||||||
g_task_return_boolean (task, TRUE);
|
|
||||||
+
|
|
||||||
+ g_object_unref (task);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -231,7 +233,6 @@ close_read_ready (GSocket *socket,
|
|
||||||
else
|
|
||||||
{
|
|
||||||
async_close_finish (task, error);
|
|
||||||
- g_object_unref (task);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
From c49502582faedecc7020155d95b16c7a1d78d432 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Ga=C3=ABl=20Bonithon?= <gael@xfce.org>
|
|
||||||
Date: Thu, 13 Jul 2023 10:06:21 +0200
|
|
||||||
Subject: [PATCH] gkeyfile: Ensure we don't add extra blank line above new
|
|
||||||
group
|
|
||||||
|
|
||||||
A forgotten edge case in 86b4b045: when the last value of the last group
|
|
||||||
has been added via g_key_file_set_value() and it contains line breaks.
|
|
||||||
The best we can do in this case is probably to do nothing.
|
|
||||||
|
|
||||||
Closes: #3047
|
|
||||||
Fixes: 86b4b0453ea3a814167d4a5f7a4031d467543716
|
|
||||||
---
|
|
||||||
glib/gkeyfile.c | 6 +++++-
|
|
||||||
glib/tests/keyfile.c | 10 ++++++++++
|
|
||||||
2 files changed, 15 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
|
|
||||||
index 145136706f..0e21ab4f14 100644
|
|
||||||
--- a/glib/gkeyfile.c
|
|
||||||
+++ b/glib/gkeyfile.c
|
|
||||||
@@ -3858,8 +3858,12 @@ g_key_file_add_group (GKeyFile *key_file,
|
|
||||||
{
|
|
||||||
/* separate groups by a blank line if we don't keep comments or group is created */
|
|
||||||
GKeyFileGroup *next_group = key_file->groups->next->data;
|
|
||||||
+ GKeyFileKeyValuePair *pair;
|
|
||||||
+ if (next_group->key_value_pairs != NULL)
|
|
||||||
+ pair = next_group->key_value_pairs->data;
|
|
||||||
+
|
|
||||||
if (next_group->key_value_pairs == NULL ||
|
|
||||||
- ((GKeyFileKeyValuePair *) next_group->key_value_pairs->data)->key != NULL)
|
|
||||||
+ (pair->key != NULL && !g_strstr_len (pair->value, -1, "\n")))
|
|
||||||
{
|
|
||||||
GKeyFileKeyValuePair *pair = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
pair->key = NULL;
|
|
||||||
diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c
|
|
||||||
index d3eed29841..80cdc93d8f 100644
|
|
||||||
--- a/glib/tests/keyfile.c
|
|
||||||
+++ b/glib/tests/keyfile.c
|
|
||||||
@@ -480,6 +480,16 @@ test_comments (void)
|
|
||||||
G_KEY_FILE_ERROR_GROUP_NOT_FOUND);
|
|
||||||
g_assert_null (comment);
|
|
||||||
|
|
||||||
+ g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/3047");
|
|
||||||
+
|
|
||||||
+ /* check if we don't add a blank line above new group if last value of preceding
|
|
||||||
+ * group was added via g_key_file_set_value() and contains line breaks */
|
|
||||||
+ g_key_file_set_value (keyfile, "group4", "key1", "value1\n\n# group comment");
|
|
||||||
+ g_key_file_set_string (keyfile, "group5", "key1", "value1");
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "group5", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_null (comment);
|
|
||||||
+
|
|
||||||
g_key_file_free (keyfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
|
|
||||||
@ -1,530 +0,0 @@
|
|||||||
From f74589f53041abff29d538a5d9884c3202f2c00a Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Ga=C3=ABl=20Bonithon?= <gael@xfce.org>
|
|
||||||
Date: Thu, 20 Apr 2023 16:52:19 +0200
|
|
||||||
Subject: [PATCH 1/2] gkeyfile: Replace g_slice_*() with
|
|
||||||
g_new*()/g_free_sized()
|
|
||||||
|
|
||||||
---
|
|
||||||
glib/gkeyfile.c | 26 +++++++++++++-------------
|
|
||||||
1 file changed, 13 insertions(+), 13 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
|
|
||||||
index 9a4821bc5a..d76335653f 100644
|
|
||||||
--- a/glib/gkeyfile.c
|
|
||||||
+++ b/glib/gkeyfile.c
|
|
||||||
@@ -638,7 +638,7 @@ G_DEFINE_QUARK (g-key-file-error-quark, g_key_file_error)
|
|
||||||
static void
|
|
||||||
g_key_file_init (GKeyFile *key_file)
|
|
||||||
{
|
|
||||||
- key_file->current_group = g_slice_new0 (GKeyFileGroup);
|
|
||||||
+ key_file->current_group = g_new0 (GKeyFileGroup, 1);
|
|
||||||
key_file->groups = g_list_prepend (NULL, key_file->current_group);
|
|
||||||
key_file->group_hash = NULL;
|
|
||||||
key_file->start_group = NULL;
|
|
||||||
@@ -700,7 +700,7 @@ g_key_file_new (void)
|
|
||||||
{
|
|
||||||
GKeyFile *key_file;
|
|
||||||
|
|
||||||
- key_file = g_slice_new0 (GKeyFile);
|
|
||||||
+ key_file = g_new0 (GKeyFile, 1);
|
|
||||||
key_file->ref_count = 1;
|
|
||||||
g_key_file_init (key_file);
|
|
||||||
|
|
||||||
@@ -1205,7 +1205,7 @@ g_key_file_free (GKeyFile *key_file)
|
|
||||||
g_key_file_clear (key_file);
|
|
||||||
|
|
||||||
if (g_atomic_int_dec_and_test (&key_file->ref_count))
|
|
||||||
- g_slice_free (GKeyFile, key_file);
|
|
||||||
+ g_free_sized (key_file, sizeof (GKeyFile));
|
|
||||||
else
|
|
||||||
g_key_file_init (key_file);
|
|
||||||
}
|
|
||||||
@@ -1227,7 +1227,7 @@ g_key_file_unref (GKeyFile *key_file)
|
|
||||||
if (g_atomic_int_dec_and_test (&key_file->ref_count))
|
|
||||||
{
|
|
||||||
g_key_file_clear (key_file);
|
|
||||||
- g_slice_free (GKeyFile, key_file);
|
|
||||||
+ g_free_sized (key_file, sizeof (GKeyFile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1317,7 +1317,7 @@ g_key_file_parse_comment (GKeyFile *key_file,
|
|
||||||
|
|
||||||
g_warn_if_fail (key_file->current_group != NULL);
|
|
||||||
|
|
||||||
- pair = g_slice_new (GKeyFileKeyValuePair);
|
|
||||||
+ pair = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
pair->key = NULL;
|
|
||||||
pair->value = g_strndup (line, length);
|
|
||||||
|
|
||||||
@@ -1442,7 +1442,7 @@ g_key_file_parse_key_value_pair (GKeyFile *key_file,
|
|
||||||
{
|
|
||||||
GKeyFileKeyValuePair *pair;
|
|
||||||
|
|
||||||
- pair = g_slice_new (GKeyFileKeyValuePair);
|
|
||||||
+ pair = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
pair->key = g_steal_pointer (&key);
|
|
||||||
pair->value = g_strndup (value_start, value_len);
|
|
||||||
|
|
||||||
@@ -3339,7 +3339,7 @@ g_key_file_set_key_comment (GKeyFile *key_file,
|
|
||||||
|
|
||||||
/* Now we can add our new comment
|
|
||||||
*/
|
|
||||||
- pair = g_slice_new (GKeyFileKeyValuePair);
|
|
||||||
+ pair = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
pair->key = NULL;
|
|
||||||
pair->value = g_key_file_parse_comment_as_value (key_file, comment);
|
|
||||||
|
|
||||||
@@ -3383,7 +3383,7 @@ g_key_file_set_group_comment (GKeyFile *key_file,
|
|
||||||
|
|
||||||
/* Now we can add our new comment
|
|
||||||
*/
|
|
||||||
- group->comment = g_slice_new (GKeyFileKeyValuePair);
|
|
||||||
+ group->comment = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
group->comment->key = NULL;
|
|
||||||
group->comment->value = g_key_file_parse_comment_as_value (key_file, comment);
|
|
||||||
|
|
||||||
@@ -3416,7 +3416,7 @@ g_key_file_set_top_comment (GKeyFile *key_file,
|
|
||||||
if (comment == NULL)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
- pair = g_slice_new (GKeyFileKeyValuePair);
|
|
||||||
+ pair = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
pair->key = NULL;
|
|
||||||
pair->value = g_key_file_parse_comment_as_value (key_file, comment);
|
|
||||||
|
|
||||||
@@ -3840,7 +3840,7 @@ g_key_file_add_group (GKeyFile *key_file,
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
- group = g_slice_new0 (GKeyFileGroup);
|
|
||||||
+ group = g_new0 (GKeyFileGroup, 1);
|
|
||||||
group->name = g_strdup (group_name);
|
|
||||||
group->lookup_map = g_hash_table_new (g_str_hash, g_str_equal);
|
|
||||||
key_file->groups = g_list_prepend (key_file->groups, group);
|
|
||||||
@@ -3862,7 +3862,7 @@ g_key_file_key_value_pair_free (GKeyFileKeyValuePair *pair)
|
|
||||||
{
|
|
||||||
g_free (pair->key);
|
|
||||||
g_free (pair->value);
|
|
||||||
- g_slice_free (GKeyFileKeyValuePair, pair);
|
|
||||||
+ g_free_sized (pair, sizeof (GKeyFileKeyValuePair));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -3971,7 +3971,7 @@ g_key_file_remove_group_node (GKeyFile *key_file,
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free ((gchar *) group->name);
|
|
||||||
- g_slice_free (GKeyFileGroup, group);
|
|
||||||
+ g_free_sized (group, sizeof (GKeyFileGroup));
|
|
||||||
g_list_free_1 (group_node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -4031,7 +4031,7 @@ g_key_file_add_key (GKeyFile *key_file,
|
|
||||||
{
|
|
||||||
GKeyFileKeyValuePair *pair;
|
|
||||||
|
|
||||||
- pair = g_slice_new (GKeyFileKeyValuePair);
|
|
||||||
+ pair = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
pair->key = g_strdup (key);
|
|
||||||
pair->value = g_strdup (value);
|
|
||||||
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
|
|
||||||
|
|
||||||
From 86b4b0453ea3a814167d4a5f7a4031d467543716 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Ga=C3=ABl=20Bonithon?= <gael@xfce.org>
|
|
||||||
Date: Fri, 14 Apr 2023 19:40:30 +0200
|
|
||||||
Subject: [PATCH 2/2] gkeyfile: Fix group comment management
|
|
||||||
|
|
||||||
This removes the `comment` member of the GKeyFileGroup structure, which
|
|
||||||
seemed intended to distinguish comments just above a group from comments
|
|
||||||
above them, separated by one or more blank lines. Indeed:
|
|
||||||
* This does not seem to match any specification in the documentation,
|
|
||||||
where blank lines and lines starting with `#` are indiscriminately
|
|
||||||
considered comments. In particular, no distinction is made between the
|
|
||||||
comment above the first group and the comment at the beginning of the
|
|
||||||
file.
|
|
||||||
* This distinction was only half implemented, resulting in confusion
|
|
||||||
between comment above a group and comment at the end of the preceding
|
|
||||||
group.
|
|
||||||
|
|
||||||
Instead, the same logic is used for groups as for keys: the comment
|
|
||||||
above a group is simply the sequence of key-value pairs of the preceding
|
|
||||||
group where the key is null, starting from the bottom.
|
|
||||||
|
|
||||||
The addition of a blank line above groups when writing, involved in
|
|
||||||
bugs #104 and #2927, is kept, but:
|
|
||||||
* It is now added as a comment as soon as the group is added (since a
|
|
||||||
blank line is considered a comment), so that
|
|
||||||
`g_key_file_get_comment()` returns the correct result right away.
|
|
||||||
* It is always added if comments are not kept.
|
|
||||||
* Otherwise it is only added if the group is newly created (not present
|
|
||||||
in the original data), in order to really keep comments (existing and
|
|
||||||
not existing).
|
|
||||||
|
|
||||||
Closes: #104, #2927
|
|
||||||
---
|
|
||||||
glib/gkeyfile.c | 137 +++++++++++++++++++++++--------------------
|
|
||||||
glib/tests/keyfile.c | 75 ++++++++++++++++++++++-
|
|
||||||
2 files changed, 147 insertions(+), 65 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
|
|
||||||
index d76335653f..1fcef9fc91 100644
|
|
||||||
--- a/glib/gkeyfile.c
|
|
||||||
+++ b/glib/gkeyfile.c
|
|
||||||
@@ -529,8 +529,6 @@ struct _GKeyFileGroup
|
|
||||||
{
|
|
||||||
const gchar *name; /* NULL for above first group (which will be comments) */
|
|
||||||
|
|
||||||
- GKeyFileKeyValuePair *comment; /* Special comment that is stuck to the top of a group */
|
|
||||||
-
|
|
||||||
GList *key_value_pairs;
|
|
||||||
|
|
||||||
/* Used in parallel with key_value_pairs for
|
|
||||||
@@ -579,7 +577,8 @@ static void g_key_file_add_key (GKeyFile
|
|
||||||
const gchar *key,
|
|
||||||
const gchar *value);
|
|
||||||
static void g_key_file_add_group (GKeyFile *key_file,
|
|
||||||
- const gchar *group_name);
|
|
||||||
+ const gchar *group_name,
|
|
||||||
+ gboolean created);
|
|
||||||
static gboolean g_key_file_is_group_name (const gchar *name);
|
|
||||||
static gboolean g_key_file_is_key_name (const gchar *name,
|
|
||||||
gsize len);
|
|
||||||
@@ -1354,7 +1353,7 @@ g_key_file_parse_group (GKeyFile *key_file,
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
- g_key_file_add_group (key_file, group_name);
|
|
||||||
+ g_key_file_add_group (key_file, group_name, FALSE);
|
|
||||||
g_free (group_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1610,14 +1609,6 @@ g_key_file_to_data (GKeyFile *key_file,
|
|
||||||
|
|
||||||
group = (GKeyFileGroup *) group_node->data;
|
|
||||||
|
|
||||||
- /* separate groups by at least an empty line */
|
|
||||||
- if (data_string->len >= 2 &&
|
|
||||||
- data_string->str[data_string->len - 2] != '\n')
|
|
||||||
- g_string_append_c (data_string, '\n');
|
|
||||||
-
|
|
||||||
- if (group->comment != NULL)
|
|
||||||
- g_string_append_printf (data_string, "%s\n", group->comment->value);
|
|
||||||
-
|
|
||||||
if (group->name != NULL)
|
|
||||||
g_string_append_printf (data_string, "[%s]\n", group->name);
|
|
||||||
|
|
||||||
@@ -1902,7 +1893,7 @@ g_key_file_set_value (GKeyFile *key_file,
|
|
||||||
|
|
||||||
if (!group)
|
|
||||||
{
|
|
||||||
- g_key_file_add_group (key_file, group_name);
|
|
||||||
+ g_key_file_add_group (key_file, group_name, TRUE);
|
|
||||||
group = (GKeyFileGroup *) key_file->groups->data;
|
|
||||||
|
|
||||||
g_key_file_add_key (key_file, group, key, value);
|
|
||||||
@@ -3349,6 +3340,42 @@ g_key_file_set_key_comment (GKeyFile *key_file,
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static gboolean
|
|
||||||
+g_key_file_set_top_comment (GKeyFile *key_file,
|
|
||||||
+ const gchar *comment,
|
|
||||||
+ GError **error)
|
|
||||||
+{
|
|
||||||
+ GList *group_node;
|
|
||||||
+ GKeyFileGroup *group;
|
|
||||||
+ GKeyFileKeyValuePair *pair;
|
|
||||||
+
|
|
||||||
+ /* The last group in the list should be the top (comments only)
|
|
||||||
+ * group in the file
|
|
||||||
+ */
|
|
||||||
+ g_warn_if_fail (key_file->groups != NULL);
|
|
||||||
+ group_node = g_list_last (key_file->groups);
|
|
||||||
+ group = (GKeyFileGroup *) group_node->data;
|
|
||||||
+ g_warn_if_fail (group->name == NULL);
|
|
||||||
+
|
|
||||||
+ /* Note all keys must be comments at the top of
|
|
||||||
+ * the file, so we can just free it all.
|
|
||||||
+ */
|
|
||||||
+ g_list_free_full (group->key_value_pairs, (GDestroyNotify) g_key_file_key_value_pair_free);
|
|
||||||
+ group->key_value_pairs = NULL;
|
|
||||||
+
|
|
||||||
+ if (comment == NULL)
|
|
||||||
+ return TRUE;
|
|
||||||
+
|
|
||||||
+ pair = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
+ pair->key = NULL;
|
|
||||||
+ pair->value = g_key_file_parse_comment_as_value (key_file, comment);
|
|
||||||
+
|
|
||||||
+ group->key_value_pairs =
|
|
||||||
+ g_list_prepend (group->key_value_pairs, pair);
|
|
||||||
+
|
|
||||||
+ return TRUE;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static gboolean
|
|
||||||
g_key_file_set_group_comment (GKeyFile *key_file,
|
|
||||||
const gchar *group_name,
|
|
||||||
@@ -3356,6 +3383,8 @@ g_key_file_set_group_comment (GKeyFile *key_file,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
GKeyFileGroup *group;
|
|
||||||
+ GList *group_node;
|
|
||||||
+ GKeyFileKeyValuePair *pair;
|
|
||||||
|
|
||||||
g_return_val_if_fail (group_name != NULL && g_key_file_is_group_name (group_name), FALSE);
|
|
||||||
|
|
||||||
@@ -3370,12 +3399,22 @@ g_key_file_set_group_comment (GKeyFile *key_file,
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (group == key_file->start_group)
|
|
||||||
+ return g_key_file_set_top_comment (key_file, comment, error);
|
|
||||||
+
|
|
||||||
/* First remove any existing comment
|
|
||||||
*/
|
|
||||||
- if (group->comment)
|
|
||||||
+ group_node = g_key_file_lookup_group_node (key_file, group_name);
|
|
||||||
+ group = group_node->next->data;
|
|
||||||
+ for (GList *lp = group->key_value_pairs; lp != NULL; )
|
|
||||||
{
|
|
||||||
- g_key_file_key_value_pair_free (group->comment);
|
|
||||||
- group->comment = NULL;
|
|
||||||
+ GList *lnext = lp->next;
|
|
||||||
+ pair = lp->data;
|
|
||||||
+ if (pair->key != NULL)
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
+ g_key_file_remove_key_value_pair_node (key_file, group, lp);
|
|
||||||
+ lp = lnext;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (comment == NULL)
|
|
||||||
@@ -3383,45 +3422,10 @@ g_key_file_set_group_comment (GKeyFile *key_file,
|
|
||||||
|
|
||||||
/* Now we can add our new comment
|
|
||||||
*/
|
|
||||||
- group->comment = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
- group->comment->key = NULL;
|
|
||||||
- group->comment->value = g_key_file_parse_comment_as_value (key_file, comment);
|
|
||||||
-
|
|
||||||
- return TRUE;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static gboolean
|
|
||||||
-g_key_file_set_top_comment (GKeyFile *key_file,
|
|
||||||
- const gchar *comment,
|
|
||||||
- GError **error)
|
|
||||||
-{
|
|
||||||
- GList *group_node;
|
|
||||||
- GKeyFileGroup *group;
|
|
||||||
- GKeyFileKeyValuePair *pair;
|
|
||||||
-
|
|
||||||
- /* The last group in the list should be the top (comments only)
|
|
||||||
- * group in the file
|
|
||||||
- */
|
|
||||||
- g_warn_if_fail (key_file->groups != NULL);
|
|
||||||
- group_node = g_list_last (key_file->groups);
|
|
||||||
- group = (GKeyFileGroup *) group_node->data;
|
|
||||||
- g_warn_if_fail (group->name == NULL);
|
|
||||||
-
|
|
||||||
- /* Note all keys must be comments at the top of
|
|
||||||
- * the file, so we can just free it all.
|
|
||||||
- */
|
|
||||||
- g_list_free_full (group->key_value_pairs, (GDestroyNotify) g_key_file_key_value_pair_free);
|
|
||||||
- group->key_value_pairs = NULL;
|
|
||||||
-
|
|
||||||
- if (comment == NULL)
|
|
||||||
- return TRUE;
|
|
||||||
-
|
|
||||||
pair = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
pair->key = NULL;
|
|
||||||
pair->value = g_key_file_parse_comment_as_value (key_file, comment);
|
|
||||||
-
|
|
||||||
- group->key_value_pairs =
|
|
||||||
- g_list_prepend (group->key_value_pairs, pair);
|
|
||||||
+ group->key_value_pairs = g_list_prepend (group->key_value_pairs, pair);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
@@ -3629,9 +3633,6 @@ g_key_file_get_group_comment (GKeyFile *key_file,
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (group->comment)
|
|
||||||
- return g_strdup (group->comment->value);
|
|
||||||
-
|
|
||||||
group_node = g_key_file_lookup_group_node (key_file, group_name);
|
|
||||||
group_node = group_node->next;
|
|
||||||
group = (GKeyFileGroup *)group_node->data;
|
|
||||||
@@ -3826,7 +3827,8 @@ g_key_file_has_key (GKeyFile *key_file,
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_key_file_add_group (GKeyFile *key_file,
|
|
||||||
- const gchar *group_name)
|
|
||||||
+ const gchar *group_name,
|
|
||||||
+ gboolean created)
|
|
||||||
{
|
|
||||||
GKeyFileGroup *group;
|
|
||||||
|
|
||||||
@@ -3847,7 +3849,22 @@ g_key_file_add_group (GKeyFile *key_file,
|
|
||||||
key_file->current_group = group;
|
|
||||||
|
|
||||||
if (key_file->start_group == NULL)
|
|
||||||
- key_file->start_group = group;
|
|
||||||
+ {
|
|
||||||
+ key_file->start_group = group;
|
|
||||||
+ }
|
|
||||||
+ else if (!(key_file->flags & G_KEY_FILE_KEEP_COMMENTS) || created)
|
|
||||||
+ {
|
|
||||||
+ /* separate groups by a blank line if we don't keep comments or group is created */
|
|
||||||
+ GKeyFileGroup *next_group = key_file->groups->next->data;
|
|
||||||
+ if (next_group->key_value_pairs == NULL ||
|
|
||||||
+ ((GKeyFileKeyValuePair *) next_group->key_value_pairs->data)->key != NULL)
|
|
||||||
+ {
|
|
||||||
+ GKeyFileKeyValuePair *pair = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
+ pair->key = NULL;
|
|
||||||
+ pair->value = g_strdup ("");
|
|
||||||
+ next_group->key_value_pairs = g_list_prepend (next_group->key_value_pairs, pair);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
|
|
||||||
if (!key_file->group_hash)
|
|
||||||
key_file->group_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
|
||||||
@@ -3958,12 +3975,6 @@ g_key_file_remove_group_node (GKeyFile *key_file,
|
|
||||||
|
|
||||||
g_warn_if_fail (group->key_value_pairs == NULL);
|
|
||||||
|
|
||||||
- if (group->comment)
|
|
||||||
- {
|
|
||||||
- g_key_file_key_value_pair_free (group->comment);
|
|
||||||
- group->comment = NULL;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
if (group->lookup_map)
|
|
||||||
{
|
|
||||||
g_hash_table_destroy (group->lookup_map);
|
|
||||||
diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c
|
|
||||||
index 3d72d9670e..d3eed29841 100644
|
|
||||||
--- a/glib/tests/keyfile.c
|
|
||||||
+++ b/glib/tests/keyfile.c
|
|
||||||
@@ -382,7 +382,9 @@ test_comments (void)
|
|
||||||
"key4 = value4\n"
|
|
||||||
"# group comment\n"
|
|
||||||
"# group comment, continued\n"
|
|
||||||
- "[group2]\n";
|
|
||||||
+ "[group2]\n\n"
|
|
||||||
+ "[group3]\n"
|
|
||||||
+ "[group4]\n";
|
|
||||||
|
|
||||||
const gchar *top_comment = " top comment\n top comment, continued";
|
|
||||||
const gchar *group_comment = " group comment\n group comment, continued";
|
|
||||||
@@ -427,6 +429,12 @@ test_comments (void)
|
|
||||||
check_name ("top comment", comment, top_comment, 0);
|
|
||||||
g_free (comment);
|
|
||||||
|
|
||||||
+ g_key_file_remove_comment (keyfile, NULL, NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, NULL, NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_null (comment);
|
|
||||||
+
|
|
||||||
comment = g_key_file_get_comment (keyfile, "group1", "key2", &error);
|
|
||||||
check_no_error (&error);
|
|
||||||
check_name ("key comment", comment, key_comment, 0);
|
|
||||||
@@ -448,7 +456,25 @@ test_comments (void)
|
|
||||||
check_name ("group comment", comment, group_comment, 0);
|
|
||||||
g_free (comment);
|
|
||||||
|
|
||||||
+ g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/104");
|
|
||||||
+
|
|
||||||
+ /* check if comments above another group than the first one are properly removed */
|
|
||||||
+ g_key_file_remove_comment (keyfile, "group2", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "group2", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_null (comment);
|
|
||||||
+
|
|
||||||
comment = g_key_file_get_comment (keyfile, "group3", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ check_name ("group comment", comment, "", 0);
|
|
||||||
+ g_free (comment);
|
|
||||||
+
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "group4", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_null (comment);
|
|
||||||
+
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "group5", NULL, &error);
|
|
||||||
check_error (&error,
|
|
||||||
G_KEY_FILE_ERROR,
|
|
||||||
G_KEY_FILE_ERROR_GROUP_NOT_FOUND);
|
|
||||||
@@ -1321,9 +1347,16 @@ test_reload_idempotency (void)
|
|
||||||
"[fifth]\n";
|
|
||||||
GKeyFile *keyfile;
|
|
||||||
GError *error = NULL;
|
|
||||||
- gchar *data1, *data2;
|
|
||||||
+ gchar *data1, *data2, *comment;
|
|
||||||
gsize len1, len2;
|
|
||||||
|
|
||||||
+ const gchar *key_comment = " A random comment in the first group";
|
|
||||||
+ const gchar *top_comment = " Top comment\n\n First comment";
|
|
||||||
+ const gchar *group_comment_1 = top_comment;
|
|
||||||
+ const gchar *group_comment_2 = " Second comment - one line";
|
|
||||||
+ const gchar *group_comment_3 = " Third comment - two lines\n Third comment - two lines";
|
|
||||||
+ const gchar *group_comment_4 = "\n";
|
|
||||||
+
|
|
||||||
g_test_bug ("https://bugzilla.gnome.org/show_bug.cgi?id=420686");
|
|
||||||
|
|
||||||
/* check that we only insert a single new line between groups */
|
|
||||||
@@ -1347,6 +1380,44 @@ test_reload_idempotency (void)
|
|
||||||
|
|
||||||
data2 = g_key_file_to_data (keyfile, &len2, &error);
|
|
||||||
g_assert_nonnull (data2);
|
|
||||||
+
|
|
||||||
+ g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/2927");
|
|
||||||
+
|
|
||||||
+ /* check if comments are preserved on reload */
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "first", "anotherkey", &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_cmpstr (comment, ==, key_comment);
|
|
||||||
+ g_free (comment);
|
|
||||||
+
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, NULL, NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_cmpstr (comment, ==, top_comment);
|
|
||||||
+ g_free (comment);
|
|
||||||
+
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "first", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_cmpstr (comment, ==, group_comment_1);
|
|
||||||
+ g_free (comment);
|
|
||||||
+
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "second", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_cmpstr (comment, ==, group_comment_2);
|
|
||||||
+ g_free (comment);
|
|
||||||
+
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "third", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_cmpstr (comment, ==, group_comment_3);
|
|
||||||
+ g_free (comment);
|
|
||||||
+
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "fourth", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_cmpstr (comment, ==, group_comment_4);
|
|
||||||
+ g_free (comment);
|
|
||||||
+
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "fifth", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ g_assert_null (comment);
|
|
||||||
+
|
|
||||||
g_key_file_free (keyfile);
|
|
||||||
|
|
||||||
g_assert_cmpstr (data1, ==, data2);
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
|
|
||||||
@ -1,97 +0,0 @@
|
|||||||
From 51dfb3c229c0478b3615f486fbbc36de2586bd52 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Ga=C3=ABl=20Bonithon?= <gael@xfce.org>
|
|
||||||
Date: Thu, 13 Jul 2023 10:19:04 +0200
|
|
||||||
Subject: [PATCH] gkeyfile: Skip group comment when adding a new key to a group
|
|
||||||
|
|
||||||
An oversight in 86b4b045: since the comment of group N now consists of
|
|
||||||
the last null-key values of group N-1, these keys must obviously be
|
|
||||||
skipped when adding a new non-null key to group N-1.
|
|
||||||
|
|
||||||
Closes: #3047
|
|
||||||
Fixes: 86b4b0453ea3a814167d4a5f7a4031d467543716
|
|
||||||
---
|
|
||||||
glib/gkeyfile.c | 19 ++++++++++++++-----
|
|
||||||
glib/tests/keyfile.c | 9 +++++++++
|
|
||||||
2 files changed, 23 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
|
|
||||||
index 0e21ab4f14..4759051977 100644
|
|
||||||
--- a/glib/gkeyfile.c
|
|
||||||
+++ b/glib/gkeyfile.c
|
|
||||||
@@ -573,7 +573,8 @@ static void g_key_file_remove_key_value_pair_node (GKeyFile
|
|
||||||
|
|
||||||
static void g_key_file_add_key_value_pair (GKeyFile *key_file,
|
|
||||||
GKeyFileGroup *group,
|
|
||||||
- GKeyFileKeyValuePair *pair);
|
|
||||||
+ GKeyFileKeyValuePair *pair,
|
|
||||||
+ GList *sibling);
|
|
||||||
static void g_key_file_add_key (GKeyFile *key_file,
|
|
||||||
GKeyFileGroup *group,
|
|
||||||
const gchar *key,
|
|
||||||
@@ -1447,7 +1448,8 @@ g_key_file_parse_key_value_pair (GKeyFile *key_file,
|
|
||||||
pair->key = g_steal_pointer (&key);
|
|
||||||
pair->value = g_strndup (value_start, value_len);
|
|
||||||
|
|
||||||
- g_key_file_add_key_value_pair (key_file, key_file->current_group, pair);
|
|
||||||
+ g_key_file_add_key_value_pair (key_file, key_file->current_group, pair,
|
|
||||||
+ key_file->current_group->key_value_pairs);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (key);
|
|
||||||
@@ -4034,10 +4036,11 @@ g_key_file_remove_group (GKeyFile *key_file,
|
|
||||||
static void
|
|
||||||
g_key_file_add_key_value_pair (GKeyFile *key_file,
|
|
||||||
GKeyFileGroup *group,
|
|
||||||
- GKeyFileKeyValuePair *pair)
|
|
||||||
+ GKeyFileKeyValuePair *pair,
|
|
||||||
+ GList *sibling)
|
|
||||||
{
|
|
||||||
g_hash_table_replace (group->lookup_map, pair->key, pair);
|
|
||||||
- group->key_value_pairs = g_list_prepend (group->key_value_pairs, pair);
|
|
||||||
+ group->key_value_pairs = g_list_insert_before (group->key_value_pairs, sibling, pair);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
@@ -4047,12 +4050,18 @@ g_key_file_add_key (GKeyFile *key_file,
|
|
||||||
const gchar *value)
|
|
||||||
{
|
|
||||||
GKeyFileKeyValuePair *pair;
|
|
||||||
+ GList *lp;
|
|
||||||
|
|
||||||
pair = g_new (GKeyFileKeyValuePair, 1);
|
|
||||||
pair->key = g_strdup (key);
|
|
||||||
pair->value = g_strdup (value);
|
|
||||||
|
|
||||||
- g_key_file_add_key_value_pair (key_file, group, pair);
|
|
||||||
+ /* skip group comment */
|
|
||||||
+ lp = group->key_value_pairs;
|
|
||||||
+ while (lp != NULL && ((GKeyFileKeyValuePair *) lp->data)->key == NULL)
|
|
||||||
+ lp = lp->next;
|
|
||||||
+
|
|
||||||
+ g_key_file_add_key_value_pair (key_file, group, pair, lp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c
|
|
||||||
index 80cdc93d8f..2c8eca4ebc 100644
|
|
||||||
--- a/glib/tests/keyfile.c
|
|
||||||
+++ b/glib/tests/keyfile.c
|
|
||||||
@@ -456,6 +456,15 @@ test_comments (void)
|
|
||||||
check_name ("group comment", comment, group_comment, 0);
|
|
||||||
g_free (comment);
|
|
||||||
|
|
||||||
+ g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/3047");
|
|
||||||
+
|
|
||||||
+ /* check if adding a key to group N preserve group comment of group N+1 */
|
|
||||||
+ g_key_file_set_string (keyfile, "group1", "key5", "value5");
|
|
||||||
+ comment = g_key_file_get_comment (keyfile, "group2", NULL, &error);
|
|
||||||
+ check_no_error (&error);
|
|
||||||
+ check_name ("group comment", comment, group_comment, 0);
|
|
||||||
+ g_free (comment);
|
|
||||||
+
|
|
||||||
g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/104");
|
|
||||||
|
|
||||||
/* check if comments above another group than the first one are properly removed */
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
|
|
||||||
@ -1,120 +0,0 @@
|
|||||||
From 406f85a48f1ec41cda15ae617a979f7df749cb27 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Aleksei Rybalkin <aleksei@rybalkin.org>
|
|
||||||
Date: Sun, 20 Aug 2023 16:33:53 +0200
|
|
||||||
Subject: [PATCH 1/2] gregex: if JIT stack limit is reached, fall back to
|
|
||||||
interpretive matching
|
|
||||||
|
|
||||||
Conflict:Move large_test_string to fix declaration-after-statement
|
|
||||||
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/406f85a48f1ec41cda15ae617a979f7df749cb27
|
|
||||||
|
|
||||||
---
|
|
||||||
glib/gregex.c | 13 ++++++++++---
|
|
||||||
glib/tests/regex.c | 10 +++++++++-
|
|
||||||
2 files changed, 19 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/glib/gregex.c b/glib/gregex.c
|
|
||||||
index 5ce034db41..1b3ee02f30 100644
|
|
||||||
--- a/glib/gregex.c
|
|
||||||
+++ b/glib/gregex.c
|
|
||||||
@@ -484,8 +484,6 @@ translate_match_error (gint errcode)
|
|
||||||
/* not used by pcre2_match() */
|
|
||||||
break;
|
|
||||||
case PCRE2_ERROR_MATCHLIMIT:
|
|
||||||
- case PCRE2_ERROR_JIT_STACKLIMIT:
|
|
||||||
- return _("backtracking limit reached");
|
|
||||||
case PCRE2_ERROR_CALLOUT:
|
|
||||||
/* callouts are not implemented */
|
|
||||||
break;
|
|
||||||
@@ -1107,8 +1105,17 @@ g_match_info_next (GMatchInfo *match_info,
|
|
||||||
opts,
|
|
||||||
match_info->match_data,
|
|
||||||
match_info->match_context);
|
|
||||||
+ /* if the JIT stack limit was reached, fall back to non-JIT matching in
|
|
||||||
+ * the next conditional statement */
|
|
||||||
+ if (match_info->matches == PCRE2_ERROR_JIT_STACKLIMIT)
|
|
||||||
+ {
|
|
||||||
+ g_info ("PCRE2 JIT stack limit reached, falling back to "
|
|
||||||
+ "non-optimized matching.");
|
|
||||||
+ opts |= PCRE2_NO_JIT;
|
|
||||||
+ jit_status = JIT_STATUS_DISABLED;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
- else
|
|
||||||
+ if (jit_status != JIT_STATUS_ENABLED)
|
|
||||||
{
|
|
||||||
match_info->matches = pcre2_match (match_info->regex->pcre_re,
|
|
||||||
(PCRE2_SPTR8) match_info->string,
|
|
||||||
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
|
|
||||||
index 821fc59608..f18db483c2 100644
|
|
||||||
--- a/glib/tests/regex.c
|
|
||||||
+++ b/glib/tests/regex.c
|
|
||||||
@@ -51,8 +51,9 @@
|
|
||||||
/* A random value use to mark untouched integer variables. */
|
|
||||||
#define UNTOUCHED -559038737
|
|
||||||
|
|
||||||
-/* A length of the test string in JIT stack test */
|
|
||||||
+/* Lengths of test strings in JIT stack tests */
|
|
||||||
#define TEST_STRING_LEN 20000
|
|
||||||
+#define LARGE_TEST_STRING_LEN 200000
|
|
||||||
|
|
||||||
static gint total;
|
|
||||||
|
|
||||||
@@ -2485,6 +2486,7 @@ int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
char test_string[TEST_STRING_LEN];
|
|
||||||
+ char large_test_string[LARGE_TEST_STRING_LEN];
|
|
||||||
setlocale (LC_ALL, "");
|
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
|
||||||
@@ -2711,6 +2713,12 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
test_string[TEST_STRING_LEN - 1] = '\0';
|
|
||||||
TEST_MATCH_SIMPLE ("^(?:[ \t\n]|[^[:cntrl:]])*$", test_string, 0, 0, TRUE);
|
|
||||||
|
|
||||||
+ /* Test that gregex falls back to unoptimized matching when reaching the JIT
|
|
||||||
+ * compiler stack limit */
|
|
||||||
+ memset (large_test_string, '*', LARGE_TEST_STRING_LEN);
|
|
||||||
+ large_test_string[LARGE_TEST_STRING_LEN - 1] = '\0';
|
|
||||||
+ TEST_MATCH_SIMPLE ("^(?:[ \t\n]|[^[:cntrl:]])*$", large_test_string, 0, 0, TRUE);
|
|
||||||
+
|
|
||||||
/* TEST_MATCH(pattern, compile_opts, match_opts, string,
|
|
||||||
* string_len, start_position, match_opts2, expected) */
|
|
||||||
TEST_MATCH("a", 0, 0, "a", -1, 0, 0, TRUE);
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
|
|
||||||
|
|
||||||
From 986fa3fdad5155924b17dbde16811d017a6413da Mon Sep 17 00:00:00 2001
|
|
||||||
From: Philip Withnall <philip@tecnocode.co.uk>
|
|
||||||
Date: Mon, 21 Aug 2023 10:19:43 +0000
|
|
||||||
Subject: [PATCH 2/2] Apply 2 suggestion(s) to 1 file(s)
|
|
||||||
|
|
||||||
Conflict:NA
|
|
||||||
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/986fa3fdad5155924b17dbde16811d017a6413da
|
|
||||||
|
|
||||||
---
|
|
||||||
glib/gregex.c | 5 +++--
|
|
||||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/glib/gregex.c b/glib/gregex.c
|
|
||||||
index 1b3ee02f30..b37a5e04c7 100644
|
|
||||||
--- a/glib/gregex.c
|
|
||||||
+++ b/glib/gregex.c
|
|
||||||
@@ -1109,12 +1109,13 @@ g_match_info_next (GMatchInfo *match_info,
|
|
||||||
* the next conditional statement */
|
|
||||||
if (match_info->matches == PCRE2_ERROR_JIT_STACKLIMIT)
|
|
||||||
{
|
|
||||||
- g_info ("PCRE2 JIT stack limit reached, falling back to "
|
|
||||||
- "non-optimized matching.");
|
|
||||||
+ g_debug ("PCRE2 JIT stack limit reached, falling back to "
|
|
||||||
+ "non-optimized matching.");
|
|
||||||
opts |= PCRE2_NO_JIT;
|
|
||||||
jit_status = JIT_STATUS_DISABLED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+
|
|
||||||
if (jit_status != JIT_STATUS_ENABLED)
|
|
||||||
{
|
|
||||||
match_info->matches = pcre2_match (match_info->regex->pcre_re,
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
@ -1,166 +0,0 @@
|
|||||||
From 842a105464f6390a433da8791d7b19b65df16f47 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Aleksei Rybalkin <aleksei@rybalkin.org>
|
|
||||||
Date: Mon, 14 Aug 2023 20:32:48 +0200
|
|
||||||
Subject: [PATCH 1/2] gregex: remove redundant call to
|
|
||||||
enable_jit_with_match_options
|
|
||||||
|
|
||||||
There is no point to enable jit in g_regex_new, since JIT will be only
|
|
||||||
used when we do a first match, and at that point
|
|
||||||
enable_jit_with_match_options will be called again already and will
|
|
||||||
update the options set in g_regex_new. Instead just run it at first
|
|
||||||
match for the first time, to the same end result.
|
|
||||||
|
|
||||||
Conflict:NA
|
|
||||||
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/842a105464f6390a433da8791d7b19b65df16f47
|
|
||||||
|
|
||||||
---
|
|
||||||
glib/gregex.c | 1 -
|
|
||||||
1 file changed, 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/glib/gregex.c b/glib/gregex.c
|
|
||||||
index 39b9edeecd..f6b2b716fc 100644
|
|
||||||
--- a/glib/gregex.c
|
|
||||||
+++ b/glib/gregex.c
|
|
||||||
@@ -1764,7 +1764,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
regex->orig_compile_opts = compile_options;
|
|
||||||
regex->match_opts = pcre_match_options;
|
|
||||||
regex->orig_match_opts = match_options;
|
|
||||||
- regex->jit_status = enable_jit_with_match_options (regex, regex->match_opts);
|
|
||||||
|
|
||||||
return regex;
|
|
||||||
}
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
|
|
||||||
|
|
||||||
From c3ff5b8eb39f1ab31383604910ae12f325e5afee Mon Sep 17 00:00:00 2001
|
|
||||||
From: Aleksei Rybalkin <aleksei@rybalkin.org>
|
|
||||||
Date: Mon, 14 Aug 2023 20:41:40 +0200
|
|
||||||
Subject: [PATCH 2/2] gregex: set default max stack size for PCRE2 JIT compiler
|
|
||||||
to 512KiB
|
|
||||||
|
|
||||||
Previous default used was 32KiB (the library default) which caused some
|
|
||||||
complex patterns to fail, see #2824. The memory will not be allocated
|
|
||||||
unless used.
|
|
||||||
|
|
||||||
Conflict:Move test_string to fix declaration-after-statement
|
|
||||||
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/c3ff5b8eb39f1ab31383604910ae12f325e5afee
|
|
||||||
|
|
||||||
---
|
|
||||||
glib/gregex.c | 22 ++++++++++++++--------
|
|
||||||
glib/tests/regex.c | 9 +++++++++
|
|
||||||
2 files changed, 23 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/glib/gregex.c b/glib/gregex.c
|
|
||||||
index f6b2b716fc..5ce034db41 100644
|
|
||||||
--- a/glib/gregex.c
|
|
||||||
+++ b/glib/gregex.c
|
|
||||||
@@ -232,6 +232,7 @@ struct _GMatchInfo
|
|
||||||
gssize string_len; /* length of string, in bytes */
|
|
||||||
pcre2_match_context *match_context;
|
|
||||||
pcre2_match_data *match_data;
|
|
||||||
+ pcre2_jit_stack *jit_stack;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
@@ -896,22 +897,22 @@ recalc_match_offsets (GMatchInfo *match_info,
|
|
||||||
}
|
|
||||||
|
|
||||||
static JITStatus
|
|
||||||
-enable_jit_with_match_options (GRegex *regex,
|
|
||||||
+enable_jit_with_match_options (GMatchInfo *match_info,
|
|
||||||
uint32_t match_options)
|
|
||||||
{
|
|
||||||
gint retval;
|
|
||||||
uint32_t old_jit_options, new_jit_options;
|
|
||||||
|
|
||||||
- if (!(regex->orig_compile_opts & G_REGEX_OPTIMIZE))
|
|
||||||
+ if (!(match_info->regex->orig_compile_opts & G_REGEX_OPTIMIZE))
|
|
||||||
return JIT_STATUS_DISABLED;
|
|
||||||
|
|
||||||
- if (regex->jit_status == JIT_STATUS_DISABLED)
|
|
||||||
+ if (match_info->regex->jit_status == JIT_STATUS_DISABLED)
|
|
||||||
return JIT_STATUS_DISABLED;
|
|
||||||
|
|
||||||
if (match_options & G_REGEX_PCRE2_JIT_UNSUPPORTED_OPTIONS)
|
|
||||||
return JIT_STATUS_DISABLED;
|
|
||||||
|
|
||||||
- old_jit_options = regex->jit_options;
|
|
||||||
+ old_jit_options = match_info->regex->jit_options;
|
|
||||||
new_jit_options = old_jit_options | PCRE2_JIT_COMPLETE;
|
|
||||||
if (match_options & PCRE2_PARTIAL_HARD)
|
|
||||||
new_jit_options |= PCRE2_JIT_PARTIAL_HARD;
|
|
||||||
@@ -920,13 +921,16 @@ enable_jit_with_match_options (GRegex *regex,
|
|
||||||
|
|
||||||
/* no new options enabled */
|
|
||||||
if (new_jit_options == old_jit_options)
|
|
||||||
- return regex->jit_status;
|
|
||||||
+ return match_info->regex->jit_status;
|
|
||||||
|
|
||||||
- retval = pcre2_jit_compile (regex->pcre_re, new_jit_options);
|
|
||||||
+ retval = pcre2_jit_compile (match_info->regex->pcre_re, new_jit_options);
|
|
||||||
switch (retval)
|
|
||||||
{
|
|
||||||
case 0: /* JIT enabled successfully */
|
|
||||||
- regex->jit_options = new_jit_options;
|
|
||||||
+ match_info->regex->jit_options = new_jit_options;
|
|
||||||
+ /* Set min stack size for JIT to 32KiB and max to 512KiB */
|
|
||||||
+ match_info->jit_stack = pcre2_jit_stack_create (1 << 15, 1 << 19, NULL);
|
|
||||||
+ pcre2_jit_stack_assign (match_info->match_context, NULL, match_info->jit_stack);
|
|
||||||
return JIT_STATUS_ENABLED;
|
|
||||||
case PCRE2_ERROR_NOMEMORY:
|
|
||||||
g_debug ("JIT compilation was requested with G_REGEX_OPTIMIZE, "
|
|
||||||
@@ -1023,6 +1027,8 @@ g_match_info_unref (GMatchInfo *match_info)
|
|
||||||
g_regex_unref (match_info->regex);
|
|
||||||
if (match_info->match_context)
|
|
||||||
pcre2_match_context_free (match_info->match_context);
|
|
||||||
+ if (match_info->jit_stack)
|
|
||||||
+ pcre2_jit_stack_free (match_info->jit_stack);
|
|
||||||
if (match_info->match_data)
|
|
||||||
pcre2_match_data_free (match_info->match_data);
|
|
||||||
g_free (match_info->offsets);
|
|
||||||
@@ -1091,7 +1097,7 @@ g_match_info_next (GMatchInfo *match_info,
|
|
||||||
|
|
||||||
opts = match_info->regex->match_opts | match_info->match_opts;
|
|
||||||
|
|
||||||
- jit_status = enable_jit_with_match_options (match_info->regex, opts);
|
|
||||||
+ jit_status = enable_jit_with_match_options (match_info, opts);
|
|
||||||
if (jit_status == JIT_STATUS_ENABLED)
|
|
||||||
{
|
|
||||||
match_info->matches = pcre2_jit_match (match_info->regex->pcre_re,
|
|
||||||
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
|
|
||||||
index cf2bb8199d..821fc59608 100644
|
|
||||||
--- a/glib/tests/regex.c
|
|
||||||
+++ b/glib/tests/regex.c
|
|
||||||
@@ -51,6 +51,9 @@
|
|
||||||
/* A random value use to mark untouched integer variables. */
|
|
||||||
#define UNTOUCHED -559038737
|
|
||||||
|
|
||||||
+/* A length of the test string in JIT stack test */
|
|
||||||
+#define TEST_STRING_LEN 20000
|
|
||||||
+
|
|
||||||
static gint total;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
@@ -2481,6 +2484,7 @@ test_jit_unsupported_matching_options (void)
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
+ char test_string[TEST_STRING_LEN];
|
|
||||||
setlocale (LC_ALL, "");
|
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
|
||||||
@@ -2702,6 +2706,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
TEST_MATCH_SIMPLE("\\", "a", 0, 0, FALSE);
|
|
||||||
TEST_MATCH_SIMPLE("[", "", 0, 0, FALSE);
|
|
||||||
|
|
||||||
+ /* Test that JIT compiler has enough stack */
|
|
||||||
+ memset (test_string, '*', TEST_STRING_LEN);
|
|
||||||
+ test_string[TEST_STRING_LEN - 1] = '\0';
|
|
||||||
+ TEST_MATCH_SIMPLE ("^(?:[ \t\n]|[^[:cntrl:]])*$", test_string, 0, 0, TRUE);
|
|
||||||
+
|
|
||||||
/* TEST_MATCH(pattern, compile_opts, match_opts, string,
|
|
||||||
* string_len, start_position, match_opts2, expected) */
|
|
||||||
TEST_MATCH("a", 0, 0, "a", -1, 0, 0, TRUE);
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
Binary file not shown.
BIN
glib-2.78.3.tar.xz
Normal file
BIN
glib-2.78.3.tar.xz
Normal file
Binary file not shown.
33
glib2.spec
33
glib2.spec
@ -1,21 +1,14 @@
|
|||||||
Name: glib2
|
Name: glib2
|
||||||
Version: 2.76.4
|
Version: 2.78.3
|
||||||
Release: 3
|
Release: 1
|
||||||
Summary: The core library that forms the basis for projects such as GTK+ and GNOME
|
Summary: The core library that forms the basis for projects such as GTK+ and GNOME
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: https://www.gtk.org
|
URL: https://www.gtk.org
|
||||||
Source0: https://download.gnome.org/sources/glib/2.76/glib-%{version}.tar.xz
|
Source0: https://download.gnome.org/sources/glib/2.78/glib-%{version}.tar.xz
|
||||||
|
|
||||||
Patch1: gspawn-eperm.patch
|
Patch1: gspawn-eperm.patch
|
||||||
Patch6001: backport-gkeyfile-Fix-group-comment-management.patch
|
Patch2: backport-gmessages-fix-dropping-irrelevant-log-domains.patch
|
||||||
Patch6002: backport-gkeyfile-Ensure-we-don-t-add-extra-blank-line-above-new-group.patch
|
Patch3: backport-gutils-Fix-an-unlikely-minor-leak-in-g_build_user_data_dir.patch
|
||||||
Patch6003: backport-gkeyfile-Skip-group-comment-when-adding-a-new-key-to-a-group.patch
|
|
||||||
|
|
||||||
Patch6004: backport-gregex-set-default-max-stack-size-for-PCRE2-JIT-compiler-to-512KiB.patch
|
|
||||||
Patch6005: backport-gregex-if-JIT-stack-limit-is-reached-fall-back-to-interpretive-matching.patch
|
|
||||||
Patch6006: backport-Make-sure-the-GTask-is-freed-on-a-graceful-disconnect.patch
|
|
||||||
Patch6007: backport-gmessages-fix-dropping-irrelevant-log-domains.patch
|
|
||||||
Patch6008: backport-gutils-Fix-an-unlikely-minor-leak-in-g_build_user_data_dir.patch
|
|
||||||
|
|
||||||
BuildRequires: chrpath gcc gcc-c++ gettext perl-interpreter
|
BuildRequires: chrpath gcc gcc-c++ gettext perl-interpreter
|
||||||
BUildRequires: glibc-devel libattr-devel libselinux-devel meson
|
BUildRequires: glibc-devel libattr-devel libselinux-devel meson
|
||||||
@ -24,9 +17,6 @@ BuildRequires: pkgconfig(libpcre2-8) pkgconfig(mount) pkgconfig(zlib)
|
|||||||
BuildRequires: python3-devel
|
BuildRequires: python3-devel
|
||||||
%ifnarch i686
|
%ifnarch i686
|
||||||
BuildRequires: desktop-file-utils shared-mime-info gtk-doc
|
BuildRequires: desktop-file-utils shared-mime-info gtk-doc
|
||||||
%if %{?openEuler:1}0
|
|
||||||
BuildRequires: pkgconfig(sysprof-capture-4)
|
|
||||||
%endif
|
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
Provides: %{name}-fam = %{version}-%{release}
|
Provides: %{name}-fam = %{version}-%{release}
|
||||||
@ -57,9 +47,6 @@ Development files for the GLib library.
|
|||||||
%package static
|
%package static
|
||||||
Summary: glib static
|
Summary: glib static
|
||||||
Requires: pcre2-static
|
Requires: pcre2-static
|
||||||
%if %{?openEuler:1}0
|
|
||||||
Requires: sysprof-capture-static
|
|
||||||
%endif
|
|
||||||
Requires: %{name}-devel = %{version}-%{release}
|
Requires: %{name}-devel = %{version}-%{release}
|
||||||
Provides: %{name}-static = %{version}-%{release}
|
Provides: %{name}-static = %{version}-%{release}
|
||||||
Obsoletes: %{name}-static < %{version}-%{release}
|
Obsoletes: %{name}-static < %{version}-%{release}
|
||||||
@ -94,15 +81,12 @@ help document for the glib2 package.
|
|||||||
%build
|
%build
|
||||||
%meson --default-library=both -Ddtrace=true \
|
%meson --default-library=both -Ddtrace=true \
|
||||||
%ifnarch i686
|
%ifnarch i686
|
||||||
%if %{?openEuler:1}0
|
|
||||||
-Dsysprof=enabled \
|
|
||||||
%endif
|
|
||||||
-Dman=true -Dgtk_doc=true \
|
-Dman=true -Dgtk_doc=true \
|
||||||
%else
|
%else
|
||||||
-Dsysprof=disabled -Dman=false -Dgtk_doc=false \
|
-Dman=false -Dgtk_doc=false \
|
||||||
%endif
|
%endif
|
||||||
-Dsystemtap=true -Dinstalled_tests=true \
|
-Dsystemtap=true -Dinstalled_tests=true \
|
||||||
-Dglib_debug=disabled
|
-Dglib_debug=disabled -Dsysprof=disabled
|
||||||
|
|
||||||
%meson_build
|
%meson_build
|
||||||
find . -name *.dtrace-temp.c -exec rm -f {} \;
|
find . -name *.dtrace-temp.c -exec rm -f {} \;
|
||||||
@ -209,6 +193,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Feb 5 2024 hanhuihui <hanhuihui5@huawei.com> - 2.78.3-1
|
||||||
|
- Update to 2.78.3
|
||||||
|
|
||||||
* Thu Jan 11 2024 hanhuihui <hanhuihui5@huawei.com> - 2.76.4-3
|
* Thu Jan 11 2024 hanhuihui <hanhuihui5@huawei.com> - 2.76.4-3
|
||||||
- fix pcre2 error , memory leak and log domains error
|
- fix pcre2 error , memory leak and log domains error
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user