cvs -q diff -u
Index: io/io.c
===================================================================
RCS file: /cvs/public/parrot/io/io.c,v
retrieving revision 1.98
diff -u -u -r1.98 io.c
--- io/io.c	3 Jul 2004 10:48:23 -0000	1.98
+++ io/io.c	4 Jul 2004 22:31:41 -0000
@@ -795,11 +795,11 @@
 STRING *
 PIO_reads(theINTERP, PMC *pmc, size_t len)
 {
-    STRING *res = new_string_header(interpreter, 0);
+    STRING *res = NULL;
     ParrotIOLayer *l = PMC_struct_val(pmc);
     ParrotIO *io = PMC_data(pmc);
 
-    res->representation = enum_stringrep_one;
+    res = PIO_make_io_string(interpreter, &res, len );
 
     if (!io)
         return res;
Index: src/string.c
===================================================================
RCS file: /cvs/public/parrot/src/string.c,v
retrieving revision 1.206
diff -u -u -r1.206 string.c
--- src/string.c	18 Jun 2004 15:14:56 -0000	1.206
+++ src/string.c	4 Jul 2004 22:32:08 -0000
@@ -1389,8 +1389,7 @@
     else
         dest = make_COW_reference(interpreter, src);
 
-    dest->strstart = (char *)dest->strstart
-                        + string_max_bytes(interpreter, dest, true_offset);
+    dest->strstart += string_max_bytes(interpreter, dest, true_offset);
     dest->bufused = string_max_bytes(interpreter, dest, true_length);
 
     dest->strlen = true_length;
Index: t/pmc/io.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/io.t,v
retrieving revision 1.31
diff -u -u -r1.31 io.t
--- t/pmc/io.t	23 Jun 2004 12:42:24 -0000	1.31
+++ t/pmc/io.t	4 Jul 2004 22:32:09 -0000
@@ -16,7 +16,7 @@
 
 =cut
 
-use Parrot::Test tests => 27;
+use Parrot::Test tests => 28;
 use Test::More;
 
 sub file_content_is {
@@ -497,3 +497,47 @@
 01234
 OUTPUT
 
+output_is(<<'CODE', <<'OUTPUT', "multiple substr after reading from file");
+##PIR##
+.sub _main 
+    # Write something into a file
+    .local pmc out
+    out = open "temp.file", ">"
+    print out, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"
+    close out
+
+    .local pmc in
+    .local string line
+    in = open 'temp.file', '<'
+    line = read in, 50000
+    close in
+
+    .local string sub_1
+    sub_1 = ''
+    .local string sub_2
+    sub_2 = ''
+    .local string sub_3
+    sub_3 = ''
+    substr sub_1, line, 0, 3
+    substr sub_2, line, 0, 3, ''
+    substr sub_3, line, 0, 3, ''
+    print "line: "
+    print line
+    print "sub_1: "
+    print sub_1
+    print "\n"
+    print "sub_2: "
+    print sub_2
+    print "\n"
+    print "sub_3: "
+    print sub_3
+    print "\n"
+
+  end
+.end
+CODE
+line: 6789ABCDEFGHIJKLMNOPQRSTUVWXYZ
+sub_1: 012
+sub_2: 012
+sub_3: 345
+OUTPUT
