mb/dell/snb_ivb_latitude/*/hda_verb.c: Use AZALIA_PIN_DESC macro
[coreboot.git] / util / scripts / parse-maintainers.pl
blob4b47efe300df995304928a1c5e69062ce2a111bb
1 #!/usr/bin/env perl
2 # SPDX-License-Identifier: GPL-2.0-only
4 use strict;
5 use warnings;
7 my %map;
9 # sort comparison function
10 sub by_category($$) {
11 my ($a, $b) = @_;
13 $a = uc $a;
14 $b = uc $b;
16 # This always sorts last
17 $a =~ s/THE REST/ZZZZZZ/g;
18 $b =~ s/THE REST/ZZZZZZ/g;
20 $a cmp $b;
23 sub alpha_output {
24 my $key;
25 my $sort_method = \&by_category;
26 my $sep = "";
28 foreach $key (sort $sort_method keys %map) {
29 if ($key ne " ") {
30 print $sep . $key . "\n";
31 $sep = "\n";
33 print $map{$key};
37 sub trim {
38 my $s = shift;
39 $s =~ s/\s+$//;
40 $s =~ s/^\s+//;
41 return $s;
44 sub file_input {
45 my $lastline = "";
46 my $case = " ";
47 $map{$case} = "";
49 while (<>) {
50 my $line = $_;
52 # Pattern line?
53 if ($line =~ m/^([A-Z]):\s*(.*)/) {
54 $line = $1 . ":\t" . trim($2) . "\n";
55 if ($lastline eq "") {
56 $map{$case} = $map{$case} . $line;
57 next;
59 $case = trim($lastline);
60 exists $map{$case} and die "Header '$case' already exists";
61 $map{$case} = $line;
62 $lastline = "";
63 next;
66 if ($case eq " ") {
67 $map{$case} = $map{$case} . $lastline;
68 $lastline = $line;
69 next;
71 trim($lastline) eq "" or die ("Odd non-pattern line '$lastline' for '$case'");
72 $lastline = $line;
74 $map{$case} = $map{$case} . $lastline;
77 &file_input;
78 &alpha_output;
79 exit(0);