[gtksourceview] pcre2: match gregex flags more closely
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gtksourceview] pcre2: match gregex flags more closely
- Date: Thu,  1 Oct 2020 22:38:52 +0000 (UTC)
commit 48934c02a772c6128050b6d72ee7176685fd8eac
Author: Christian Hergert <chergert redhat com>
Date:   Thu Oct 1 15:38:47 2020 -0700
    pcre2: match gregex flags more closely
    
    This makes various flags closer to what gregex would do internally when
    using PCRE.
 gtksourceview/implregex.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gtksourceview/implregex.c b/gtksourceview/implregex.c
index dbe04a69..04f5389b 100644
--- a/gtksourceview/implregex.c
+++ b/gtksourceview/implregex.c
@@ -76,7 +76,9 @@ translate_compile_flags (GRegexCompileFlags flags)
                ret |= PCRE2_DUPNAMES;
 
        ret |= PCRE2_UCP;
-       ret |= PCRE2_BSR_UNICODE;
+
+       if (~flags & G_REGEX_BSR_ANYCRLF)
+               ret |= PCRE2_BSR_UNICODE;
 
        return ret;
 }
@@ -153,7 +155,7 @@ impl_regex_new (const char          *pattern,
        else if (compile_options & G_REGEX_NEWLINE_ANYCRLF)
                pcre2_set_newline (context, PCRE2_NEWLINE_ANYCRLF);
        else
-               pcre2_set_newline (context, PCRE2_NEWLINE_LF);
+               pcre2_set_newline (context, PCRE2_NEWLINE_ANY);
 
        regex->code = pcre2_compile ((PCRE2_SPTR)pattern,
                                     PCRE2_ZERO_TERMINATED,
@@ -543,11 +545,16 @@ again:
        }
        else
        {
+               gsize match_flags = match_info->regex->match_flags;
+
+               if (match_info->regex->compile_flags & PCRE2_UTF)
+                       match_flags |= PCRE2_NO_UTF_CHECK;
+
                rc = pcre2_match (match_info->regex->code,
                                  (PCRE2_SPTR)match_info->string,
                                  match_info->string_len,
                                  match_info->start_pos,
-                                 match_info->match_flags,
+                                 match_flags,
                                  match_info->match_data,
                                  NULL);
        }
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]