[svn:parrot] r49801 - in branches/tt532_headerizer_refactor: lib/Parrot/Headerizer tools/dev
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Mon Nov 8 02:19:55 UTC 2010
Author: jkeenan
Date: Mon Nov 8 02:19:54 2010
New Revision: 49801
URL: https://trac.parrot.org/parrot/changeset/49801
Log:
Encapsulate some code within main() into a function. Place that function in Parrot::Headerizer::Functions.
Modified:
branches/tt532_headerizer_refactor/lib/Parrot/Headerizer/Functions.pm
branches/tt532_headerizer_refactor/tools/dev/headerizer.pl
Modified: branches/tt532_headerizer_refactor/lib/Parrot/Headerizer/Functions.pm
==============================================================================
--- branches/tt532_headerizer_refactor/lib/Parrot/Headerizer/Functions.pm Mon Nov 8 02:13:21 2010 (r49800)
+++ branches/tt532_headerizer_refactor/lib/Parrot/Headerizer/Functions.pm Mon Nov 8 02:19:54 2010 (r49801)
@@ -6,6 +6,7 @@
use warnings;
use base qw( Exporter );
our @EXPORT_OK = qw(
+ print_headerizer_warnings
read_file
write_file
);
@@ -28,6 +29,30 @@
=cut
+sub print_headerizer_warnings {
+ my $warnings_ref = shift;
+ my %warnings = %{$warnings_ref};
+ if ( keys %warnings ) {
+ my $nwarnings = 0;
+ my $nwarningfuncs = 0;
+ my $nwarningfiles = 0;
+ for my $file ( sort keys %warnings ) {
+ ++$nwarningfiles;
+ print "$file\n";
+ my $funcs = $warnings{$file};
+ for my $func ( sort keys %{$funcs} ) {
+ ++$nwarningfuncs;
+ for my $error ( @{ $funcs->{$func} } ) {
+ print " $func: $error\n";
+ ++$nwarnings;
+ }
+ }
+ }
+
+ print "$nwarnings warnings in $nwarningfuncs funcs in $nwarningfiles C files\n";
+ }
+}
+
sub read_file {
my $filename = shift;
Modified: branches/tt532_headerizer_refactor/tools/dev/headerizer.pl
==============================================================================
--- branches/tt532_headerizer_refactor/tools/dev/headerizer.pl Mon Nov 8 02:13:21 2010 (r49800)
+++ branches/tt532_headerizer_refactor/tools/dev/headerizer.pl Mon Nov 8 02:19:54 2010 (r49801)
@@ -9,6 +9,7 @@
use Parrot::Config;
use Parrot::Headerizer;
use Parrot::Headerizer::Functions qw(
+ print_headerizer_warnings
read_file
write_file
);
@@ -198,26 +199,7 @@
print "Headerization complete.\n";
}
- my %warnings = %{$headerizer->{warnings}};
- if ( keys %warnings ) {
- my $nwarnings = 0;
- my $nwarningfuncs = 0;
- my $nwarningfiles = 0;
- for my $file ( sort keys %warnings ) {
- ++$nwarningfiles;
- print "$file\n";
- my $funcs = $warnings{$file};
- for my $func ( sort keys %{$funcs} ) {
- ++$nwarningfuncs;
- for my $error ( @{ $funcs->{$func} } ) {
- print " $func: $error\n";
- ++$nwarnings;
- }
- }
- }
-
- print "$nwarnings warnings in $nwarningfuncs funcs in $nwarningfiles C files\n";
- }
+ print_headerizer_warnings($headerizer->{warnings});
return;
}
More information about the parrot-commits
mailing list