flags_to_win32 sets fdwShareMode to FILE_SHARE_DELETE, which is not supported
in win98 and will cause the CreateFile to fail, so the ParrotIO is NULL, and
subsequent PIO_read on its io PMC will return -1. When len is -1, some tests
in t/src/io.t will think it's positive since it has it as a UINTVAL (should
be an INTVAL) causing it to loop forever. Also using -1 as an index into the
buffer could overwrite that len variable, making it actually positive. And it
uses ParrotIO* where it should be using PMC* (dosen't really matter but it's
nice to use the right type of pointer). Furthermore, test 13 fails since it
expects a 60000 byte file, but actually creates one larger than that because
of \n -> \r\n translation.

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
--- io/io_win32.c~      Wed Feb  4 07:46:48 2004
+++ io/io_win32.c       Mon Feb 16 10:41:18 2004
@@ -103,7 +103,7 @@
         *fdwCreate = OPEN_EXISTING;
     }
 
-    *fdwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
+    *fdwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
     if (flags & PIO_F_APPEND) {
         /* dealt with specially in _write and _puts */
     }
--- io.t~       Mon Feb  9 01:10:46 2004
+++ io.t        Mon Feb 16 11:00:26 2004
@@ -11,6 +11,7 @@
        my $content = @_ ? shift : "This is a test\n";
 
        open(FILE, ">$name") or die "Failed to create $name";
+       binmode FILE;
        print FILE $content;
        close(FILE);
 
@@ -69,7 +70,7 @@
 the_test(struct Parrot_Interp *interpreter,
        opcode_t *cur_op, opcode_t *start)
 {
-    ParrotIO *io;
+    PMC *io;
     char *p;
 
     io = PIO_STDOUT(interpreter);
@@ -100,15 +101,15 @@
 the_test(struct Parrot_Interp *interpreter,
        opcode_t *cur_op, opcode_t *start)
 {
-    ParrotIO *io;
+    PMC *io;
     char buf[1024];
-    UINTVAL len;
+    INTVAL len;
 
     io = PIO_open(interpreter, NULL, "temp.file", "<");
     len = PIO_read(interpreter, io, buf, sizeof(buf)-1);
     PIO_close(interpreter, io);
 
-    buf[len] = '\0';
+    buf[len < 0 ? 0 : len] = '\0';
     PIO_printf(interpreter, "%s", buf);
 
     io = PIO_open(interpreter, NULL, "temp.file", "<");
@@ -117,8 +118,8 @@
 
     do {
         len = PIO_read(interpreter, io, buf, 3);
-        buf[len] = '\0';
-       /* dont write trailing spaces */
+        buf[len < 0 ? 0 : len] = '\0';
+        /* don't write trailing spaces */
         PIO_printf(interpreter, "%d: %s\n", len, len ? buf : "EOF");
     } while (len > 0);
 
@@ -142,7 +143,7 @@
 the_test(struct Parrot_Interp *interpreter,
        opcode_t *cur_op, opcode_t *start)
 {
-    ParrotIO *io;
+    PMC *io;
 
     io = PIO_open(interpreter, NULL, "temp.file", ">>");
     PIO_write(interpreter, io, "Parrot flies.\n", 14);
@@ -166,8 +167,8 @@
 the_test(struct Parrot_Interp *interpreter,
        opcode_t *cur_op, opcode_t *start)
 {
-    ParrotIO *io;
-    size_t len;
+    PMC *io;
+    INTVAL len;
     char buf[1024];
 
     io = PIO_open(interpreter, NULL, "temp.file", "<");
@@ -175,7 +176,7 @@
 
     do {
         len = PIO_read(interpreter, io, buf, sizeof(buf)-1);
-        buf[len] = '\0';
+        buf[len < 0 ? 0 : len] = '\0';
         PIO_printf(interpreter, "%d: %s", len, len ? buf : "EOF");
     } while (len > 0);
 

Reply via email to