Re: New copyright program

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: New copyright program
Дата
Msg-id 201108192148.p7JLmgt14737@momjian.us
обсуждение исходный текст
Ответ на Re: New copyright program  (Kris Jurka <books@ejurka.com>)
Ответы Re: New copyright program  (Kris Jurka <books@ejurka.com>)
Список pgsql-hackers
Kris Jurka wrote:
>
>
> On Fri, 19 Aug 2011, Kris Jurka wrote:
>
> > For me this fails with:
> >
> > Bareword "Tie::File" not allowed while "strict subs" in use  at
> > /home/jurka/pg/server/postgresql/src/tools/copyright.pl line 28.
> >
>
> This fixes things for me.  The copyright matching wasn't working for me
> either without escaping the parentheses.

Was able to reproduce the error you reported with Perl 5.10.  I then
tried the single-quote idea I got from Googling, but then got an error
about TIEARRAY being missing, so I recoded it as a simple file
open/close.  I also incorported your regex fix.  Path attached and
applied.  Thanks.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/src/tools/copyright.pl b/src/tools/copyright.pl
new file mode 100755
index 96b1f22..91f73e3
*** a/src/tools/copyright.pl
--- b/src/tools/copyright.pl
*************** use warnings;
*** 13,19 ****
  use File::Find;

  my $pgdg = 'PostgreSQL Global Development Group';
! my $cc = 'Copyright (c) ';
  # year-1900 is what localtime(time) puts in element 5
  my $year = 1900 + ${[localtime(time)]}[5];

--- 13,19 ----
  use File::Find;

  my $pgdg = 'PostgreSQL Global Development Group';
! my $cc = 'Copyright \(c\) ';
  # year-1900 is what localtime(time) puts in element 5
  my $year = 1900 + ${[localtime(time)]}[5];

*************** print "Using current year:  $year\n";
*** 22,33 ****
  find({wanted => \&wanted, no_chdir => 1}, '.');

  sub wanted {
!     return unless -f $File::Find::name;

!     my @lines;
!     tie @lines, Tie::File, $File::Find::name;

!     foreach my $line (@lines) {
          # We only care about lines with a copyright notice.
          next unless $line =~ m/$cc.*$pgdg/;
          # We stop when we've done one substitution.  This is both for
--- 22,35 ----
  find({wanted => \&wanted, no_chdir => 1}, '.');

  sub wanted {
!     my $filename = $File::Find::name;

!     # only regular files
!     return if ! -f $filename;

!     open(my $FILE, '<', $filename) or die "Cannot open $filename";
!
!     foreach my $line (<$FILE>) {
          # We only care about lines with a copyright notice.
          next unless $line =~ m/$cc.*$pgdg/;
          # We stop when we've done one substitution.  This is both for
*************** sub wanted {
*** 37,43 ****
          last if $line =~ s/($cc\d{4})(, $pgdg)/$1-$year$2/;
          last if $line =~ s/($cc\d{4})-\d{4}(, $pgdg)/$1-$year$2/;
      }
!     untie @lines;
  }

  print "Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too\n";
--- 39,45 ----
          last if $line =~ s/($cc\d{4})(, $pgdg)/$1-$year$2/;
          last if $line =~ s/($cc\d{4})-\d{4}(, $pgdg)/$1-$year$2/;
      }
!     close($FILE) or die "Cannot close $filename";
  }

  print "Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too\n";

В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Fetter
Дата:
Сообщение: Re: New copyright program
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: New copyright program