From 0023790fec867fffa2b333ea7de38c0882fc940a Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 4 Jul 2022 09:52:50 -0700 Subject: [PATCH] applets/(c99,c11)std: better handling of capture groups within -text option --- applets/c11std.pl | 8 ++++++-- applets/c99std.pl | 8 ++++++-- lib/PBot/VERSION.pm | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/applets/c11std.pl b/applets/c11std.pl index c0bd6b17..30e9aa52 100755 --- a/applets/c11std.pl +++ b/applets/c11std.pl @@ -239,8 +239,12 @@ if (length $match_text) { $match_result =~ s/\s+/ /g; my $match = eval { - $match_result =~ m/(.*)($match_text)(.*)/msi; - return [$1, $2, $3]; + my @matches = ($match_result =~ m/($match_text)/msp); + if (@matches > 1) { + shift @matches; + @matches = grep { length $_ } @matches; + } + return [${^PREMATCH}, join (' ... ', @matches), ${^POSTMATCH}]; }; if ($@) { diff --git a/applets/c99std.pl b/applets/c99std.pl index b3d99144..735cc2da 100755 --- a/applets/c99std.pl +++ b/applets/c99std.pl @@ -239,8 +239,12 @@ if (length $match_text) { $match_result =~ s/\s+/ /g; my $match = eval { - $match_result =~ m/(.*)($match_text)(.*)/msi; - return [$1, $2, $3]; + my @matches = ($match_result =~ m/($match_text)/msp); + if (@matches > 1) { + shift @matches; + @matches = grep { length $_ } @matches; + } + return [${^PREMATCH}, join (' ... ', @matches), ${^POSTMATCH}]; }; if ($@) { diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 094f8ef9..10dbdef5 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4549, - BUILD_DATE => "2022-07-03", + BUILD_REVISION => 4550, + BUILD_DATE => "2022-07-04", }; sub initialize {}