scripts/get_maintainer.pl: better fix for subscriber-only mailing lists
[sfrench/cifs-2.6.git] / scripts / get_maintainer.pl
index 60dc0c48c929b15953a751a1875c1aebd767e80e..f302ad3759f35d661899f6e204b7c0cd9445e74a 100755 (executable)
@@ -13,7 +13,7 @@
 use strict;
 
 my $P = $0;
-my $V = '0.15';
+my $V = '0.16';
 
 use Getopt::Long qw(:config no_auto_abbrev);
 
@@ -169,6 +169,7 @@ foreach my $file (@ARGV) {
 }
 
 my @email_to = ();
+my @list_to = ();
 my @scm = ();
 my @web = ();
 my @subsystem = ();
@@ -182,7 +183,7 @@ foreach my $file (@files) {
 
     my $exclude = 0;
     foreach my $line (@typevalue) {
-       if ($line =~ m/^(\C):(.*)/) {
+       if ($line =~ m/^(\C):\s*(.*)/) {
            my $type = $1;
            my $value = $2;
            if ($type eq 'X') {
@@ -196,7 +197,7 @@ foreach my $file (@files) {
     if (!$exclude) {
        my $tvi = 0;
        foreach my $line (@typevalue) {
-           if ($line =~ m/^(\C):(.*)/) {
+           if ($line =~ m/^(\C):\s*(.*)/) {
                my $type = $1;
                my $value = $2;
                if ($type eq 'F') {
@@ -229,15 +230,18 @@ if ($email_git_penguin_chiefs) {
     }
 }
 
-if ($email) {
-    my $address_cnt = @email_to;
-    if ($address_cnt == 0 && $email_list) {
-       push(@email_to, "linux-kernel\@vger.kernel.org");
+if ($email || $email_list) {
+    my @to = ();
+    if ($email) {
+       @to = (@to, @email_to);
     }
-
-#Don't sort email address list, but do remove duplicates
-    @email_to = uniq(@email_to);
-    output(@email_to);
+    if ($email_list) {
+       if (@list_to == 0) {
+           push(@list_to, "linux-kernel\@vger.kernel.org");
+       @to = (@to, @list_to);
+       }
+    }
+    output(uniq(@to));
 }
 
 if ($scm) {
@@ -307,7 +311,7 @@ Output type options:
   --multiline => print 1 entry per line
 
 Default options:
-  [--email --git --m --l --multiline]
+  [--email --git --m --n --l --multiline]
 
 Other options:
   --version -> show version
@@ -366,26 +370,30 @@ sub add_categories {
     $index = $index - 1;
     while ($index >= 0) {
        my $tv = $typevalue[$index];
-       if ($tv =~ m/^(\C):(.*)/) {
+       if ($tv =~ m/^(\C):\s*(.*)/) {
            my $ptype = $1;
            my $pvalue = $2;
            if ($ptype eq "L") {
-               my $subscr = $pvalue;
-               if ($subscr =~ m/\s*\(subscribers-only\)/) {
+               my $list_address = $pvalue;
+               my $list_additional = "";
+               if ($list_address =~ m/([^\s]+)\s+(.*)$/) {
+                   $list_address = $1;
+                   $list_additional = $2;
+               }
+               if ($list_additional =~ m/subscribers-only/) {
                    if ($email_subscriber_list) {
-                       $subscr =~ s/\s*\(subscribers-only\)//g;
-                       push(@email_to, $subscr);
+                       push(@list_to, $list_address);
                    }
                } else {
                    if ($email_list) {
-                       push(@email_to, $pvalue);
+                       push(@list_to, $list_address);
                    }
                }
            } elsif ($ptype eq "M") {
                if ($email_maintainer) {
                    if ($index >= 0) {
                        my $tv = $typevalue[$index - 1];
-                       if ($tv =~ m/^(\C):(.*)/) {
+                       if ($tv =~ m/^(\C):\s*(.*)/) {
                            if ($1 eq "P" && $email_usename) {
                                push(@email_to, format_email($2, $pvalue));
                            } else {