[Bps-public-commit] r9197 - Text-Quoted
ruz at bestpractical.com
ruz at bestpractical.com
Wed Oct 3 07:01:49 EDT 2007
Author: ruz
Date: Wed Oct 3 07:01:48 2007
New Revision: 9197
Modified:
Text-Quoted/ (props changed)
Text-Quoted/Quoted.pm
Log:
r18253 at cubic-pc: cubic | 2007-10-03 04:56:02 +0400
* refactor find_below
** use streams (grep, map)
** sort after greps
Modified: Text-Quoted/Quoted.pm
==============================================================================
--- Text-Quoted/Quoted.pm (original)
+++ Text-Quoted/Quoted.pm Wed Oct 3 07:01:48 2007
@@ -140,28 +140,15 @@
sub find_below {
my ( $top_level, @stuff ) = @_;
- #print "## Looking for the next level of quoting after $top_level\n";
- #print "## We have:\n";
- #print "## $_->{raw}\n" for @stuff;
-
- my @prefices = sort { length $a <=> length $b } map { $_->{quoter} } @stuff;
-
# Find the prefices, shortest first.
-
- # return $prefices[0] if $prefices[0] eq $prefices[-1];
-
- for (@prefices) {
-
- # And return the first one which is "below" where we are right
- # now but is a proper subset of the next line.
- next unless $_;
- if ( $_ =~ /^\Q$top_level\E.+/ and $stuff[0]->{quoter} =~ /^\Q$_\E/ ) {
-
- #print "## We decided on $_\n";
- return $_;
- }
- }
- die "Can't happen";
+ # And return the first one which is "below" where we are right
+ # now but is a proper subset of the next line.
+ return (
+ sort { length $a <=> length $b }
+ grep $_ && /^\Q$top_level\E./ && $stuff[0]->{quoter} =~ /^\Q$_\E/,
+ map $_->{quoter},
+ @stuff
+ )[0];
}
# Everything below this point is essentially Text::Autoformat.
More information about the Bps-public-commit
mailing list