]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/Autom4te/XFile.pm (getline, getlines): New functions,
authorAlexandre Duret-Lutz <adl@gnu.org>
Thu, 14 Feb 2002 12:04:39 +0000 (12:04 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Thu, 14 Feb 2002 12:04:39 +0000 (12:04 +0000)
translate rn to n.

ChangeLog
lib/Autom4te/XFile.pm

index d778afcc5c0a2a9b33090ca4654a7452ecf8e61e..c7d9ef809586e609d02048b78c4ec7d3da725da4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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.
index 58162995e3854165e4b17bb3d63618f247e76eda..1940bac65ca5fea1f3a551bd70fe9225eb0937af 100644 (file)
 
 # 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
@@ -59,7 +64,8 @@ Autom4te::XFile - supply object methods for filehandles with error handling
 =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
 
@@ -86,7 +92,7 @@ require DynaLoader;
 
 @ISA = qw(IO::File Exporter DynaLoader);
 
-$VERSION = "1.0";
+$VERSION = "1.1";
 
 @EXPORT = @IO::File::EXPORT;
 
@@ -158,4 +164,31 @@ sub close
     }
 }
 
+################################################
+## 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;