summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2023-01-08 14:16:36 +0100
committerYves Orton <demerphq@gmail.com>2023-01-09 22:43:38 +0100
commit6f9328ca348b95ff60b2672e0c425242e6e87419 (patch)
tree03b62b9852452d8d1540fa105db610142ce85249 /ext
parent239136505f79898ae40cd38f706babe0f23f0993 (diff)
downloadperl-6f9328ca348b95ff60b2672e0c425242e6e87419.tar.gz
regcomp.pl - fixup intflags debug data to handle gaps properly
We were not handling gaps in the sequence properly, and effectively showing the wrong flag names or missing the last flag. Now we die if there are any collisions or if any of the PREGf defines set more than one bit. This also adds some crude tests to validate that intflags serialization is working properly. Note, extflags handles more complex scenarios and seems to handle this gracefully already, hence the reason I haven't touched it as well. This also tweaks a comment in lexical_debug.t which part of this was cribbed from.
Diffstat (limited to 'ext')
-rw-r--r--ext/re/re.pm2
-rw-r--r--ext/re/t/intflags.pl16
-rw-r--r--ext/re/t/intflags.t25
-rw-r--r--ext/re/t/lexical_debug.t2
4 files changed, 43 insertions, 2 deletions
diff --git a/ext/re/re.pm b/ext/re/re.pm
index cf1f7421a2..6da4e02f32 100644
--- a/ext/re/re.pm
+++ b/ext/re/re.pm
@@ -4,7 +4,7 @@ package re;
use strict;
use warnings;
-our $VERSION = "0.43";
+our $VERSION = "0.44";
our @ISA = qw(Exporter);
our @EXPORT_OK = qw{
is_regexp regexp_pattern
diff --git a/ext/re/t/intflags.pl b/ext/re/t/intflags.pl
new file mode 100644
index 0000000000..a79180681e
--- /dev/null
+++ b/ext/re/t/intflags.pl
@@ -0,0 +1,16 @@
+use re 'Debug' => qw(DUMP FLAGS);
+our $count;
+my $code= '(?{$count++})';
+my @p= (
+ qr/(foo)(?1)?/,
+ qr/\Gfoo/,
+ qr/.*foo/,
+ qr/^foo/,
+ qr/(foo(*THEN)bar|food)/,
+ qr/a.*b.*/,
+ qr/a{1,4}\Gfoo/,
+ qr/a+/,
+ do { use re 'eval'; qr/a$code/},
+);
+
+print STDERR "-OK-\n";
diff --git a/ext/re/t/intflags.t b/ext/re/t/intflags.t
new file mode 100644
index 0000000000..256bf1f007
--- /dev/null
+++ b/ext/re/t/intflags.t
@@ -0,0 +1,25 @@
+#!./perl
+
+BEGIN {
+ require Config;
+ if (($Config::Config{'extensions'} !~ /\bre\b/) ){
+ print "1..0 # Skip -- Perl configured without re module\n";
+ exit 0;
+ }
+}
+
+use strict;
+
+# must use a BEGIN or the prototypes wont be respected meaning
+# tests could pass that shouldn't.
+BEGIN { require "../../t/test.pl"; }
+my $out = runperl(progfile => "t/intflags.pl", stderr => 1 );
+like($out,qr/-OK-\n/, "intflags.pl ran to completion");
+
+my %seen;
+foreach my $line (split /\n/, $out) {
+ $line=~s/^r->intflags:\s+// or next;
+ length($_) and $seen{$_}++ for split /\s+/, $line;
+}
+is(0+keys %seen,14);
+done_testing;
diff --git a/ext/re/t/lexical_debug.t b/ext/re/t/lexical_debug.t
index b2570f0e2d..4c8b47d54f 100644
--- a/ext/re/t/lexical_debug.t
+++ b/ext/re/t/lexical_debug.t
@@ -11,7 +11,7 @@ BEGIN {
use strict;
# must use a BEGIN or the prototypes wont be respected meaning
- # tests could pass that shouldn't
+# tests could pass that shouldn't
BEGIN { require "../../t/test.pl"; }
my $out = runperl(progfile => "t/lexical_debug.pl", stderr => 1 );