summaryrefslogtreecommitdiff
path: root/Porting/Maintainers.pm
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-04-23 21:33:46 +0100
committerNicholas Clark <nick@ccl4.org>2009-04-23 21:33:46 +0100
commite1ae7bac59dc665dbcf504f414286127af684b23 (patch)
tree099822c0ca43e14790c2bc9a46dcb0a6de65a3b0 /Porting/Maintainers.pm
parent15a429282c81f4de88a288bd7c65c302f676da4c (diff)
downloadperl-e1ae7bac59dc665dbcf504f414286127af684b23.tar.gz
Break out the logic that maps file names to modules into files_to_modules().
Diffstat (limited to 'Porting/Maintainers.pm')
-rw-r--r--Porting/Maintainers.pm136
1 files changed, 70 insertions, 66 deletions
diff --git a/Porting/Maintainers.pm b/Porting/Maintainers.pm
index 0b03e0579e..666e4516db 100644
--- a/Porting/Maintainers.pm
+++ b/Porting/Maintainers.pm
@@ -18,7 +18,7 @@ use vars qw(@ISA @EXPORT_OK $VERSION);
@ISA = qw(Exporter);
@EXPORT_OK = qw(%Modules %Maintainers
get_module_files get_module_pat
- show_results process_options);
+ show_results process_options files_to_modules);
$VERSION = 0.02;
require Exporter;
@@ -135,6 +135,71 @@ sub process_options {
return ($Maintainer, $Module, $Files, @Files);
}
+sub files_to_modules {
+ my @Files = @_;
+ my %ModuleByFile;
+
+ for (@Files) { s:^\./:: }
+
+ @ModuleByFile{@Files} = ();
+
+ # First try fast match.
+
+ my %ModuleByPat;
+ for my $module (keys %Modules) {
+ for my $pat (get_module_pat($module)) {
+ $ModuleByPat{$pat} = $module;
+ }
+ }
+ # Expand any globs.
+ my %ExpModuleByPat;
+ for my $pat (keys %ModuleByPat) {
+ if (-e $pat) {
+ $ExpModuleByPat{$pat} = $ModuleByPat{$pat};
+ } else {
+ for my $exp (glob($pat)) {
+ $ExpModuleByPat{$exp} = $ModuleByPat{$pat};
+ }
+ }
+ }
+ %ModuleByPat = %ExpModuleByPat;
+ for my $file (@Files) {
+ $ModuleByFile{$file} = $ModuleByPat{$file}
+ if exists $ModuleByPat{$file};
+ }
+
+ # If still unresolved files...
+ if (my @ToDo = grep { !defined $ModuleByFile{$_} } keys %ModuleByFile) {
+
+ # Cannot match what isn't there.
+ @ToDo = grep { -e $_ } @ToDo;
+
+ if (@ToDo) {
+ # Try prefix matching.
+
+ # Remove trailing slashes.
+ for (@ToDo) { s|/$|| }
+
+ my %ToDo;
+ @ToDo{@ToDo} = ();
+
+ for my $pat (keys %ModuleByPat) {
+ last unless keys %ToDo;
+ if (-d $pat) {
+ my @Done;
+ for my $file (keys %ToDo) {
+ if ($file =~ m|^$pat|i) {
+ $ModuleByFile{$file} = $ModuleByPat{$pat};
+ push @Done, $file;
+ }
+ }
+ delete @ToDo{@Done};
+ }
+ }
+ }
+ }
+ \%ModuleByFile;
+}
sub show_results {
my ($Maintainer, $Module, $Files, @Files) = @_;
@@ -179,72 +244,11 @@ sub show_results {
duplicated_maintainers();
}
} elsif (@Files) {
- my %ModuleByFile;
-
- for (@Files) { s:^\./:: }
-
- @ModuleByFile{@Files} = ();
-
- # First try fast match.
-
- my %ModuleByPat;
- for my $module (keys %Modules) {
- for my $pat (get_module_pat($module)) {
- $ModuleByPat{$pat} = $module;
- }
- }
- # Expand any globs.
- my %ExpModuleByPat;
- for my $pat (keys %ModuleByPat) {
- if (-e $pat) {
- $ExpModuleByPat{$pat} = $ModuleByPat{$pat};
- } else {
- for my $exp (glob($pat)) {
- $ExpModuleByPat{$exp} = $ModuleByPat{$pat};
- }
- }
- }
- %ModuleByPat = %ExpModuleByPat;
- for my $file (@Files) {
- $ModuleByFile{$file} = $ModuleByPat{$file}
- if exists $ModuleByPat{$file};
- }
-
- # If still unresolved files...
- if (my @ToDo = grep { !defined $ModuleByFile{$_} } keys %ModuleByFile) {
-
- # Cannot match what isn't there.
- @ToDo = grep { -e $_ } @ToDo;
-
- if (@ToDo) {
- # Try prefix matching.
-
- # Remove trailing slashes.
- for (@ToDo) { s|/$|| }
-
- my %ToDo;
- @ToDo{@ToDo} = ();
-
- for my $pat (keys %ModuleByPat) {
- last unless keys %ToDo;
- if (-d $pat) {
- my @Done;
- for my $file (keys %ToDo) {
- if ($file =~ m|^$pat|i) {
- $ModuleByFile{$file} = $ModuleByPat{$pat};
- push @Done, $file;
- }
- }
- delete @ToDo{@Done};
- }
- }
- }
- }
-
+ my $ModuleByFile = files_to_modules(@Files);
for my $file (@Files) {
- if (defined $ModuleByFile{$file}) {
- my $module = $ModuleByFile{$file};
- my $maintainer = $Modules{$ModuleByFile{$file}}{MAINTAINER};
+ if (defined $ModuleByFile->{$file}) {
+ my $module = $ModuleByFile->{$file};
+ my $maintainer = $Modules{$ModuleByFile->{$file}}{MAINTAINER};
my $upstream = $Modules{$module}{UPSTREAM}||'unknown';
printf "%-15s [%-7s] $module $maintainer $Maintainers{$maintainer}\n", $file, $upstream;
} else {