diff options
author | Yves Orton <demerphq@gmail.com> | 2022-02-11 06:30:45 +0100 |
---|---|---|
committer | Hugo van der Sanden <hv@crypt.org> | 2022-02-18 15:08:24 +0000 |
commit | c45b45416a61f2f56dbe348f33fb1bb07a1d5444 (patch) | |
tree | 3af45bebe39f1185787116521a5e2f1afcd813c6 /proto.h | |
parent | bddb8c791b4cd7f67db06213e35b0f2351c0fea8 (diff) | |
download | perl-c45b45416a61f2f56dbe348f33fb1bb07a1d5444.tar.gz |
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.
Diffstat (limited to 'proto.h')
-rw-r--r-- | proto.h | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -4720,6 +4720,9 @@ STATIC void S_regdump_extflags(pTHX_ const char *lead, const U32 flags); #define PERL_ARGS_ASSERT_REGDUMP_EXTFLAGS STATIC void S_regdump_intflags(pTHX_ const char *lead, const U32 flags); #define PERL_ARGS_ASSERT_REGDUMP_INTFLAGS +STATIC regnode_offset S_regnode_guts_debug(pTHX_ RExC_state_t *pRExC_state, const U8 op, const STRLEN extra_len); +#define PERL_ARGS_ASSERT_REGNODE_GUTS_DEBUG \ + assert(pRExC_state) STATIC bool S_regtail_study(pTHX_ RExC_state_t *pRExC_state, regnode_offset p, const regnode_offset val, U32 depth) __attribute__warn_unused_result__; #define PERL_ARGS_ASSERT_REGTAIL_STUDY \ @@ -5886,9 +5889,9 @@ STATIC bool S_handle_names_wildcard(pTHX_ const char * wname, const STRLEN wname STATIC int S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state, const char* const s, char ** updated_parse_ptr, AV** posix_warnings, const bool check_only); #define PERL_ARGS_ASSERT_HANDLE_POSSIBLE_POSIX \ assert(pRExC_state); assert(s) -STATIC regnode_offset S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV ** return_invlist, I32 *flagp, U32 depth, char * const oregcomp_parse); +STATIC regnode_offset S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV ** return_invlist, I32 *flagp, U32 depth); #define PERL_ARGS_ASSERT_HANDLE_REGEX_SETS \ - assert(pRExC_state); assert(flagp); assert(oregcomp_parse) + assert(pRExC_state); assert(flagp) STATIC SV * S_handle_user_defined_property(pTHX_ const char * name, const STRLEN name_len, const bool is_utf8, const bool to_fold, const bool runtime, const bool deferrable, SV* contents, bool *user_defined_ptr, SV * msg, const STRLEN level); #define PERL_ARGS_ASSERT_HANDLE_USER_DEFINED_PROPERTY \ assert(name); assert(contents); assert(user_defined_ptr); assert(msg) @@ -5990,9 +5993,9 @@ STATIC unsigned int S_regex_set_precedence(const U8 my_operator) STATIC void S_reginsert(pTHX_ RExC_state_t *pRExC_state, const U8 op, const regnode_offset operand, const U32 depth); #define PERL_ARGS_ASSERT_REGINSERT \ assert(pRExC_state) -STATIC regnode_offset S_regnode_guts(pTHX_ RExC_state_t *pRExC_state, const U8 op, const STRLEN extra_len, const char* const name); +STATIC regnode_offset S_regnode_guts(pTHX_ RExC_state_t *pRExC_state, const STRLEN extra_len); #define PERL_ARGS_ASSERT_REGNODE_GUTS \ - assert(pRExC_state); assert(name) + assert(pRExC_state) STATIC regnode_offset S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth); #define PERL_ARGS_ASSERT_REGPIECE \ assert(pRExC_state); assert(flagp) |