Subject: | Use of pregcomp breaks Package::Stash::XS with perl < 5.9.5 |
The pregcomp API changed in perl 5.9.5 (according to ppport.h) and needs
2 arguments in current perls, as used in Package::Stash::XS 0.24. Prior
to that it needed three arguments, and attempting to build
Package::Stash::XS on an older perl results in this error:
XS.xs:810:44: error: macro "pregcomp" requires 3 arguments, but only 2 given
XS.xs: In function 'boot_Package__Stash__XS':
XS.xs:810: error: 'pregcomp' undeclared (first use in this function)
XS.xs:810: error: (Each undeclared identifier is reported only once
XS.xs:810: error: for each function it appears in.)
make: *** [XS.o] Error 1
I tried the attached patch and it seemed to fix the problem, passing the
test suite on a variety of perls back to 5.8.3.
Subject: | Package-Stash-XS-0.24-perl58.patch |
API for pregcomp changed from 3-args to 2-args in 5.9.5, and
ppport.h can't automagically fix that for us.
--- Package-Stash-XS-0.24/XS.xs
+++ Package-Stash-XS-0.24/XS.xs
@@ -804,10 +804,18 @@
BOOT:
{
+ const char *vmre = "\\A[0-9A-Z_a-z]+(?:::[0-9A-Z_a-z]+)*\\z";
+#if (PERL_VERSION < 9) || ((PERL_VERSION == 9) && (PERL_SUBVERSION < 5))
+ PMOP fakepmop;
+
+ fakepmop.op_pmflags = 0;
+ valid_module_regex = pregcomp(vmre, vmre + strlen(vmre), &fakepmop);
+#else
SV *re;
- re = newSVpv("\\A[0-9A-Z_a-z]+(?:::[0-9A-Z_a-z]+)*\\z", 0);
+ re = newSVpv(vmre, 0);
valid_module_regex = pregcomp(re, 0);
+#endif
name_key = newSVpvs("name");
PERL_HASH(name_hash, "name", 4);