Re: [PATCH 05/12] log: add exhaustive tests for pattern style options & config
- From
Jeff King <peff@peff.net>
- Date
- Apr 11, 2017, 10:51 UTC
- Message-ID
- <20170411105130.2ezvvm4kl5wdav3x@sigill.intra.peff.net>
- In-Reply-To
- <CACBZZX5jGGUToK83e2iugpbSBDpATi7J0BWg9=UY=YC4ZixT+Q@mail.gmail.com>
On Tue, Apr 11, 2017 at 12:32:57PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 7 quoted lines
> > This can be tricky since POSIX allows implementations to add arbitrary > > extensions for otherwise invalid syntax. > > For POSIX basic v.s. extended I'm relying on (|) not being > metacharacters in basic but metachars needing quoting in extended. I > very much doubt any regex implementation doesn't conform to that, but > maybe some crazy implementation does...
Yeah, I think BRE vs ERE (vs fixed) is fine, because POSIX specifies the differences. It's really PCRE, because ERE implementations have a surprising amount of flexibility according to the standard (basically anything invalid is listed as "undefined" and implementations are allowed to do what they please).
Show 13 quoted lines
> >> + if test_have_prereq LIBPCRE > >> + then > >> + git -c grep.patternType=perl log --pretty=tformat:%s \ > >> + --grep="\((?=1)" >actual.perl > >> + fi && > > > > I'd have to double-check POSIX, but I suspect that it may allow (?=1) to > > work in an ERE (since it's otherwise bogus to have "?" without a prior > > element to match). > > Distinguishing PCRE from the rest is much easier, I'll add some more > obscure PCRE feature to that which definitely doesn't exist in any > POSIX rx library, e.g. (*COMMIT) or something.
I think (*) would be "undefined" by POSIX, and thus allowed for extensions (though in practice it's probably fine). The "[\d]" trick was the simplest one I could find that is reliably defined to be different between ERE and PCRE.
-Peff