From 7e8b5ea442f235f5e272b0fe7a4768bf897b6aad Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Thu, 7 Jun 2012 14:48:51 +0200 Subject: [PATCH] regex: Assert that our flags values are the same as PCRE's We rely on those flags having the same values as PCRE's (so we can pass them right through), so assert this at compile time. --- glib/gregex.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/glib/gregex.c b/glib/gregex.c index b7f0060d5..7da65694b 100644 --- a/glib/gregex.c +++ b/glib/gregex.c @@ -125,6 +125,30 @@ G_REGEX_MATCH_NEWLINE_CRLF | \ G_REGEX_MATCH_NEWLINE_ANY) +/* we rely on these flags having the same values */ +G_STATIC_ASSERT (G_REGEX_CASELESS == PCRE_CASELESS); +G_STATIC_ASSERT (G_REGEX_MULTILINE == PCRE_MULTILINE); +G_STATIC_ASSERT (G_REGEX_DOTALL == PCRE_DOTALL); +G_STATIC_ASSERT (G_REGEX_EXTENDED == PCRE_EXTENDED); +G_STATIC_ASSERT (G_REGEX_ANCHORED == PCRE_ANCHORED); +G_STATIC_ASSERT (G_REGEX_DOLLAR_ENDONLY == PCRE_DOLLAR_ENDONLY); +G_STATIC_ASSERT (G_REGEX_UNGREEDY == PCRE_UNGREEDY); +G_STATIC_ASSERT (G_REGEX_NO_AUTO_CAPTURE == PCRE_NO_AUTO_CAPTURE); +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_MATCH_ANCHORED == PCRE_ANCHORED); +G_STATIC_ASSERT (G_REGEX_MATCH_NOTBOL == PCRE_NOTBOL); +G_STATIC_ASSERT (G_REGEX_MATCH_NOTEOL == PCRE_NOTEOL); +G_STATIC_ASSERT (G_REGEX_MATCH_NOTEMPTY == PCRE_NOTEMPTY); +G_STATIC_ASSERT (G_REGEX_MATCH_PARTIAL == PCRE_PARTIAL); +G_STATIC_ASSERT (G_REGEX_MATCH_NEWLINE_CR == PCRE_NEWLINE_CR); +G_STATIC_ASSERT (G_REGEX_MATCH_NEWLINE_LF == PCRE_NEWLINE_LF); +G_STATIC_ASSERT (G_REGEX_MATCH_NEWLINE_CRLF == PCRE_NEWLINE_CRLF); +G_STATIC_ASSERT (G_REGEX_MATCH_NEWLINE_ANY == PCRE_NEWLINE_ANY); + /* if the string is in UTF-8 use g_utf8_ functions, else use * use just +/- 1. */ #define NEXT_CHAR(re, s) (((re)->compile_opts & PCRE_UTF8) ? \