Change 19634 by [EMAIL PROTECTED] on 2003/05/29 09:11:30

        Subject: [patch] IO::File->open() with encoding
        From: Pradeep Hodigere <[EMAIL PROTECTED]>
        Date: Mon, 19 May 2003 16:05:47 -0700 (PDT)
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/MANIFEST#1024 edit
... //depot/perl/ext/IO/lib/IO/File.pm#17 edit
... //depot/perl/ext/IO/lib/IO/t/io_utf8.t#1 add

Differences ...

==== //depot/perl/MANIFEST#1024 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#1023~19603~   Fri May 23 22:32:34 2003
+++ perl/MANIFEST       Thu May 29 02:11:30 2003
@@ -469,6 +469,7 @@
 ext/IO/lib/IO/t/io_tell.t      See if seek()/tell()-related methods from IO work
 ext/IO/lib/IO/t/io_udp.t       See if UDP socket-related methods from IO work
 ext/IO/lib/IO/t/io_unix.t      See if UNIX socket-related methods from IO work
+ext/IO/lib/IO/t/io_utf8.t      See if perlio opens work
 ext/IO/lib/IO/t/io_xs.t                See if XSUB methods from IO work
 ext/IO/Makefile.PL             IO extension makefile writer
 ext/IO/poll.c                  IO poll() emulation using select()

==== //depot/perl/ext/IO/lib/IO/File.pm#17 (text) ====
Index: perl/ext/IO/lib/IO/File.pm
--- perl/ext/IO/lib/IO/File.pm#16~19072~        Wed Mar 26 14:30:09 2003
+++ perl/ext/IO/lib/IO/File.pm  Thu May 29 02:11:30 2003
@@ -71,6 +71,8 @@
 
 =item open( FILENAME [,MODE [,PERMS]] )
 
+=item open( FILENAME, IOLAYERS )
+
 C<open> accepts one, two or three parameters.  With one parameter,
 it is just a front end for the built-in C<open> function.  With two or three
 parameters, the first parameter is a filename that may include
@@ -85,6 +87,9 @@
 and the optional permissions value to the Perl C<sysopen> operator.
 The permissions default to 0666.
 
+If C<IO::File::open> is given a mode that includes the C<:> character,
+it passes all the three arguments to the three-argument C<open> operator.
+
 For convenience, C<IO::File> exports the O_XXX constants from the
 Fcntl module, if this module is available.
 
@@ -157,6 +162,9 @@
        if ($mode =~ /^\d+$/) {
            defined $perms or $perms = 0666;
            return sysopen($fh, $file, $mode, $perms);
+       } elsif ($mode =~ /:/) {
+           return open($fh, $mode, $file) if @_ == 3;
+           croak 'usage: $fh->open(FILENAME, IOLAYERS)';
        }
        if (defined($file) && length($file)
            && ! File::Spec->file_name_is_absolute($file))

==== //depot/perl/ext/IO/lib/IO/t/io_utf8.t#1 (text) ====
Index: perl/ext/IO/lib/IO/t/io_utf8.t
--- /dev/null   Tue May  5 13:32:27 1998
+++ perl/ext/IO/lib/IO/t/io_utf8.t      Thu May 29 02:11:30 2003
@@ -0,0 +1,33 @@
+#!./perl
+
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+    unless (find PerlIO::Layer 'perlio') {
+       print "1..0 # Skip: not perlio\n";
+       exit 0;
+    }
+}
+
+require "./test.pl";
+
+plan(tests => 5);
+
+my $io;
+
+use_ok('IO::File');
+
+$io = IO::File->new;
+
+ok($io->open("io_utf8", ">:utf8"), "open >:utf8");
+ok((print $io chr(256)), "print chr(256)");
+undef $io;
+
+$io = IO::File->new;
+ok($io->open("io_utf8", "<:utf8"), "open <:utf8");
+is(ord(<$io>), 256, "readline chr(256)");
+undef $io;
+
+END {
+  1 while unlink "io_utf8";
+}
End of Patch.

Reply via email to