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 9d7460244aaac5886a36c0df46bf6e19635314e8..2b2678d006861a41571b3e2dfe846b3eea019cd0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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
index 59ce6b6c6bffa4c912c92e126ec8a2f24dee052b..777d3e5b90931bb788c3c868813e86ec76e20df6 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