[gtksourceview] implregex: add some helpers



commit 64686b6dd7f576137148acf11fee8cab86592353
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jul 2 12:20:13 2021 -0700

    implregex: add some helpers

 gtksourceview/implregex-private.h |  2 ++
 gtksourceview/implregex.c         | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)
---
diff --git a/gtksourceview/implregex-private.h b/gtksourceview/implregex-private.h
index cbcc77f1..fc3e1135 100644
--- a/gtksourceview/implregex-private.h
+++ b/gtksourceview/implregex-private.h
@@ -75,5 +75,7 @@ gboolean    impl_match_info_matches         (const ImplMatchInfo    *match_info)
 gboolean    impl_match_info_next            (ImplMatchInfo          *match_info,
                                              GError                **error);
 const char *impl_regex_get_pattern          (const ImplRegex        *regex);
+int         impl_match_info_get_match_count  (const ImplMatchInfo    *match_info);
+int         impl_regex_get_max_lookbehind    (const ImplRegex        *regex);
 
 G_END_DECLS
diff --git a/gtksourceview/implregex.c b/gtksourceview/implregex.c
index 8d1ffb94..7853e27c 100644
--- a/gtksourceview/implregex.c
+++ b/gtksourceview/implregex.c
@@ -607,3 +607,24 @@ again:
 
        return impl_match_info_matches (match_info);
 }
+
+int
+impl_regex_get_max_lookbehind (const ImplRegex *regex)
+{
+       size_t value = 0;
+
+       g_return_val_if_fail (regex != NULL, 0);
+       g_return_val_if_fail (regex->code != NULL, 0);
+
+       pcre2_pattern_info (regex->code, PCRE2_INFO_MAXLOOKBEHIND, &value);
+
+       return value;
+}
+
+int
+impl_match_info_get_match_count (const ImplMatchInfo *match_info)
+{
+       g_return_val_if_fail (match_info != NULL, 0);
+
+       return MAX (0, match_info->n_groups);
+}


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