update-copyright: support EOL=\r\n
authorJoel E. Denny <jdenny@clemson.edu>
Fri, 31 Jul 2009 13:32:30 +0000 (09:32 -0400)
committerJim Meyering <meyering@redhat.com>
Tue, 4 Aug 2009 07:25:32 +0000 (09:25 +0200)
* build-aux/update-copyright: Implement that.

ChangeLog
build-aux/update-copyright

index 9d74602..2b2678d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-07-31  Joel E. Denny  <jdenny@clemson.edu>
 
+       update-copyright: support EOL=\r\n
+       * build-aux/update-copyright: Implement that.
+
+2009-07-31  Joel E. Denny  <jdenny@clemson.edu>
+
        update-copyright: automatically format copyright statements
        * build-aux/update-copyright: Implement that.
        Also, be a little more predictable and safer by always failing
index 59ce6b6..777d3e5 100755 (executable)
@@ -107,6 +107,9 @@ my $holder = 'Free Software Foundation, Inc.';
 my $prefix_max = 5;
 my $margin = 72;
 
+# Unless the file consistently uses "\r\n" as the EOL, use "\n" instead.
+my $eol = /(?:^|[^\r])\n/ ? "\n" : "\r\n";
+
 my $leading;
 my $prefix;
 my $ws;
@@ -164,7 +167,7 @@ if (defined($old) && /$old/)
                 || ($new =~ s/^([\S]+)(?: |$)//))
               {
                 my $line = $1;
-                $new_wrapped .= $new_wrapped ? "\n" : $leading;
+                $new_wrapped .= $new_wrapped ? $eol : $leading;
                 $new_wrapped .= "$prefix$line";
               }
             else