Commit | Line | Data |
---|---|---|
cb7301c7 JP |
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 | # | |
3bd7bf5f RK |
8 | # usage: perl scripts/get_maintainer.pl [OPTIONS] <patch> |
9 | # perl scripts/get_maintainer.pl [OPTIONS] -f <file> | |
cb7301c7 JP |
10 | # |
11 | # Licensed under the terms of the GNU GPL License version 2 | |
12 | ||
13 | use strict; | |
14 | ||
15 | my $P = $0; | |
3c7385b8 | 16 | my $V = '0.22'; |
cb7301c7 JP |
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; | |
afa81ee1 | 30 | my $email_git_min_percent = 5; |
cb7301c7 | 31 | my $email_git_since = "1-year-ago"; |
f5492666 | 32 | my $email_git_blame = 0; |
11ecf53c | 33 | my $email_remove_duplicates = 1; |
cb7301c7 JP |
34 | my $output_multiline = 1; |
35 | my $output_separator = ", "; | |
3c7385b8 JP |
36 | my $output_roles = 0; |
37 | my $output_rolestats = 0; | |
cb7301c7 JP |
38 | my $scm = 0; |
39 | my $web = 0; | |
40 | my $subsystem = 0; | |
41 | my $status = 0; | |
dcf36a92 | 42 | my $keywords = 1; |
4a7fdb5f | 43 | my $from_filename = 0; |
3fb55652 | 44 | my $pattern_depth = 0; |
cb7301c7 JP |
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 | ||
5f2441e9 | 65 | # rfc822 email address - preloaded methods go here. |
1b5e1cf6 | 66 | my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])"; |
df4cc036 | 67 | my $rfc822_char = '[\\000-\\377]'; |
1b5e1cf6 | 68 | |
cb7301c7 JP |
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, | |
afa81ee1 | 75 | 'git-min-percent=i' => \$email_git_min_percent, |
cb7301c7 | 76 | 'git-since=s' => \$email_git_since, |
f5492666 | 77 | 'git-blame!' => \$email_git_blame, |
11ecf53c | 78 | 'remove-duplicates!' => \$email_remove_duplicates, |
cb7301c7 JP |
79 | 'm!' => \$email_maintainer, |
80 | 'n!' => \$email_usename, | |
81 | 'l!' => \$email_list, | |
82 | 's!' => \$email_subscriber_list, | |
83 | 'multiline!' => \$output_multiline, | |
3c7385b8 JP |
84 | 'roles!' => \$output_roles, |
85 | 'rolestats!' => \$output_rolestats, | |
cb7301c7 JP |
86 | 'separator=s' => \$output_separator, |
87 | 'subsystem!' => \$subsystem, | |
88 | 'status!' => \$status, | |
89 | 'scm!' => \$scm, | |
90 | 'web!' => \$web, | |
3fb55652 | 91 | 'pattern-depth=i' => \$pattern_depth, |
dcf36a92 | 92 | 'k|keywords!' => \$keywords, |
4a7fdb5f | 93 | 'f|file' => \$from_filename, |
cb7301c7 JP |
94 | 'v|version' => \$version, |
95 | 'h|help' => \$help, | |
96 | )) { | |
3c7385b8 | 97 | die "$P: invalid argument - use --help if necessary\n"; |
cb7301c7 JP |
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 | ||
cb7301c7 JP |
110 | if ($#ARGV < 0) { |
111 | usage(); | |
112 | die "$P: argument missing: patchfile or -f file please\n"; | |
113 | } | |
114 | ||
42498316 JP |
115 | if ($output_separator ne ", ") { |
116 | $output_multiline = 0; | |
117 | } | |
118 | ||
3c7385b8 JP |
119 | if ($output_rolestats) { |
120 | $output_roles = 1; | |
121 | } | |
122 | ||
cb7301c7 JP |
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 | ||
f5492666 JP |
129 | if ($email && |
130 | ($email_maintainer + $email_list + $email_subscriber_list + | |
131 | $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) { | |
cb7301c7 JP |
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 = (); | |
dcf36a92 JP |
144 | my %keyword_hash; |
145 | ||
cb7301c7 JP |
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 . | |
870020f9 JP |
159 | ##if pattern is a directory and it lacks a trailing slash, add one |
160 | if ((-d $value)) { | |
161 | $value =~ s@([^/])$@$1/@; | |
162 | } | |
dcf36a92 JP |
163 | } elsif ($type eq "K") { |
164 | $keyword_hash{@typevalue} = $value; | |
cb7301c7 JP |
165 | } |
166 | push(@typevalue, "$type:$value"); | |
167 | } elsif (!/^(\s)*$/) { | |
168 | $line =~ s/\n$//g; | |
169 | push(@typevalue, $line); | |
170 | } | |
171 | } | |
172 | close(MAINT); | |
173 | ||
8cbb3a77 JP |
174 | my %mailmap; |
175 | ||
11ecf53c JP |
176 | if ($email_remove_duplicates) { |
177 | open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n"; | |
178 | while (<MAILMAP>) { | |
179 | my $line = $_; | |
8cbb3a77 | 180 | |
11ecf53c JP |
181 | next if ($line =~ m/^\s*#/); |
182 | next if ($line =~ m/^\s*$/); | |
8cbb3a77 | 183 | |
11ecf53c JP |
184 | my ($name, $address) = parse_email($line); |
185 | $line = format_email($name, $address); | |
8cbb3a77 | 186 | |
11ecf53c | 187 | next if ($line =~ m/^\s*$/); |
8cbb3a77 | 188 | |
11ecf53c JP |
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 | } | |
8cbb3a77 | 196 | } |
11ecf53c | 197 | close(MAILMAP); |
8cbb3a77 JP |
198 | } |
199 | ||
4a7fdb5f | 200 | ## use the filenames on the command line or find the filenames in the patchfiles |
cb7301c7 JP |
201 | |
202 | my @files = (); | |
f5492666 | 203 | my @range = (); |
dcf36a92 | 204 | my @keyword_tvi = (); |
cb7301c7 | 205 | |
4a7fdb5f | 206 | foreach my $file (@ARGV) { |
870020f9 JP |
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)) { | |
4a7fdb5f | 211 | die "$P: file '${file}' not found\n"; |
cb7301c7 | 212 | } |
4a7fdb5f JP |
213 | if ($from_filename) { |
214 | push(@files, $file); | |
dcf36a92 JP |
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 | } | |
4a7fdb5f JP |
227 | } else { |
228 | my $file_cnt = @files; | |
f5492666 | 229 | my $lastfile; |
4a7fdb5f JP |
230 | open(PATCH, "<$file") or die "$P: Can't open ${file}\n"; |
231 | while (<PATCH>) { | |
dcf36a92 | 232 | my $patch_line = $_; |
4a7fdb5f JP |
233 | if (m/^\+\+\+\s+(\S+)/) { |
234 | my $filename = $1; | |
235 | $filename =~ s@^[^/]*/@@; | |
236 | $filename =~ s@\n@@; | |
f5492666 | 237 | $lastfile = $filename; |
4a7fdb5f | 238 | push(@files, $filename); |
f5492666 JP |
239 | } elsif (m/^\@\@ -(\d+),(\d+)/) { |
240 | if ($email_git_blame) { | |
241 | push(@range, "$lastfile:$1:$2"); | |
242 | } | |
dcf36a92 JP |
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 | } | |
4a7fdb5f | 249 | } |
cb7301c7 | 250 | } |
4a7fdb5f JP |
251 | close(PATCH); |
252 | if ($file_cnt == @files) { | |
7f29fd27 | 253 | warn "$P: file '${file}' doesn't appear to be a patch. " |
4a7fdb5f JP |
254 | . "Add -f to options?\n"; |
255 | } | |
256 | @files = sort_and_uniq(@files); | |
cb7301c7 | 257 | } |
cb7301c7 JP |
258 | } |
259 | ||
260 | my @email_to = (); | |
290603c1 | 261 | my @list_to = (); |
cb7301c7 JP |
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) { | |
290603c1 | 275 | if ($line =~ m/^(\C):\s*(.*)/) { |
cb7301c7 JP |
276 | my $type = $1; |
277 | my $value = $2; | |
278 | if ($type eq 'X') { | |
279 | if (file_match_pattern($file, $value)) { | |
280 | $exclude = 1; | |
1d606b4e | 281 | last; |
cb7301c7 JP |
282 | } |
283 | } | |
284 | } | |
285 | } | |
286 | ||
287 | if (!$exclude) { | |
288 | my $tvi = 0; | |
1d606b4e | 289 | my %hash; |
cb7301c7 | 290 | foreach my $line (@typevalue) { |
290603c1 | 291 | if ($line =~ m/^(\C):\s*(.*)/) { |
cb7301c7 JP |
292 | my $type = $1; |
293 | my $value = $2; | |
294 | if ($type eq 'F') { | |
295 | if (file_match_pattern($file, $value)) { | |
3fb55652 JP |
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 | } | |
cb7301c7 JP |
303 | } |
304 | } | |
305 | } | |
306 | $tvi++; | |
307 | } | |
1d606b4e JP |
308 | foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { |
309 | add_categories($line); | |
310 | } | |
cb7301c7 JP |
311 | } |
312 | ||
4a7fdb5f | 313 | if ($email && $email_git) { |
cb7301c7 JP |
314 | recent_git_signoffs($file); |
315 | } | |
316 | ||
f5492666 JP |
317 | if ($email && $email_git_blame) { |
318 | git_assign_blame($file); | |
319 | } | |
cb7301c7 JP |
320 | } |
321 | ||
dcf36a92 JP |
322 | if ($keywords) { |
323 | @keyword_tvi = sort_and_uniq(@keyword_tvi); | |
324 | foreach my $line (@keyword_tvi) { | |
325 | add_categories($line); | |
326 | } | |
327 | } | |
328 | ||
f5f5078d | 329 | if ($email) { |
cb7301c7 JP |
330 | foreach my $chief (@penguin_chief) { |
331 | if ($chief =~ m/^(.*):(.*)/) { | |
f5f5078d | 332 | my $email_address; |
0e70e83d JP |
333 | |
334 | $email_address = format_email($1, $2); | |
f5f5078d | 335 | if ($email_git_penguin_chiefs) { |
3c7385b8 | 336 | push(@email_to, [$email_address, 'chief penguin']); |
f5f5078d | 337 | } else { |
3c7385b8 | 338 | @email_to = grep($_->[0] !~ /${email_address}/, @email_to); |
cb7301c7 JP |
339 | } |
340 | } | |
341 | } | |
342 | } | |
343 | ||
290603c1 JP |
344 | if ($email || $email_list) { |
345 | my @to = (); | |
346 | if ($email) { | |
347 | @to = (@to, @email_to); | |
cb7301c7 | 348 | } |
290603c1 | 349 | if ($email_list) { |
290603c1 | 350 | @to = (@to, @list_to); |
290603c1 | 351 | } |
3c7385b8 | 352 | output(merge_email(@to)); |
cb7301c7 JP |
353 | } |
354 | ||
355 | if ($scm) { | |
b781655a | 356 | @scm = uniq(@scm); |
cb7301c7 JP |
357 | output(@scm); |
358 | } | |
359 | ||
360 | if ($status) { | |
b781655a | 361 | @status = uniq(@status); |
cb7301c7 JP |
362 | output(@status); |
363 | } | |
364 | ||
365 | if ($subsystem) { | |
b781655a | 366 | @subsystem = uniq(@subsystem); |
cb7301c7 JP |
367 | output(@subsystem); |
368 | } | |
369 | ||
370 | if ($web) { | |
b781655a | 371 | @web = uniq(@web); |
cb7301c7 JP |
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 | |
870020f9 | 398 | $P [options] -f file|directory |
cb7301c7 JP |
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) | |
3d202aeb | 407 | --git-min-percent => minimum percentage of commits required (default: 5) |
cb7301c7 | 408 | --git-since => git history to use (default: 1-year-ago) |
f5492666 | 409 | --git-blame => use git blame to find modified commits for patch or file |
cb7301c7 JP |
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 | |
11ecf53c | 414 | --remove-duplicates => minimize duplicate email names/addresses |
3c7385b8 JP |
415 | --roles => show roles (status:subsystem, git-signer, list, etc...) |
416 | --rolestats => show roles and statistics (commits/total_commits, %) | |
cb7301c7 JP |
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 | |
42498316 | 424 | using --separator also sets --nomultiline if --separator is not [, ] |
cb7301c7 JP |
425 | --multiline => print 1 entry per line |
426 | ||
cb7301c7 | 427 | Other options: |
3fb55652 | 428 | --pattern-depth => Number of pattern directory traversals (default: 0 (all)) |
dcf36a92 | 429 | --keywords => scan patch for keywords (default: 1 (on)) |
f5f5078d | 430 | --version => show version |
cb7301c7 JP |
431 | --help => show this help information |
432 | ||
3fb55652 | 433 | Default options: |
11ecf53c | 434 | [--email --git --m --n --l --multiline --pattern-depth=0 --remove-duplicates] |
3fb55652 | 435 | |
870020f9 JP |
436 | Notes: |
437 | Using "-f directory" may give unexpected results: | |
f5492666 JP |
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. | |
3c7385b8 JP |
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. | |
cb7301c7 JP |
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 | ||
0e70e83d JP |
484 | sub parse_email { |
485 | my ($formatted_email) = @_; | |
486 | ||
487 | my $name = ""; | |
488 | my $address = ""; | |
489 | ||
11ecf53c | 490 | if ($formatted_email =~ /^([^<]+)<(.+\@.*)>.*$/) { |
0e70e83d JP |
491 | $name = $1; |
492 | $address = $2; | |
11ecf53c | 493 | } elsif ($formatted_email =~ /^\s*<(.+\@\S*)>.*$/) { |
0e70e83d | 494 | $address = $1; |
b781655a | 495 | } elsif ($formatted_email =~ /^(.+\@\S*).*$/) { |
0e70e83d JP |
496 | $address = $1; |
497 | } | |
cb7301c7 JP |
498 | |
499 | $name =~ s/^\s+|\s+$//g; | |
d789504a | 500 | $name =~ s/^\"|\"$//g; |
0e70e83d | 501 | $address =~ s/^\s+|\s+$//g; |
cb7301c7 | 502 | |
0e70e83d JP |
503 | if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars |
504 | $name =~ s/(?<!\\)"/\\"/g; ##escape quotes | |
505 | $name = "\"$name\""; | |
506 | } | |
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; | |
cb7301c7 JP |
519 | |
520 | if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars | |
521 | $name =~ s/(?<!\\)"/\\"/g; ##escape quotes | |
0e70e83d JP |
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 | } | |
cb7301c7 | 531 | } else { |
0e70e83d | 532 | $formatted_email = $address; |
cb7301c7 | 533 | } |
0e70e83d | 534 | |
cb7301c7 JP |
535 | return $formatted_email; |
536 | } | |
537 | ||
b781655a | 538 | sub find_starting_index { |
b781655a JP |
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 { | |
cb7301c7 JP |
553 | my ($index) = @_; |
554 | ||
b781655a | 555 | while ($index < @typevalue) { |
cb7301c7 | 556 | my $tv = $typevalue[$index]; |
b781655a JP |
557 | if (!($tv =~ m/^(\C):\s*(.*)/)) { |
558 | last; | |
559 | } | |
560 | $index++; | |
561 | } | |
562 | ||
563 | return $index; | |
564 | } | |
565 | ||
3c7385b8 JP |
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 | ||
b781655a JP |
631 | sub add_categories { |
632 | my ($index) = @_; | |
633 | ||
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]; | |
290603c1 | 642 | if ($tv =~ m/^(\C):\s*(.*)/) { |
cb7301c7 JP |
643 | my $ptype = $1; |
644 | my $pvalue = $2; | |
645 | if ($ptype eq "L") { | |
290603c1 JP |
646 | my $list_address = $pvalue; |
647 | my $list_additional = ""; | |
3c7385b8 JP |
648 | my $list_role = get_list_role($i); |
649 | ||
650 | if ($list_role ne "") { | |
651 | $list_role = ":" . $list_role; | |
652 | } | |
290603c1 JP |
653 | if ($list_address =~ m/([^\s]+)\s+(.*)$/) { |
654 | $list_address = $1; | |
655 | $list_additional = $2; | |
656 | } | |
bdf7c685 | 657 | if ($list_additional =~ m/subscribers-only/) { |
cb7301c7 | 658 | if ($email_subscriber_list) { |
3c7385b8 | 659 | push(@list_to, [$list_address, "subscriber list${list_role}"]); |
cb7301c7 JP |
660 | } |
661 | } else { | |
662 | if ($email_list) { | |
3c7385b8 | 663 | push(@list_to, [$list_address, "open list${list_role}"]); |
cb7301c7 JP |
664 | } |
665 | } | |
666 | } elsif ($ptype eq "M") { | |
0e70e83d JP |
667 | my ($name, $address) = parse_email($pvalue); |
668 | if ($name eq "") { | |
b781655a JP |
669 | if ($i > 0) { |
670 | my $tv = $typevalue[$i - 1]; | |
0e70e83d JP |
671 | if ($tv =~ m/^(\C):\s*(.*)/) { |
672 | if ($1 eq "P") { | |
673 | $name = $2; | |
b781655a | 674 | $pvalue = format_email($name, $address); |
5f2441e9 JP |
675 | } |
676 | } | |
677 | } | |
678 | } | |
0e70e83d | 679 | if ($email_maintainer) { |
3c7385b8 JP |
680 | my $role = get_maintainer_role($i); |
681 | push_email_addresses($pvalue, $role); | |
cb7301c7 JP |
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 | } | |
cb7301c7 JP |
690 | } |
691 | } | |
692 | } | |
693 | ||
11ecf53c JP |
694 | my %email_hash_name; |
695 | my %email_hash_address; | |
0e70e83d | 696 | |
11ecf53c JP |
697 | sub email_inuse { |
698 | my ($name, $address) = @_; | |
699 | ||
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})); | |
0e70e83d | 703 | |
0e70e83d JP |
704 | return 0; |
705 | } | |
706 | ||
1b5e1cf6 | 707 | sub push_email_address { |
3c7385b8 | 708 | my ($line, $role) = @_; |
1b5e1cf6 | 709 | |
0e70e83d | 710 | my ($name, $address) = parse_email($line); |
1b5e1cf6 | 711 | |
b781655a JP |
712 | if ($address eq "") { |
713 | return 0; | |
714 | } | |
715 | ||
11ecf53c | 716 | if (!$email_remove_duplicates) { |
3c7385b8 | 717 | push(@email_to, [format_email($name, $address), $role]); |
11ecf53c | 718 | } elsif (!email_inuse($name, $address)) { |
3c7385b8 | 719 | push(@email_to, [format_email($name, $address), $role]); |
11ecf53c JP |
720 | $email_hash_name{$name}++; |
721 | $email_hash_address{$address}++; | |
1b5e1cf6 | 722 | } |
b781655a JP |
723 | |
724 | return 1; | |
1b5e1cf6 JP |
725 | } |
726 | ||
727 | sub push_email_addresses { | |
3c7385b8 | 728 | my ($address, $role) = @_; |
1b5e1cf6 JP |
729 | |
730 | my @address_list = (); | |
731 | ||
5f2441e9 | 732 | if (rfc822_valid($address)) { |
3c7385b8 | 733 | push_email_address($address, $role); |
5f2441e9 | 734 | } elsif (@address_list = rfc822_validlist($address)) { |
1b5e1cf6 JP |
735 | my $array_count = shift(@address_list); |
736 | while (my $entry = shift(@address_list)) { | |
3c7385b8 | 737 | push_email_address($entry, $role); |
1b5e1cf6 | 738 | } |
5f2441e9 | 739 | } else { |
3c7385b8 | 740 | if (!push_email_address($address, $role)) { |
b781655a JP |
741 | warn("Invalid MAINTAINERS address: '" . $address . "'\n"); |
742 | } | |
1b5e1cf6 | 743 | } |
1b5e1cf6 JP |
744 | } |
745 | ||
3c7385b8 JP |
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 | ||
cb7301c7 JP |
774 | sub which { |
775 | my ($bin) = @_; | |
776 | ||
f5f5078d | 777 | foreach my $path (split(/:/, $ENV{PATH})) { |
cb7301c7 JP |
778 | if (-e "$path/$bin") { |
779 | return "$path/$bin"; | |
780 | } | |
781 | } | |
782 | ||
783 | return ""; | |
784 | } | |
785 | ||
8cbb3a77 JP |
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; | |
11ecf53c JP |
794 | } elsif ($address ne $hash{$name}) { |
795 | $address = $hash{$name}; | |
796 | $line = format_email($name, $address); | |
8cbb3a77 JP |
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 | ||
cb7301c7 JP |
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 = (); | |
0e70e83d | 820 | my %hash; |
afa81ee1 | 821 | my $total_sign_offs; |
cb7301c7 JP |
822 | |
823 | if (which("git") eq "") { | |
de2fc492 JP |
824 | warn("$P: git not found. Add --nogit to options?\n"); |
825 | return; | |
826 | } | |
827 | if (!(-d ".git")) { | |
5f2441e9 JP |
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"); | |
de2fc492 | 830 | return; |
cb7301c7 JP |
831 | } |
832 | ||
833 | $cmd = "git log --since=${email_git_since} -- ${file}"; | |
cb7301c7 JP |
834 | |
835 | $output = `${cmd}`; | |
836 | $output =~ s/^\s*//gm; | |
837 | ||
838 | @lines = split("\n", $output); | |
afa81ee1 | 839 | |
0e70e83d JP |
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 | ||
8cbb3a77 | 847 | $total_sign_offs = @lines; |
3c7385b8 JP |
848 | foreach my $line (@lines) { |
849 | my ($name, $address) = parse_email($line); | |
850 | $line = format_email($name, $address); | |
851 | } | |
8cbb3a77 | 852 | |
11ecf53c JP |
853 | if ($email_remove_duplicates) { |
854 | @lines = mailmap(@lines); | |
855 | } | |
0e70e83d | 856 | |
0e70e83d | 857 | @lines = sort(@lines); |
11ecf53c | 858 | |
0e70e83d | 859 | # uniq -c |
11ecf53c JP |
860 | $hash{$_}++ for @lines; |
861 | ||
0e70e83d | 862 | # sort -rn |
0e70e83d | 863 | foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { |
11ecf53c | 864 | my $sign_offs = $hash{$line}; |
3c7385b8 JP |
865 | my $role; |
866 | ||
11ecf53c JP |
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); | |
3c7385b8 JP |
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); | |
f5492666 JP |
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); | |
892 | } | |
893 | } | |
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")); | |
8cbb3a77 | 915 | $cmd = "git blame -l -L $diff_start,+$diff_length $file"; |
f5492666 | 916 | @commits = save_commits($cmd, @commits); |
cb7301c7 | 917 | } |
f5492666 JP |
918 | } else { |
919 | if (-f $file) { | |
8cbb3a77 | 920 | $cmd = "git blame -l $file"; |
f5492666 JP |
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}"; | |
f5492666 JP |
929 | |
930 | $output = `${cmd}`; | |
931 | $output =~ s/^\s*//gm; | |
932 | @lines = split("\n", $output); | |
0e70e83d JP |
933 | |
934 | @lines = grep(/^[-_ a-z]+by:.*\@.*$/i, @lines); | |
935 | if (!$email_git_penguin_chiefs) { | |
936 | @lines = grep(!/${penguin_chiefs}/i, @lines); | |
937 | } | |
8cbb3a77 | 938 | |
0e70e83d JP |
939 | # cut -f2- -d":" |
940 | s/.*:\s*(.+)\s*/$1/ for (@lines); | |
941 | ||
f5492666 | 942 | $total_sign_offs += @lines; |
8cbb3a77 | 943 | |
11ecf53c JP |
944 | if ($email_remove_duplicates) { |
945 | @lines = mailmap(@lines); | |
946 | } | |
8cbb3a77 JP |
947 | |
948 | $hash{$_}++ for @lines; | |
f5492666 JP |
949 | } |
950 | ||
951 | $count = 0; | |
952 | foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { | |
953 | my $sign_offs = $hash{$line}; | |
3c7385b8 JP |
954 | my $role; |
955 | ||
f5492666 JP |
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); | |
3c7385b8 JP |
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); | |
cb7301c7 | 971 | } |
cb7301c7 JP |
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 | ||
3c7385b8 JP |
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 | ||
cb7301c7 JP |
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 | } | |
1b5e1cf6 JP |
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*$/) { | |
5f2441e9 | 1107 | while ($s =~ m/(?:^|,$rfc822_lwsp*)($rfc822re)/gos) { |
1b5e1cf6 JP |
1108 | push @r, $1; |
1109 | } | |
1110 | return wantarray ? (scalar(@r), @r) : 1; | |
1111 | } | |
1112 | else { | |
1113 | return wantarray ? () : 0; | |
1114 | } | |
1115 | } |