2 # SPDX-License-Identifier: GPL-2.0
8 # sort comparison functions
15 # This always sorts last
16 $a =~ s/THE REST/ZZZZZZ/g;
17 $b =~ s/THE REST/ZZZZZZ/g;
24 my $preferred_order = 'MRPLSWTQBCFXNK';
26 my $a1 = uc(substr($a, 0, 1));
27 my $b1 = uc(substr($b, 0, 1));
29 my $a_index = index($preferred_order, $a1);
30 my $b_index = index($preferred_order, $b1);
32 $a_index = 1000 if ($a_index == -1);
33 $b_index = 1000 if ($b_index == -1);
35 if (($a1 =~ /^F$/ && $b1 =~ /^F$/) ||
36 ($a1 =~ /^X$/ && $b1 =~ /^X$/)) {
40 if ($a_index < $b_index) {
42 } elsif ($a_index == $b_index) {
57 my ($hashref, $filename) = (@_);
59 open(my $file, '>', "$filename") or die "$P: $filename: open failed - $!\n";
60 foreach my $key (sort by_category keys %$hashref) {
62 chomp $$hashref{$key};
63 print $file $$hashref{$key};
65 print $file "\n" . $key . "\n";
66 foreach my $pattern (sort by_pattern split('\n', %$hashref{$key})) {
67 print $file ($pattern . "\n");
75 my ($hashref, $filename) = (@_);
79 $$hashref{$case} = "";
81 open(my $file, '<', "$filename") or die "$P: $filename: open failed - $!\n";
87 if ($line =~ m/^([A-Z]):\s*(.*)/) {
88 $line = $1 . ":\t" . trim($2) . "\n";
89 if ($lastline eq "") {
90 $$hashref{$case} = $$hashref{$case} . $line;
93 $case = trim($lastline);
94 exists $$hashref{$case} and die "Header '$case' already exists";
95 $$hashref{$case} = $line;
101 $$hashref{$case} = $$hashref{$case} . $lastline;
105 trim($lastline) eq "" or die ("Odd non-pattern line '$lastline' for '$case'");
108 $$hashref{$case} = $$hashref{$case} . $lastline;
115 file_input(\%hash, "MAINTAINERS");
117 foreach my $type (@ARGV) {
118 foreach my $key (keys %hash) {
119 if ($key =~ /$type/ || $hash{$key} =~ /$type/) {
120 $new_hash{$key} = $hash{$key};
126 alpha_output(\%hash, "MAINTAINERS.new");
127 alpha_output(\%new_hash, "SECTION.new");