diff --git a/util/merge_copyrights b/util/merge_copyrights index c86b772125..63e8a85e0a 100644 --- a/util/merge_copyrights +++ b/util/merge_copyrights @@ -78,6 +78,8 @@ while () { $file_types{$_} = "YACC"; } elsif ($base =~ /\.pl$/i) { $file_types{$_} = "PERL"; + } elsif ($base =~ /\.py$/i) { + $file_types{$_} = "PYTHON"; } elsif ($base =~ /\.sh$/) { $file_types{$_} = "SH"; } elsif ($base =~ /\.docbook$/ || diff --git a/util/update_copyrights b/util/update_copyrights index 3d45966815..9171774bf3 100644 --- a/util/update_copyrights +++ b/util/update_copyrights @@ -56,10 +56,9 @@ my %file_years = (); my $years_list; my $parent; -($dummy,$dummy,$dummy,$dummy,$dummy,$this_year,$dummy,$dummy,$dummy) = localtime(time()); +($dummy,$dummy,$dummy,$dummy,$this_month,$this_year,$dummy,$dummy,$dummy) = localtime(time()); $this_year += 1900; - while (<>) { chomp; ($file, $type, $years) = split(/\s+/); @@ -151,6 +150,7 @@ foreach $file (keys %file_types) { $sgml_comment = 0; $zone_comment = 0; $man_comment = 0; + $python_comment = 0; $start_comment = ""; $end_comment = ""; $first = ""; @@ -161,7 +161,11 @@ foreach $file (keys %file_types) { $end_comment = " */\n"; } elsif ($type =~ /^(SH|PERL|TCL|MAKE|CONF-SH|RNC)$/) { $shell_comment = 1; + } elsif ($type =~ /^PYTHON$/) { + $python_comment = 1; + $start_comment = "############################################################################\n"; $prefix = "# "; + $end_comment = "############################################################################\n" } elsif ($type eq "ZONE" || $type eq "MC") { $zone_comment = 1; $prefix = "; "; @@ -230,6 +234,28 @@ foreach $file (keys %file_types) { } else { $first = $_; } + } elsif ($python_comment) { + if (/^\#\!/) { + $before_copyright = "$_"; + $_ = ; + $_ = if $_ eq "#\n"; + $_ = if $_ eq "############################################################################\n"; + } + if (/^\#/) { + if ($_ !~ /[Cc]opyright/) { + print "$file: non-copyright comment\n"; + close(SOURCE); + next; + } + while () { + if ($_ !~ /^\#/) { + $first = $_; + last; + } + } + } else { + $first = $_; + } } elsif (($m4_comment || $zone_comment || $man_comment) && /^\Q$nonspaceprefix\E/) { @@ -382,9 +408,11 @@ foreach $file (keys %file_types) { $years = ""; $anchor_end = length($years); my $andor = 0; + my $noid = 0; foreach $year (@years) { if ($year < 2004) { next; } $andor = 1 if ($year >= 2007); + $noid = 1 if ($year > 2012 || ($year == 2012 && $this_month >= 5) ); if ($last_year != 0 && $year == $last_year + 1) { if ($year > $anchor_year + 1) { substr($years, $anchor_end) = "-$year"; @@ -473,7 +501,10 @@ foreach $file (keys %file_types) { } my ($start, $end); - if ($start_comment ne "") { + if ($type =~ /^PYTHON$/) { + ($start = $prefix) =~ s/\s*\n//; + $end = "\n"; + } elsif ($start_comment ne "") { ($start = $start_comment) =~ s/\s*\n/ /; ($end = $end_comment) =~ s/^\s*(.*)\n/ $1\n/; } elsif ($prefix ne "") { @@ -484,7 +515,7 @@ foreach $file (keys %file_types) { $end = "\n"; } - if ($first !~ /$keyword_pat/ && + if (!$noid && $first !~ /$keyword_pat/ && (!defined($_) || $_ !~ /$keyword_pat/)) { $end = "\n$nonspaceprefix" if ($type eq "MAN"); print TARGET "$start\$";