>>> "Eric" == Eric Blake <[EMAIL PROTECTED]> writes:
Eric> OK, I really want this bug gone. So I did some more research, this time Eric> with a fresh copy of automake from the head of CVS (no patches Eric> applied). I'm using a cygwin text mount, so every file has \r\n on Eric> every line after the CVS update. If I understand XFile.pm correctly, Eric> this means that automake should read files with \r\n -> \n, but write in Eric> binmode. And that means that if the output file has \r\n, perl was Eric> writing a string with \r\n. Yep. [...] Eric> I'm not familiar enough with automake to know which lines came from Eric> which files, but it does look like perl was keeping the \r from some Eric> sources and not others. You perl installation is clearly not converting new lines. "\r" are present *everywhere*, and they all come from the input. (The "\r\r\n" occurence is also ok, those two \r come from different lines.) Eric> How would this idea work for a hack? In Automake::XFile, overload the Eric> getline method (as well as the <HANDLE> operator) to strip \r before Eric> passing any line of text to the rest of automake. I don't know if there a way to overwrite <HANDLE>. However Automake is using getline everywhere. Is the following what you had in mind: Index: lib/Automake/XFile.pm =================================================================== RCS file: /cvs/automake/automake/lib/Automake/XFile.pm,v retrieving revision 1.1 diff -u -r1.1 XFile.pm --- lib/Automake/XFile.pm 2001/10/02 17:17:45 1.1 +++ lib/Automake/XFile.pm 2002/02/12 21:21:25 @@ -59,7 +59,8 @@ =head1 DESCRIPTION C<Automake::XFile> inherits from C<IO::File>. It provides dying -version of the methods C<open>, C<new>, and C<close>. +version of the methods C<open>, C<new>, and C<close>. It also +overrides the C<getline> method to translate C<\r\n> to C<\n>. =head1 SEE ALSO @@ -151,6 +152,21 @@ my $file = ${*$fh}{'autom4te_xfile_file'}; croak "$me: cannot close $file: $!\n"; } +} + +################################################ +## Getline +## + +# Some Win32/perl installations fail to translate \r\n to \n on input +# so we do that here. +sub getline +{ + local $_ = $_[0]->SUPER::getline; + # Perform a _global_ replacement: $_ may can contains many lines + # in slurp mode ($/ = undef). + s/\015\012/\n/gs if defined $_; + return $_; } 1; -- Alexandre Duret-Lutz