Add API functions for regex global pos
magic
#22971
Open
+222
−43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a set of API functions for XS to see or modify any
pos()
magic position on an SV.While reviewing some of my modules' more internals-hackery uses of the MAGIC API, I found a place where I have to reach deep into innards of how
PERL_MAGIC_regexp_global
works, in order to see or manipulate thepos()
position annotation on a string SV. See this XS function:https://metacpan.org/release/PEVANS/Term-TermKey-0.17/source/lib/Term/TermKey.xs#L713
This makes the code very tightly dependent on exact details of how Perl's magic currently works.
By adding these API functions (which can be easily emulated by earlier perls), the XS code can now be made much more robust against inner changes that may later affect how Perl implements this.
I'm not super convinced by the naming prefix on these -
sv_regexp_global_pos_...
might be considered rather too long. Will take suggestions on better ideas.