cvsuser 04/06/23 05:42:24
Modified: io io.c
t/pmc io.t
Log:
#30412 - PIO_reads fix
Courtesy of Bernhard Schmalhofer <[EMAIL PROTECTED]>
Revision Changes Path
1.96 +3 -1 parrot/io/io.c
Index: io.c
===================================================================
RCS file: /cvs/public/parrot/io/io.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -w -r1.95 -r1.96
--- io.c 21 Jun 2004 15:56:08 -0000 1.95
+++ io.c 23 Jun 2004 12:42:12 -0000 1.96
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-$Id: io.c,v 1.95 2004/06/21 15:56:08 leo Exp $
+$Id: io.c,v 1.96 2004/06/23 12:42:12 leo Exp $
=head1 NAME
@@ -799,6 +799,8 @@
ParrotIOLayer *l = PMC_struct_val(pmc);
ParrotIO *io = PMC_data(pmc);
+ res->representation = enum_stringrep_one;
+
if (!io)
return res;
1.31 +29 -2 parrot/t/pmc/io.t
Index: io.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/io.t,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -w -r1.30 -r1.31
--- io.t 22 Jun 2004 10:57:27 -0000 1.30
+++ io.t 23 Jun 2004 12:42:24 -0000 1.31
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: io.t,v 1.30 2004/06/22 10:57:27 leo Exp $
+# $Id: io.t,v 1.31 2004/06/23 12:42:24 leo Exp $
=head1 NAME
@@ -16,7 +16,7 @@
=cut
-use Parrot::Test tests => 26;
+use Parrot::Test tests => 27;
use Test::More;
sub file_content_is {
@@ -470,3 +470,30 @@
buf
OUTPUT
+output_is(<<'CODE', <<'OUTPUT', "substr after reading from file");
+##PIR##
+.sub _main
+ # Write something into a file
+ .local pmc out
+ out = open "temp.file", ">"
+ print out, "0123456789\n"
+ close out
+
+ # read file contents back in
+ .local pmc in
+ in = open "temp.file", "<"
+ .local string from_file
+ from_file = read in, 20
+
+ # Extract part of the read in file
+ .local string head_from_file
+ substr head_from_file, from_file, 0, 5, ''
+ print head_from_file
+ print "\n"
+
+ end
+.end
+CODE
+01234
+OUTPUT
+