[padb-devel] [padb] r204 committed - Merge the complex bits of default_output_handler and show_results_from...
codesite-noreply at google.com
codesite-noreply at google.com
Mon Sep 7 21:55:23 BST 2009
Revision: 204
Author: apittman
Date: Mon Sep 7 13:54:28 2009
Log: Merge the complex bits of default_output_handler and
show_results_from_file into
one function called complex_output_handler.
http://code.google.com/p/padb/source/detail?r=204
Modified:
/branches/cleanup/src/padb
=======================================
--- /branches/cleanup/src/padb Mon Sep 7 11:24:28 2009
+++ /branches/cleanup/src/padb Mon Sep 7 13:54:28 2009
@@ -3068,6 +3068,11 @@
$allfns{$mode}{out_handler}( undef, $nlines );
return;
}
+
+ my $of = 'raw';
+ $of = 'tree' if $tree;
+ $of = 'compress' if $compress;
+ $of = 'compress_c' if $compress_c;
#if ( $mode eq "stack" or $input_file ) {
# if ( $strip_below_main or $strip_above_wait ) {
@@ -3075,37 +3080,8 @@
# }
#}
- if ($tree) {
- print show_tree( make_tree($lines) );
- } elsif ($compress) {
- foreach my $tag ( sort { $a <=> $b } ( keys %$lines ) ) {
- next if ( not defined $lines->{$tag} );
- my $rng = rng_create_empty();
- rng_add_value( $rng, $tag );
- foreach my $tag2 ( keys %$lines ) {
- next if ( $tag2 eq $tag );
- if ( cmp_list( \@{ $lines->{$tag} }, \@{ $lines->{$tag2} }
) ) {
- rng_add_value( $rng, $tag2 );
- delete( $lines->{$tag2} );
- }
- }
- print("----------------\n");
- printf "%s\n", rng_convert_to_user($rng);
- print("----------------\n");
- foreach my $data ( @{ $lines->{$tag} } ) {
- print("$data\n");
- }
- }
- } elsif ($compress_c) {
- foreach my $tag ( sort { $a <=> $b } ( keys %$lines ) ) {
- print("----------------\n");
- print("$tag\n");
- print("----------------\n");
- foreach my $data ( @{ $lines->{$tag} } ) {
- print("$data\n");
- }
- }
- }
+ complex_output_handler( $of, $lines );
+
return;
}
@@ -3154,11 +3130,8 @@
# Warn on missing output here...
return unless exists $d->{target_output};
- my $lines = $d->{target_output};
- my $mode = $req->{mode};
- my $output = 'raw';
-
- $output = $req->{out_format} if defined $req->{out_format};
+ my $lines = $d->{target_output};
+ my $mode = $req->{mode};
if ( $mode eq 'stack' or $input_file ) {
if ( $cargs->{strip_below_main} or $cargs->{strip_above_wait} ) {
@@ -3166,6 +3139,27 @@
}
}
+ if ( defined $req->{out_format} ) {
+ complex_output_handler( $req->{out_format}, $lines );
+ } else {
+ my $nprocesses = keys %{ $d->{target_output} };
+ foreach my $process ( sort { $a <=> $b } keys %{
$d->{target_output} } )
+ {
+ foreach my $line ( @{ $d->{target_output}{$process} } ) {
+ if ( $nprocesses == 1 ) {
+ print "$line\n";
+ } else {
+ print "$process:$line\n";
+ }
+ }
+ }
+ }
+ return;
+}
+
+sub complex_output_handler {
+ my ( $output, $lines ) = @_;
+
if ( $output eq 'tree' ) {
print show_tree( make_tree($lines) );
} elsif ( $output eq 'compress' ) {
@@ -3198,17 +3192,7 @@
}
}
} else {
- my $nprocesses = keys %{ $d->{target_output} };
- foreach my $process ( sort { $a <=> $b } keys %{
$d->{target_output} } )
- {
- foreach my $line ( @{ $d->{target_output}{$process} } ) {
- if ( $nprocesses == 1 ) {
- print "$line\n";
- } else {
- print "$process:$line\n";
- }
- }
- }
+ die("Unexpected output mode $output");
}
return;
}
More information about the padb-devel
mailing list