+2002-02-13 Alexandre Duret-Lutz <duret_g@epita.fr>
+
+ * lib/Autom4te/XFile.pm (getline, getlines): New functions,
+ translate \r\n to \n.
+
2002-02-07 Akim Demaille <akim@epita.fr>
Version 2.52h.
# Written by Akim Demaille <akim@freefriends.org>.
+###############################################################
+# The main copy of this file is in Autoconf's CVS repository. #
+# Updates should be sent to autoconf-patches@gnu.org. #
+###############################################################
+
package Autom4te::XFile;
=head1 NAME
=head1 DESCRIPTION
C<Autom4te::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> and C<getlines> methods to translate C<\r\n> to C<\n>.
=head1 SEE ALSO
@ISA = qw(IO::File Exporter DynaLoader);
-$VERSION = "1.0";
+$VERSION = "1.1";
@EXPORT = @IO::File::EXPORT;
}
}
+################################################
+## 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 $_;
+}
+
+################################################
+## Getlines
+##
+
+sub getlines
+{
+ my @res = ();
+ my $line;
+ push @res, $line while $line = $_[0]->getline;
+ return @res;
+}
+
1;