7 # sort comparison functions
14 # This always sorts last
15 $a =~ s/THE REST/ZZZZZZ/g;
16 $b =~ s/THE REST/ZZZZZZ/g;
23 my $preferred_order = 'MRPLSWTQBCFXNK';
25 my $a1 = uc(substr($a, 0, 1));
26 my $b1 = uc(substr($b, 0, 1));
28 my $a_index = index($preferred_order, $a1);
29 my $b_index = index($preferred_order, $b1);
31 $a_index = 1000 if ($a_index == -1);
32 $b_index = 1000 if ($b_index == -1);
34 if (($a1 =~ /^F$/ && $b1 =~ /^F$/) ||
35 ($a1 =~ /^X$/ && $b1 =~ /^X$/)) {
39 if ($a_index < $b_index) {
41 } elsif ($a_index == $b_index) {
56 my ($hashref, $filename) = (@_);
58 open(my $file, '>', "$filename") or die "$P: $filename: open failed - $!\n";
59 foreach my $key (sort by_category
keys %$hashref) {
61 chomp $$hashref{$key};
62 print $file $$hashref{$key};
64 print $file "\n" . $key . "\n";
65 foreach my $pattern (sort by_pattern
split('\n', %$hashref{$key})) {
66 print $file ($pattern . "\n");
74 my ($hashref, $filename) = (@_);
78 $$hashref{$case} = "";
80 open(my $file, '<', "$filename") or die "$P: $filename: open failed - $!\n";
86 if ($line =~ m/^([A-Z]):\s*(.*)/) {
87 $line = $1 . ":\t" . trim
($2) . "\n";
88 if ($lastline eq "") {
89 $$hashref{$case} = $$hashref{$case} . $line;
92 $case = trim
($lastline);
93 exists $$hashref{$case} and die "Header '$case' already exists";
94 $$hashref{$case} = $line;
100 $$hashref{$case} = $$hashref{$case} . $lastline;
104 trim
($lastline) eq "" or die ("Odd non-pattern line '$lastline' for '$case'");
107 $$hashref{$case} = $$hashref{$case} . $lastline;
114 file_input
(\
%hash, "MAINTAINERS");
116 foreach my $type (@ARGV) {
117 foreach my $key (keys %hash) {
118 if ($key =~ /$type/ || $hash{$key} =~ /$type/) {
119 $new_hash{$key} = $hash{$key};
125 alpha_output
(\
%hash, "MAINTAINERS.new");
126 alpha_output
(\
%new_hash, "SECTION.new");