#! /usr/bin/perl use strict; use warnings; ## This table is for determining what order to show entries from different ## source "Maintainers" files. They are prioritized based on the number and ## significance of each field, as listed in this table. Any field not found ## here will be assumed to have a significance of "1". my %fieldprio = ( p => 5, ## Person m => 5, ## Email l => 5, ## Mailing List f => 0, ## File ); my %mprio; my %maint; my $section; my $origin; my $pathprefix; my $printorigin; while (<>) { unless (defined $origin and $origin eq $ARGV) { undef $section; ## Get rid of extra slashes, unnecessary "./" entries $ARGV =~ s{//+}{/}g; $ARGV =~ s{(^|/)\./}{$1}; $origin = $ARGV; } chomp; s/\s+/ /g; s/^ //; s/ $//; /\S+/ or next; if (/^\[ ?([^]]+) ?\]$/) { $section = uc $1; $printorigin = 1 if $origin ne '-'; $maint{$section}{$origin} ||= []; $mprio{$section}{$origin} ||= 0; ## Figure out a useful path prefix if there is one $pathprefix = ($origin =~ m{(^.*/)(?!\.\.?$)[^/]+$})?$1:""; next; } unless (/^([^:]+?) ?: ?(.*)$/) { print STDERR "$ARGV:$.: Invalid line: $_\n"; next; } my($field,$value) = (lc($1), $2); unless (defined $section) { print STDERR "$ARGV:$.: Found field '\u$field' before ", "any subsystem declaration: $_\n"; next; } ## Preprocess paths to make them absolute $value = $pathprefix.$value if $field eq 'f'; ## Update the sorting order if (exists $fieldprio{$field}) { $mprio{$section}{$origin} += $fieldprio{$field}; } else { $mprio{$section}{$origin}++; } push @{$maint{$section}{$origin}}, [$field, $value]; } sub priosort ( $@ ) { my $section = shift; return sort {$mprio{$section}{$b} <=> $mprio{$section}{$a}} @_; } for $section (sort {$a cmp $b} keys %maint) { print "[$section]\n"; for my $origin (priosort $section, keys %{$maint{$section}}) { print "\nOrigin: $origin\n" if $printorigin; print "\u$_->[0]: $_->[1]\n" for @{$maint{$section}{$origin}}; } print "\n\n"; } # vim:set ft=perl: