1From a164b49532957359c781ab56c3e1690f65f40788 Mon Sep 17 00:00:00 2001 2From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org> 3Date: Fri, 23 Sep 2022 14:48:07 +0200 4Subject: [PATCH] gregex: Allow G_REGEX_JAVASCRIPT_COMPAT in compile mask for 5 g_regex_new 6 7The flag is still ignored but this way we properly deprecate 8at compile time without raising an unexpected criticals at runtime: 9 10 g_regex_new: assertion '(compile_options & ~G_REGEX_COMPILE_MASK) == 0' failed 11 12and then failing to create the regex completely. 13 14Fixes 8d5a44dc8 ("replace pcre1 with pcre2") 15 16Conflict:NA 17Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/a164b49532957359c781ab56c3e1690f65f40788 18 19--- 20 glib/gregex.c | 5 ++++- 21 glib/tests/regex.c | 4 ++++ 22 2 files changed, 8 insertions(+), 1 deletion(-) 23 24diff --git a/glib/gregex.c b/glib/gregex.c 25index 220a1a11ac..6b22f1f151 100644 26--- a/glib/gregex.c 27+++ b/glib/gregex.c 28@@ -1684,7 +1684,10 @@ g_regex_new (const gchar *pattern, 29 30 g_return_val_if_fail (pattern != NULL, NULL); 31 g_return_val_if_fail (error == NULL || *error == NULL, NULL); 32- g_return_val_if_fail ((compile_options & ~G_REGEX_COMPILE_MASK) == 0, NULL); 33+G_GNUC_BEGIN_IGNORE_DEPRECATIONS 34+ g_return_val_if_fail ((compile_options & ~(G_REGEX_COMPILE_MASK | 35+ G_REGEX_JAVASCRIPT_COMPAT)) == 0, NULL); 36+G_GNUC_END_IGNORE_DEPRECATIONS 37 g_return_val_if_fail ((match_options & ~G_REGEX_MATCH_MASK) == 0, NULL); 38 39 if (g_once_init_enter (&initialised)) 40diff --git a/glib/tests/regex.c b/glib/tests/regex.c 41index 9803d49659..f2e1a04ada 100644 42--- a/glib/tests/regex.c 43+++ b/glib/tests/regex.c 44@@ -2542,6 +2542,10 @@ main (int argc, char *argv[]) 45 TEST_NEW_CHECK_FLAGS ("(*BSR_ANYCRLF)a", 0, 0, G_REGEX_BSR_ANYCRLF, 0); 46 TEST_NEW_CHECK_FLAGS ("(*BSR_UNICODE)a", 0, 0, 0 /* this is the default in GRegex */, 0); 47 TEST_NEW_CHECK_FLAGS ("(*NO_START_OPT)a", 0, 0, 0 /* not exposed in GRegex */, 0); 48+ /* Make sure we ignore deprecated G_REGEX_JAVASCRIPT_COMPAT */ 49+G_GNUC_BEGIN_IGNORE_DEPRECATIONS 50+ TEST_NEW_CHECK_FLAGS ("a", G_REGEX_JAVASCRIPT_COMPAT, 0, 0, 0); 51+G_GNUC_END_IGNORE_DEPRECATIONS 52 53 /* TEST_NEW_FAIL(pattern, compile_opts, expected_error) */ 54 TEST_NEW_FAIL("(", 0, G_REGEX_ERROR_UNMATCHED_PARENTHESIS); 55-- 56GitLab 57 58