[gtksourceview] regex: fix various PCRE2 API use



commit 95396154d270c452ee49bbaed611c8a1e25e3a45
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jul 6 13:47:52 2021 -0700

    regex: fix various PCRE2 API use
    
    pcre2_pattern_info() specifies uint32_t for all "what" types except a
    handeful. These therefore should be uint32_t.
    
    errmsg is already \0 terminated by pcre2_get_error_message() so we can
    drop the additional \0.
    
    Fixes #199

 gtksourceview/implregex.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/gtksourceview/implregex.c b/gtksourceview/implregex.c
index 05e763de..e8dcbe01 100644
--- a/gtksourceview/implregex.c
+++ b/gtksourceview/implregex.c
@@ -75,7 +75,7 @@ struct _ImplMatchInfo
        pcre2_match_data *match_data;
        PCRE2_SIZE       *offsets;
        int               matches;
-       int               n_subpatterns;
+       uint32_t          n_subpatterns;
        gssize            pos;
 };
 
@@ -216,7 +216,6 @@ impl_regex_new (const char          *pattern,
                char errmsg[128];
 
                pcre2_get_error_message (errnumber, (guchar *)errmsg, sizeof errmsg-1);
-               errmsg[sizeof errmsg-1] = 0;
 
                g_set_error (error,
                             G_REGEX_ERROR,
@@ -1135,7 +1134,7 @@ impl_match_info_next (ImplMatchInfo  *match_info,
 int
 impl_regex_get_max_lookbehind (const ImplRegex *regex)
 {
-       size_t value = 0;
+       uint32_t value = 0;
 
        g_return_val_if_fail (regex != NULL, 0);
        g_return_val_if_fail (regex->code != NULL, 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]