[glib/wip/pcre-8.31: 4/4] regex: Add accessor to get max length of lookbehind characters
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/pcre-8.31: 4/4] regex: Add accessor to get max length of lookbehind characters
- Date: Fri, 29 Jun 2012 07:02:54 +0000 (UTC)
commit 2fac72a29e7165504a88c7c100d94843965c4686
Author: Christian Persch <chpe gnome org>
Date: Thu Jun 14 22:33:15 2012 +0200
regex: Add accessor to get max length of lookbehind characters
Use PCRE_INFO_MAXLOOKBEHIND to get the length (in characters) of the
longest lookbehind assertion in the pattern.
docs/reference/glib/glib-sections.txt | 1 +
glib/gregex.c | 28 ++++++++++++++++++++++++++++
glib/gregex.h | 1 +
3 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 02652a7..298e9fc 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -1004,6 +1004,7 @@ g_regex_ref
g_regex_unref
g_regex_get_pattern
g_regex_get_max_backref
+g_regex_get_max_lookbehind
g_regex_get_capture_count
g_regex_get_has_cr_or_lf
g_regex_get_string_number
diff --git a/glib/gregex.c b/glib/gregex.c
index afd3f92..a064868 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -1525,6 +1525,34 @@ g_regex_get_max_backref (const GRegex *regex)
return value;
}
+
+/**
+ * g_regex_get_max_backref:
+ * @regex: a #GRegex
+ *
+ * Returns the lentgh of the longest lookbehind assertion in the pattern, in
+ * characters. Returns <literal>0</literal> if the pattern does not
+ * contain lookbehind assertions.
+ *
+ * This information may be useful when doing incremental partial matching; in
+ * that case you should always keep at least this many characters before the
+ * partially matched string.
+ *
+ * Returns: the length of the longest lookbehind assertion in the pattern
+ *
+ * Since: 2.34
+ */
+gint
+g_regex_get_max_lookbehind (const GRegex *regex)
+{
+ gint value;
+
+ pcre_fullinfo (regex->pcre_re, regex->extra,
+ PCRE_INFO_MAXLOOKBEHIND, &value);
+
+ return value;
+}
+
/**
* g_regex_get_capture_count:
* @regex: a #GRegex
diff --git a/glib/gregex.h b/glib/gregex.h
index 7820a14..33e5451 100644
--- a/glib/gregex.h
+++ b/glib/gregex.h
@@ -449,6 +449,7 @@ GRegex *g_regex_ref (GRegex *regex);
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_max_lookbehind (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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]