ALSA: usb-audio: add support for Akai MPD16
[safe/jmp/linux-2.6] / scripts / get_maintainer.pl
index bff2390..6f97a13 100755 (executable)
@@ -41,6 +41,7 @@ my $web = 0;
 my $subsystem = 0;
 my $status = 0;
 my $keywords = 1;
+my $sections = 0;
 my $file_emails = 0;
 my $from_filename = 0;
 my $pattern_depth = 0;
@@ -121,10 +122,11 @@ if (!GetOptions(
                'web!' => \$web,
                'pattern-depth=i' => \$pattern_depth,
                'k|keywords!' => \$keywords,
+               'sections!' => \$sections,
                'fe|file-emails!' => \$file_emails,
                'f|file' => \$from_filename,
                'v|version' => \$version,
-               'h|help' => \$help,
+               'h|help|usage' => \$help,
                )) {
     die "$P: invalid argument - use --help if necessary\n";
 }
@@ -139,9 +141,9 @@ if ($version != 0) {
     exit 0;
 }
 
-if ($#ARGV < 0) {
-    usage();
-    die "$P: argument missing: patchfile or -f file please\n";
+if (-t STDIN && !@ARGV) {
+    # We're talking to a terminal, but have no command line arguments.
+    die "$P: missing patchfile or -f file - use --help if necessary\n";
 }
 
 if ($output_separator ne ", ") {
@@ -152,16 +154,24 @@ if ($output_rolestats) {
     $output_roles = 1;
 }
 
-my $selections = $email + $scm + $status + $subsystem + $web;
-if ($selections == 0) {
-    usage();
-    die "$P:  Missing required option: email, scm, status, subsystem or web\n";
+if ($sections) {
+    $email = 0;
+    $email_list = 0;
+    $scm = 0;
+    $status = 0;
+    $subsystem = 0;
+    $web = 0;
+    $keywords = 0;
+} else {
+    my $selections = $email + $scm + $status + $subsystem + $web;
+    if ($selections == 0) {
+       die "$P:  Missing required option: email, scm, status, subsystem or web\n";
+    }
 }
 
 if ($email &&
     ($email_maintainer + $email_list + $email_subscriber_list +
      $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) {
-    usage();
     die "$P: Please select at least 1 email option\n";
 }
 
@@ -175,8 +185,9 @@ if (!top_of_kernel_tree($lk_path)) {
 my @typevalue = ();
 my %keyword_hash;
 
-open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n";
-while (<MAINT>) {
+open (my $maint, '<', "${lk_path}MAINTAINERS")
+    or die "$P: Can't open MAINTAINERS: $!\n";
+while (<$maint>) {
     my $line = $_;
 
     if ($line =~ m/^(\C):\s*(.*)/) {
@@ -201,13 +212,14 @@ while (<MAINT>) {
        push(@typevalue, $line);
     }
 }
-close(MAINT);
+close($maint);
 
 my %mailmap;
 
 if ($email_remove_duplicates) {
-    open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n";
-    while (<MAILMAP>) {
+    open(my $mailmap, '<', "${lk_path}.mailmap")
+       or warn "$P: Can't open .mailmap: $!\n";
+    while (<$mailmap>) {
        my $line = $_;
 
        next if ($line =~ m/^\s*#/);
@@ -226,7 +238,7 @@ if ($email_remove_duplicates) {
            $mailmap{$name} = \@arr;
        }
     }
-    close(MAILMAP);
+    close($mailmap);
 }
 
 ## use the filenames on the command line or find the filenames in the patchfiles
@@ -236,19 +248,26 @@ my @range = ();
 my @keyword_tvi = ();
 my @file_emails = ();
 
+if (!@ARGV) {
+    push(@ARGV, "&STDIN");
+}
+
 foreach my $file (@ARGV) {
-    ##if $file is a directory and it lacks a trailing slash, add one
-    if ((-d $file)) {
-       $file =~ s@([^/])$@$1/@;
-    } elsif (!(-f $file)) {
-       die "$P: file '${file}' not found\n";
+    if ($file ne "&STDIN") {
+       ##if $file is a directory and it lacks a trailing slash, add one
+       if ((-d $file)) {
+           $file =~ s@([^/])$@$1/@;
+       } elsif (!(-f $file)) {
+           die "$P: file '${file}' not found\n";
+       }
     }
     if ($from_filename) {
        push(@files, $file);
        if (-f $file && ($keywords || $file_emails)) {
-           open(FILE, "<$file") or die "$P: Can't open ${file}\n";
-           my $text = do { local($/) ; <FILE> };
-           close(FILE);
+           open(my $f, '<', $file)
+               or die "$P: Can't open $file: $!\n";
+           my $text = do { local($/) ; <$f> };
+           close($f);
            if ($keywords) {
                foreach my $line (keys %keyword_hash) {
                    if ($text =~ m/$keyword_hash{$line}/x) {
@@ -264,8 +283,10 @@ foreach my $file (@ARGV) {
     } else {
        my $file_cnt = @files;
        my $lastfile;
-       open(PATCH, "<$file") or die "$P: Can't open ${file}\n";
-       while (<PATCH>) {
+
+       open(my $patch, "< $file")
+           or die "$P: Can't open $file: $!\n";
+       while (<$patch>) {
            my $patch_line = $_;
            if (m/^\+\+\+\s+(\S+)/) {
                my $filename = $1;
@@ -285,7 +306,8 @@ foreach my $file (@ARGV) {
                }
            }
        }
-       close(PATCH);
+       close($patch);
+
        if ($file_cnt == @files) {
            warn "$P: file '${file}' doesn't appear to be a patch.  "
                . "Add -f to options?\n";
@@ -325,6 +347,7 @@ foreach my $file (@files) {
                if ($type eq 'X') {
                    if (file_match_pattern($file, $value)) {
                        $exclude = 1;
+                       last;
                    }
                }
            }
@@ -351,12 +374,28 @@ foreach my $file (@files) {
            }
        }
 
-       $tvi += ($end - $start);
-
+       $tvi = $end + 1;
     }
 
     foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
        add_categories($line);
+           if ($sections) {
+               my $i;
+               my $start = find_starting_index($line);
+               my $end = find_ending_index($line);
+               for ($i = $start; $i < $end; $i++) {
+                   my $line = $typevalue[$i];
+                   if ($line =~ /^[FX]:/) {            ##Restore file patterns
+                       $line =~ s/([^\\])\.([^\*])/$1\?$2/g;
+                       $line =~ s/([^\\])\.$/$1\?/g;   ##Convert . back to ?
+                       $line =~ s/\\\./\./g;           ##Convert \. to .
+                       $line =~ s/\.\*/\*/g;           ##Convert .* to *
+                   }
+                   $line =~ s/^([A-Z]):/$1:\t/g;
+                   print("$line\n");
+               }
+               print("\n");
+           }
     }
 
     if ($email && $email_git) {
@@ -486,6 +525,7 @@ Output type options:
 Other options:
   --pattern-depth => Number of pattern directory traversals (default: 0 (all))
   --keywords => scan patch for keywords (default: 1 (on))
+  --sections => print the entire subsystem sections with pattern matches
   --version => show version
   --help => show this help information
 
@@ -565,7 +605,7 @@ sub parse_email {
     $name =~ s/^\"|\"$//g;
     $address =~ s/^\s+|\s+$//g;
 
-    if ($name =~ /[^a-z0-9 \.\-]/i) {    ##has "must quote" chars
+    if ($name =~ /[^\w \-]/i) {         ##has "must quote" chars
        $name =~ s/(?<!\\)"/\\"/g;       ##escape quotes
        $name = "\"$name\"";
     }
@@ -582,7 +622,7 @@ sub format_email {
     $name =~ s/^\"|\"$//g;
     $address =~ s/^\s+|\s+$//g;
 
-    if ($name =~ /[^a-z0-9 \.\-]/i) {    ##has "must quote" chars
+    if ($name =~ /[^\w \-]/i) {          ##has "must quote" chars
        $name =~ s/(?<!\\)"/\\"/g;       ##escape quotes
        $name = "\"$name\"";
     }
@@ -1252,7 +1292,7 @@ sub rfc822_strip_comments {
 
 #   valid: returns true if the parameter is an RFC822 valid address
 #
-sub rfc822_valid ($) {
+sub rfc822_valid {
     my $s = rfc822_strip_comments(shift);
 
     if (!$rfc822re) {
@@ -1272,7 +1312,7 @@ sub rfc822_valid ($) {
 #              from success with no addresses found, because an empty string is
 #              a valid list.
 
-sub rfc822_validlist ($) {
+sub rfc822_validlist {
     my $s = rfc822_strip_comments(shift);
 
     if (!$rfc822re) {