coreboot-kgpe-d16/util/scripts/parse-maintainers.pl
Patrick Georgi 1afe286367 util: Add SPDX header, replacing boiler plate where applicable
In a few cases a license was added: Stuff coming from Linux is
"GPL-2.0" (not GPL-2.0-only!), build-release is by me and got the
usual GPL-2.0-only treatment. uio_usbdebug and spkmodem had their
licenses propagate to all their files.

Change-Id: Ia5712bbaa417cb9e937834512351fcc0acfa16be
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41202
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-05-11 17:11:59 +00:00

79 lines
1.5 KiB
Perl
Executable file

#!/usr/bin/env perl
# SPDX-License-Identifier: GPL-2.0
use strict;
use warnings;
my %map;
# sort comparison function
sub by_category($$) {
my ($a, $b) = @_;
$a = uc $a;
$b = uc $b;
# This always sorts last
$a =~ s/THE REST/ZZZZZZ/g;
$b =~ s/THE REST/ZZZZZZ/g;
$a cmp $b;
}
sub alpha_output {
my $key;
my $sort_method = \&by_category;
my $sep = "";
foreach $key (sort $sort_method keys %map) {
if ($key ne " ") {
print $sep . $key . "\n";
$sep = "\n";
}
print $map{$key};
}
}
sub trim {
my $s = shift;
$s =~ s/\s+$//;
$s =~ s/^\s+//;
return $s;
}
sub file_input {
my $lastline = "";
my $case = " ";
$map{$case} = "";
while (<>) {
my $line = $_;
# Pattern line?
if ($line =~ m/^([A-Z]):\s*(.*)/) {
$line = $1 . ":\t" . trim($2) . "\n";
if ($lastline eq "") {
$map{$case} = $map{$case} . $line;
next;
}
$case = trim($lastline);
exists $map{$case} and die "Header '$case' already exists";
$map{$case} = $line;
$lastline = "";
next;
}
if ($case eq " ") {
$map{$case} = $map{$case} . $lastline;
$lastline = $line;
next;
}
trim($lastline) eq "" or die ("Odd non-pattern line '$lastline' for '$case'");
$lastline = $line;
}
$map{$case} = $map{$case} . $lastline;
}
&file_input;
&alpha_output;
exit(0);