diff options
author | Eric Wong <e@80x24.org> | 2016-08-05 00:24:18 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-08-05 00:58:36 +0000 |
commit | 1203c8b745adfe6f0717e410ce1636260b5d9e46 (patch) | |
tree | 2c5fba98f4414f3d595947b83e93450138a5859f | |
parent | 96529fbf563a82ed5dca7b0e79d87b2aa1f75b8f (diff) | |
download | public-inbox-1203c8b745adfe6f0717e410ce1636260b5d9e46.tar.gz |
Yet another monkey patch to fix a problem encountered in upstream Mail::Thread. ref: - https://rt.cpan.org/Ticket/Display.html?id=116727 - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833479
-rw-r--r-- | lib/PublicInbox/Thread.pm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/PublicInbox/Thread.pm b/lib/PublicInbox/Thread.pm index 44a565ad..8af94616 100644 --- a/lib/PublicInbox/Thread.pm +++ b/lib/PublicInbox/Thread.pm @@ -5,6 +5,10 @@ # - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=795913 # - https://rt.cpan.org/Ticket/Display.html?id=106498 # +# And avoid recursion in recurse_down: +# - https://rt.cpan.org/Ticket/Display.html?id=116727 +# - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833479 +# # License differs from the rest of public-inbox (but is compatible): # This library is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. @@ -42,6 +46,32 @@ sub topmost { $_[0]->SUPER::topmost || PublicInbox::Thread::CPANRTBug106498->new; } +# non-recursive version of recurse_down to avoid stack depth warnings +sub recurse_down { + my ($self, $callback) = @_; + my %seen; + my @q = ($self); + while (my $cont = shift @q) { + $seen{$cont}++; + $callback->($cont); + + if (my $next = $cont->next) { + if ($seen{$next}) { + $cont->next(undef); + } else { + push @q, $next; + } + } + if (my $child = $cont->child) { + if ($seen{$child}) { + $cont->child(undef); + } else { + push @q, $child; + } + } + } +} + # ref: # - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=795913 # - https://rt.cpan.org/Ticket/Display.html?id=106498 |