From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: "Jeff King" <peff@peff.net>,
"Marco Nenciarini" <marco.nenciarini@enterprisedb.com>,
git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: BUG: git grep behave oddly with alternatives
Date: Sun, 08 Jan 2023 10:27:58 +0900 [thread overview]
Message-ID: <xmqqpmbp24td.fsf@gitster.g> (raw)
In-Reply-To: <26a0d4ca-3d97-ace4-1a1f-92b1ee6715a6@web.de> ("René Scharfe"'s message of "Sun, 8 Jan 2023 01:42:04 +0100")
René Scharfe <l.s.r@web.de> writes:
> diff --git a/Makefile b/Makefile
> index db447d0738..46e30be673 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -289,6 +289,10 @@ include shared.mak
> # Define NO_REGEX if your C library lacks regex support with REG_STARTEND
> # feature.
> #
> +# Define USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS if your C library provides
> +# the flag REG_ENHANCED and you'd like to use it to enable enhanced basic
> +# regular expressions.
> +#
I wondered if we should mention macOS somewhere in the description
to help those users that may be affeced, but it seems that looking
for "REG_ENHANCED BSD" with a search engine finds pages that
indicate this is available on BSD's in general?
> @@ -2037,6 +2041,11 @@ endif
> ifdef NO_REGEX
> COMPAT_CFLAGS += -Icompat/regex
> COMPAT_OBJS += compat/regex/regex.o
> +else
> +ifdef USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS
> + COMPAT_CFLAGS += -DUSE_ENHANCED_BASIC_REGULAR_EXPRESSIONS
> + COMPAT_OBJS += compat/regcomp_enhanced.o
> +endif
OK.
> 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);
> +}
OK. I like the "we only want to affect BRE" bit, that is carefully
done.
> diff --git a/config.mak.uname b/config.mak.uname
> index d63629fe80..7d25995265 100644
> --- a/config.mak.uname
> +++ b/config.mak.uname
> @@ -147,6 +147,7 @@ ifeq ($(uname_S),Darwin)
> FREAD_READS_DIRECTORIES = UnfortunatelyYes
> HAVE_NS_GET_EXECUTABLE_PATH = YesPlease
> CSPRNG_METHOD = arc4random
> + USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS = YesPlease
OK. This would give macOS folks who have already been using the
enhanced mode (without us asking) with their older libraries the
behaviour they are more familiar with. Good.
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 76e4b11131..1efa834089 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -1338,6 +1338,11 @@ static inline int regexec_buf(const regex_t *preg, const char *buf, size_t size,
> return regexec(preg, buf, nmatch, pmatch, eflags | REG_STARTEND);
> }
>
> +#ifdef USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS
> +int git_regcomp(regex_t *preg, const char *pattern, int cflags);
> +#define regcomp git_regcomp
> +#endif
OK.
next prev parent reply other threads:[~2023-01-08 1:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 9:53 BUG: git grep behave oddly with alternatives Marco Nenciarini
2023-01-03 16:29 ` René Scharfe
2023-01-03 18:13 ` Marco Nenciarini
2023-01-03 20:52 ` René Scharfe
2023-01-04 6:13 ` Junio C Hamano
2023-01-04 7:46 ` Jeff King
2023-01-04 16:36 ` René Scharfe
2023-01-06 9:09 ` Jeff King
2023-01-08 0:42 ` René Scharfe
2023-01-08 1:27 ` Junio C Hamano [this message]
2023-01-11 18:56 ` Jeff King
2023-01-12 17:13 ` René Scharfe
2023-01-12 17:52 ` Ævar Arnfjörð Bjarmason
2023-01-12 21:54 ` Jeff King
2023-01-13 8:28 ` Ævar Arnfjörð Bjarmason
2023-01-13 17:19 ` Junio C Hamano
2023-01-14 6:44 ` René Scharfe
2023-01-14 8:31 ` René Scharfe
2023-01-14 12:45 ` Diomidis Spinellis
2023-01-14 16:08 ` Junio C Hamano
2023-01-13 17:24 ` René Scharfe
2023-01-13 23:03 ` René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqpmbp24td.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
--cc=marco.nenciarini@enterprisedb.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).