This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c,re.pm: Remove "offsets" debugging code
authorYves Orton <demerphq@gmail.com>
Fri, 11 Feb 2022 05:30:45 +0000 (06:30 +0100)
committerHugo van der Sanden <hv@crypt.org>
Fri, 18 Feb 2022 15:08:24 +0000 (15:08 +0000)
commitc45b45416a61f2f56dbe348f33fb1bb07a1d5444
tree3af45bebe39f1185787116521a5e2f1afcd813c6
parentbddb8c791b4cd7f67db06213e35b0f2351c0fea8
regcomp.c,re.pm: Remove "offsets" debugging code

This code was added by Mark Jason Dominus to aid a regex debugger
he wrote for ActiveState. The basic premise is that every opcode
in a regex can be attributed back to a contiguous sequence of characters
that make up the pattern. This assumption has not been true ever since
the "jump" TRIE optimizations were added to the engine.

I spoke to MJD many years ago about whether it was ok to remove this
from the regex engine and he said he had no objections.

An example of a pattern that cannot be handled correctly by this logic is

    /(?: a x+ | b y+ | c z+ )/x

where the

    (?:a ... | b ... | c ...)

parts will now be handled by the TRIE logic and not by the BRANCH/EXACT
opcodes that it would have been in the past. The offset debug output
cannot handle this type of transformation, and produce nonsense output
that mention opcodes that have been optimized away from the final program.

The regex compiler is complicated enough without having to maintain this
logic. There are essentially no tests for it, and the few tests that do
cover it do so as a byproduct of testing other things. Despite the offsets
logic only being used in debug supporting it does have a cost to non-debug
logic as various internal routines include parameters related to it that
are otherwise unused.

Note this output is only usable or visible by enabling special flags
in re.pm, there is no formal API to access it short of parsing the
output of the debug mode of the regex engine, which has changed multiple
time over the past years.
embed.fnc
embed.h
ext/re/re.pm
ext/re/t/regop.pl
ext/re/t/regop.t
pod/perlreguts.pod
proto.h
regcomp.c
regcomp.h