mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
regex: Add accessor for PCRE_INFO_HASCRORLF
This flag is new in PCRE 7.3, and checks whether there is an explicit CR or LF reference in the pattern.
This commit is contained in:
parent
7ada976516
commit
69a12e3275
@ -1005,6 +1005,7 @@ g_regex_unref
|
||||
g_regex_get_pattern
|
||||
g_regex_get_max_backref
|
||||
g_regex_get_capture_count
|
||||
g_regex_get_has_cr_or_lf
|
||||
g_regex_get_string_number
|
||||
g_regex_get_compile_flags
|
||||
g_regex_get_match_flags
|
||||
|
@ -1405,6 +1405,7 @@ g_regex_unref
|
||||
g_regex_get_pattern
|
||||
g_regex_get_max_backref
|
||||
g_regex_get_capture_count
|
||||
g_regex_get_has_cr_or_lf
|
||||
g_regex_get_string_number
|
||||
g_regex_get_compile_flags
|
||||
g_regex_get_match_flags
|
||||
|
@ -1455,6 +1455,27 @@ g_regex_get_capture_count (const GRegex *regex)
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_regex_get_has_cr_or_lf:
|
||||
* @regex: a #GRegex structure
|
||||
*
|
||||
* Checks whether the pattern contains explicit CR or LF references.
|
||||
*
|
||||
* Returns: %TRUE if the pattern contains explicit CR or LF references
|
||||
*
|
||||
* Since: 2.34
|
||||
*/
|
||||
gboolean
|
||||
g_regex_get_has_cr_or_lf (const GRegex *regex)
|
||||
{
|
||||
gint value;
|
||||
|
||||
pcre_fullinfo (regex->pcre_re, regex->extra,
|
||||
PCRE_INFO_HASCRORLF, &value);
|
||||
|
||||
return !!value;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_regex_get_compile_flags:
|
||||
* @regex: a #GRegex
|
||||
|
@ -406,6 +406,7 @@ void g_regex_unref (GRegex *regex);
|
||||
const gchar *g_regex_get_pattern (const GRegex *regex);
|
||||
gint g_regex_get_max_backref (const GRegex *regex);
|
||||
gint g_regex_get_capture_count (const GRegex *regex);
|
||||
gboolean g_regex_get_has_cr_or_lf (const GRegex *regex);
|
||||
gint g_regex_get_string_number (const GRegex *regex,
|
||||
const gchar *name);
|
||||
gchar *g_regex_escape_string (const gchar *string,
|
||||
|
@ -2023,6 +2023,16 @@ test_multiline (void)
|
||||
g_assert_cmpint (count, ==, 2);
|
||||
}
|
||||
|
||||
static void
|
||||
test_explicit_crlf (void)
|
||||
{
|
||||
GRegex *regex;
|
||||
|
||||
regex = g_regex_new ("[\r\n]a", 0, 0, NULL);
|
||||
g_assert_cmpint (g_regex_get_has_cr_or_lf (regex), ==, TRUE);
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -2041,6 +2051,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/regex/condition", test_condition);
|
||||
g_test_add_func ("/regex/recursion", test_recursion);
|
||||
g_test_add_func ("/regex/multiline", test_multiline);
|
||||
g_test_add_func ("/regex/explicit-crlf", test_explicit_crlf);
|
||||
|
||||
/* TEST_NEW(pattern, compile_opts, match_opts) */
|
||||
TEST_NEW("", 0, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user