diff options
-rw-r--r-- | src/regexp.c | 8 | ||||
-rw-r--r-- | src/regexp.h | 8 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/regexp.c b/src/regexp.c index 29ae8f9e4..62035a96c 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -16,6 +16,8 @@ int git_regexp_compile(git_regexp *r, const char *pattern, int flags) if (flags & GIT_REGEXP_ICASE) cflags |= PCRE_CASELESS; + if (flags & GIT_REGEXP_NEWLINE) + cflags |= PCRE_MULTILINE; if ((*r = pcre_compile(pattern, cflags, &error, &erroffset, NULL)) == NULL) { git_error_set_str(GIT_ERROR_REGEX, error); @@ -102,6 +104,8 @@ int git_regexp_compile(git_regexp *r, const char *pattern, int flags) if (flags & GIT_REGEXP_ICASE) cflags |= PCRE2_CASELESS; + if (flags & GIT_REGEXP_NEWLINE) + cflags |= PCRE2_MULTILINE; if ((*r = pcre2_compile((const unsigned char *) pattern, PCRE2_ZERO_TERMINATED, cflags, &error, &erroff, NULL)) == NULL) { @@ -200,6 +204,10 @@ int git_regexp_compile(git_regexp *r, const char *pattern, int flags) if (flags & GIT_REGEXP_ICASE) cflags |= REG_ICASE; + if (flags & GIT_REGEXP_EXTENDED) + cflags |= REG_EXTENDED; + if (flags & GIT_REGEXP_NEWLINE) + cflags |= REG_NEWLINE; # if defined(GIT_REGEX_REGCOMP) if ((error = regcomp(r, pattern, cflags)) != 0) diff --git a/src/regexp.h b/src/regexp.h index d914a807a..61824bf5c 100644 --- a/src/regexp.h +++ b/src/regexp.h @@ -30,7 +30,13 @@ typedef regex_t git_regexp; /** Options supported by @git_regexp_compile. */ typedef enum { /** Enable case-insensitive matching */ - GIT_REGEXP_ICASE = (1 << 0) + GIT_REGEXP_ICASE = (1 << 0), + + /** Enable extended matching */ + GIT_REGEXP_EXTENDED = (1 << 1), + + /** Newline matching */ + GIT_REGEXP_NEWLINE = (1 << 2) } git_regexp_flags_t; /** Structure containing information about regular expression matching groups */ |