From ee639d277787a75183d3763728f02da0d0a6ae52 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Fri, 19 Aug 2011 19:31:12 -0400
Subject: [PATCH] Fix copyright.pl to properly us 'tie' function.

Kris Jurka
---
 src/tools/backend/flow.gif | Bin 501220 -> 501221 bytes
 src/tools/copyright.pl     |  13 ++++++-------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/tools/backend/flow.gif b/src/tools/backend/flow.gif
index f1ebeb7b63d73f35a8861c8582cebcc0c4e5c900..e0cd8db9b193c7667e00131fa3f3847af97daa14 100644
GIT binary patch
delta 25
hcmaEITJGs-xrP?T7N!>F7M2#)7Pc+yPnI%r0RWFX377x?

delta 23
fcmaEQTJFhdxrP?T7N!>F7M2#)7Pc+yPnH4zd>9Fh

diff --git a/src/tools/copyright.pl b/src/tools/copyright.pl
index 91f73e37ab3..08e5f5e39d4 100755
--- a/src/tools/copyright.pl
+++ b/src/tools/copyright.pl
@@ -11,6 +11,7 @@ use strict;
 use warnings;
 
 use File::Find;
+use Tie::File;
 
 my $pgdg = 'PostgreSQL Global Development Group';
 my $cc = 'Copyright \(c\) ';
@@ -22,14 +23,12 @@ print "Using current year:  $year\n";
 find({wanted => \&wanted, no_chdir => 1}, '.');
 
 sub wanted {
-    my $filename = $File::Find::name;
+    return if ! -f $File::Find::name || -l $File::Find::name;
 
-    # only regular files
-    return if ! -f $filename;
+    my @lines;
+    tie @lines, "Tie::File", $File::Find::name;
 
-    open(my $FILE, '<', $filename) or die "Cannot open $filename";
-
-    foreach my $line (<$FILE>) {
+    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
@@ -39,7 +38,7 @@ sub wanted {
         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";
+    untie @lines;
 }
 
 print "Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too\n";
-- 
GitLab