From 54463d32ef6798c772c8bbf69b2c1897a854db9f Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Sun, 8 Jan 2023 01:42:04 +0100 Subject: use enhanced basic regular expressions on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When 1819ad327b (grep: fix multibyte regex handling under macOS, 2022-08-26) started to use the native regex library instead of Git's own (compat/regex/), it lost support for alternation in basic regular expressions. Bring it back by enabling the flag REG_ENHANCED on macOS when compiling basic regular expressions. Reported-by: Marco Nenciarini Suggested-by: Jeff King Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- compat/regcomp_enhanced.c | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 compat/regcomp_enhanced.c (limited to 'compat') diff --git a/compat/regcomp_enhanced.c b/compat/regcomp_enhanced.c new file mode 100644 index 0000000000..84193ce53b --- /dev/null +++ b/compat/regcomp_enhanced.c @@ -0,0 +1,9 @@ +#include "../git-compat-util.h" +#undef regcomp + +int git_regcomp(regex_t *preg, const char *pattern, int cflags) +{ + if (!(cflags & REG_EXTENDED)) + cflags |= REG_ENHANCED; + return regcomp(preg, pattern, cflags); +} -- cgit v1.3