Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yves/fix 5 37 8 bugs #40

Merged
merged 3 commits into from
Jan 21, 2023
Merged

Yves/fix 5 37 8 bugs #40

merged 3 commits into from
Jan 21, 2023

Conversation

demerphq
Copy link
Contributor

@demerphq demerphq commented Jan 20, 2023

This PR fixes various bugs I found while trying to get the module to pass test on 5.37.8.

See the commits themselves for details.

This fixes #39
It also fixes #37

It may fix other bugs in the list.

Otherwise we will fail build with:

    PCRE2.xs:315:23: error: ‘PL_core_reg_engine’ undeclared (first use in this function)

Note PCRE2 likely will not build against most of 5.37 up until 5.37.8,
where the Perl_re_op_compile() function was marked in embed.fnc as
available to extensions (with the right define).
logical_parens needs to be set up the same as nparens unless
branch reset is in use (?|(...)|(...)) buffers are now separated
into logical buffers (eg $1) and physical buffers. In the case
of a branch reset like above there would be two physical buffers,
and 1 logical buffer.

I dont think PCRE2 does branch reset properly, so we can just
default it to the same value of nparens.

This patch also includes changes to set re->lastparen and
re->lastcloseparen in the exec sub, and not in the compile sub.
Last paren indicates the highest capture buffer that has content,
and lastcloseparen indicates the last capture buffer that match
so that we can support $^N. These two values are subtly different
and are not necessarily the same, although usually they are.
This is probably not the most efficient way to deal with this,
but we cant just pointer copy the buffer. It might be modified
or freed while the regex is still alive, and then bad things happen
when the regex is freed. Instead we just clone it with savepvn()

Ideally we would more closely mimic the behavior of core in this
regard, so that we can take advantage of perl level COW support
to get a cheaper string clone.
@demerphq
Copy link
Contributor Author

Note this may require a patch i am about to push to core. (Not 100% sure.) I will follow up with the PR info.

@demerphq
Copy link
Contributor Author

If this doesnt work for you then it should work once these are merged:

Perl/perl5#20732
Perl/perl5#20731

But it should work i think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants