[gtksourceview] implregex: add helper for partial match



commit 63783a2309affaf0724eeca0c0d9207e9f975871
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jul 2 12:34:45 2021 -0700

    implregex: add helper for partial match

 gtksourceview/implregex-private.h | 1 +
 gtksourceview/implregex.c         | 8 ++++++++
 2 files changed, 9 insertions(+)
---
diff --git a/gtksourceview/implregex-private.h b/gtksourceview/implregex-private.h
index fc3e1135..7d6f5d6d 100644
--- a/gtksourceview/implregex-private.h
+++ b/gtksourceview/implregex-private.h
@@ -75,6 +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);
+gboolean    impl_match_info_is_partial_match (const ImplMatchInfo    *match_info);
 int         impl_match_info_get_match_count  (const ImplMatchInfo    *match_info);
 int         impl_regex_get_max_lookbehind    (const ImplRegex        *regex);
 
diff --git a/gtksourceview/implregex.c b/gtksourceview/implregex.c
index 4135c293..4f348fe2 100644
--- a/gtksourceview/implregex.c
+++ b/gtksourceview/implregex.c
@@ -634,6 +634,14 @@ impl_regex_get_max_lookbehind (const ImplRegex *regex)
        return value;
 }
 
+gboolean
+impl_match_info_is_partial_match (const ImplMatchInfo *match_info)
+{
+       g_return_val_if_fail (match_info != NULL, FALSE);
+
+       return match_info->n_groups == PCRE2_ERROR_PARTIAL;
+}
+
 int
 impl_match_info_get_match_count (const ImplMatchInfo *match_info)
 {


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