[glib/wip/pcre-update: 2/17] regex: Add NEWLINE_ANYCRLF compile option
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/pcre-update: 2/17] regex: Add NEWLINE_ANYCRLF compile option
- Date: Fri, 29 Jun 2012 06:59:27 +0000 (UTC)
commit f01b8723a7132b9c482dab0dc75aaf7c89686416
Author: Christian Persch <chpe gnome org>
Date: Thu Jun 7 15:23:37 2012 +0200
regex: Add NEWLINE_ANYCRLF compile option
The PCRE_NEWLINE_ANYCRLF option is new in PCRE 7.1. With it set, the only
only newline sequences recognised are CR, LF and CRLF.
glib/gregex.c | 4 +++-
glib/gregex.h | 21 ++++++++++++++-------
glib/tests/regex.c | 2 --
3 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/glib/gregex.c b/glib/gregex.c
index 7da6569..b51d59b 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -112,7 +112,8 @@
G_REGEX_DUPNAMES | \
G_REGEX_NEWLINE_CR | \
G_REGEX_NEWLINE_LF | \
- G_REGEX_NEWLINE_CRLF)
+ G_REGEX_NEWLINE_CRLF | \
+ G_REGEX_NEWLINE_ANYCRLF)
/* Mask of all the possible values for GRegexMatchFlags. */
#define G_REGEX_MATCH_MASK (G_REGEX_MATCH_ANCHORED | \
@@ -138,6 +139,7 @@ G_STATIC_ASSERT (G_REGEX_DUPNAMES == PCRE_DUPNAMES);
G_STATIC_ASSERT (G_REGEX_NEWLINE_CR == PCRE_NEWLINE_CR);
G_STATIC_ASSERT (G_REGEX_NEWLINE_LF == PCRE_NEWLINE_LF);
G_STATIC_ASSERT (G_REGEX_NEWLINE_CRLF == PCRE_NEWLINE_CRLF);
+G_STATIC_ASSERT (G_REGEX_NEWLINE_ANYCRLF == PCRE_NEWLINE_ANYCRLF);
G_STATIC_ASSERT (G_REGEX_MATCH_ANCHORED == PCRE_ANCHORED);
G_STATIC_ASSERT (G_REGEX_MATCH_NOTBOL == PCRE_NOTBOL);
diff --git a/glib/gregex.h b/glib/gregex.h
index 4964c66..6e510c3 100644
--- a/glib/gregex.h
+++ b/glib/gregex.h
@@ -259,12 +259,18 @@ GQuark g_regex_error_quark (void);
* be unique. This can be helpful for certain types of pattern when it
* is known that only one instance of the named subpattern can ever be
* matched.
- * @G_REGEX_NEWLINE_CR: Usually any newline character is recognized, if this
- * option is set, the only recognized newline character is '\r'.
- * @G_REGEX_NEWLINE_LF: Usually any newline character is recognized, if this
- * option is set, the only recognized newline character is '\n'.
- * @G_REGEX_NEWLINE_CRLF: Usually any newline character is recognized, if this
- * option is set, the only recognized newline character sequence is '\r\n'.
+ * @G_REGEX_NEWLINE_CR: Usually any newline character or character sequence is
+ * recognized. If this option is set, the only recognized newline character
+ * is '\r'.
+ * @G_REGEX_NEWLINE_LF: Usually any newline character or character sequence is
+ * recognized. If this option is set, the only recognized newline character
+ * is '\n'.
+ * @G_REGEX_NEWLINE_CRLF: Usually any newline character or character sequence is
+ * recognized. If this option is set, the only recognized newline character
+ * sequence is '\r\n'.
+ * @G_REGEX_NEWLINE_ANYCRLF: Usually any newline character or character sequence
+ * is recognized. If this option is set, the only recognized newline character
+ * sequences are '\r', '\n', and '\r\n'. Since: 2.34
*
* Flags specifying compile-time options.
*
@@ -287,7 +293,8 @@ typedef enum
G_REGEX_DUPNAMES = 1 << 19,
G_REGEX_NEWLINE_CR = 1 << 20,
G_REGEX_NEWLINE_LF = 1 << 21,
- G_REGEX_NEWLINE_CRLF = G_REGEX_NEWLINE_CR | G_REGEX_NEWLINE_LF
+ G_REGEX_NEWLINE_CRLF = G_REGEX_NEWLINE_CR | G_REGEX_NEWLINE_LF,
+ G_REGEX_NEWLINE_ANYCRLF = G_REGEX_NEWLINE_CR | 1 << 22
} GRegexCompileFlags;
/**
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index 6deb50f..7d19333 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -2102,9 +2102,7 @@ main (int argc, char *argv[])
#endif
TEST_NEW_FAIL ("\\666", G_REGEX_RAW, G_REGEX_ERROR_INVALID_OCTAL_VALUE);
TEST_NEW_FAIL ("^(?(DEFINE) abc | xyz ) ", 0, G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE);
-#if 0
TEST_NEW_FAIL ("a", G_REGEX_NEWLINE_CRLF | G_REGEX_NEWLINE_ANYCRLF, G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS);
-#endif
TEST_NEW_FAIL ("^(a)\\g{3", 0, G_REGEX_ERROR_MISSING_BACK_REFERENCE);
TEST_NEW_FAIL ("^(a)\\g{0}", 0, G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE);
TEST_NEW_FAIL ("abc(*FAIL:123)xyz", 0, G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]