Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 1 | #!/usr/bin/perl -w |
| 2 | # (c) 2007, Joe Perches <joe@perches.com> |
| 3 | # created from checkpatch.pl |
| 4 | # |
| 5 | # Print selected MAINTAINERS information for |
| 6 | # the files modified in a patch or for a file |
| 7 | # |
Roel Kluin | 3bd7bf5 | 2009-11-11 14:26:13 -0800 | [diff] [blame] | 8 | # usage: perl scripts/get_maintainer.pl [OPTIONS] <patch> |
| 9 | # perl scripts/get_maintainer.pl [OPTIONS] -f <file> |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 10 | # |
| 11 | # Licensed under the terms of the GNU GPL License version 2 |
| 12 | |
| 13 | use strict; |
| 14 | |
| 15 | my $P = $0; |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 16 | my $V = '0.22'; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 17 | |
| 18 | use Getopt::Long qw(:config no_auto_abbrev); |
| 19 | |
| 20 | my $lk_path = "./"; |
| 21 | my $email = 1; |
| 22 | my $email_usename = 1; |
| 23 | my $email_maintainer = 1; |
| 24 | my $email_list = 1; |
| 25 | my $email_subscriber_list = 0; |
| 26 | my $email_git = 1; |
| 27 | my $email_git_penguin_chiefs = 0; |
| 28 | my $email_git_min_signatures = 1; |
| 29 | my $email_git_max_maintainers = 5; |
Joe Perches | afa81ee | 2009-07-29 15:04:28 -0700 | [diff] [blame] | 30 | my $email_git_min_percent = 5; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 31 | my $email_git_since = "1-year-ago"; |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 32 | my $email_git_blame = 0; |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 33 | my $email_remove_duplicates = 1; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 34 | my $output_multiline = 1; |
| 35 | my $output_separator = ", "; |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 36 | my $output_roles = 0; |
| 37 | my $output_rolestats = 0; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 38 | my $scm = 0; |
| 39 | my $web = 0; |
| 40 | my $subsystem = 0; |
| 41 | my $status = 0; |
Joe Perches | dcf36a9 | 2009-10-26 16:49:47 -0700 | [diff] [blame] | 42 | my $keywords = 1; |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 43 | my $from_filename = 0; |
Joe Perches | 3fb5565 | 2009-09-21 17:04:17 -0700 | [diff] [blame] | 44 | my $pattern_depth = 0; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 45 | my $version = 0; |
| 46 | my $help = 0; |
| 47 | |
| 48 | my $exit = 0; |
| 49 | |
| 50 | my @penguin_chief = (); |
| 51 | push(@penguin_chief,"Linus Torvalds:torvalds\@linux-foundation.org"); |
| 52 | #Andrew wants in on most everything - 2009/01/14 |
| 53 | #push(@penguin_chief,"Andrew Morton:akpm\@linux-foundation.org"); |
| 54 | |
| 55 | my @penguin_chief_names = (); |
| 56 | foreach my $chief (@penguin_chief) { |
| 57 | if ($chief =~ m/^(.*):(.*)/) { |
| 58 | my $chief_name = $1; |
| 59 | my $chief_addr = $2; |
| 60 | push(@penguin_chief_names, $chief_name); |
| 61 | } |
| 62 | } |
| 63 | my $penguin_chiefs = "\(" . join("|",@penguin_chief_names) . "\)"; |
| 64 | |
Joe Perches | 5f2441e | 2009-06-16 15:34:02 -0700 | [diff] [blame] | 65 | # rfc822 email address - preloaded methods go here. |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 66 | my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])"; |
Joe Perches | df4cc03 | 2009-06-16 15:34:04 -0700 | [diff] [blame] | 67 | my $rfc822_char = '[\\000-\\377]'; |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 68 | |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 69 | if (!GetOptions( |
| 70 | 'email!' => \$email, |
| 71 | 'git!' => \$email_git, |
| 72 | 'git-chief-penguins!' => \$email_git_penguin_chiefs, |
| 73 | 'git-min-signatures=i' => \$email_git_min_signatures, |
| 74 | 'git-max-maintainers=i' => \$email_git_max_maintainers, |
Joe Perches | afa81ee | 2009-07-29 15:04:28 -0700 | [diff] [blame] | 75 | 'git-min-percent=i' => \$email_git_min_percent, |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 76 | 'git-since=s' => \$email_git_since, |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 77 | 'git-blame!' => \$email_git_blame, |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 78 | 'remove-duplicates!' => \$email_remove_duplicates, |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 79 | 'm!' => \$email_maintainer, |
| 80 | 'n!' => \$email_usename, |
| 81 | 'l!' => \$email_list, |
| 82 | 's!' => \$email_subscriber_list, |
| 83 | 'multiline!' => \$output_multiline, |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 84 | 'roles!' => \$output_roles, |
| 85 | 'rolestats!' => \$output_rolestats, |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 86 | 'separator=s' => \$output_separator, |
| 87 | 'subsystem!' => \$subsystem, |
| 88 | 'status!' => \$status, |
| 89 | 'scm!' => \$scm, |
| 90 | 'web!' => \$web, |
Joe Perches | 3fb5565 | 2009-09-21 17:04:17 -0700 | [diff] [blame] | 91 | 'pattern-depth=i' => \$pattern_depth, |
Joe Perches | dcf36a9 | 2009-10-26 16:49:47 -0700 | [diff] [blame] | 92 | 'k|keywords!' => \$keywords, |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 93 | 'f|file' => \$from_filename, |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 94 | 'v|version' => \$version, |
| 95 | 'h|help' => \$help, |
| 96 | )) { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 97 | die "$P: invalid argument - use --help if necessary\n"; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | if ($help != 0) { |
| 101 | usage(); |
| 102 | exit 0; |
| 103 | } |
| 104 | |
| 105 | if ($version != 0) { |
| 106 | print("${P} ${V}\n"); |
| 107 | exit 0; |
| 108 | } |
| 109 | |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 110 | if ($#ARGV < 0) { |
| 111 | usage(); |
| 112 | die "$P: argument missing: patchfile or -f file please\n"; |
| 113 | } |
| 114 | |
Joe Perches | 4249831 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 115 | if ($output_separator ne ", ") { |
| 116 | $output_multiline = 0; |
| 117 | } |
| 118 | |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 119 | if ($output_rolestats) { |
| 120 | $output_roles = 1; |
| 121 | } |
| 122 | |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 123 | my $selections = $email + $scm + $status + $subsystem + $web; |
| 124 | if ($selections == 0) { |
| 125 | usage(); |
| 126 | die "$P: Missing required option: email, scm, status, subsystem or web\n"; |
| 127 | } |
| 128 | |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 129 | if ($email && |
| 130 | ($email_maintainer + $email_list + $email_subscriber_list + |
| 131 | $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) { |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 132 | usage(); |
| 133 | die "$P: Please select at least 1 email option\n"; |
| 134 | } |
| 135 | |
| 136 | if (!top_of_kernel_tree($lk_path)) { |
| 137 | die "$P: The current directory does not appear to be " |
| 138 | . "a linux kernel source tree.\n"; |
| 139 | } |
| 140 | |
| 141 | ## Read MAINTAINERS for type/value pairs |
| 142 | |
| 143 | my @typevalue = (); |
Joe Perches | dcf36a9 | 2009-10-26 16:49:47 -0700 | [diff] [blame] | 144 | my %keyword_hash; |
| 145 | |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 146 | open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n"; |
| 147 | while (<MAINT>) { |
| 148 | my $line = $_; |
| 149 | |
| 150 | if ($line =~ m/^(\C):\s*(.*)/) { |
| 151 | my $type = $1; |
| 152 | my $value = $2; |
| 153 | |
| 154 | ##Filename pattern matching |
| 155 | if ($type eq "F" || $type eq "X") { |
| 156 | $value =~ s@\.@\\\.@g; ##Convert . to \. |
| 157 | $value =~ s/\*/\.\*/g; ##Convert * to .* |
| 158 | $value =~ s/\?/\./g; ##Convert ? to . |
Joe Perches | 870020f | 2009-07-29 15:04:28 -0700 | [diff] [blame] | 159 | ##if pattern is a directory and it lacks a trailing slash, add one |
| 160 | if ((-d $value)) { |
| 161 | $value =~ s@([^/])$@$1/@; |
| 162 | } |
Joe Perches | dcf36a9 | 2009-10-26 16:49:47 -0700 | [diff] [blame] | 163 | } elsif ($type eq "K") { |
| 164 | $keyword_hash{@typevalue} = $value; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 165 | } |
| 166 | push(@typevalue, "$type:$value"); |
| 167 | } elsif (!/^(\s)*$/) { |
| 168 | $line =~ s/\n$//g; |
| 169 | push(@typevalue, $line); |
| 170 | } |
| 171 | } |
| 172 | close(MAINT); |
| 173 | |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 174 | my %mailmap; |
| 175 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 176 | if ($email_remove_duplicates) { |
| 177 | open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n"; |
| 178 | while (<MAILMAP>) { |
| 179 | my $line = $_; |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 180 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 181 | next if ($line =~ m/^\s*#/); |
| 182 | next if ($line =~ m/^\s*$/); |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 183 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 184 | my ($name, $address) = parse_email($line); |
| 185 | $line = format_email($name, $address); |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 186 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 187 | next if ($line =~ m/^\s*$/); |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 188 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 189 | if (exists($mailmap{$name})) { |
| 190 | my $obj = $mailmap{$name}; |
| 191 | push(@$obj, $address); |
| 192 | } else { |
| 193 | my @arr = ($address); |
| 194 | $mailmap{$name} = \@arr; |
| 195 | } |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 196 | } |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 197 | close(MAILMAP); |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 198 | } |
| 199 | |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 200 | ## use the filenames on the command line or find the filenames in the patchfiles |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 201 | |
| 202 | my @files = (); |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 203 | my @range = (); |
Joe Perches | dcf36a9 | 2009-10-26 16:49:47 -0700 | [diff] [blame] | 204 | my @keyword_tvi = (); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 205 | |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 206 | foreach my $file (@ARGV) { |
Joe Perches | 870020f | 2009-07-29 15:04:28 -0700 | [diff] [blame] | 207 | ##if $file is a directory and it lacks a trailing slash, add one |
| 208 | if ((-d $file)) { |
| 209 | $file =~ s@([^/])$@$1/@; |
| 210 | } elsif (!(-f $file)) { |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 211 | die "$P: file '${file}' not found\n"; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 212 | } |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 213 | if ($from_filename) { |
| 214 | push(@files, $file); |
Joe Perches | dcf36a9 | 2009-10-26 16:49:47 -0700 | [diff] [blame] | 215 | if (-f $file && $keywords) { |
| 216 | open(FILE, "<$file") or die "$P: Can't open ${file}\n"; |
| 217 | while (<FILE>) { |
| 218 | my $patch_line = $_; |
| 219 | foreach my $line (keys %keyword_hash) { |
| 220 | if ($patch_line =~ m/^.*$keyword_hash{$line}/x) { |
| 221 | push(@keyword_tvi, $line); |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | close(FILE); |
| 226 | } |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 227 | } else { |
| 228 | my $file_cnt = @files; |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 229 | my $lastfile; |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 230 | open(PATCH, "<$file") or die "$P: Can't open ${file}\n"; |
| 231 | while (<PATCH>) { |
Joe Perches | dcf36a9 | 2009-10-26 16:49:47 -0700 | [diff] [blame] | 232 | my $patch_line = $_; |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 233 | if (m/^\+\+\+\s+(\S+)/) { |
| 234 | my $filename = $1; |
| 235 | $filename =~ s@^[^/]*/@@; |
| 236 | $filename =~ s@\n@@; |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 237 | $lastfile = $filename; |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 238 | push(@files, $filename); |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 239 | } elsif (m/^\@\@ -(\d+),(\d+)/) { |
| 240 | if ($email_git_blame) { |
| 241 | push(@range, "$lastfile:$1:$2"); |
| 242 | } |
Joe Perches | dcf36a9 | 2009-10-26 16:49:47 -0700 | [diff] [blame] | 243 | } elsif ($keywords) { |
| 244 | foreach my $line (keys %keyword_hash) { |
| 245 | if ($patch_line =~ m/^[+-].*$keyword_hash{$line}/x) { |
| 246 | push(@keyword_tvi, $line); |
| 247 | } |
| 248 | } |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 249 | } |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 250 | } |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 251 | close(PATCH); |
| 252 | if ($file_cnt == @files) { |
Joe Perches | 7f29fd27 | 2009-06-16 15:34:04 -0700 | [diff] [blame] | 253 | warn "$P: file '${file}' doesn't appear to be a patch. " |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 254 | . "Add -f to options?\n"; |
| 255 | } |
| 256 | @files = sort_and_uniq(@files); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 257 | } |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | my @email_to = (); |
Joe Perches | 290603c | 2009-06-16 15:33:58 -0700 | [diff] [blame] | 261 | my @list_to = (); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 262 | my @scm = (); |
| 263 | my @web = (); |
| 264 | my @subsystem = (); |
| 265 | my @status = (); |
| 266 | |
| 267 | # Find responsible parties |
| 268 | |
| 269 | foreach my $file (@files) { |
| 270 | |
| 271 | #Do not match excluded file patterns |
| 272 | |
| 273 | my $exclude = 0; |
| 274 | foreach my $line (@typevalue) { |
Joe Perches | 290603c | 2009-06-16 15:33:58 -0700 | [diff] [blame] | 275 | if ($line =~ m/^(\C):\s*(.*)/) { |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 276 | my $type = $1; |
| 277 | my $value = $2; |
| 278 | if ($type eq 'X') { |
| 279 | if (file_match_pattern($file, $value)) { |
| 280 | $exclude = 1; |
Joe Perches | 1d606b4 | 2009-09-21 17:04:14 -0700 | [diff] [blame] | 281 | last; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | if (!$exclude) { |
| 288 | my $tvi = 0; |
Joe Perches | 1d606b4 | 2009-09-21 17:04:14 -0700 | [diff] [blame] | 289 | my %hash; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 290 | foreach my $line (@typevalue) { |
Joe Perches | 290603c | 2009-06-16 15:33:58 -0700 | [diff] [blame] | 291 | if ($line =~ m/^(\C):\s*(.*)/) { |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 292 | my $type = $1; |
| 293 | my $value = $2; |
| 294 | if ($type eq 'F') { |
| 295 | if (file_match_pattern($file, $value)) { |
Joe Perches | 3fb5565 | 2009-09-21 17:04:17 -0700 | [diff] [blame] | 296 | my $value_pd = ($value =~ tr@/@@); |
| 297 | my $file_pd = ($file =~ tr@/@@); |
| 298 | $value_pd++ if (substr($value,-1,1) ne "/"); |
| 299 | if ($pattern_depth == 0 || |
| 300 | (($file_pd - $value_pd) < $pattern_depth)) { |
| 301 | $hash{$tvi} = $value_pd; |
| 302 | } |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 303 | } |
| 304 | } |
| 305 | } |
| 306 | $tvi++; |
| 307 | } |
Joe Perches | 1d606b4 | 2009-09-21 17:04:14 -0700 | [diff] [blame] | 308 | foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { |
| 309 | add_categories($line); |
| 310 | } |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 311 | } |
| 312 | |
Joe Perches | 4a7fdb5 | 2009-04-10 12:28:57 -0700 | [diff] [blame] | 313 | if ($email && $email_git) { |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 314 | recent_git_signoffs($file); |
| 315 | } |
| 316 | |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 317 | if ($email && $email_git_blame) { |
| 318 | git_assign_blame($file); |
| 319 | } |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 320 | } |
| 321 | |
Joe Perches | dcf36a9 | 2009-10-26 16:49:47 -0700 | [diff] [blame] | 322 | if ($keywords) { |
| 323 | @keyword_tvi = sort_and_uniq(@keyword_tvi); |
| 324 | foreach my $line (@keyword_tvi) { |
| 325 | add_categories($line); |
| 326 | } |
| 327 | } |
| 328 | |
Joe Perches | f5f5078 | 2009-06-16 15:34:00 -0700 | [diff] [blame] | 329 | if ($email) { |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 330 | foreach my $chief (@penguin_chief) { |
| 331 | if ($chief =~ m/^(.*):(.*)/) { |
Joe Perches | f5f5078 | 2009-06-16 15:34:00 -0700 | [diff] [blame] | 332 | my $email_address; |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 333 | |
| 334 | $email_address = format_email($1, $2); |
Joe Perches | f5f5078 | 2009-06-16 15:34:00 -0700 | [diff] [blame] | 335 | if ($email_git_penguin_chiefs) { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 336 | push(@email_to, [$email_address, 'chief penguin']); |
Joe Perches | f5f5078 | 2009-06-16 15:34:00 -0700 | [diff] [blame] | 337 | } else { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 338 | @email_to = grep($_->[0] !~ /${email_address}/, @email_to); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 339 | } |
| 340 | } |
| 341 | } |
| 342 | } |
| 343 | |
Joe Perches | 290603c | 2009-06-16 15:33:58 -0700 | [diff] [blame] | 344 | if ($email || $email_list) { |
| 345 | my @to = (); |
| 346 | if ($email) { |
| 347 | @to = (@to, @email_to); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 348 | } |
Joe Perches | 290603c | 2009-06-16 15:33:58 -0700 | [diff] [blame] | 349 | if ($email_list) { |
Joe Perches | 290603c | 2009-06-16 15:33:58 -0700 | [diff] [blame] | 350 | @to = (@to, @list_to); |
Joe Perches | 290603c | 2009-06-16 15:33:58 -0700 | [diff] [blame] | 351 | } |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 352 | output(merge_email(@to)); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | if ($scm) { |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 356 | @scm = uniq(@scm); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 357 | output(@scm); |
| 358 | } |
| 359 | |
| 360 | if ($status) { |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 361 | @status = uniq(@status); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 362 | output(@status); |
| 363 | } |
| 364 | |
| 365 | if ($subsystem) { |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 366 | @subsystem = uniq(@subsystem); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 367 | output(@subsystem); |
| 368 | } |
| 369 | |
| 370 | if ($web) { |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 371 | @web = uniq(@web); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 372 | output(@web); |
| 373 | } |
| 374 | |
| 375 | exit($exit); |
| 376 | |
| 377 | sub file_match_pattern { |
| 378 | my ($file, $pattern) = @_; |
| 379 | if (substr($pattern, -1) eq "/") { |
| 380 | if ($file =~ m@^$pattern@) { |
| 381 | return 1; |
| 382 | } |
| 383 | } else { |
| 384 | if ($file =~ m@^$pattern@) { |
| 385 | my $s1 = ($file =~ tr@/@@); |
| 386 | my $s2 = ($pattern =~ tr@/@@); |
| 387 | if ($s1 == $s2) { |
| 388 | return 1; |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | return 0; |
| 393 | } |
| 394 | |
| 395 | sub usage { |
| 396 | print <<EOT; |
| 397 | usage: $P [options] patchfile |
Joe Perches | 870020f | 2009-07-29 15:04:28 -0700 | [diff] [blame] | 398 | $P [options] -f file|directory |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 399 | version: $V |
| 400 | |
| 401 | MAINTAINER field selection options: |
| 402 | --email => print email address(es) if any |
| 403 | --git => include recent git \*-by: signers |
| 404 | --git-chief-penguins => include ${penguin_chiefs} |
| 405 | --git-min-signatures => number of signatures required (default: 1) |
| 406 | --git-max-maintainers => maximum maintainers to add (default: 5) |
Joe Perches | 3d202ae | 2009-07-29 15:04:29 -0700 | [diff] [blame] | 407 | --git-min-percent => minimum percentage of commits required (default: 5) |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 408 | --git-since => git history to use (default: 1-year-ago) |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 409 | --git-blame => use git blame to find modified commits for patch or file |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 410 | --m => include maintainer(s) if any |
| 411 | --n => include name 'Full Name <addr\@domain.tld>' |
| 412 | --l => include list(s) if any |
| 413 | --s => include subscriber only list(s) if any |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 414 | --remove-duplicates => minimize duplicate email names/addresses |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 415 | --roles => show roles (status:subsystem, git-signer, list, etc...) |
| 416 | --rolestats => show roles and statistics (commits/total_commits, %) |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 417 | --scm => print SCM tree(s) if any |
| 418 | --status => print status if any |
| 419 | --subsystem => print subsystem name if any |
| 420 | --web => print website(s) if any |
| 421 | |
| 422 | Output type options: |
| 423 | --separator [, ] => separator for multiple entries on 1 line |
Joe Perches | 4249831 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 424 | using --separator also sets --nomultiline if --separator is not [, ] |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 425 | --multiline => print 1 entry per line |
| 426 | |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 427 | Other options: |
Joe Perches | 3fb5565 | 2009-09-21 17:04:17 -0700 | [diff] [blame] | 428 | --pattern-depth => Number of pattern directory traversals (default: 0 (all)) |
Joe Perches | dcf36a9 | 2009-10-26 16:49:47 -0700 | [diff] [blame] | 429 | --keywords => scan patch for keywords (default: 1 (on)) |
Joe Perches | f5f5078 | 2009-06-16 15:34:00 -0700 | [diff] [blame] | 430 | --version => show version |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 431 | --help => show this help information |
| 432 | |
Joe Perches | 3fb5565 | 2009-09-21 17:04:17 -0700 | [diff] [blame] | 433 | Default options: |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 434 | [--email --git --m --n --l --multiline --pattern-depth=0 --remove-duplicates] |
Joe Perches | 3fb5565 | 2009-09-21 17:04:17 -0700 | [diff] [blame] | 435 | |
Joe Perches | 870020f | 2009-07-29 15:04:28 -0700 | [diff] [blame] | 436 | Notes: |
| 437 | Using "-f directory" may give unexpected results: |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 438 | Used with "--git", git signators for _all_ files in and below |
| 439 | directory are examined as git recurses directories. |
| 440 | Any specified X: (exclude) pattern matches are _not_ ignored. |
| 441 | Used with "--nogit", directory is used as a pattern match, |
| 442 | no individual file within the directory or subdirectory |
| 443 | is matched. |
| 444 | Used with "--git-blame", does not iterate all files in directory |
| 445 | Using "--git-blame" is slow and may add old committers and authors |
| 446 | that are no longer active maintainers to the output. |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 447 | Using "--roles" or "--rolestats" with git send-email --cc-cmd or any |
| 448 | other automated tools that expect only ["name"] <email address> |
| 449 | may not work because of additional output after <email address>. |
| 450 | Using "--rolestats" and "--git-blame" shows the #/total=% commits, |
| 451 | not the percentage of the entire file authored. # of commits is |
| 452 | not a good measure of amount of code authored. 1 major commit may |
| 453 | contain a thousand lines, 5 trivial commits may modify a single line. |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 454 | EOT |
| 455 | } |
| 456 | |
| 457 | sub top_of_kernel_tree { |
| 458 | my ($lk_path) = @_; |
| 459 | |
| 460 | if ($lk_path ne "" && substr($lk_path,length($lk_path)-1,1) ne "/") { |
| 461 | $lk_path .= "/"; |
| 462 | } |
| 463 | if ( (-f "${lk_path}COPYING") |
| 464 | && (-f "${lk_path}CREDITS") |
| 465 | && (-f "${lk_path}Kbuild") |
| 466 | && (-f "${lk_path}MAINTAINERS") |
| 467 | && (-f "${lk_path}Makefile") |
| 468 | && (-f "${lk_path}README") |
| 469 | && (-d "${lk_path}Documentation") |
| 470 | && (-d "${lk_path}arch") |
| 471 | && (-d "${lk_path}include") |
| 472 | && (-d "${lk_path}drivers") |
| 473 | && (-d "${lk_path}fs") |
| 474 | && (-d "${lk_path}init") |
| 475 | && (-d "${lk_path}ipc") |
| 476 | && (-d "${lk_path}kernel") |
| 477 | && (-d "${lk_path}lib") |
| 478 | && (-d "${lk_path}scripts")) { |
| 479 | return 1; |
| 480 | } |
| 481 | return 0; |
| 482 | } |
| 483 | |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 484 | sub parse_email { |
| 485 | my ($formatted_email) = @_; |
| 486 | |
| 487 | my $name = ""; |
| 488 | my $address = ""; |
| 489 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 490 | if ($formatted_email =~ /^([^<]+)<(.+\@.*)>.*$/) { |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 491 | $name = $1; |
| 492 | $address = $2; |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 493 | } elsif ($formatted_email =~ /^\s*<(.+\@\S*)>.*$/) { |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 494 | $address = $1; |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 495 | } elsif ($formatted_email =~ /^(.+\@\S*).*$/) { |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 496 | $address = $1; |
| 497 | } |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 498 | |
| 499 | $name =~ s/^\s+|\s+$//g; |
Joe Perches | d789504 | 2009-06-16 15:34:02 -0700 | [diff] [blame] | 500 | $name =~ s/^\"|\"$//g; |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 501 | $address =~ s/^\s+|\s+$//g; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 502 | |
| 503 | if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars |
| 504 | $name =~ s/(?<!\\)"/\\"/g; ##escape quotes |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 505 | $name = "\"$name\""; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 506 | } |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 507 | |
| 508 | return ($name, $address); |
| 509 | } |
| 510 | |
| 511 | sub format_email { |
| 512 | my ($name, $address) = @_; |
| 513 | |
| 514 | my $formatted_email; |
| 515 | |
| 516 | $name =~ s/^\s+|\s+$//g; |
| 517 | $name =~ s/^\"|\"$//g; |
| 518 | $address =~ s/^\s+|\s+$//g; |
| 519 | |
| 520 | if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars |
| 521 | $name =~ s/(?<!\\)"/\\"/g; ##escape quotes |
| 522 | $name = "\"$name\""; |
| 523 | } |
| 524 | |
| 525 | if ($email_usename) { |
| 526 | if ("$name" eq "") { |
| 527 | $formatted_email = "$address"; |
| 528 | } else { |
| 529 | $formatted_email = "$name <${address}>"; |
| 530 | } |
| 531 | } else { |
| 532 | $formatted_email = $address; |
| 533 | } |
| 534 | |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 535 | return $formatted_email; |
| 536 | } |
| 537 | |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 538 | sub find_starting_index { |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 539 | my ($index) = @_; |
| 540 | |
| 541 | while ($index > 0) { |
| 542 | my $tv = $typevalue[$index]; |
| 543 | if (!($tv =~ m/^(\C):\s*(.*)/)) { |
| 544 | last; |
| 545 | } |
| 546 | $index--; |
| 547 | } |
| 548 | |
| 549 | return $index; |
| 550 | } |
| 551 | |
| 552 | sub find_ending_index { |
| 553 | my ($index) = @_; |
| 554 | |
| 555 | while ($index < @typevalue) { |
| 556 | my $tv = $typevalue[$index]; |
| 557 | if (!($tv =~ m/^(\C):\s*(.*)/)) { |
| 558 | last; |
| 559 | } |
| 560 | $index++; |
| 561 | } |
| 562 | |
| 563 | return $index; |
| 564 | } |
| 565 | |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 566 | sub get_maintainer_role { |
| 567 | my ($index) = @_; |
| 568 | |
| 569 | my $i; |
| 570 | my $start = find_starting_index($index); |
| 571 | my $end = find_ending_index($index); |
| 572 | |
| 573 | my $role; |
| 574 | my $subsystem = $typevalue[$start]; |
| 575 | if (length($subsystem) > 20) { |
| 576 | $subsystem = substr($subsystem, 0, 17); |
| 577 | $subsystem =~ s/\s*$//; |
| 578 | $subsystem = $subsystem . "..."; |
| 579 | } |
| 580 | |
| 581 | for ($i = $start + 1; $i < $end; $i++) { |
| 582 | my $tv = $typevalue[$i]; |
| 583 | if ($tv =~ m/^(\C):\s*(.*)/) { |
| 584 | my $ptype = $1; |
| 585 | my $pvalue = $2; |
| 586 | if ($ptype eq "S") { |
| 587 | $role = $pvalue; |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | $role = lc($role); |
| 593 | if ($role eq "supported") { |
| 594 | $role = "supporter"; |
| 595 | } elsif ($role eq "maintained") { |
| 596 | $role = "maintainer"; |
| 597 | } elsif ($role eq "odd fixes") { |
| 598 | $role = "odd fixer"; |
| 599 | } elsif ($role eq "orphan") { |
| 600 | $role = "orphan minder"; |
| 601 | } elsif ($role eq "obsolete") { |
| 602 | $role = "obsolete minder"; |
| 603 | } elsif ($role eq "buried alive in reporters") { |
| 604 | $role = "chief penguin"; |
| 605 | } |
| 606 | |
| 607 | return $role . ":" . $subsystem; |
| 608 | } |
| 609 | |
| 610 | sub get_list_role { |
| 611 | my ($index) = @_; |
| 612 | |
| 613 | my $i; |
| 614 | my $start = find_starting_index($index); |
| 615 | my $end = find_ending_index($index); |
| 616 | |
| 617 | my $subsystem = $typevalue[$start]; |
| 618 | if (length($subsystem) > 20) { |
| 619 | $subsystem = substr($subsystem, 0, 17); |
| 620 | $subsystem =~ s/\s*$//; |
| 621 | $subsystem = $subsystem . "..."; |
| 622 | } |
| 623 | |
| 624 | if ($subsystem eq "THE REST") { |
| 625 | $subsystem = ""; |
| 626 | } |
| 627 | |
| 628 | return $subsystem; |
| 629 | } |
| 630 | |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 631 | sub add_categories { |
| 632 | my ($index) = @_; |
| 633 | |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 634 | my $i; |
| 635 | my $start = find_starting_index($index); |
| 636 | my $end = find_ending_index($index); |
| 637 | |
| 638 | push(@subsystem, $typevalue[$start]); |
| 639 | |
| 640 | for ($i = $start + 1; $i < $end; $i++) { |
| 641 | my $tv = $typevalue[$i]; |
Joe Perches | 290603c | 2009-06-16 15:33:58 -0700 | [diff] [blame] | 642 | if ($tv =~ m/^(\C):\s*(.*)/) { |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 643 | my $ptype = $1; |
| 644 | my $pvalue = $2; |
| 645 | if ($ptype eq "L") { |
Joe Perches | 290603c | 2009-06-16 15:33:58 -0700 | [diff] [blame] | 646 | my $list_address = $pvalue; |
| 647 | my $list_additional = ""; |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 648 | my $list_role = get_list_role($i); |
| 649 | |
| 650 | if ($list_role ne "") { |
| 651 | $list_role = ":" . $list_role; |
| 652 | } |
Joe Perches | 290603c | 2009-06-16 15:33:58 -0700 | [diff] [blame] | 653 | if ($list_address =~ m/([^\s]+)\s+(.*)$/) { |
| 654 | $list_address = $1; |
| 655 | $list_additional = $2; |
| 656 | } |
Joe Perches | bdf7c68 | 2009-06-16 15:33:59 -0700 | [diff] [blame] | 657 | if ($list_additional =~ m/subscribers-only/) { |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 658 | if ($email_subscriber_list) { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 659 | push(@list_to, [$list_address, "subscriber list${list_role}"]); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 660 | } |
| 661 | } else { |
| 662 | if ($email_list) { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 663 | push(@list_to, [$list_address, "open list${list_role}"]); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 664 | } |
| 665 | } |
| 666 | } elsif ($ptype eq "M") { |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 667 | my ($name, $address) = parse_email($pvalue); |
| 668 | if ($name eq "") { |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 669 | if ($i > 0) { |
| 670 | my $tv = $typevalue[$i - 1]; |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 671 | if ($tv =~ m/^(\C):\s*(.*)/) { |
| 672 | if ($1 eq "P") { |
| 673 | $name = $2; |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 674 | $pvalue = format_email($name, $address); |
Joe Perches | 5f2441e | 2009-06-16 15:34:02 -0700 | [diff] [blame] | 675 | } |
| 676 | } |
| 677 | } |
| 678 | } |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 679 | if ($email_maintainer) { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 680 | my $role = get_maintainer_role($i); |
| 681 | push_email_addresses($pvalue, $role); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 682 | } |
| 683 | } elsif ($ptype eq "T") { |
| 684 | push(@scm, $pvalue); |
| 685 | } elsif ($ptype eq "W") { |
| 686 | push(@web, $pvalue); |
| 687 | } elsif ($ptype eq "S") { |
| 688 | push(@status, $pvalue); |
| 689 | } |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 690 | } |
| 691 | } |
| 692 | } |
| 693 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 694 | my %email_hash_name; |
| 695 | my %email_hash_address; |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 696 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 697 | sub email_inuse { |
| 698 | my ($name, $address) = @_; |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 699 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 700 | return 1 if (($name eq "") && ($address eq "")); |
| 701 | return 1 if (($name ne "") && exists($email_hash_name{$name})); |
| 702 | return 1 if (($address ne "") && exists($email_hash_address{$address})); |
| 703 | |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 704 | return 0; |
| 705 | } |
| 706 | |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 707 | sub push_email_address { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 708 | my ($line, $role) = @_; |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 709 | |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 710 | my ($name, $address) = parse_email($line); |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 711 | |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 712 | if ($address eq "") { |
| 713 | return 0; |
| 714 | } |
| 715 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 716 | if (!$email_remove_duplicates) { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 717 | push(@email_to, [format_email($name, $address), $role]); |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 718 | } elsif (!email_inuse($name, $address)) { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 719 | push(@email_to, [format_email($name, $address), $role]); |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 720 | $email_hash_name{$name}++; |
| 721 | $email_hash_address{$address}++; |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 722 | } |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 723 | |
| 724 | return 1; |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | sub push_email_addresses { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 728 | my ($address, $role) = @_; |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 729 | |
| 730 | my @address_list = (); |
| 731 | |
Joe Perches | 5f2441e | 2009-06-16 15:34:02 -0700 | [diff] [blame] | 732 | if (rfc822_valid($address)) { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 733 | push_email_address($address, $role); |
Joe Perches | 5f2441e | 2009-06-16 15:34:02 -0700 | [diff] [blame] | 734 | } elsif (@address_list = rfc822_validlist($address)) { |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 735 | my $array_count = shift(@address_list); |
| 736 | while (my $entry = shift(@address_list)) { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 737 | push_email_address($entry, $role); |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 738 | } |
Joe Perches | 5f2441e | 2009-06-16 15:34:02 -0700 | [diff] [blame] | 739 | } else { |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 740 | if (!push_email_address($address, $role)) { |
Joe Perches | b781655 | 2009-09-21 17:04:24 -0700 | [diff] [blame] | 741 | warn("Invalid MAINTAINERS address: '" . $address . "'\n"); |
| 742 | } |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 743 | } |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 744 | } |
| 745 | |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 746 | sub add_role { |
| 747 | my ($line, $role) = @_; |
| 748 | |
| 749 | my ($name, $address) = parse_email($line); |
| 750 | my $email = format_email($name, $address); |
| 751 | |
| 752 | foreach my $entry (@email_to) { |
| 753 | if ($email_remove_duplicates) { |
| 754 | my ($entry_name, $entry_address) = parse_email($entry->[0]); |
| 755 | if ($name eq $entry_name || $address eq $entry_address) { |
| 756 | if ($entry->[1] eq "") { |
| 757 | $entry->[1] = "$role"; |
| 758 | } else { |
| 759 | $entry->[1] = "$entry->[1],$role"; |
| 760 | } |
| 761 | } |
| 762 | } else { |
| 763 | if ($email eq $entry->[0]) { |
| 764 | if ($entry->[1] eq "") { |
| 765 | $entry->[1] = "$role"; |
| 766 | } else { |
| 767 | $entry->[1] = "$entry->[1],$role"; |
| 768 | } |
| 769 | } |
| 770 | } |
| 771 | } |
| 772 | } |
| 773 | |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 774 | sub which { |
| 775 | my ($bin) = @_; |
| 776 | |
Joe Perches | f5f5078 | 2009-06-16 15:34:00 -0700 | [diff] [blame] | 777 | foreach my $path (split(/:/, $ENV{PATH})) { |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 778 | if (-e "$path/$bin") { |
| 779 | return "$path/$bin"; |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | return ""; |
| 784 | } |
| 785 | |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 786 | sub mailmap { |
| 787 | my @lines = @_; |
| 788 | my %hash; |
| 789 | |
| 790 | foreach my $line (@lines) { |
| 791 | my ($name, $address) = parse_email($line); |
| 792 | if (!exists($hash{$name})) { |
| 793 | $hash{$name} = $address; |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 794 | } elsif ($address ne $hash{$name}) { |
| 795 | $address = $hash{$name}; |
| 796 | $line = format_email($name, $address); |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 797 | } |
| 798 | if (exists($mailmap{$name})) { |
| 799 | my $obj = $mailmap{$name}; |
| 800 | foreach my $map_address (@$obj) { |
| 801 | if (($map_address eq $address) && |
| 802 | ($map_address ne $hash{$name})) { |
| 803 | $line = format_email($name, $hash{$name}); |
| 804 | } |
| 805 | } |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | return @lines; |
| 810 | } |
| 811 | |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 812 | sub recent_git_signoffs { |
| 813 | my ($file) = @_; |
| 814 | |
| 815 | my $sign_offs = ""; |
| 816 | my $cmd = ""; |
| 817 | my $output = ""; |
| 818 | my $count = 0; |
| 819 | my @lines = (); |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 820 | my %hash; |
Joe Perches | afa81ee | 2009-07-29 15:04:28 -0700 | [diff] [blame] | 821 | my $total_sign_offs; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 822 | |
| 823 | if (which("git") eq "") { |
Joe Perches | de2fc49 | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 824 | warn("$P: git not found. Add --nogit to options?\n"); |
| 825 | return; |
| 826 | } |
| 827 | if (!(-d ".git")) { |
Joe Perches | 5f2441e | 2009-06-16 15:34:02 -0700 | [diff] [blame] | 828 | warn("$P: .git directory not found. Use a git repository for better results.\n"); |
| 829 | warn("$P: perhaps 'git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git'\n"); |
Joe Perches | de2fc49 | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 830 | return; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | $cmd = "git log --since=${email_git_since} -- ${file}"; |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 834 | |
| 835 | $output = `${cmd}`; |
| 836 | $output =~ s/^\s*//gm; |
| 837 | |
| 838 | @lines = split("\n", $output); |
Joe Perches | afa81ee | 2009-07-29 15:04:28 -0700 | [diff] [blame] | 839 | |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 840 | @lines = grep(/^[-_ a-z]+by:.*\@.*$/i, @lines); |
| 841 | if (!$email_git_penguin_chiefs) { |
| 842 | @lines = grep(!/${penguin_chiefs}/i, @lines); |
| 843 | } |
| 844 | # cut -f2- -d":" |
| 845 | s/.*:\s*(.+)\s*/$1/ for (@lines); |
| 846 | |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 847 | $total_sign_offs = @lines; |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 848 | foreach my $line (@lines) { |
| 849 | my ($name, $address) = parse_email($line); |
| 850 | $line = format_email($name, $address); |
| 851 | } |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 852 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 853 | if ($email_remove_duplicates) { |
| 854 | @lines = mailmap(@lines); |
| 855 | } |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 856 | |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 857 | @lines = sort(@lines); |
Joe Perches | afa81ee | 2009-07-29 15:04:28 -0700 | [diff] [blame] | 858 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 859 | # uniq -c |
| 860 | $hash{$_}++ for @lines; |
| 861 | |
| 862 | # sort -rn |
| 863 | foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { |
| 864 | my $sign_offs = $hash{$line}; |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 865 | my $role; |
| 866 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 867 | $count++; |
| 868 | last if ($sign_offs < $email_git_min_signatures || |
| 869 | $count > $email_git_max_maintainers || |
| 870 | $sign_offs * 100 / $total_sign_offs < $email_git_min_percent); |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 871 | push_email_address($line, ''); |
| 872 | $role = "git-signer"; |
| 873 | if ($output_rolestats) { |
| 874 | my $percent = sprintf("%.0f", $sign_offs * 100 / $total_sign_offs); |
| 875 | $role = "$role:$sign_offs/$total_sign_offs=$percent%"; |
| 876 | } |
| 877 | add_role($line, $role); |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 878 | } |
| 879 | } |
| 880 | |
| 881 | sub save_commits { |
| 882 | my ($cmd, @commits) = @_; |
| 883 | my $output; |
| 884 | my @lines = (); |
| 885 | |
| 886 | $output = `${cmd}`; |
| 887 | |
| 888 | @lines = split("\n", $output); |
| 889 | foreach my $line (@lines) { |
| 890 | if ($line =~ m/^(\w+) /) { |
| 891 | push (@commits, $1); |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 892 | } |
| 893 | } |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 894 | return @commits; |
| 895 | } |
| 896 | |
| 897 | sub git_assign_blame { |
| 898 | my ($file) = @_; |
| 899 | |
| 900 | my @lines = (); |
| 901 | my @commits = (); |
| 902 | my $cmd; |
| 903 | my $output; |
| 904 | my %hash; |
| 905 | my $total_sign_offs; |
| 906 | my $count; |
| 907 | |
| 908 | if (@range) { |
| 909 | foreach my $file_range_diff (@range) { |
| 910 | next if (!($file_range_diff =~ m/(.+):(.+):(.+)/)); |
| 911 | my $diff_file = $1; |
| 912 | my $diff_start = $2; |
| 913 | my $diff_length = $3; |
| 914 | next if (!("$file" eq "$diff_file")); |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 915 | $cmd = "git blame -l -L $diff_start,+$diff_length $file"; |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 916 | @commits = save_commits($cmd, @commits); |
| 917 | } |
| 918 | } else { |
| 919 | if (-f $file) { |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 920 | $cmd = "git blame -l $file"; |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 921 | @commits = save_commits($cmd, @commits); |
| 922 | } |
| 923 | } |
| 924 | |
| 925 | $total_sign_offs = 0; |
| 926 | @commits = uniq(@commits); |
| 927 | foreach my $commit (@commits) { |
| 928 | $cmd = "git log -1 ${commit}"; |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 929 | |
| 930 | $output = `${cmd}`; |
| 931 | $output =~ s/^\s*//gm; |
| 932 | @lines = split("\n", $output); |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 933 | |
| 934 | @lines = grep(/^[-_ a-z]+by:.*\@.*$/i, @lines); |
| 935 | if (!$email_git_penguin_chiefs) { |
| 936 | @lines = grep(!/${penguin_chiefs}/i, @lines); |
| 937 | } |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 938 | |
Joe Perches | 0e70e83 | 2009-09-21 17:04:20 -0700 | [diff] [blame] | 939 | # cut -f2- -d":" |
| 940 | s/.*:\s*(.+)\s*/$1/ for (@lines); |
| 941 | |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 942 | $total_sign_offs += @lines; |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 943 | |
Joe Perches | 11ecf53 | 2009-09-21 17:04:22 -0700 | [diff] [blame] | 944 | if ($email_remove_duplicates) { |
| 945 | @lines = mailmap(@lines); |
| 946 | } |
Joe Perches | 8cbb3a7 | 2009-09-21 17:04:21 -0700 | [diff] [blame] | 947 | |
| 948 | $hash{$_}++ for @lines; |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | $count = 0; |
| 952 | foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { |
| 953 | my $sign_offs = $hash{$line}; |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 954 | my $role; |
| 955 | |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 956 | $count++; |
| 957 | last if ($sign_offs < $email_git_min_signatures || |
| 958 | $count > $email_git_max_maintainers || |
| 959 | $sign_offs * 100 / $total_sign_offs < $email_git_min_percent); |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 960 | push_email_address($line, ''); |
| 961 | if ($from_filename) { |
| 962 | $role = "commits"; |
| 963 | } else { |
| 964 | $role = "modified commits"; |
| 965 | } |
| 966 | if ($output_rolestats) { |
| 967 | my $percent = sprintf("%.0f", $sign_offs * 100 / $total_sign_offs); |
| 968 | $role = "$role:$sign_offs/$total_sign_offs=$percent%"; |
| 969 | } |
| 970 | add_role($line, $role); |
Joe Perches | f549266 | 2009-09-21 17:04:13 -0700 | [diff] [blame] | 971 | } |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | sub uniq { |
| 975 | my @parms = @_; |
| 976 | |
| 977 | my %saw; |
| 978 | @parms = grep(!$saw{$_}++, @parms); |
| 979 | return @parms; |
| 980 | } |
| 981 | |
| 982 | sub sort_and_uniq { |
| 983 | my @parms = @_; |
| 984 | |
| 985 | my %saw; |
| 986 | @parms = sort @parms; |
| 987 | @parms = grep(!$saw{$_}++, @parms); |
| 988 | return @parms; |
| 989 | } |
| 990 | |
Joe Perches | 3c7385b | 2009-12-14 18:00:46 -0800 | [diff] [blame^] | 991 | sub merge_email { |
| 992 | my @lines; |
| 993 | my %saw; |
| 994 | |
| 995 | for (@_) { |
| 996 | my ($address, $role) = @$_; |
| 997 | if (!$saw{$address}) { |
| 998 | if ($output_roles) { |
| 999 | push @lines, "$address ($role)"; |
| 1000 | } else { |
| 1001 | push @lines, $address; |
| 1002 | } |
| 1003 | $saw{$address} = 1; |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | return @lines; |
| 1008 | } |
| 1009 | |
Joe Perches | cb7301c | 2009-04-07 20:40:12 -0700 | [diff] [blame] | 1010 | sub output { |
| 1011 | my @parms = @_; |
| 1012 | |
| 1013 | if ($output_multiline) { |
| 1014 | foreach my $line (@parms) { |
| 1015 | print("${line}\n"); |
| 1016 | } |
| 1017 | } else { |
| 1018 | print(join($output_separator, @parms)); |
| 1019 | print("\n"); |
| 1020 | } |
| 1021 | } |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 1022 | |
| 1023 | my $rfc822re; |
| 1024 | |
| 1025 | sub make_rfc822re { |
| 1026 | # Basic lexical tokens are specials, domain_literal, quoted_string, atom, and |
| 1027 | # comment. We must allow for rfc822_lwsp (or comments) after each of these. |
| 1028 | # This regexp will only work on addresses which have had comments stripped |
| 1029 | # and replaced with rfc822_lwsp. |
| 1030 | |
| 1031 | my $specials = '()<>@,;:\\\\".\\[\\]'; |
| 1032 | my $controls = '\\000-\\037\\177'; |
| 1033 | |
| 1034 | my $dtext = "[^\\[\\]\\r\\\\]"; |
| 1035 | my $domain_literal = "\\[(?:$dtext|\\\\.)*\\]$rfc822_lwsp*"; |
| 1036 | |
| 1037 | my $quoted_string = "\"(?:[^\\\"\\r\\\\]|\\\\.|$rfc822_lwsp)*\"$rfc822_lwsp*"; |
| 1038 | |
| 1039 | # Use zero-width assertion to spot the limit of an atom. A simple |
| 1040 | # $rfc822_lwsp* causes the regexp engine to hang occasionally. |
| 1041 | my $atom = "[^$specials $controls]+(?:$rfc822_lwsp+|\\Z|(?=[\\[\"$specials]))"; |
| 1042 | my $word = "(?:$atom|$quoted_string)"; |
| 1043 | my $localpart = "$word(?:\\.$rfc822_lwsp*$word)*"; |
| 1044 | |
| 1045 | my $sub_domain = "(?:$atom|$domain_literal)"; |
| 1046 | my $domain = "$sub_domain(?:\\.$rfc822_lwsp*$sub_domain)*"; |
| 1047 | |
| 1048 | my $addr_spec = "$localpart\@$rfc822_lwsp*$domain"; |
| 1049 | |
| 1050 | my $phrase = "$word*"; |
| 1051 | my $route = "(?:\@$domain(?:,\@$rfc822_lwsp*$domain)*:$rfc822_lwsp*)"; |
| 1052 | my $route_addr = "\\<$rfc822_lwsp*$route?$addr_spec\\>$rfc822_lwsp*"; |
| 1053 | my $mailbox = "(?:$addr_spec|$phrase$route_addr)"; |
| 1054 | |
| 1055 | my $group = "$phrase:$rfc822_lwsp*(?:$mailbox(?:,\\s*$mailbox)*)?;\\s*"; |
| 1056 | my $address = "(?:$mailbox|$group)"; |
| 1057 | |
| 1058 | return "$rfc822_lwsp*$address"; |
| 1059 | } |
| 1060 | |
| 1061 | sub rfc822_strip_comments { |
| 1062 | my $s = shift; |
| 1063 | # Recursively remove comments, and replace with a single space. The simpler |
| 1064 | # regexps in the Email Addressing FAQ are imperfect - they will miss escaped |
| 1065 | # chars in atoms, for example. |
| 1066 | |
| 1067 | while ($s =~ s/^((?:[^"\\]|\\.)* |
| 1068 | (?:"(?:[^"\\]|\\.)*"(?:[^"\\]|\\.)*)*) |
| 1069 | \((?:[^()\\]|\\.)*\)/$1 /osx) {} |
| 1070 | return $s; |
| 1071 | } |
| 1072 | |
| 1073 | # valid: returns true if the parameter is an RFC822 valid address |
| 1074 | # |
| 1075 | sub rfc822_valid ($) { |
| 1076 | my $s = rfc822_strip_comments(shift); |
| 1077 | |
| 1078 | if (!$rfc822re) { |
| 1079 | $rfc822re = make_rfc822re(); |
| 1080 | } |
| 1081 | |
| 1082 | return $s =~ m/^$rfc822re$/so && $s =~ m/^$rfc822_char*$/; |
| 1083 | } |
| 1084 | |
| 1085 | # validlist: In scalar context, returns true if the parameter is an RFC822 |
| 1086 | # valid list of addresses. |
| 1087 | # |
| 1088 | # In list context, returns an empty list on failure (an invalid |
| 1089 | # address was found); otherwise a list whose first element is the |
| 1090 | # number of addresses found and whose remaining elements are the |
| 1091 | # addresses. This is needed to disambiguate failure (invalid) |
| 1092 | # from success with no addresses found, because an empty string is |
| 1093 | # a valid list. |
| 1094 | |
| 1095 | sub rfc822_validlist ($) { |
| 1096 | my $s = rfc822_strip_comments(shift); |
| 1097 | |
| 1098 | if (!$rfc822re) { |
| 1099 | $rfc822re = make_rfc822re(); |
| 1100 | } |
| 1101 | # * null list items are valid according to the RFC |
| 1102 | # * the '1' business is to aid in distinguishing failure from no results |
| 1103 | |
| 1104 | my @r; |
| 1105 | if ($s =~ m/^(?:$rfc822re)?(?:,(?:$rfc822re)?)*$/so && |
| 1106 | $s =~ m/^$rfc822_char*$/) { |
Joe Perches | 5f2441e | 2009-06-16 15:34:02 -0700 | [diff] [blame] | 1107 | while ($s =~ m/(?:^|,$rfc822_lwsp*)($rfc822re)/gos) { |
Joe Perches | 1b5e1cf | 2009-06-16 15:34:01 -0700 | [diff] [blame] | 1108 | push @r, $1; |
| 1109 | } |
| 1110 | return wantarray ? (scalar(@r), @r) : 1; |
| 1111 | } |
| 1112 | else { |
| 1113 | return wantarray ? () : 0; |
| 1114 | } |
| 1115 | } |