!106 replace pcre1 with pcre2

From: @han_hui_hui 
Reviewed-by: @t_feng, @yanan-rock 
Signed-off-by: @t_feng, @yanan-rock
This commit is contained in:
openeuler-ci-bot 2022-09-05 09:26:20 +00:00 committed by Gitee
commit bb05de172e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
19 changed files with 6344 additions and 1 deletions

View File

@ -0,0 +1,228 @@
From 4f79f0712cd5c67301e60e758a2f6c60b44e7a0e Mon Sep 17 00:00:00 2001
From: Philip Withnall <pwithnall@endlessos.org>
Date: Mon, 28 Mar 2022 12:55:20 +0100
Subject: [PATCH] gversionmacros: Add version macros for GLib 2.74
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/4f79f0712cd5c67301e60e758a2f6c60b44e7a0e
---
docs/reference/gio/gio-docs.xml | 4 +++
docs/reference/glib/glib-docs.xml | 4 +++
docs/reference/glib/glib-sections.txt | 14 ++++++++
docs/reference/gobject/gobject-docs.xml | 4 +++
docs/reference/meson.build | 2 +-
glib/gversionmacros.h | 44 +++++++++++++++++++++++++
6 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/docs/reference/gio/gio-docs.xml b/docs/reference/gio/gio-docs.xml
index 76057e8978..bee46875ff 100644
--- a/docs/reference/gio/gio-docs.xml
+++ b/docs/reference/gio/gio-docs.xml
@@ -400,6 +400,10 @@
<title>Index of new symbols in 2.72</title>
<xi:include href="xml/api-index-2.72.xml"><xi:fallback /></xi:include>
</index>
+ <index id="api-index-2-74" role="2.74">
+ <title>Index of new symbols in 2.74</title>
+ <xi:include href="xml/api-index-2.74.xml"><xi:fallback /></xi:include>
+ </index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
diff --git a/docs/reference/glib/glib-docs.xml b/docs/reference/glib/glib-docs.xml
index e642f4e930..b3928257e4 100644
--- a/docs/reference/glib/glib-docs.xml
+++ b/docs/reference/glib/glib-docs.xml
@@ -296,6 +296,10 @@
<title>Index of new symbols in 2.72</title>
<xi:include href="xml/api-index-2.72.xml"><xi:fallback /></xi:include>
</index>
+ <index id="api-index-2-74" role="2.74">
+ <title>Index of new symbols in 2.74</title>
+ <xi:include href="xml/api-index-2.74.xml"><xi:fallback /></xi:include>
+ </index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 97dcf1f701..3532d28cb0 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -140,6 +140,7 @@ GLIB_VERSION_2_66
GLIB_VERSION_2_68
GLIB_VERSION_2_70
GLIB_VERSION_2_72
+GLIB_VERSION_2_74
GLIB_VERSION_CUR_STABLE
GLIB_VERSION_PREV_STABLE
GLIB_VERSION_MIN_REQUIRED
@@ -172,6 +173,7 @@ GLIB_AVAILABLE_ENUMERATOR_IN_2_66
GLIB_AVAILABLE_ENUMERATOR_IN_2_68
GLIB_AVAILABLE_ENUMERATOR_IN_2_70
GLIB_AVAILABLE_ENUMERATOR_IN_2_72
+GLIB_AVAILABLE_ENUMERATOR_IN_2_74
GLIB_AVAILABLE_IN_ALL
GLIB_AVAILABLE_IN_2_26
GLIB_AVAILABLE_IN_2_28
@@ -197,6 +199,7 @@ GLIB_AVAILABLE_IN_2_66
GLIB_AVAILABLE_IN_2_68
GLIB_AVAILABLE_IN_2_70
GLIB_AVAILABLE_IN_2_72
+GLIB_AVAILABLE_IN_2_74
GLIB_AVAILABLE_MACRO_IN_2_26
GLIB_AVAILABLE_MACRO_IN_2_28
GLIB_AVAILABLE_MACRO_IN_2_30
@@ -221,6 +224,7 @@ GLIB_AVAILABLE_MACRO_IN_2_66
GLIB_AVAILABLE_MACRO_IN_2_68
GLIB_AVAILABLE_MACRO_IN_2_70
GLIB_AVAILABLE_MACRO_IN_2_72
+GLIB_AVAILABLE_MACRO_IN_2_74
GLIB_AVAILABLE_STATIC_INLINE_IN_2_44
GLIB_AVAILABLE_STATIC_INLINE_IN_2_60
GLIB_AVAILABLE_STATIC_INLINE_IN_2_62
@@ -229,6 +233,7 @@ GLIB_AVAILABLE_STATIC_INLINE_IN_2_66
GLIB_AVAILABLE_STATIC_INLINE_IN_2_68
GLIB_AVAILABLE_STATIC_INLINE_IN_2_70
GLIB_AVAILABLE_STATIC_INLINE_IN_2_72
+GLIB_AVAILABLE_STATIC_INLINE_IN_2_74
GLIB_AVAILABLE_TYPE_IN_2_26
GLIB_AVAILABLE_TYPE_IN_2_28
GLIB_AVAILABLE_TYPE_IN_2_30
@@ -253,6 +258,7 @@ GLIB_AVAILABLE_TYPE_IN_2_66
GLIB_AVAILABLE_TYPE_IN_2_68
GLIB_AVAILABLE_TYPE_IN_2_70
GLIB_AVAILABLE_TYPE_IN_2_72
+GLIB_AVAILABLE_TYPE_IN_2_74
GLIB_DEPRECATED_ENUMERATOR
GLIB_DEPRECATED_ENUMERATOR_FOR
GLIB_DEPRECATED_ENUMERATOR_IN_2_26
@@ -303,6 +309,8 @@ GLIB_DEPRECATED_ENUMERATOR_IN_2_70
GLIB_DEPRECATED_ENUMERATOR_IN_2_70_FOR
GLIB_DEPRECATED_ENUMERATOR_IN_2_72
GLIB_DEPRECATED_ENUMERATOR_IN_2_72_FOR
+GLIB_DEPRECATED_ENUMERATOR_IN_2_74
+GLIB_DEPRECATED_ENUMERATOR_IN_2_74_FOR
GLIB_DEPRECATED_IN_2_26
GLIB_DEPRECATED_IN_2_26_FOR
GLIB_DEPRECATED_IN_2_28
@@ -351,6 +359,8 @@ GLIB_DEPRECATED_IN_2_70
GLIB_DEPRECATED_IN_2_70_FOR
GLIB_DEPRECATED_IN_2_72
GLIB_DEPRECATED_IN_2_72_FOR
+GLIB_DEPRECATED_IN_2_74
+GLIB_DEPRECATED_IN_2_74_FOR
GLIB_DEPRECATED_MACRO
GLIB_DEPRECATED_MACRO_FOR
GLIB_DEPRECATED_MACRO_IN_2_26
@@ -401,6 +411,8 @@ GLIB_DEPRECATED_MACRO_IN_2_70
GLIB_DEPRECATED_MACRO_IN_2_70_FOR
GLIB_DEPRECATED_MACRO_IN_2_72
GLIB_DEPRECATED_MACRO_IN_2_72_FOR
+GLIB_DEPRECATED_MACRO_IN_2_74
+GLIB_DEPRECATED_MACRO_IN_2_74_FOR
GLIB_DEPRECATED_TYPE
GLIB_DEPRECATED_TYPE_FOR
GLIB_DEPRECATED_TYPE_IN_2_26
@@ -451,6 +463,8 @@ GLIB_DEPRECATED_TYPE_IN_2_70
GLIB_DEPRECATED_TYPE_IN_2_70_FOR
GLIB_DEPRECATED_TYPE_IN_2_72
GLIB_DEPRECATED_TYPE_IN_2_72_FOR
+GLIB_DEPRECATED_TYPE_IN_2_74
+GLIB_DEPRECATED_TYPE_IN_2_74_FOR
GLIB_VERSION_CUR_STABLE
GLIB_VERSION_PREV_STABLE
</SECTION>
diff --git a/docs/reference/gobject/gobject-docs.xml b/docs/reference/gobject/gobject-docs.xml
index aa5a9c7220..bfab048372 100644
--- a/docs/reference/gobject/gobject-docs.xml
+++ b/docs/reference/gobject/gobject-docs.xml
@@ -218,6 +218,10 @@
<title>Index of new symbols in 2.72</title>
<xi:include href="xml/api-index-2.72.xml"><xi:fallback /></xi:include>
</index>
+ <index id="api-index-2-74" role="2.74">
+ <title>Index of new symbols in 2.74</title>
+ <xi:include href="xml/api-index-2.74.xml"><xi:fallback /></xi:include>
+ </index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index 8128e21bf2..1bc97a2f6e 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -7,7 +7,7 @@
stable_2_series_versions = [
'26', '28', '30', '32', '34', '36', '38',
'40', '42', '44', '46', '48', '50', '52', '54', '56', '58',
- '60', '62', '64', '66', '68', '70', '72',
+ '60', '62', '64', '66', '68', '70', '72', '74',
]
ignore_decorators = [
diff --git a/glib/gversionmacros.h b/glib/gversionmacros.h
index e08c809019..143e048241 100644
--- a/glib/gversionmacros.h
+++ b/glib/gversionmacros.h
@@ -275,6 +275,16 @@
*/
#define GLIB_VERSION_2_72 (G_ENCODE_VERSION (2, 72))
+/**
+ * GLIB_VERSION_2_74:
+ *
+ * A macro that evaluates to the 2.74 version of GLib, in a format
+ * that can be used by the C pre-processor.
+ *
+ * Since: 2.74
+ */
+#define GLIB_VERSION_2_74 (G_ENCODE_VERSION (2, 74))
+
/**
* GLIB_VERSION_CUR_STABLE:
*
@@ -1164,4 +1174,38 @@
# define GLIB_AVAILABLE_TYPE_IN_2_72
#endif
+#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_74
+# define GLIB_DEPRECATED_IN_2_74 GLIB_DEPRECATED
+# define GLIB_DEPRECATED_IN_2_74_FOR(f) GLIB_DEPRECATED_FOR(f)
+# define GLIB_DEPRECATED_MACRO_IN_2_74 GLIB_DEPRECATED_MACRO
+# define GLIB_DEPRECATED_MACRO_IN_2_74_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f)
+# define GLIB_DEPRECATED_ENUMERATOR_IN_2_74 GLIB_DEPRECATED_ENUMERATOR
+# define GLIB_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f)
+# define GLIB_DEPRECATED_TYPE_IN_2_74 GLIB_DEPRECATED_TYPE
+# define GLIB_DEPRECATED_TYPE_IN_2_74_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f)
+#else
+# define GLIB_DEPRECATED_IN_2_74 _GLIB_EXTERN
+# define GLIB_DEPRECATED_IN_2_74_FOR(f) _GLIB_EXTERN
+# define GLIB_DEPRECATED_MACRO_IN_2_74
+# define GLIB_DEPRECATED_MACRO_IN_2_74_FOR(f)
+# define GLIB_DEPRECATED_ENUMERATOR_IN_2_74
+# define GLIB_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f)
+# define GLIB_DEPRECATED_TYPE_IN_2_74
+# define GLIB_DEPRECATED_TYPE_IN_2_74_FOR(f)
+#endif
+
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_74
+# define GLIB_AVAILABLE_IN_2_74 GLIB_UNAVAILABLE(2, 74)
+# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_74 GLIB_UNAVAILABLE_STATIC_INLINE(2, 74)
+# define GLIB_AVAILABLE_MACRO_IN_2_74 GLIB_UNAVAILABLE_MACRO(2, 74)
+# define GLIB_AVAILABLE_ENUMERATOR_IN_2_74 GLIB_UNAVAILABLE_ENUMERATOR(2, 74)
+# define GLIB_AVAILABLE_TYPE_IN_2_74 GLIB_UNAVAILABLE_TYPE(2, 74)
+#else
+# define GLIB_AVAILABLE_IN_2_74 _GLIB_EXTERN
+# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_74
+# define GLIB_AVAILABLE_MACRO_IN_2_74
+# define GLIB_AVAILABLE_ENUMERATOR_IN_2_74
+# define GLIB_AVAILABLE_TYPE_IN_2_74
+#endif
+
#endif /* __G_VERSION_MACROS_H__ */
--
GitLab

View File

@ -0,0 +1,58 @@
From cef780e9ef86b1d9545db892c6b8340488da21d9 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 23 Jun 2022 10:12:44 +0100
Subject: [PATCH] giochannel: Add G_IO_FLAG_NONE
This makes the state where no flags are set a bit more self-documenting.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/cef780e9ef86b1d9545db892c6b8340488da21d9
---
glib/giochannel.c | 1 +
glib/giochannel.h | 1 +
glib/giounix.c | 2 +-
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/glib/giochannel.c b/glib/giochannel.c
index 6fec45f66d..25baf42c9a 100644
--- a/glib/giochannel.c
+++ b/glib/giochannel.c
@@ -946,6 +946,7 @@ g_io_channel_get_line_term (GIOChannel *channel,
**/
/**
* GIOFlags:
+ * @G_IO_FLAG_NONE: no special flags set. Since: 2.74
* @G_IO_FLAG_APPEND: turns on append mode, corresponds to %O_APPEND
* (see the documentation of the UNIX open() syscall)
* @G_IO_FLAG_NONBLOCK: turns on nonblocking mode, corresponds to
diff --git a/glib/giochannel.h b/glib/giochannel.h
index 5a13449d58..dee3d7d055 100644
--- a/glib/giochannel.h
+++ b/glib/giochannel.h
@@ -85,6 +85,7 @@ typedef enum
typedef enum
{
+ G_IO_FLAG_NONE GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0,
G_IO_FLAG_APPEND = 1 << 0,
G_IO_FLAG_NONBLOCK = 1 << 1,
G_IO_FLAG_IS_READABLE = 1 << 2, /* Read only flag */
diff --git a/glib/giounix.c b/glib/giounix.c
index b6345b6c68..067cecf9ac 100644
--- a/glib/giounix.c
+++ b/glib/giounix.c
@@ -400,7 +400,7 @@ g_io_unix_set_flags (GIOChannel *channel,
static GIOFlags
g_io_unix_get_flags (GIOChannel *channel)
{
- GIOFlags flags = 0;
+ GIOFlags flags = G_IO_FLAG_NONE;
glong fcntl_flags;
GIOUnixChannel *unix_channel = (GIOUnixChannel *) channel;
--
GitLab

View File

@ -0,0 +1,82 @@
From f59e02a1439c70616547d51abf0a6da33e095e80 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 31 Mar 2022 14:28:56 +0100
Subject: [PATCH] gioenums: Add G_TLS_CERTIFICATE_FLAGS_NONE
This makes the absence of flags (in other words, a valid certificate)
more self-documenting.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/f59e02a1439c70616547d51abf0a6da33e095e80
---
gio/gdtlsclientconnection.c | 2 +-
gio/gioenums.h | 2 ++
gio/gtlscertificate.c | 2 ++
gio/gtlsclientconnection.c | 2 +-
4 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gio/gdtlsclientconnection.c b/gio/gdtlsclientconnection.c
index 74cce7572f..403c8b74d0 100644
--- a/gio/gdtlsclientconnection.c
+++ b/gio/gdtlsclientconnection.c
@@ -191,7 +191,7 @@ g_dtls_client_connection_new (GDatagramBased *base_socket,
GTlsCertificateFlags
g_dtls_client_connection_get_validation_flags (GDtlsClientConnection *conn)
{
- GTlsCertificateFlags flags = 0;
+ GTlsCertificateFlags flags = G_TLS_CERTIFICATE_FLAGS_NONE;
g_return_val_if_fail (G_IS_DTLS_CLIENT_CONNECTION (conn), 0);
diff --git a/gio/gioenums.h b/gio/gioenums.h
index 0d27c15a2b..deacd62206 100644
--- a/gio/gioenums.h
+++ b/gio/gioenums.h
@@ -1578,6 +1578,7 @@ typedef enum {
/**
* GTlsCertificateFlags:
+ * @G_TLS_CERTIFICATE_FLAGS_NONE: No flags. Since: 2.74
* @G_TLS_CERTIFICATE_UNKNOWN_CA: The signing certificate authority is
* not known.
* @G_TLS_CERTIFICATE_BAD_IDENTITY: The certificate does not match the
@@ -1609,6 +1610,7 @@ typedef enum {
* Since: 2.28
*/
typedef enum {
+ G_TLS_CERTIFICATE_FLAGS_NONE GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0,
G_TLS_CERTIFICATE_UNKNOWN_CA = (1 << 0),
G_TLS_CERTIFICATE_BAD_IDENTITY = (1 << 1),
G_TLS_CERTIFICATE_NOT_ACTIVATED = (1 << 2),
diff --git a/gio/gtlscertificate.c b/gio/gtlscertificate.c
index ca09b180ae..e97b8ac144 100644
--- a/gio/gtlscertificate.c
+++ b/gio/gtlscertificate.c
@@ -1121,6 +1121,8 @@ g_tls_certificate_get_issuer (GTlsCertificate *cert)
* check a certificate against a CA that is not part of the system
* CA database.
*
+ * If @cert is valid, %G_TLS_CERTIFICATE_FLAGS_NONE is returned.
+ *
* If @identity is not %NULL, @cert's name(s) will be compared against
* it, and %G_TLS_CERTIFICATE_BAD_IDENTITY will be set in the return
* value if it does not match. If @identity is %NULL, that bit will
diff --git a/gio/gtlsclientconnection.c b/gio/gtlsclientconnection.c
index a6dc897f9f..e6c77b681d 100644
--- a/gio/gtlsclientconnection.c
+++ b/gio/gtlsclientconnection.c
@@ -213,7 +213,7 @@ g_tls_client_connection_new (GIOStream *base_io_stream,
GTlsCertificateFlags
g_tls_client_connection_get_validation_flags (GTlsClientConnection *conn)
{
- GTlsCertificateFlags flags = 0;
+ GTlsCertificateFlags flags = G_TLS_CERTIFICATE_FLAGS_NONE;
g_return_val_if_fail (G_IS_TLS_CLIENT_CONNECTION (conn), 0);
--
GitLab

View File

@ -0,0 +1,53 @@
From cc528f6c2e336a3484c920fe2d11337388829dbe Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 23 Jun 2022 10:09:15 +0100
Subject: [PATCH] giomodule test: Don't pass a magic number to
g_test_trap_subprocess()
This worked, but seems like bad style.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/cc528f6c2e336a3484c920fe2d11337388829dbe
---
gio/tests/giomodule.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/gio/tests/giomodule.c b/gio/tests/giomodule.c
index b4923eeefd..4ea6efebd1 100644
--- a/gio/tests/giomodule.c
+++ b/gio/tests/giomodule.c
@@ -80,6 +80,10 @@ test_extension_point (void)
g_assert (g_io_extension_get_priority (ext) == 10);
}
+#define INHERIT_ALL (G_TEST_SUBPROCESS_INHERIT_STDIN | \
+ G_TEST_SUBPROCESS_INHERIT_STDOUT | \
+ G_TEST_SUBPROCESS_INHERIT_STDERR)
+
static void
test_module_scan_all (void)
{
@@ -105,7 +109,7 @@ test_module_scan_all (void)
g_assert_cmpstr (g_io_extension_get_name (ext), ==, "test-a");
return;
}
- g_test_trap_subprocess (NULL, 0, 7);
+ g_test_trap_subprocess (NULL, 0, INHERIT_ALL);
g_test_trap_assert_passed ();
}
@@ -136,7 +140,7 @@ test_module_scan_all_with_scope (void)
g_io_module_scope_free (scope);
return;
}
- g_test_trap_subprocess (NULL, 0, 7);
+ g_test_trap_subprocess (NULL, 0, INHERIT_ALL);
g_test_trap_assert_passed ();
}
--
GitLab

View File

@ -0,0 +1,157 @@
From 0d4e401ede234a3ce25e6098776ef5e966ad080b Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 23 Jun 2022 10:18:08 +0100
Subject: [PATCH] gmarkup: Add G_MARKUP_PARSE_FLAGS_NONE
Signed-off-by: Simon McVittie <smcv@collabora.com>
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/0d4e401ede234a3ce25e6098776ef5e966ad080b
---
gio/gcontenttype.c | 3 ++-
glib/gbookmarkfile.c | 2 +-
glib/gmarkup.h | 2 ++
glib/tests/autoptr.c | 4 +++-
glib/tests/markup-collect.c | 4 +++-
glib/tests/markup-parse.c | 2 +-
glib/tests/markup-subparser.c | 3 ++-
glib/tests/markup.c | 3 ++-
gobject/tests/boxed.c | 3 ++-
9 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/gio/gcontenttype.c b/gio/gcontenttype.c
index 190c5d7bf8..170bb43419 100644
--- a/gio/gcontenttype.c
+++ b/gio/gcontenttype.c
@@ -435,7 +435,8 @@ load_comment_for_mime_helper (const char *dir,
if (!res)
return NULL;
- context = g_markup_parse_context_new (&parser, 0, &parse_data, NULL);
+ context = g_markup_parse_context_new (&parser, G_MARKUP_PARSE_FLAGS_NONE,
+ &parse_data, NULL);
res = g_markup_parse_context_parse (context, data, len, NULL);
g_free (data);
g_markup_parse_context_free (context);
diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c
index 5ae1ad6642..a45f939b0f 100644
--- a/glib/gbookmarkfile.c
+++ b/glib/gbookmarkfile.c
@@ -1510,7 +1510,7 @@ g_bookmark_file_parse (GBookmarkFile *bookmark,
parse_data->bookmark_file = bookmark;
context = g_markup_parse_context_new (&markup_parser,
- 0,
+ G_MARKUP_PARSE_FLAGS_NONE,
parse_data,
(GDestroyNotify) parse_data_free);
diff --git a/glib/gmarkup.h b/glib/gmarkup.h
index ae6976b154..6224d13431 100644
--- a/glib/gmarkup.h
+++ b/glib/gmarkup.h
@@ -76,6 +76,7 @@ GQuark g_markup_error_quark (void);
/**
* GMarkupParseFlags:
+ * @G_MARKUP_PARSE_FLAGS_NONE: No special behaviour. Since: 2.74
* @G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG: flag you should not use
* @G_MARKUP_TREAT_CDATA_AS_TEXT: When this flag is set, CDATA marked
* sections are not passed literally to the @passthrough function of
@@ -96,6 +97,7 @@ GQuark g_markup_error_quark (void);
*/
typedef enum
{
+ G_MARKUP_PARSE_FLAGS_NONE GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0, /*< nick=none >*/
G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0,
G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1,
G_MARKUP_PREFIX_ERROR_POSITION = 1 << 2,
diff --git a/glib/tests/autoptr.c b/glib/tests/autoptr.c
index 1b2dd7b094..035d3f6133 100644
--- a/glib/tests/autoptr.c
+++ b/glib/tests/autoptr.c
@@ -243,7 +243,9 @@ static GMarkupParser parser = {
static void
test_g_markup_parse_context (void)
{
- g_autoptr(GMarkupParseContext) val = g_markup_parse_context_new (&parser, 0, NULL, NULL);
+ g_autoptr(GMarkupParseContext) val = g_markup_parse_context_new (&parser,
+ G_MARKUP_PARSE_FLAGS_NONE,
+ NULL, NULL);
g_assert_nonnull (val);
}
diff --git a/glib/tests/markup-collect.c b/glib/tests/markup-collect.c
index 04b814b6cc..fa89b0ca61 100644
--- a/glib/tests/markup-collect.c
+++ b/glib/tests/markup-collect.c
@@ -206,7 +206,9 @@ test_cleanup (void)
if (!g_test_undefined ())
return;
- context = g_markup_parse_context_new (&cleanup_parser, 0, NULL, NULL);
+ context = g_markup_parse_context_new (&cleanup_parser,
+ G_MARKUP_PARSE_FLAGS_NONE, NULL,
+ NULL);
g_markup_parse_context_parse (context, XML, -1, NULL);
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
diff --git a/glib/tests/markup-parse.c b/glib/tests/markup-parse.c
index 00742d7459..1945bc39bd 100644
--- a/glib/tests/markup-parse.c
+++ b/glib/tests/markup-parse.c
@@ -314,7 +314,7 @@ main (int argc, char *argv[])
if (argc > 1)
{
gint arg = 1;
- GMarkupParseFlags flags = 0;
+ GMarkupParseFlags flags = G_MARKUP_PARSE_FLAGS_NONE;
if (strcmp (argv[1], "--cdata-as-text") == 0)
{
diff --git a/glib/tests/markup-subparser.c b/glib/tests/markup-subparser.c
index 71b9ac6af5..4b1bc50185 100644
--- a/glib/tests/markup-subparser.c
+++ b/glib/tests/markup-subparser.c
@@ -289,7 +289,8 @@ test (gconstpointer user_data)
error = NULL;
string = g_string_new (NULL);
- ctx = g_markup_parse_context_new (&parser, 0, string, NULL);
+ ctx = g_markup_parse_context_new (&parser, G_MARKUP_PARSE_FLAGS_NONE,
+ string, NULL);
result = g_markup_parse_context_parse (ctx, tc->markup,
strlen (tc->markup), &error);
if (result)
diff --git a/glib/tests/markup.c b/glib/tests/markup.c
index 71f9ff16c3..6fced87d49 100644
--- a/glib/tests/markup.c
+++ b/glib/tests/markup.c
@@ -80,7 +80,8 @@ test_markup_stack (void)
gboolean res;
GError *error = NULL;
- context = g_markup_parse_context_new (&parser, 0, &data, NULL);
+ context = g_markup_parse_context_new (&parser, G_MARKUP_PARSE_FLAGS_NONE,
+ &data, NULL);
res = g_markup_parse_context_parse (context, content, -1, &error);
g_assert (res);
g_assert_no_error (error);
diff --git a/gobject/tests/boxed.c b/gobject/tests/boxed.c
index f961a2f87b..c2d091c54a 100644
--- a/gobject/tests/boxed.c
+++ b/gobject/tests/boxed.c
@@ -560,7 +560,8 @@ test_boxed_markup (void)
g_value_init (&value, G_TYPE_MARKUP_PARSE_CONTEXT);
g_assert (G_VALUE_HOLDS_BOXED (&value));
- c = g_markup_parse_context_new (&parser, 0, NULL, NULL);
+ c = g_markup_parse_context_new (&parser, G_MARKUP_PARSE_FLAGS_NONE,
+ NULL, NULL);
g_value_take_boxed (&value, c);
c2 = g_value_get_boxed (&value);
--
GitLab

View File

@ -0,0 +1,679 @@
From 879b9cd669f03ecd69f0c6913f06275d9c1973c6 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 23 Jun 2022 10:34:15 +0100
Subject: [PATCH] gregex: Add G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT
Signed-off-by: Simon McVittie <smcv@collabora.com>
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/879b9cd669f03ecd69f0c6913f06275d9c1973c6
---
gio/gsettingsschema.c | 12 ++--
glib/gregex.c | 8 +--
glib/gregex.h | 4 ++
glib/tests/autoptr.c | 6 +-
glib/tests/regex.c | 143 +++++++++++++++++++++---------------------
gobject/tests/boxed.c | 4 +-
6 files changed, 94 insertions(+), 83 deletions(-)
diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c
index 6ac1dfffa0..fb3bb70122 100644
--- a/gio/gsettingsschema.c
+++ b/gio/gsettingsschema.c
@@ -579,10 +579,14 @@ normalise_whitespace (const gchar *orig)
{
GRegex *s;
- cleanup[0] = g_regex_new ("^\\s+", 0, 0, 0);
- cleanup[1] = g_regex_new ("\\s+$", 0, 0, 0);
- cleanup[2] = g_regex_new ("\\s+", 0, 0, 0);
- s = g_regex_new ("\\n\\s*\\n+", 0, 0, 0);
+ cleanup[0] = g_regex_new ("^\\s+", G_REGEX_DEFAULT,
+ G_REGEX_MATCH_DEFAULT, NULL);
+ cleanup[1] = g_regex_new ("\\s+$", G_REGEX_DEFAULT,
+ G_REGEX_MATCH_DEFAULT, NULL);
+ cleanup[2] = g_regex_new ("\\s+", G_REGEX_DEFAULT,
+ G_REGEX_MATCH_DEFAULT, NULL);
+ s = g_regex_new ("\\n\\s*\\n+", G_REGEX_DEFAULT,
+ G_REGEX_MATCH_DEFAULT, NULL);
g_once_init_leave (&splitter, s);
}
diff --git a/glib/gregex.c b/glib/gregex.c
index 2fa0698911..5254d8d282 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -1653,7 +1653,7 @@ g_regex_match_simple (const gchar *pattern,
GRegex *regex;
gboolean result;
- regex = g_regex_new (pattern, compile_options, 0, NULL);
+ regex = g_regex_new (pattern, compile_options, G_REGEX_MATCH_DEFAULT, NULL);
if (!regex)
return FALSE;
result = g_regex_match_full (regex, string, -1, 0, match_options, NULL, NULL);
@@ -1692,7 +1692,7 @@ g_regex_match_simple (const gchar *pattern,
* GRegex *regex;
* GMatchInfo *match_info;
*
- * regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
+ * regex = g_regex_new ("[A-Z]+", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
* g_regex_match (regex, string, 0, &match_info);
* while (g_match_info_matches (match_info))
* {
@@ -1768,7 +1768,7 @@ g_regex_match (const GRegex *regex,
* GMatchInfo *match_info;
* GError *error = NULL;
*
- * regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
+ * regex = g_regex_new ("[A-Z]+", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
* g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
* while (g_match_info_matches (match_info))
* {
@@ -2949,7 +2949,7 @@ g_regex_replace_literal (const GRegex *regex,
* g_hash_table_insert (h, "3", "THREE");
* g_hash_table_insert (h, "4", "FOUR");
*
- * reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
+ * reg = g_regex_new ("1|2|3|4", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
* res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
* g_hash_table_destroy (h);
*
diff --git a/glib/gregex.h b/glib/gregex.h
index 89c8485471..3fd61806f7 100644
--- a/glib/gregex.h
+++ b/glib/gregex.h
@@ -218,6 +218,7 @@ GQuark g_regex_error_quark (void);
/**
* GRegexCompileFlags:
+ * @G_REGEX_DEFAULT: No special options set. Since: 2.74
* @G_REGEX_CASELESS: Letters in the pattern match both upper- and
* lowercase letters. This option can be changed within a pattern
* by a "(?i)" option setting.
@@ -297,6 +298,7 @@ GQuark g_regex_error_quark (void);
*/
typedef enum
{
+ G_REGEX_DEFAULT GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0,
G_REGEX_CASELESS = 1 << 0,
G_REGEX_MULTILINE = 1 << 1,
G_REGEX_DOTALL = 1 << 2,
@@ -319,6 +321,7 @@ typedef enum
/**
* GRegexMatchFlags:
+ * @G_REGEX_MATCH_DEFAULT: No special options set. Since: 2.74
* @G_REGEX_MATCH_ANCHORED: The pattern is forced to be "anchored", that is,
* it is constrained to match only at the first matching point in the
* string that is being searched. This effect can also be achieved by
@@ -387,6 +390,7 @@ typedef enum
* adding a new flag. */
typedef enum
{
+ G_REGEX_MATCH_DEFAULT GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0,
G_REGEX_MATCH_ANCHORED = 1 << 4,
G_REGEX_MATCH_NOTBOL = 1 << 7,
G_REGEX_MATCH_NOTEOL = 1 << 8,
diff --git a/glib/tests/autoptr.c b/glib/tests/autoptr.c
index 035d3f6133..c5d9877bbe 100644
--- a/glib/tests/autoptr.c
+++ b/glib/tests/autoptr.c
@@ -296,14 +296,16 @@ test_g_rand (void)
static void
test_g_regex (void)
{
- g_autoptr(GRegex) val = g_regex_new (".*", 0, 0, NULL);
+ g_autoptr(GRegex) val = g_regex_new (".*", G_REGEX_DEFAULT,
+ G_REGEX_MATCH_DEFAULT, NULL);
g_assert_nonnull (val);
}
static void
test_g_match_info (void)
{
- g_autoptr(GRegex) regex = g_regex_new (".*", 0, 0, NULL);
+ g_autoptr(GRegex) regex = g_regex_new (".*", G_REGEX_DEFAULT,
+ G_REGEX_MATCH_DEFAULT, NULL);
g_autoptr(GMatchInfo) match = NULL;
if (!g_regex_match (regex, "hello", 0, &match))
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index e19f975875..c39d640fa2 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -286,7 +286,7 @@ test_match_next (gconstpointer d)
GSList *matches;
GSList *l_exp, *l_match;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert (regex != NULL);
@@ -478,7 +478,7 @@ test_match_count (gconstpointer d)
GMatchInfo *match_info;
gint count;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert (regex != NULL);
@@ -515,7 +515,7 @@ test_partial (gconstpointer d)
GRegex *regex;
GMatchInfo *match_info;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert (regex != NULL);
@@ -567,7 +567,7 @@ test_sub_pattern (gconstpointer d)
gchar *sub_expr;
gint start = UNTOUCHED, end = UNTOUCHED;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert (regex != NULL);
@@ -622,7 +622,7 @@ test_named_sub_pattern (gconstpointer d)
gint start = UNTOUCHED, end = UNTOUCHED;
gchar *sub_expr;
- regex = g_regex_new (data->pattern, data->flags, 0, NULL);
+ regex = g_regex_new (data->pattern, data->flags, G_REGEX_MATCH_DEFAULT, NULL);
g_assert (regex != NULL);
@@ -694,7 +694,7 @@ test_fetch_all (gconstpointer d)
gint match_count;
gint i;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert (regex != NULL);
@@ -788,7 +788,8 @@ test_split_simple (gconstpointer d)
gint token_count;
gint i;
- tokens = g_regex_split_simple (data->pattern, data->string, 0, 0);
+ tokens = g_regex_split_simple (data->pattern, data->string,
+ G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
if (tokens)
token_count = g_strv_length (tokens);
else
@@ -867,7 +868,7 @@ test_split_full (gconstpointer d)
gint token_count;
gint i;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert (regex != NULL);
@@ -901,7 +902,7 @@ test_split (gconstpointer d)
gint token_count;
gint i;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert (regex != NULL);
@@ -1057,8 +1058,8 @@ test_expand (gconstpointer d)
if (data->pattern)
{
- regex = g_regex_new (data->pattern, data->raw ? G_REGEX_RAW : 0, 0,
- &error);
+ regex = g_regex_new (data->pattern, data->raw ? G_REGEX_RAW : 0,
+ G_REGEX_MATCH_DEFAULT, &error);
g_assert_no_error (error);
g_regex_match (regex, data->string, 0, &match_info);
}
@@ -1100,7 +1101,7 @@ test_replace (gconstpointer d)
GRegex *regex;
gchar *res;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
res = g_regex_replace (regex, data->string, -1, data->start_position, data->replacement, 0, NULL);
g_assert_cmpstr (res, ==, data->expected);
@@ -1130,7 +1131,7 @@ test_replace_lit (gconstpointer d)
GRegex *regex;
gchar *res;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
res = g_regex_replace_literal (regex, data->string, -1, data->start_position,
data->replacement, 0, NULL);
g_assert_cmpstr (res, ==, data->expected);
@@ -1166,7 +1167,7 @@ test_get_string_number (gconstpointer d)
GRegex *regex;
gint num;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
num = g_regex_get_string_number (regex, data->name);
g_assert_cmpint (num, ==, data->expected_num);
@@ -1260,7 +1261,7 @@ test_match_all_full (gconstpointer d)
gint match_count;
gint i;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
match_ok = g_regex_match_all_full (regex, data->string, data->string_len, data->start_position,
0, &match_info, NULL);
@@ -1305,7 +1306,7 @@ test_match_all (gconstpointer d)
gboolean match_ok;
guint i, match_count;
- regex = g_regex_new (data->pattern, 0, 0, NULL);
+ regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
match_ok = g_regex_match_all (regex, data->string, 0, &match_info);
if (g_slist_length (data->expected) == 0)
@@ -1502,7 +1503,7 @@ test_properties (void)
gchar *str;
error = NULL;
- regex = g_regex_new ("\\p{L}\\p{Ll}\\p{Lu}\\p{L&}\\p{N}\\p{Nd}", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("\\p{L}\\p{Ll}\\p{Lu}\\p{L&}\\p{N}\\p{Nd}", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
res = g_regex_match (regex, "ppPP01", 0, &match);
g_assert (res);
str = g_match_info_fetch (match, 0);
@@ -1523,7 +1524,7 @@ test_class (void)
gchar *str;
error = NULL;
- regex = g_regex_new ("[abc\\x{0B1E}\\p{Mn}\\x{0391}-\\x{03A9}]", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("[abc\\x{0B1E}\\p{Mn}\\x{0391}-\\x{03A9}]", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
res = g_regex_match (regex, "a:b:\340\254\236:\333\253:\316\240", 0, &match);
g_assert (res);
str = g_match_info_fetch (match, 0);
@@ -1569,7 +1570,7 @@ test_lookahead (void)
gint start, end;
error = NULL;
- regex = g_regex_new ("\\w+(?=;)", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("\\w+(?=;)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "word1 word2: word3;", 0, &match);
@@ -1583,7 +1584,7 @@ test_lookahead (void)
g_regex_unref (regex);
error = NULL;
- regex = g_regex_new ("foo(?!bar)", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("foo(?!bar)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "foobar foobaz", 0, &match);
@@ -1598,7 +1599,7 @@ test_lookahead (void)
g_regex_unref (regex);
error = NULL;
- regex = g_regex_new ("(?!bar)foo", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?!bar)foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "foobar foobaz", 0, &match);
@@ -1631,7 +1632,7 @@ test_lookbehind (void)
gint start, end;
error = NULL;
- regex = g_regex_new ("(?<!foo)bar", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?<!foo)bar", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "foobar boobar", 0, &match);
@@ -1646,7 +1647,7 @@ test_lookbehind (void)
g_regex_unref (regex);
error = NULL;
- regex = g_regex_new ("(?<=bullock|donkey) poo", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?<=bullock|donkey) poo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "don poo, and bullock poo", 0, &match);
@@ -1659,17 +1660,17 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<!dogs?|cats?) x", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?<!dogs?|cats?) x", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex == NULL);
g_assert_error (error, G_REGEX_ERROR, G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND);
g_clear_error (&error);
- regex = g_regex_new ("(?<=ab(c|de)) foo", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?<=ab(c|de)) foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex == NULL);
g_assert_error (error, G_REGEX_ERROR, G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND);
g_clear_error (&error);
- regex = g_regex_new ("(?<=abc|abde)foo", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?<=abc|abde)foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abfoo, abdfoo, abcfoo", 0, &match);
@@ -1681,7 +1682,7 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^.*+(?<=abcd)", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("^.*+(?<=abcd)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abcabcabcabcabcabcabcabcabcd", 0, &match);
@@ -1690,7 +1691,7 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<=\\d{3})(?<!999)foo", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?<=\\d{3})(?<!999)foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "999foo 123abcfoo 123foo", 0, &match);
@@ -1702,7 +1703,7 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<=\\d{3}...)(?<!999)foo", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?<=\\d{3}...)(?<!999)foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "999foo 123abcfoo 123foo", 0, &match);
@@ -1714,7 +1715,7 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<=\\d{3}(?!999)...)foo", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?<=\\d{3}(?!999)...)foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "999foo 123abcfoo 123foo", 0, &match);
@@ -1726,7 +1727,7 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<=(?<!foo)bar)baz", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?<=(?<!foo)bar)baz", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "foobarbaz barfoobaz barbarbaz", 0, &match);
@@ -1751,7 +1752,7 @@ test_subpattern (void)
gint start;
error = NULL;
- regex = g_regex_new ("cat(aract|erpillar|)", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("cat(aract|erpillar|)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
g_assert_cmpint (g_regex_get_capture_count (regex), ==, 1);
@@ -1769,7 +1770,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("the ((red|white) (king|queen))", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("the ((red|white) (king|queen))", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
g_assert_cmpint (g_regex_get_capture_count (regex), ==, 3);
@@ -1793,7 +1794,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("the ((?:red|white) (king|queen))", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("the ((?:red|white) (king|queen))", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "the white queen", 0, &match);
@@ -1813,7 +1814,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?|(Sat)(ur)|(Sun))day (morning|afternoon)", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?|(Sat)(ur)|(Sun))day (morning|afternoon)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
g_assert_cmpint (g_regex_get_capture_count (regex), ==, 3);
@@ -1833,7 +1834,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?|(abc)|(def))\\1", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?|(abc)|(def))\\1", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
g_assert_cmpint (g_regex_get_max_backref (regex), ==, 1);
@@ -1851,7 +1852,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?|(abc)|(def))(?1)", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("(?|(abc)|(def))(?1)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abcabc abcdef defabc defdef", 0, &match);
@@ -1868,7 +1869,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<DN>Mon|Fri|Sun)(?:day)?|(?<DN>Tue)(?:sday)?|(?<DN>Wed)(?:nesday)?|(?<DN>Thu)(?:rsday)?|(?<DN>Sat)(?:urday)?", G_REGEX_OPTIMIZE|G_REGEX_DUPNAMES, 0, &error);
+ regex = g_regex_new ("(?<DN>Mon|Fri|Sun)(?:day)?|(?<DN>Tue)(?:sday)?|(?<DN>Wed)(?:nesday)?|(?<DN>Thu)(?:rsday)?|(?<DN>Sat)(?:urday)?", G_REGEX_OPTIMIZE|G_REGEX_DUPNAMES, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "Mon Tuesday Wed Saturday", 0, &match);
@@ -1895,7 +1896,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^(a|b\\1)+$", G_REGEX_OPTIMIZE|G_REGEX_DUPNAMES, 0, &error);
+ regex = g_regex_new ("^(a|b\\1)+$", G_REGEX_OPTIMIZE|G_REGEX_DUPNAMES, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "aaaaaaaaaaaaaaaa", 0, &match);
@@ -1919,7 +1920,7 @@ test_condition (void)
gboolean res;
error = NULL;
- regex = g_regex_new ("^(a+)(\\()?[^()]+(?(-1)\\))(b+)$", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("^(a+)(\\()?[^()]+(?(-1)\\))(b+)$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "a(zzzzzz)b", 0, &match);
@@ -1933,7 +1934,7 @@ test_condition (void)
g_regex_unref (regex);
error = NULL;
- regex = g_regex_new ("^(a+)(?<OPEN>\\()?[^()]+(?(<OPEN>)\\))(b+)$", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("^(a+)(?<OPEN>\\()?[^()]+(?(<OPEN>)\\))(b+)$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "a(zzzzzz)b", 0, &match);
@@ -1946,7 +1947,7 @@ test_condition (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^(a+)(?(+1)\\[|\\<)?[^()]+(\\])?(b+)$", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("^(a+)(?(+1)\\[|\\<)?[^()]+(\\])?(b+)$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "a[zzzzzz]b", 0, &match);
@@ -2013,7 +2014,7 @@ test_recursion (void)
gint start;
error = NULL;
- regex = g_regex_new ("\\( ( [^()]++ | (?R) )* \\)", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, 0, &error);
+ regex = g_regex_new ("\\( ( [^()]++ | (?R) )* \\)", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "(middle)", 0, &match);
@@ -2030,7 +2031,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^( \\( ( [^()]++ | (?1) )* \\) )$", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, 0, &error);
+ regex = g_regex_new ("^( \\( ( [^()]++ | (?1) )* \\) )$", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "((((((((((((((((middle))))))))))))))))", 0, &match);
@@ -2043,7 +2044,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^(?<pn> \\( ( [^()]++ | (?&pn) )* \\) )$", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, 0, &error);
+ regex = g_regex_new ("^(?<pn> \\( ( [^()]++ | (?&pn) )* \\) )$", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
g_regex_match (regex, "(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()", 0, &match);
@@ -2052,7 +2053,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("< (?: (?(R) \\d++ | [^<>]*+) | (?R)) * >", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, 0, &error);
+ regex = g_regex_new ("< (?: (?(R) \\d++ | [^<>]*+) | (?R)) * >", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "<ab<01<23<4>>>>", 0, &match);
@@ -2071,7 +2072,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^((.)(?1)\\2|.)$", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("^((.)(?1)\\2|.)$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abcdcba", 0, &match);
@@ -2084,7 +2085,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^(?:((.)(?1)\\2|)|((.)(?3)\\4|.))$", G_REGEX_OPTIMIZE, 0, &error);
+ regex = g_regex_new ("^(?:((.)(?1)\\2|)|((.)(?3)\\4|.))$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abcdcba", 0, &match);
@@ -2097,7 +2098,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^\\W*+(?:((.)\\W*+(?1)\\W*+\\2|)|((.)\\W*+(?3)\\W*+\\4|\\W*+.\\W*+))\\W*+$", G_REGEX_OPTIMIZE|G_REGEX_CASELESS, 0, &error);
+ regex = g_regex_new ("^\\W*+(?:((.)\\W*+(?1)\\W*+\\2|)|((.)\\W*+(?3)\\W*+\\4|\\W*+.\\W*+))\\W*+$", G_REGEX_OPTIMIZE|G_REGEX_CASELESS, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abcdcba", 0, &match);
@@ -2124,7 +2125,7 @@ test_multiline (void)
g_test_bug ("https://bugzilla.gnome.org/show_bug.cgi?id=640489");
- regex = g_regex_new ("^a$", G_REGEX_MULTILINE|G_REGEX_DOTALL, 0, NULL);
+ regex = g_regex_new ("^a$", G_REGEX_MULTILINE|G_REGEX_DOTALL, G_REGEX_MATCH_DEFAULT, NULL);
count = 0;
g_regex_match (regex, "a\nb\na", 0, &info);
@@ -2144,7 +2145,7 @@ test_explicit_crlf (void)
{
GRegex *regex;
- regex = g_regex_new ("[\r\n]a", 0, 0, NULL);
+ regex = g_regex_new ("[\r\n]a", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert_cmpint (g_regex_get_has_cr_or_lf (regex), ==, TRUE);
g_regex_unref (regex);
}
@@ -2154,15 +2155,15 @@ test_max_lookbehind (void)
{
GRegex *regex;
- regex = g_regex_new ("abc", 0, 0, NULL);
+ regex = g_regex_new ("abc", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert_cmpint (g_regex_get_max_lookbehind (regex), ==, 0);
g_regex_unref (regex);
- regex = g_regex_new ("\\babc", 0, 0, NULL);
+ regex = g_regex_new ("\\babc", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert_cmpint (g_regex_get_max_lookbehind (regex), ==, 1);
g_regex_unref (regex);
- regex = g_regex_new ("(?<=123)abc", 0, 0, NULL);
+ regex = g_regex_new ("(?<=123)abc", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_assert_cmpint (g_regex_get_max_lookbehind (regex), ==, 3);
g_regex_unref (regex);
}
@@ -2205,25 +2206,25 @@ main (int argc, char *argv[])
/* TEST_NEW(pattern, compile_opts, match_opts) */
TEST_NEW("[A-Z]+", G_REGEX_CASELESS | G_REGEX_EXTENDED | G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTBOL | G_REGEX_MATCH_PARTIAL);
- TEST_NEW("", 0, 0);
- TEST_NEW(".*", 0, 0);
- TEST_NEW(".*", G_REGEX_OPTIMIZE, 0);
- TEST_NEW(".*", G_REGEX_MULTILINE, 0);
- TEST_NEW(".*", G_REGEX_DOTALL, 0);
+ TEST_NEW("", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW(".*", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW(".*", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW(".*", G_REGEX_MULTILINE, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW(".*", G_REGEX_DOTALL, G_REGEX_MATCH_DEFAULT);
TEST_NEW(".*", G_REGEX_DOTALL, G_REGEX_MATCH_NOTBOL);
- TEST_NEW("(123\\d*)[a-zA-Z]+(?P<hello>.*)", 0, 0);
- TEST_NEW("(123\\d*)[a-zA-Z]+(?P<hello>.*)", G_REGEX_CASELESS, 0);
- TEST_NEW("(123\\d*)[a-zA-Z]+(?P<hello>.*)", G_REGEX_CASELESS | G_REGEX_OPTIMIZE, 0);
- TEST_NEW("(?P<A>x)|(?P<A>y)", G_REGEX_DUPNAMES, 0);
- TEST_NEW("(?P<A>x)|(?P<A>y)", G_REGEX_DUPNAMES | G_REGEX_OPTIMIZE, 0);
+ TEST_NEW("(123\\d*)[a-zA-Z]+(?P<hello>.*)", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW("(123\\d*)[a-zA-Z]+(?P<hello>.*)", G_REGEX_CASELESS, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW("(123\\d*)[a-zA-Z]+(?P<hello>.*)", G_REGEX_CASELESS | G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW("(?P<A>x)|(?P<A>y)", G_REGEX_DUPNAMES, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW("(?P<A>x)|(?P<A>y)", G_REGEX_DUPNAMES | G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT);
/* This gives "internal error: code overflow" with pcre 6.0 */
- TEST_NEW("(?i)(?-i)", 0, 0);
- TEST_NEW ("(?i)a", 0, 0);
- TEST_NEW ("(?m)a", 0, 0);
- TEST_NEW ("(?s)a", 0, 0);
- TEST_NEW ("(?x)a", 0, 0);
- TEST_NEW ("(?J)a", 0, 0);
- TEST_NEW ("(?U)[a-z]+", 0, 0);
+ TEST_NEW("(?i)(?-i)", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW ("(?i)a", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW ("(?m)a", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW ("(?s)a", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW ("(?x)a", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW ("(?J)a", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
+ TEST_NEW ("(?U)[a-z]+", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
/* TEST_NEW_CHECK_FLAGS(pattern, compile_opts, match_ops, real_compile_opts, real_match_opts) */
TEST_NEW_CHECK_FLAGS ("a", G_REGEX_OPTIMIZE, 0, G_REGEX_OPTIMIZE, 0);
diff --git a/gobject/tests/boxed.c b/gobject/tests/boxed.c
index c2d091c54a..dd45a80a34 100644
--- a/gobject/tests/boxed.c
+++ b/gobject/tests/boxed.c
@@ -281,7 +281,7 @@ test_boxed_regex (void)
g_value_init (&value, G_TYPE_REGEX);
g_assert (G_VALUE_HOLDS_BOXED (&value));
- v = g_regex_new ("a+b+", 0, 0, NULL);
+ v = g_regex_new ("a+b+", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
g_value_take_boxed (&value, v);
v2 = g_value_get_boxed (&value);
@@ -305,7 +305,7 @@ test_boxed_matchinfo (void)
g_value_init (&value, G_TYPE_MATCH_INFO);
g_assert (G_VALUE_HOLDS_BOXED (&value));
- r = g_regex_new ("ab", 0, 0, NULL);
+ r = g_regex_new ("ab", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
ret = g_regex_match (r, "blabla abab bla", 0, &info);
g_assert (ret);
g_value_take_boxed (&value, info);
--
GitLab

View File

@ -0,0 +1,36 @@
From 6c93ac876f71d7221a172e430ca450b6c0b8b699 Mon Sep 17 00:00:00 2001
From: Marco Trevisan <mail@3v1n0.net>
Date: Wed, 20 Jul 2022 06:32:30 +0200
Subject: [PATCH] gregex: Free match info if offset matching recalc failed
It's not probably ever happening in practice, but coverity found it and
it's easy enough to fix it.
Coverity CID: #1490730
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/6c93ac876f71d7221a172e430ca450b6c0b8b699
---
glib/gregex.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/glib/gregex.c b/glib/gregex.c
index 5fc7b16bc8..be03f0e094 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -2237,7 +2237,10 @@ g_regex_match_all_full (const GRegex *regex,
info->workspace, info->n_workspace);
if (!recalc_match_offsets (info, error))
- return FALSE;
+ {
+ g_match_info_free (info);
+ return FALSE;
+ }
if (info->matches == PCRE2_ERROR_DFA_WSSIZE)
{
--
GitLab

View File

@ -0,0 +1,27 @@
From a2b5b9e906256f43b0bac702424613ea0e7ddcb0 Mon Sep 17 00:00:00 2001
From: Aleksei Rybalkin <aleksei@rybalkin.org>
Date: Mon, 25 Jul 2022 16:57:06 +0200
Subject: [PATCH] gregex: add original test case for issue #2700
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/a2b5b9e906256f43b0bac702424613ea0e7ddcb0
---
glib/tests/regex.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index 5839465fae..acb082b704 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -2495,6 +2495,7 @@ main (int argc, char *argv[])
/* see https://gitlab.gnome.org/GNOME/glib/-/issues/2700 */
TEST_MATCH("(\n.+)+", G_REGEX_DEFAULT, 0, "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n", -1, 0, 0, TRUE);
+ TEST_MATCH("\n([\\-\\.a-zA-Z]+[\\-\\.0-9]*) +connected ([^(\n ]*)[^\n]*((\n +[0-9]+x[0-9]+[^\n]+)+)", G_REGEX_DEFAULT, 0, "Screen 0: minimum 1 x 1, current 3840 x 1080, maximum 8192 x 8192\nVirtual1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm\n 1920x1080 60.00*+ 59.96 \n 3840x2400 59.97 \n 3840x2160 59.97 \n 2880x1800 59.95 \n 2560x1600 59.99 \n 2560x1440 59.95 \n 1920x1440 60.00 \n 1856x1392 60.00 \n 1792x1344 60.00 \n 1920x1200 59.88 \n 1600x1200 60.00 \n 1680x1050 59.95 \n 1400x1050 59.98 \n 1280x1024 60.02 \n 1440x900 59.89 \n 1280x960 60.00 \n 1360x768 60.02 \n 1280x800 59.81 \n 1152x864 75.00 \n 1280x768 59.87 \n 1280x720 59.86 \n 1024x768 60.00 \n 800x600 60.32 \n 640x480 59.94 \nVirtual2 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 0mm x 0mm\n 1920x1080 60.00*+ 59.96 \n 3840x2400 59.97 \n 3840x2160 59.97 \n 2880x1800 59.95 \n 2560x1600 59.99 \n 2560x1440 59.95 \n 1920x1440 60.00 \n 1856x1392 60.00 \n 1792x1344 60.00 \n 1920x1200 59.88 \n 1600x1200 60.00 \n 1680x1050 59.95 \n 1400x1050 59.98 \n 1280x1024 60.02 \n 1440x900 59.89 \n 1280x960 60.00 \n 1360x768 60.02 \n 1280x800 59.81 \n 1152x864 75.00 \n 1280x768 59.87 \n 1280x720 59.86 \n 1024x768 60.00 \n 800x600 60.32 \n 640x480 59.94 \nVirtual3 disconnected (normal left inverted right x axis y axis)\nVirtual4 disconnected (normal left inverted right x axis y axis)\nVirtual5 disconnected (normal left inverted right x axis y axis)\nVirtual6 disconnected (normal left inverted right x axis y axis)\nVirtual7 disconnected (normal left inverted right x axis y axis)\nVirtual8 disconnected (normal left inverted right x axis y axis)\n", -1, 0, 0, TRUE);
/* TEST_MATCH_NEXT#(pattern, string, string_len, start_position, ...) */
TEST_MATCH_NEXT0("a", "x", -1, 0);
--
GitLab

View File

@ -0,0 +1,49 @@
From 6535c77b00a444750148d9d658e4d47214bb4562 Mon Sep 17 00:00:00 2001
From: Aleksei Rybalkin <aleksei@rybalkin.org>
Date: Mon, 25 Jul 2022 16:48:03 +0200
Subject: [PATCH] gregex: do not set match and recursion limits on match
context
These are not really necessary, and cause breakages (e.g. #2700).
pcre2_set_recursion_limit is also deprecated.
Fixes: #2700
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/6535c77b00a444750148d9d658e4d47214bb4562
---
glib/gregex.c | 2 --
glib/tests/regex.c | 3 +++
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/glib/gregex.c b/glib/gregex.c
index 6741d2479f..dd61dc4813 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -769,8 +769,6 @@ match_info_new (const GRegex *regex,
&match_info->n_subpatterns);
match_info->match_context = pcre2_match_context_create (NULL);
- pcre2_set_match_limit (match_info->match_context, 65536); /* should be plenty */
- pcre2_set_recursion_limit (match_info->match_context, 64); /* should be plenty */
if (is_dfa)
{
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index bb1a5ff762..5839465fae 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -2493,6 +2493,9 @@ main (int argc, char *argv[])
TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "dž", -1, 0, 0, TRUE);
TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "Dž", -1, 0, 0, TRUE);
+ /* see https://gitlab.gnome.org/GNOME/glib/-/issues/2700 */
+ TEST_MATCH("(\n.+)+", G_REGEX_DEFAULT, 0, "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n", -1, 0, 0, TRUE);
+
/* TEST_MATCH_NEXT#(pattern, string, string_len, start_position, ...) */
TEST_MATCH_NEXT0("a", "x", -1, 0);
TEST_MATCH_NEXT0("a", "ax", -1, 1);
--
GitLab

View File

@ -0,0 +1,85 @@
From c05d09044fb71bdea599c81bf0ae896a5503e76a Mon Sep 17 00:00:00 2001
From: Marco Trevisan <mail@3v1n0.net>
Date: Fri, 15 Jul 2022 01:27:33 +0200
Subject: [PATCH] gregex: Ensure we translate the errcode without asserting on
G_REGEX_ERROR_COMPILE
Since commit 8d5a44dc in order to ensure that we were setting the errcode in
translate_compile_error(), we did an assert checking whether it was a
valid value, but we assumed that 0 was not a valid error, while it is as
it's the generic G_REGEX_ERROR_COMPILE.
So, set errcode and errmsg to invalid values before translating and
ensure we've change them.
Fixes: #2694
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/c05d09044fb71bdea599c81bf0ae896a5503e76a
---
glib/gregex.c | 8 ++++++--
glib/tests/regex.c | 13 +++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/glib/gregex.c b/glib/gregex.c
index 5fc7b16bc8..2a54929bf4 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -476,8 +476,12 @@ translate_compile_error (gint *errcode, const gchar **errmsg)
* Note that there can be more PCRE errors with the same GRegexError
* and that some PCRE errors are useless for us.
*/
+ gint original_errcode = *errcode;
- switch (*errcode)
+ *errcode = -1;
+ *errmsg = NULL;
+
+ switch (original_errcode)
{
case PCRE2_ERROR_END_BACKSLASH:
*errcode = G_REGEX_ERROR_STRAY_BACKSLASH;
@@ -725,7 +729,7 @@ translate_compile_error (gint *errcode, const gchar **errmsg)
break;
}
- g_assert (*errcode != 0);
+ g_assert (*errcode != -1);
g_assert (*errmsg != NULL);
}
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index 3355f64e54..9a1977b248 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -2187,6 +2187,18 @@ pcre2_ge (guint64 major, guint64 minor)
return (pcre2_major > major) || (pcre2_major == major && pcre2_minor >= minor);
}
+static void
+test_compile_errors (void)
+{
+ GRegex *regex;
+ GError *error = NULL;
+
+ regex = g_regex_new ("\\o{999}", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ g_assert_null (regex);
+ g_assert_error (error, G_REGEX_ERROR, G_REGEX_ERROR_COMPILE);
+ g_clear_error (&error);
+}
+
int
main (int argc, char *argv[])
{
@@ -2204,6 +2216,7 @@ main (int argc, char *argv[])
g_test_add_func ("/regex/multiline", test_multiline);
g_test_add_func ("/regex/explicit-crlf", test_explicit_crlf);
g_test_add_func ("/regex/max-lookbehind", test_max_lookbehind);
+ g_test_add_func ("/regex/compile-errors", test_compile_errors);
/* TEST_NEW(pattern, compile_opts, match_opts) */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
--
GitLab

View File

@ -0,0 +1,44 @@
From 5cd94a0982e4a910ee33ec58f7678429ec067b6f Mon Sep 17 00:00:00 2001
From: Aleksei Rybalkin <aleksei@rybalkin.org>
Date: Thu, 14 Jul 2022 13:14:31 +0000
Subject: [PATCH] gregex: use %s format specifier for localized error message
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/5cd94a0982e4a910ee33ec58f7678429ec067b6f
---
glib/gregex.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/glib/gregex.c b/glib/gregex.c
index 55672249cb..5fc7b16bc8 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -1661,6 +1661,7 @@ regex_compile (const gchar *pattern,
if (re == NULL)
{
GError *tmp_error;
+ gchar *offset_str;
/* Translate the PCRE error code to GRegexError and use a translated
* error message if possible */
@@ -1669,11 +1670,13 @@ regex_compile (const gchar *pattern,
/* PCRE uses byte offsets but we want to show character offsets */
erroffset = g_utf8_pointer_to_offset (pattern, &pattern[erroffset]);
+ offset_str = g_strdup_printf ("%" G_GSIZE_FORMAT, erroffset);
tmp_error = g_error_new (G_REGEX_ERROR, errcode,
- _("Error while compiling regular "
- "expression %s at char %" G_GSIZE_FORMAT ": %s"),
- pattern, erroffset, errmsg);
+ _("Error while compiling regular expression %s "
+ "at char %s: %s"),
+ pattern, offset_str, errmsg);
g_propagate_error (error, tmp_error);
+ g_free (offset_str);
return NULL;
}
--
GitLab

View File

@ -0,0 +1,678 @@
From bcd8cb3e142bf7f1c92583aa81c34fe8ff8521c0 Mon Sep 17 00:00:00 2001
From: Aleksei Rybalkin <aleksei@rybalkin.org>
Date: Wed, 20 Jul 2022 20:48:17 +0000
Subject: [PATCH] gregex: use G_REGEX_OPTIMIZE flag to enable JIT compilation
Since we ported gregex to pcre2, the JIT compiler is now available to be
used. Let's undeprecate G_REGEX_OPTIMIZE flag to control whether the JIT
compilation is requested, since using JIT is itself an optimization.
See [1] for details on its implementation in pcre2.
[1] http://pcre.org/current/doc/html/pcre2jit.html
Fixes: #566
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/bcd8cb3e142bf7f1c92583aa81c34fe8ff8521c0
---
glib/gregex.c | 104 ++++++++++++++++++++++++++++++------
glib/gregex.h | 14 ++---
glib/tests/regex.c | 128 ++++++++++++++++++++++++---------------------
3 files changed, 164 insertions(+), 82 deletions(-)
diff --git a/glib/gregex.c b/glib/gregex.c
index b0edacc0d3..cf9ce23e8d 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -144,7 +144,6 @@
PCRE2_NOTBOL | \
PCRE2_NOTEOL | \
PCRE2_NOTEMPTY | \
- PCRE2_PARTIAL_SOFT | \
PCRE2_NEWLINE_CR | \
PCRE2_NEWLINE_LF | \
PCRE2_NEWLINE_CRLF | \
@@ -195,6 +194,13 @@ struct _GMatchInfo
pcre2_match_data *match_data;
};
+typedef enum
+{
+ JIT_STATUS_DEFAULT,
+ JIT_STATUS_ENABLED,
+ JIT_STATUS_DISABLED
+} JITStatus;
+
struct _GRegex
{
gint ref_count; /* the ref count for the immutable part (atomic) */
@@ -203,6 +209,8 @@ struct _GRegex
GRegexCompileFlags compile_opts; /* options used at compile time on the pattern, pcre2 values */
GRegexCompileFlags orig_compile_opts; /* options used at compile time on the pattern, gregex values */
GRegexMatchFlags match_opts; /* options used at match time on the regex */
+ gint jit_options; /* options which were enabled for jit compiler */
+ JITStatus jit_status; /* indicates the status of jit compiler for this compiled regex */
};
/* TRUE if ret is an error code, FALSE otherwise. */
@@ -262,10 +270,11 @@ map_to_pcre2_compile_flags (gint pcre1_flags)
if (pcre1_flags & G_REGEX_BSR_ANYCRLF)
pcre2_flags |= PCRE2_BSR_ANYCRLF;
- /* these are not available in pcre2 */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ /* these are not available in pcre2, but we use G_REGEX_OPTIMIZE as a special
+ * case to request JIT compilation */
if (pcre1_flags & G_REGEX_OPTIMIZE)
pcre2_flags |= 0;
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (pcre1_flags & G_REGEX_JAVASCRIPT_COMPAT)
pcre2_flags |= 0;
G_GNUC_END_IGNORE_DEPRECATIONS
@@ -291,8 +300,6 @@ map_to_pcre2_match_flags (gint pcre1_flags)
pcre2_flags |= PCRE2_NOTEOL;
if (pcre1_flags & G_REGEX_MATCH_NOTEMPTY)
pcre2_flags |= PCRE2_NOTEMPTY;
- if (pcre1_flags & G_REGEX_MATCH_PARTIAL)
- pcre2_flags |= PCRE2_PARTIAL_SOFT;
if (pcre1_flags & G_REGEX_MATCH_NEWLINE_CR)
pcre2_flags |= PCRE2_NEWLINE_CR;
if (pcre1_flags & G_REGEX_MATCH_NEWLINE_LF)
@@ -385,8 +392,6 @@ map_to_pcre1_match_flags (gint pcre2_flags)
pcre1_flags |= G_REGEX_MATCH_NOTEOL;
if (pcre2_flags & PCRE2_NOTEMPTY)
pcre1_flags |= G_REGEX_MATCH_NOTEMPTY;
- if (pcre2_flags & PCRE2_PARTIAL_SOFT)
- pcre1_flags |= G_REGEX_MATCH_PARTIAL;
if (pcre2_flags & PCRE2_NEWLINE_CR)
pcre1_flags |= G_REGEX_MATCH_NEWLINE_CR;
if (pcre2_flags & PCRE2_NEWLINE_LF)
@@ -461,6 +466,9 @@ match_error (gint errcode)
return _("bad offset");
case PCRE2_ERROR_RECURSELOOP:
return _("recursion loop");
+ case PCRE2_ERROR_JIT_BADOPTION:
+ /* should not happen in GRegex since we check modes before each match */
+ return _("matching mode is requested that was not compiled for JIT");
default:
break;
}
@@ -817,6 +825,56 @@ recalc_match_offsets (GMatchInfo *match_info,
return TRUE;
}
+static void
+enable_jit_with_match_options (GRegex *regex,
+ GRegexMatchFlags match_options)
+{
+ gint old_jit_options, new_jit_options, retval;
+
+ if (!(regex->orig_compile_opts & G_REGEX_OPTIMIZE))
+ return;
+ if (regex->jit_status == JIT_STATUS_DISABLED)
+ return;
+
+ old_jit_options = 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;
+ if (match_options & PCRE2_PARTIAL_SOFT)
+ new_jit_options |= PCRE2_JIT_PARTIAL_SOFT;
+
+ /* no new options enabled */
+ if (new_jit_options == old_jit_options)
+ return;
+
+ retval = pcre2_jit_compile (regex->pcre_re, new_jit_options);
+ switch (retval)
+ {
+ case 0: /* JIT enabled successfully */
+ regex->jit_status = JIT_STATUS_ENABLED;
+ regex->jit_options = new_jit_options;
+ break;
+ case PCRE2_ERROR_NOMEMORY:
+ g_warning ("JIT compilation was requested with G_REGEX_OPTIMIZE, "
+ "but JIT was unable to allocate executable memory for the "
+ "compiler. Falling back to interpretive code.");
+ regex->jit_status = JIT_STATUS_DISABLED;
+ break;
+ case PCRE2_ERROR_JIT_BADOPTION:
+ g_warning ("JIT compilation was requested with G_REGEX_OPTIMIZE, "
+ "but JIT support is not available. Falling back to "
+ "interpretive code.");
+ regex->jit_status = JIT_STATUS_DISABLED;
+ break;
+ default:
+ g_warning ("JIT compilation was requested with G_REGEX_OPTIMIZE, "
+ "but request for JIT support had unexpectedly failed. "
+ "Falling back to interpretive code.");
+ regex->jit_status = JIT_STATUS_DISABLED;
+ break;
+ }
+}
+
/**
* g_match_info_get_regex:
* @match_info: a #GMatchInfo
@@ -956,13 +1014,28 @@ g_match_info_next (GMatchInfo *match_info,
}
opts = map_to_pcre2_match_flags (match_info->regex->match_opts | match_info->match_opts);
- match_info->matches = pcre2_match (match_info->regex->pcre_re,
- (PCRE2_SPTR8) match_info->string,
- match_info->string_len,
- match_info->pos,
- opts & ~G_REGEX_FLAGS_CONVERTED,
- match_info->match_data,
- match_info->match_context);
+
+ enable_jit_with_match_options (match_info->regex, opts);
+ if (match_info->regex->jit_status == JIT_STATUS_ENABLED)
+ {
+ match_info->matches = pcre2_jit_match (match_info->regex->pcre_re,
+ (PCRE2_SPTR8) match_info->string,
+ match_info->string_len,
+ match_info->pos,
+ opts & ~G_REGEX_FLAGS_CONVERTED,
+ match_info->match_data,
+ match_info->match_context);
+ }
+ else
+ {
+ match_info->matches = pcre2_match (match_info->regex->pcre_re,
+ (PCRE2_SPTR8) match_info->string,
+ match_info->string_len,
+ match_info->pos,
+ opts & ~G_REGEX_FLAGS_CONVERTED,
+ match_info->match_data,
+ match_info->match_context);
+ }
if (IS_PCRE2_ERROR (match_info->matches))
{
@@ -1582,6 +1655,7 @@ g_regex_new (const gchar *pattern,
regex->compile_opts = compile_options;
regex->orig_compile_opts = orig_compile_opts;
regex->match_opts = match_options;
+ enable_jit_with_match_options (regex, regex->match_opts);
return regex;
}
@@ -1836,10 +1910,8 @@ g_regex_get_compile_flags (const GRegex *regex)
g_return_val_if_fail (regex != NULL, 0);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/* Preserve original G_REGEX_OPTIMIZE */
extra_flags = (regex->orig_compile_opts & G_REGEX_OPTIMIZE);
-G_GNUC_END_IGNORE_DEPRECATIONS
/* Also include the newline options */
pcre2_pattern_info (regex->pcre_re, PCRE2_INFO_NEWLINE, &info_value);
diff --git a/glib/gregex.h b/glib/gregex.h
index 7010d52ab8..30eb387073 100644
--- a/glib/gregex.h
+++ b/glib/gregex.h
@@ -262,11 +262,13 @@ GQuark g_regex_error_quark (void);
* followed by "?" behaves as if it were followed by "?:" but named
* parentheses can still be used for capturing (and they acquire numbers
* in the usual way).
- * @G_REGEX_OPTIMIZE: Optimize the regular expression. If the pattern will
- * be used many times, then it may be worth the effort to optimize it
- * to improve the speed of matches. Deprecated in GLib 2.74 which now uses
- * libpcre2, which doesn’t require separate optimization of queries. This
- * option is now a no-op. Deprecated: 2.74
+ * @G_REGEX_OPTIMIZE: Since 2.74 and the port to pcre2, requests JIT
+ * compilation, which, if the just-in-time compiler is available, further
+ * processes a compiled pattern into machine code that executes much
+ * faster. However, it comes at the cost of extra processing before the
+ * match is performed, so it is most beneficial to use this when the same
+ * compiled pattern is used for matching many times. Before 2.74 this
+ * option used the built-in non-JIT optimizations in pcre1.
* @G_REGEX_FIRSTLINE: Limits an unanchored pattern to match before (or at) the
* first newline. Since: 2.34
* @G_REGEX_DUPNAMES: Names used to identify capturing subpatterns need not
@@ -311,7 +313,7 @@ typedef enum
G_REGEX_UNGREEDY = 1 << 9,
G_REGEX_RAW = 1 << 11,
G_REGEX_NO_AUTO_CAPTURE = 1 << 12,
- G_REGEX_OPTIMIZE GLIB_DEPRECATED_ENUMERATOR_IN_2_74 = 1 << 13,
+ G_REGEX_OPTIMIZE = 1 << 13,
G_REGEX_FIRSTLINE = 1 << 18,
G_REGEX_DUPNAMES = 1 << 19,
G_REGEX_NEWLINE_CR = 1 << 20,
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index 9a1977b248..bb1a5ff762 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -516,7 +516,7 @@ test_partial (gconstpointer d)
GRegex *regex;
GMatchInfo *match_info;
- regex = g_regex_new (data->pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
+ regex = g_regex_new (data->pattern, data->compile_opts, G_REGEX_MATCH_DEFAULT, NULL);
g_assert (regex != NULL);
@@ -534,12 +534,13 @@ test_partial (gconstpointer d)
g_regex_unref (regex);
}
-#define TEST_PARTIAL_FULL(_pattern, _string, _match_opts, _expected) { \
+#define TEST_PARTIAL_FULL(_pattern, _string, _compile_opts, _match_opts, _expected) { \
TestMatchData *data; \
gchar *path; \
data = g_new0 (TestMatchData, 1); \
data->pattern = _pattern; \
data->string = _string; \
+ data->compile_opts = _compile_opts; \
data->match_opts = _match_opts; \
data->expected = _expected; \
path = g_strdup_printf ("/regex/match/partial/%d", ++total); \
@@ -547,7 +548,7 @@ test_partial (gconstpointer d)
g_free (path); \
}
-#define TEST_PARTIAL(_pattern, _string, _expected) TEST_PARTIAL_FULL(_pattern, _string, G_REGEX_MATCH_PARTIAL, _expected)
+#define TEST_PARTIAL(_pattern, _string, _compile_opts, _expected) TEST_PARTIAL_FULL(_pattern, _string, _compile_opts, G_REGEX_MATCH_PARTIAL, _expected)
typedef struct {
const gchar *pattern;
@@ -1504,7 +1505,7 @@ test_properties (void)
gchar *str;
error = NULL;
- regex = g_regex_new ("\\p{L}\\p{Ll}\\p{Lu}\\p{L&}\\p{N}\\p{Nd}", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("\\p{L}\\p{Ll}\\p{Lu}\\p{L&}\\p{N}\\p{Nd}", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
res = g_regex_match (regex, "ppPP01", 0, &match);
g_assert (res);
str = g_match_info_fetch (match, 0);
@@ -1525,7 +1526,7 @@ test_class (void)
gchar *str;
error = NULL;
- regex = g_regex_new ("[abc\\x{0B1E}\\p{Mn}\\x{0391}-\\x{03A9}]", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("[abc\\x{0B1E}\\p{Mn}\\x{0391}-\\x{03A9}]", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
res = g_regex_match (regex, "a:b:\340\254\236:\333\253:\316\240", 0, &match);
g_assert (res);
str = g_match_info_fetch (match, 0);
@@ -1571,7 +1572,7 @@ test_lookahead (void)
gint start, end;
error = NULL;
- regex = g_regex_new ("\\w+(?=;)", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("\\w+(?=;)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "word1 word2: word3;", 0, &match);
@@ -1585,7 +1586,7 @@ test_lookahead (void)
g_regex_unref (regex);
error = NULL;
- regex = g_regex_new ("foo(?!bar)", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("foo(?!bar)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "foobar foobaz", 0, &match);
@@ -1600,7 +1601,7 @@ test_lookahead (void)
g_regex_unref (regex);
error = NULL;
- regex = g_regex_new ("(?!bar)foo", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?!bar)foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "foobar foobaz", 0, &match);
@@ -1633,7 +1634,7 @@ test_lookbehind (void)
gint start, end;
error = NULL;
- regex = g_regex_new ("(?<!foo)bar", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?<!foo)bar", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "foobar boobar", 0, &match);
@@ -1648,7 +1649,7 @@ test_lookbehind (void)
g_regex_unref (regex);
error = NULL;
- regex = g_regex_new ("(?<=bullock|donkey) poo", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?<=bullock|donkey) poo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "don poo, and bullock poo", 0, &match);
@@ -1661,17 +1662,17 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<!dogs?|cats?) x", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?<!dogs?|cats?) x", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex == NULL);
g_assert_error (error, G_REGEX_ERROR, G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND);
g_clear_error (&error);
- regex = g_regex_new ("(?<=ab(c|de)) foo", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?<=ab(c|de)) foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex == NULL);
g_assert_error (error, G_REGEX_ERROR, G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND);
g_clear_error (&error);
- regex = g_regex_new ("(?<=abc|abde)foo", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?<=abc|abde)foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abfoo, abdfoo, abcfoo", 0, &match);
@@ -1683,7 +1684,7 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^.*+(?<=abcd)", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("^.*+(?<=abcd)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abcabcabcabcabcabcabcabcabcd", 0, &match);
@@ -1692,7 +1693,7 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<=\\d{3})(?<!999)foo", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?<=\\d{3})(?<!999)foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "999foo 123abcfoo 123foo", 0, &match);
@@ -1704,7 +1705,7 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<=\\d{3}...)(?<!999)foo", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?<=\\d{3}...)(?<!999)foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "999foo 123abcfoo 123foo", 0, &match);
@@ -1716,7 +1717,7 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<=\\d{3}(?!999)...)foo", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?<=\\d{3}(?!999)...)foo", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "999foo 123abcfoo 123foo", 0, &match);
@@ -1728,7 +1729,7 @@ test_lookbehind (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<=(?<!foo)bar)baz", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?<=(?<!foo)bar)baz", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "foobarbaz barfoobaz barbarbaz", 0, &match);
@@ -1753,7 +1754,7 @@ test_subpattern (void)
gint start;
error = NULL;
- regex = g_regex_new ("cat(aract|erpillar|)", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("cat(aract|erpillar|)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
g_assert_cmpint (g_regex_get_capture_count (regex), ==, 1);
@@ -1771,7 +1772,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("the ((red|white) (king|queen))", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("the ((red|white) (king|queen))", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
g_assert_cmpint (g_regex_get_capture_count (regex), ==, 3);
@@ -1795,7 +1796,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("the ((?:red|white) (king|queen))", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("the ((?:red|white) (king|queen))", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "the white queen", 0, &match);
@@ -1815,7 +1816,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?|(Sat)(ur)|(Sun))day (morning|afternoon)", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?|(Sat)(ur)|(Sun))day (morning|afternoon)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
g_assert_cmpint (g_regex_get_capture_count (regex), ==, 3);
@@ -1835,7 +1836,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?|(abc)|(def))\\1", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?|(abc)|(def))\\1", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
g_assert_cmpint (g_regex_get_max_backref (regex), ==, 1);
@@ -1853,7 +1854,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?|(abc)|(def))(?1)", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?|(abc)|(def))(?1)", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abcabc abcdef defabc defdef", 0, &match);
@@ -1870,7 +1871,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("(?<DN>Mon|Fri|Sun)(?:day)?|(?<DN>Tue)(?:sday)?|(?<DN>Wed)(?:nesday)?|(?<DN>Thu)(?:rsday)?|(?<DN>Sat)(?:urday)?", G_REGEX_DUPNAMES, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("(?<DN>Mon|Fri|Sun)(?:day)?|(?<DN>Tue)(?:sday)?|(?<DN>Wed)(?:nesday)?|(?<DN>Thu)(?:rsday)?|(?<DN>Sat)(?:urday)?", G_REGEX_OPTIMIZE|G_REGEX_DUPNAMES, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "Mon Tuesday Wed Saturday", 0, &match);
@@ -1897,7 +1898,7 @@ test_subpattern (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^(a|b\\1)+$", G_REGEX_DUPNAMES, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("^(a|b\\1)+$", G_REGEX_OPTIMIZE|G_REGEX_DUPNAMES, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "aaaaaaaaaaaaaaaa", 0, &match);
@@ -1921,7 +1922,7 @@ test_condition (void)
gboolean res;
error = NULL;
- regex = g_regex_new ("^(a+)(\\()?[^()]+(?(-1)\\))(b+)$", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("^(a+)(\\()?[^()]+(?(-1)\\))(b+)$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "a(zzzzzz)b", 0, &match);
@@ -1935,7 +1936,7 @@ test_condition (void)
g_regex_unref (regex);
error = NULL;
- regex = g_regex_new ("^(a+)(?<OPEN>\\()?[^()]+(?(<OPEN>)\\))(b+)$", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("^(a+)(?<OPEN>\\()?[^()]+(?(<OPEN>)\\))(b+)$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "a(zzzzzz)b", 0, &match);
@@ -1948,7 +1949,7 @@ test_condition (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^(a+)(?(+1)\\[|\\<)?[^()]+(\\])?(b+)$", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("^(a+)(?(+1)\\[|\\<)?[^()]+(\\])?(b+)$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "a[zzzzzz]b", 0, &match);
@@ -1963,7 +1964,7 @@ test_condition (void)
regex = g_regex_new ("(?(DEFINE) (?<byte> 2[0-4]\\d | 25[0-5] | 1\\d\\d | [1-9]?\\d) )"
"\\b (?&byte) (\\.(?&byte)){3} \\b",
- G_REGEX_EXTENDED, 0, &error);
+ G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, 0, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "128.0.0.1", 0, &match);
@@ -1982,7 +1983,7 @@ test_condition (void)
regex = g_regex_new ("^(?(?=[^a-z]*[a-z])"
"\\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} )$",
- G_REGEX_EXTENDED, 0, &error);
+ G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, 0, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "01-abc-24", 0, &match);
@@ -2015,7 +2016,7 @@ test_recursion (void)
gint start;
error = NULL;
- regex = g_regex_new ("\\( ( [^()]++ | (?R) )* \\)", G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("\\( ( [^()]++ | (?R) )* \\)", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "(middle)", 0, &match);
@@ -2032,7 +2033,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^( \\( ( [^()]++ | (?1) )* \\) )$", G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("^( \\( ( [^()]++ | (?1) )* \\) )$", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "((((((((((((((((middle))))))))))))))))", 0, &match);
@@ -2045,7 +2046,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^(?<pn> \\( ( [^()]++ | (?&pn) )* \\) )$", G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("^(?<pn> \\( ( [^()]++ | (?&pn) )* \\) )$", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
g_regex_match (regex, "(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()", 0, &match);
@@ -2054,7 +2055,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("< (?: (?(R) \\d++ | [^<>]*+) | (?R)) * >", G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("< (?: (?(R) \\d++ | [^<>]*+) | (?R)) * >", G_REGEX_OPTIMIZE|G_REGEX_EXTENDED, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "<ab<01<23<4>>>>", 0, &match);
@@ -2073,7 +2074,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^((.)(?1)\\2|.)$", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("^((.)(?1)\\2|.)$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abcdcba", 0, &match);
@@ -2086,7 +2087,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^(?:((.)(?1)\\2|)|((.)(?3)\\4|.))$", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("^(?:((.)(?1)\\2|)|((.)(?3)\\4|.))$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abcdcba", 0, &match);
@@ -2099,7 +2100,7 @@ test_recursion (void)
g_match_info_free (match);
g_regex_unref (regex);
- regex = g_regex_new ("^\\W*+(?:((.)\\W*+(?1)\\W*+\\2|)|((.)\\W*+(?3)\\W*+\\4|\\W*+.\\W*+))\\W*+$", G_REGEX_CASELESS, G_REGEX_MATCH_DEFAULT, &error);
+ regex = g_regex_new ("^\\W*+(?:((.)\\W*+(?1)\\W*+\\2|)|((.)\\W*+(?3)\\W*+\\4|\\W*+.\\W*+))\\W*+$", G_REGEX_OPTIMIZE|G_REGEX_CASELESS, G_REGEX_MATCH_DEFAULT, &error);
g_assert (regex);
g_assert_no_error (error);
res = g_regex_match (regex, "abcdcba", 0, &match);
@@ -2219,26 +2220,18 @@ main (int argc, char *argv[])
g_test_add_func ("/regex/compile-errors", test_compile_errors);
/* TEST_NEW(pattern, compile_opts, match_opts) */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
TEST_NEW("[A-Z]+", G_REGEX_CASELESS | G_REGEX_EXTENDED | G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTBOL | G_REGEX_MATCH_PARTIAL);
-G_GNUC_END_IGNORE_DEPRECATIONS
TEST_NEW("", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
TEST_NEW(".*", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
TEST_NEW(".*", G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT);
-G_GNUC_END_IGNORE_DEPRECATIONS
TEST_NEW(".*", G_REGEX_MULTILINE, G_REGEX_MATCH_DEFAULT);
TEST_NEW(".*", G_REGEX_DOTALL, G_REGEX_MATCH_DEFAULT);
TEST_NEW(".*", G_REGEX_DOTALL, G_REGEX_MATCH_NOTBOL);
TEST_NEW("(123\\d*)[a-zA-Z]+(?P<hello>.*)", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
TEST_NEW("(123\\d*)[a-zA-Z]+(?P<hello>.*)", G_REGEX_CASELESS, G_REGEX_MATCH_DEFAULT);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
TEST_NEW("(123\\d*)[a-zA-Z]+(?P<hello>.*)", G_REGEX_CASELESS | G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT);
-G_GNUC_END_IGNORE_DEPRECATIONS
TEST_NEW("(?P<A>x)|(?P<A>y)", G_REGEX_DUPNAMES, G_REGEX_MATCH_DEFAULT);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
TEST_NEW("(?P<A>x)|(?P<A>y)", G_REGEX_DUPNAMES | G_REGEX_OPTIMIZE, G_REGEX_MATCH_DEFAULT);
-G_GNUC_END_IGNORE_DEPRECATIONS
/* This gives "internal error: code overflow" with pcre 6.0 */
TEST_NEW("(?i)(?-i)", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
TEST_NEW ("(?i)a", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
@@ -2249,9 +2242,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
TEST_NEW ("(?U)[a-z]+", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT);
/* TEST_NEW_CHECK_FLAGS(pattern, compile_opts, match_ops, real_compile_opts, real_match_opts) */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
TEST_NEW_CHECK_FLAGS ("a", G_REGEX_OPTIMIZE, 0, G_REGEX_OPTIMIZE, 0);
-G_GNUC_END_IGNORE_DEPRECATIONS
TEST_NEW_CHECK_FLAGS ("a", G_REGEX_RAW, 0, G_REGEX_RAW, 0);
TEST_NEW_CHECK_FLAGS ("^.*", 0, 0, G_REGEX_ANCHORED, 0);
TEST_NEW_CHECK_FLAGS ("(*UTF8)a", 0, 0, 0 /* this is the default in GRegex */, 0);
@@ -2540,18 +2531,35 @@ G_GNUC_END_IGNORE_DEPRECATIONS
TEST_MATCH_COUNT("(a)?(b)", "b", 0, 0, 3);
TEST_MATCH_COUNT("(a)?(b)", "ab", 0, 0, 3);
- /* TEST_PARTIAL(pattern, string, expected) */
- TEST_PARTIAL("^ab", "a", TRUE);
- TEST_PARTIAL("^ab", "xa", FALSE);
- TEST_PARTIAL("ab", "xa", TRUE);
- TEST_PARTIAL("ab", "ab", FALSE); /* normal match. */
- TEST_PARTIAL("a+b", "aa", TRUE);
- TEST_PARTIAL("(a)+b", "aa", TRUE);
- TEST_PARTIAL("a?b", "a", TRUE);
-
- /* Test soft vs. hard partial matching */
- TEST_PARTIAL_FULL("cat(fish)?", "cat", G_REGEX_MATCH_PARTIAL_SOFT, FALSE);
- TEST_PARTIAL_FULL("cat(fish)?", "cat", G_REGEX_MATCH_PARTIAL_HARD, TRUE);
+ /* TEST_PARTIAL(pattern, string, expected), no JIT */
+ TEST_PARTIAL("^ab", "a", G_REGEX_DEFAULT, TRUE);
+ TEST_PARTIAL("^ab", "xa", G_REGEX_DEFAULT, FALSE);
+ TEST_PARTIAL("ab", "xa", G_REGEX_DEFAULT, TRUE);
+ TEST_PARTIAL("ab", "ab", G_REGEX_DEFAULT, FALSE); /* normal match. */
+ TEST_PARTIAL("a+b", "aa", G_REGEX_DEFAULT, TRUE);
+ TEST_PARTIAL("(a)+b", "aa", G_REGEX_DEFAULT, TRUE);
+ TEST_PARTIAL("a?b", "a", G_REGEX_DEFAULT, TRUE);
+
+ /* TEST_PARTIAL(pattern, string, expected) with JIT */
+ TEST_PARTIAL("^ab", "a", G_REGEX_OPTIMIZE, TRUE);
+ TEST_PARTIAL("^ab", "xa", G_REGEX_OPTIMIZE, FALSE);
+ TEST_PARTIAL("ab", "xa", G_REGEX_OPTIMIZE, TRUE);
+ TEST_PARTIAL("ab", "ab", G_REGEX_OPTIMIZE, FALSE); /* normal match. */
+ TEST_PARTIAL("a+b", "aa", G_REGEX_OPTIMIZE, TRUE);
+ TEST_PARTIAL("(a)+b", "aa", G_REGEX_OPTIMIZE, TRUE);
+ TEST_PARTIAL("a?b", "a", G_REGEX_OPTIMIZE, TRUE);
+
+ /* Test soft vs. hard partial matching, no JIT */
+ TEST_PARTIAL_FULL("cat(fish)?", "cat", G_REGEX_DEFAULT, G_REGEX_MATCH_PARTIAL_SOFT, FALSE);
+ TEST_PARTIAL_FULL("cat(fish)?", "cat", G_REGEX_DEFAULT, G_REGEX_MATCH_PARTIAL_HARD, TRUE);
+ TEST_PARTIAL_FULL("ab+", "ab", G_REGEX_DEFAULT, G_REGEX_MATCH_PARTIAL_SOFT, FALSE);
+ TEST_PARTIAL_FULL("ab+", "ab", G_REGEX_DEFAULT, G_REGEX_MATCH_PARTIAL_HARD, TRUE);
+
+ /* Test soft vs. hard partial matching with JIT */
+ TEST_PARTIAL_FULL("cat(fish)?", "cat", G_REGEX_OPTIMIZE, G_REGEX_MATCH_PARTIAL_SOFT, FALSE);
+ TEST_PARTIAL_FULL("cat(fish)?", "cat", G_REGEX_OPTIMIZE, G_REGEX_MATCH_PARTIAL_HARD, TRUE);
+ TEST_PARTIAL_FULL("ab+", "ab", G_REGEX_OPTIMIZE, G_REGEX_MATCH_PARTIAL_SOFT, FALSE);
+ TEST_PARTIAL_FULL("ab+", "ab", G_REGEX_OPTIMIZE, G_REGEX_MATCH_PARTIAL_HARD, TRUE);
/* TEST_SUB_PATTERN(pattern, string, start_position, sub_n, expected_sub,
* expected_start, expected_end) */
--
GitLab

View File

@ -0,0 +1,35 @@
From 710ccee65c010e4548ded487cdc191658f6a1f35 Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Tue, 26 Jul 2022 21:51:45 +0900
Subject: [PATCH] gregex: use correct size for pcre2_pattern_info
man pcre2_pattern_info says that the 3rd argument must
point to uint32_t variable (except for some 2nd argument value),
so correctly use it. Especially using wrong size can cause
unexpected result on big endian.
closes: #2699
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/710ccee65c010e4548ded487cdc191658f6a1f35
---
glib/gregex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/glib/gregex.c b/glib/gregex.c
index dd61dc4813..08c43ef4b5 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -1701,7 +1701,7 @@ regex_compile (const gchar *pattern,
PCRE2_SIZE erroffset;
gint errcode;
GRegexCompileFlags nonpcre_compile_options;
- unsigned long int pcre_compile_options;
+ uint32_t pcre_compile_options;
nonpcre_compile_options = compile_options & G_REGEX_COMPILE_NONPCRE_MASK;
--
GitLab

View File

@ -0,0 +1,55 @@
From 2c2e059cd354a9020ce9188e58e3ab0683008d08 Mon Sep 17 00:00:00 2001
From: Aleksei Rybalkin <aleksei@rybalkin.org>
Date: Fri, 22 Jul 2022 20:27:04 +0200
Subject: [PATCH] gregex: use g_debug instead of g_warning in case JIT is not
available
In case JIT is not available in pcre2 we printed warning about it. This
warning broke tests on systems which don't have JIT support in pcre2
(e.g. macos).
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/2c2e059cd354a9020ce9188e58e3ab0683008d08
---
glib/gregex.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/glib/gregex.c b/glib/gregex.c
index cf9ce23e8d..6741d2479f 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -855,21 +855,21 @@ enable_jit_with_match_options (GRegex *regex,
regex->jit_options = new_jit_options;
break;
case PCRE2_ERROR_NOMEMORY:
- g_warning ("JIT compilation was requested with G_REGEX_OPTIMIZE, "
- "but JIT was unable to allocate executable memory for the "
- "compiler. Falling back to interpretive code.");
+ g_debug ("JIT compilation was requested with G_REGEX_OPTIMIZE, "
+ "but JIT was unable to allocate executable memory for the "
+ "compiler. Falling back to interpretive code.");
regex->jit_status = JIT_STATUS_DISABLED;
break;
case PCRE2_ERROR_JIT_BADOPTION:
- g_warning ("JIT compilation was requested with G_REGEX_OPTIMIZE, "
- "but JIT support is not available. Falling back to "
- "interpretive code.");
+ g_debug ("JIT compilation was requested with G_REGEX_OPTIMIZE, "
+ "but JIT support is not available. Falling back to "
+ "interpretive code.");
regex->jit_status = JIT_STATUS_DISABLED;
break;
default:
- g_warning ("JIT compilation was requested with G_REGEX_OPTIMIZE, "
- "but request for JIT support had unexpectedly failed. "
- "Falling back to interpretive code.");
+ g_debug ("JIT compilation was requested with G_REGEX_OPTIMIZE, "
+ "but request for JIT support had unexpectedly failed. "
+ "Falling back to interpretive code.");
regex->jit_status = JIT_STATUS_DISABLED;
break;
}
--
GitLab

View File

@ -0,0 +1,211 @@
From 7045260c226e409530e4f961f613f8c7d6f6725a Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 23 Jun 2022 09:41:21 +0100
Subject: [PATCH] gsignal: Add G_CONNECT_DEFAULT
This makes calls to g_signal_connect_data() and g_signal_connect_object()
with default flags more self-documenting.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/7045260c226e409530e4f961f613f8c7d6f6725a
---
gio/gcancellable.c | 2 +-
gio/gdbusobjectmanagerclient.c | 4 ++--
gio/gdbusserver.c | 2 +-
gio/glocalfilemonitor.c | 5 +++--
gio/gsubprocess.c | 4 +++-
gio/gtask.c | 3 ++-
gobject/gobject.c | 8 ++++----
gobject/gsignal.h | 11 ++++++++---
gobject/tests/signals.c | 6 ++++--
9 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/gio/gcancellable.c b/gio/gcancellable.c
index 64755206be..fe3cbeb7f7 100644
--- a/gio/gcancellable.c
+++ b/gio/gcancellable.c
@@ -589,7 +589,7 @@ g_cancellable_connect (GCancellable *cancellable,
id = g_signal_connect_data (cancellable, "cancelled",
callback, data,
(GClosureNotify) data_destroy_func,
- 0);
+ G_CONNECT_DEFAULT);
g_mutex_unlock (&cancellable_mutex);
}
diff --git a/gio/gdbusobjectmanagerclient.c b/gio/gdbusobjectmanagerclient.c
index bfb73b5308..fa5e73041e 100644
--- a/gio/gdbusobjectmanagerclient.c
+++ b/gio/gdbusobjectmanagerclient.c
@@ -1456,7 +1456,7 @@ initable_init (GInitable *initable,
G_CALLBACK (on_notify_g_name_owner),
weak_ref_new (G_OBJECT (manager)),
(GClosureNotify) weak_ref_free,
- 0 /* flags */);
+ G_CONNECT_DEFAULT);
manager->priv->signal_signal_id =
g_signal_connect_data (manager->priv->control_proxy,
@@ -1464,7 +1464,7 @@ initable_init (GInitable *initable,
G_CALLBACK (on_control_proxy_g_signal),
weak_ref_new (G_OBJECT (manager)),
(GClosureNotify) weak_ref_free,
- 0 /* flags */);
+ G_CONNECT_DEFAULT);
manager->priv->name_owner = g_dbus_proxy_get_name_owner (manager->priv->control_proxy);
if (manager->priv->name_owner == NULL && manager->priv->name != NULL)
diff --git a/gio/gdbusserver.c b/gio/gdbusserver.c
index fe5b23ed4d..f144d129ae 100644
--- a/gio/gdbusserver.c
+++ b/gio/gdbusserver.c
@@ -630,7 +630,7 @@ g_dbus_server_start (GDBusServer *server)
G_CALLBACK (on_run),
g_object_ref (server),
(GClosureNotify) g_object_unref,
- 0 /* flags */);
+ G_CONNECT_DEFAULT);
g_socket_service_start (G_SOCKET_SERVICE (server->listener));
server->active = TRUE;
g_object_notify (G_OBJECT (server), "active");
diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c
index fde52193a9..8de4079394 100644
--- a/gio/glocalfilemonitor.c
+++ b/gio/glocalfilemonitor.c
@@ -809,7 +809,8 @@ g_local_file_monitor_start (GLocalFileMonitor *local_monitor,
local_monitor->mount_monitor = g_unix_mount_monitor_get ();
g_signal_connect_object (local_monitor->mount_monitor, "mounts-changed",
- G_CALLBACK (g_local_file_monitor_mounts_changed), local_monitor, 0);
+ G_CALLBACK (g_local_file_monitor_mounts_changed), local_monitor,
+ G_CONNECT_DEFAULT);
#endif
}
@@ -924,7 +925,7 @@ g_local_file_monitor_new_in_worker (const gchar *pathname,
{
if (callback)
g_signal_connect_data (monitor, "changed", G_CALLBACK (callback),
- user_data, destroy_user_data, 0 /* flags */);
+ user_data, destroy_user_data, G_CONNECT_DEFAULT);
g_local_file_monitor_start (monitor, pathname, is_directory, flags, GLIB_PRIVATE_CALL(g_get_worker_context) ());
}
diff --git a/gio/gsubprocess.c b/gio/gsubprocess.c
index bb157197fc..c4747a1481 100644
--- a/gio/gsubprocess.c
+++ b/gio/gsubprocess.c
@@ -756,7 +756,9 @@ g_subprocess_wait_async (GSubprocess *subprocess,
* see the cancellation in the _finish().
*/
if (cancellable)
- g_signal_connect_object (cancellable, "cancelled", G_CALLBACK (g_subprocess_wait_cancelled), task, 0);
+ g_signal_connect_object (cancellable, "cancelled",
+ G_CALLBACK (g_subprocess_wait_cancelled),
+ task, G_CONNECT_DEFAULT);
subprocess->pending_waits = g_slist_prepend (subprocess->pending_waits, task);
task = NULL;
diff --git a/gio/gtask.c b/gio/gtask.c
index d0f8b4e33a..774cba793a 100644
--- a/gio/gtask.c
+++ b/gio/gtask.c
@@ -1530,7 +1530,8 @@ g_task_start_task_thread (GTask *task,
g_signal_connect_data (task->cancellable, "cancelled",
G_CALLBACK (task_thread_cancelled),
g_object_ref (task),
- task_thread_cancelled_disconnect_notify, 0);
+ task_thread_cancelled_disconnect_notify,
+ G_CONNECT_DEFAULT);
}
if (g_private_get (&task_private))
diff --git a/gobject/gobject.c b/gobject/gobject.c
index df908984b7..5ba8fd017b 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -3093,8 +3093,8 @@ g_object_get_property (GObject *object,
*
* The signal specs expected by this function have the form
* "modifier::signal_name", where modifier can be one of the following:
- * - signal: equivalent to g_signal_connect_data (..., NULL, 0)
- * - object-signal, object_signal: equivalent to g_signal_connect_object (..., 0)
+ * - signal: equivalent to g_signal_connect_data (..., NULL, G_CONNECT_DEFAULT)
+ * - object-signal, object_signal: equivalent to g_signal_connect_object (..., G_CONNECT_DEFAULT)
* - swapped-signal, swapped_signal: equivalent to g_signal_connect_data (..., NULL, G_CONNECT_SWAPPED)
* - swapped_object_signal, swapped-object-signal: equivalent to g_signal_connect_object (..., G_CONNECT_SWAPPED)
* - signal_after, signal-after: equivalent to g_signal_connect_data (..., NULL, G_CONNECT_AFTER)
@@ -3135,12 +3135,12 @@ g_object_connect (gpointer _object,
if (strncmp (signal_spec, "signal::", 8) == 0)
g_signal_connect_data (object, signal_spec + 8,
callback, data, NULL,
- 0);
+ G_CONNECT_DEFAULT);
else if (strncmp (signal_spec, "object_signal::", 15) == 0 ||
strncmp (signal_spec, "object-signal::", 15) == 0)
g_signal_connect_object (object, signal_spec + 15,
callback, data,
- 0);
+ G_CONNECT_DEFAULT);
else if (strncmp (signal_spec, "swapped_signal::", 16) == 0 ||
strncmp (signal_spec, "swapped-signal::", 16) == 0)
g_signal_connect_data (object, signal_spec + 16,
diff --git a/gobject/gsignal.h b/gobject/gsignal.h
index 7b3974a8c4..53da2a6eab 100644
--- a/gobject/gsignal.h
+++ b/gobject/gsignal.h
@@ -155,9 +155,11 @@ typedef enum
#define G_SIGNAL_FLAGS_MASK 0x1ff
/**
* GConnectFlags:
- * @G_CONNECT_AFTER: whether the handler should be called before or after the
- * default handler of the signal.
- * @G_CONNECT_SWAPPED: whether the instance and data should be swapped when
+ * @G_CONNECT_DEFAULT: Default behaviour (no special flags). Since: 2.74
+ * @G_CONNECT_AFTER: If set, the handler should be called after the
+ * default handler of the signal. Normally, the handler is called before
+ * the default handler.
+ * @G_CONNECT_SWAPPED: If set, the instance and data should be swapped when
* calling the handler; see g_signal_connect_swapped() for an example.
*
* The connection flags are used to specify the behaviour of a signal's
@@ -165,6 +167,7 @@ typedef enum
*/
typedef enum
{
+ G_CONNECT_DEFAULT GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0,
G_CONNECT_AFTER = 1 << 0,
G_CONNECT_SWAPPED = 1 << 1
} GConnectFlags;
@@ -504,6 +507,8 @@ void g_signal_chain_from_overridden_handler (gpointer instance,
*
* Returns: the handler ID, of type #gulong (always greater than 0 for successful connections)
*/
+/* Intentionally not using G_CONNECT_DEFAULT here to avoid deprecation
+ * warnings with older GLIB_VERSION_MAX_ALLOWED */
#define g_signal_connect(instance, detailed_signal, c_handler, data) \
g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
/**
diff --git a/gobject/tests/signals.c b/gobject/tests/signals.c
index ea9a778bf8..e4be41575f 100644
--- a/gobject/tests/signals.c
+++ b/gobject/tests/signals.c
@@ -1109,8 +1109,10 @@ test_destroy_target_object (void)
sender = g_object_new (test_get_type (), NULL);
target1 = g_object_new (test_get_type (), NULL);
target2 = g_object_new (test_get_type (), NULL);
- g_signal_connect_object (sender, "simple", G_CALLBACK (simple_handler1), target1, 0);
- g_signal_connect_object (sender, "simple", G_CALLBACK (simple_handler2), target2, 0);
+ g_signal_connect_object (sender, "simple", G_CALLBACK (simple_handler1),
+ target1, G_CONNECT_DEFAULT);
+ g_signal_connect_object (sender, "simple", G_CALLBACK (simple_handler2),
+ target2, G_CONNECT_DEFAULT);
g_signal_emit_by_name (sender, "simple");
g_object_unref (sender);
}
--
GitLab

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,64 @@
From 5e164c661537f6b6ef5adcf0fac949959ef9ffd5 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 31 Mar 2022 13:58:36 +0100
Subject: [PATCH] gtype: Add G_TYPE_FLAG_NONE
This makes code that sets no flags a bit more self-documenting:
using G_TYPE_FLAG_NONE makes it clearer that no special behaviour is
required than literal 0, and clearer that there is no weird casting
between types than (GTypeFlags) 0.
GTypeFlags and GTypeFundamentalFlags occupy the same namespace and the
same bitfield, so I intentionally haven't added
G_TYPE_FUNDAMENTAL_FLAGS_NONE.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/5e164c661537f6b6ef5adcf0fac949959ef9ffd5
---
gobject/gtype.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 66cac1fc58..73d665626b 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1030,6 +1030,8 @@ typedef void (*GTypeInterfaceCheckFunc) (gpointer check_data,
*/
typedef enum /*< skip >*/
{
+ /* There is no G_TYPE_FUNDAMENTAL_FLAGS_NONE: this is implemented to use
+ * the same bits as GTypeFlags */
G_TYPE_FLAG_CLASSED = (1 << 0),
G_TYPE_FLAG_INSTANTIATABLE = (1 << 1),
G_TYPE_FLAG_DERIVABLE = (1 << 2),
@@ -1037,6 +1039,7 @@ typedef enum /*< skip >*/
} GTypeFundamentalFlags;
/**
* GTypeFlags:
+ * @G_TYPE_FLAG_NONE: No special flags. Since: 2.74
* @G_TYPE_FLAG_ABSTRACT: Indicates an abstract type. No instances can be
* created for an abstract type
* @G_TYPE_FLAG_VALUE_ABSTRACT: Indicates an abstract value type, i.e. a type
@@ -1049,6 +1052,7 @@ typedef enum /*< skip >*/
*/
typedef enum /*< skip >*/
{
+ G_TYPE_FLAG_NONE GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0,
G_TYPE_FLAG_ABSTRACT = (1 << 4),
G_TYPE_FLAG_VALUE_ABSTRACT = (1 << 5),
G_TYPE_FLAG_FINAL GLIB_AVAILABLE_ENUMERATOR_IN_2_70 = (1 << 6)
@@ -2180,6 +2184,8 @@ type_name##_get_type_once (void) \
_G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \
_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
+/* Intentionally using (GTypeFlags) 0 instead of G_TYPE_FLAG_NONE here,
+ * to avoid deprecation warnings with older GLIB_VERSION_MAX_ALLOWED */
#define _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PREREQ) \
\
static void type_name##_default_init (TypeName##Interface *klass); \
--
GitLab

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,30 @@
Name: glib2
Version: 2.72.2
Release: 2
Release: 3
Summary: The core library that forms the basis for projects such as GTK+ and GNOME
License: LGPLv2+
URL: http://www.gtk.org
Source0: https://download.gnome.org/sources/glib/2.71/glib-%{version}.tar.xz
Patch6000: backport-add-version-macros-for-GLib-2.74.patch
Patch6001: backport-gtype-Add-G_TYPE_FLAG_NONE.patch
Patch6002: backport-gioenums-Add-G_TLS_CERTIFICATE_FLAGS_NONE.patch
Patch6003: backport-gtestutils-Add-G_TEST_SUBPROCESS_DEFAULT.patch
Patch6004: backport-gsignal-Add-G_CONNECT_DEFAULT.patch
Patch6005: backport-giomodule-test-Dont-pass-a-magic-number-to-g_test_trap_subprocess.patch
Patch6006: backport-giochannel-Add-G_IO_FLAG_NONE.patch
Patch6007: backport-gmarkup-Add-G_MARKUP_PARSE_FLAGS_NONE.patch
Patch6008: backport-gregex-Add-G_REGEX_DEFAULT-G_REGEX_MATCH_DEFAULT.patch
Patch6009: backport-replace-pcre1-with-pcre2.patch
Patch6010: backport-gregex-format-specifier-for-localized-error-message.patch
Patch6011: backport-gregex-ensure-we-translate-the-errcode.patch
Patch6012: backport-gregex-Free-match-info-if-offset-matching-recalc-failed.patch
Patch6013: backport-gregex-use-G_REGEX_OPTIMIZE-flag-to-enable-JIT-compilation.patch
Patch6014: backport-gregex-use-g_debug-instead-of-g_warning-in-case-JIT-is-not-available.patch
Patch6015: backport-gregex-do-not-set-match-and-recursion-limits-on-match-context.patch
Patch6016: backport-gregex-add-original-test-case.patch
Patch6017: backport-gregex-use-correct-size-for-pcre2_pattern_info.patch
BuildRequires: chrpath gcc gcc-c++ gettext perl-interpreter
BUildRequires: glibc-devel libattr-devel libselinux-devel meson
BuildRequires: systemtap-sdt-devel pkgconfig(libelf) pkgconfig(libffi)
@ -178,6 +197,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%endif
%changelog
* Mon Sep 5 2022 hanhuihui <hanhuihui5@huawei.com> - 2.72.2-3
- replace pcre1 with pcre2
* Sat Jun 18 2022 zhujunhao <zhujunhao11@huawei.com> - 2.72.2-2
- remove gnutls require