Fix function shortening with complex templates (boost::asio) by using Text::Balanced instead of broken regex
--- a/dist.ini Fri May 08 20:46:42 2015 +0200
+++ b/dist.ini Fri May 08 22:25:51 2015 +0200
@@ -21,9 +21,10 @@
format = %-9v %{yyyy-MM-dd}d
[Prereqs]
-Mojolicious = 5.48
+Mojolicious = 5.48
Mojolicious::Plugin::BootstrapPagination = 0.12
UUID = 0.0.3
+Text::Balanced = 0
[Prereqs / RuntimeRecommends]
; Gearman Queue (also contains the Worker class)
Gearman::Client = 1.10
--- a/lib/CrashTest/StackFilters/HideArgs.pm Fri May 08 20:46:42 2015 +0200
+++ b/lib/CrashTest/StackFilters/HideArgs.pm Fri May 08 22:25:51 2015 +0200
@@ -13,6 +13,7 @@
package CrashTest::StackFilters::HideArgs;
use Mojo::Base -base;
+use Text::Balanced qw/extract_bracketed/;
sub priority { return 50; }
@@ -36,14 +37,18 @@
return "" if(!defined($signature) || $signature eq "");
- my $short_signature = $signature;
- if($signature =~ qr{([^<]+)<.+>::([^()]+)\(.*\)(.*)}) {
- # c++ with template
- $short_signature = "$1<>::$2()$3";
- } elsif($signature =~ qr{([^()]+)\(.*\)(.*)}) {
- # c/c++
- $short_signature = "$1()$2";
- }
+ my $short_signature = "";
+ my $text = $signature;
+ do {
+ my ($str, $next, $prefix) = extract_bracketed($text, '<(', '[^<(]*');
+ if($str) {
+ $short_signature .= $prefix . substr($str, 0, 1) . substr($str, -1, 1);
+ $text = $next;
+ } else {
+ $short_signature .= $next;
+ $text = undef;
+ }
+ } while($text);
return $self->app->t(code => (title => $signature, class => "shortened-signature prettyprint lang-cpp") => sub { return $short_signature });
}