--- Melvin Smith <[EMAIL PROTECTED]> wrote:
> At 09:27 AM 2/19/2004 -0800, Goplat wrote:
> >--- Dan Sugalski <[EMAIL PROTECTED]> wrote:
> > > At 12:40 AM +0300 2/18/04, Vladimir Lipsky wrote:
> > > >From: "Goplat" <[EMAIL PROTECTED]>
> > > >
> > > >>  --- Vladimir Lipsky <[EMAIL PROTECTED]> wrote:
> > > >>  > From: "Goplat" <[EMAIL PROTECTED]>
> > > >>  >
> > > >>  > > flags_to_win32 sets fdwShareMode to FILE_SHARE_DELETE, which is
> > > >>  > > not supported in win98
> > > >>  >
> > > >>  > A fix for that should be windows version specific and needs
> > > >>  > support of the config subsystem.
> > > >>
> > > >>  If you did that, a version compiled on NT wouldn't work on 9x. I'd
> > > >>  say most 9x users don't compile perl themself, they just download a
> > > >>  binary from ActiveState (who use NT)...
> > > >
> > > >Then there should be different binaries for different versions
> > >
> > > Yeah, I'm actually coming to that conclusion. Yes, it's sort of
> > > easier to keep a single binary around from a packaging standpoint,
> > > it's a hassle for everyone else because of it.
> >
> >Where is the hassle? It's just a few lines of code to check windows
> >version. It's easier to code that than to make another configure option.
> 
> Then submit a patch.

Okay. (attached)


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
--- io/io_win32.c~      Wed Feb  4 07:46:48 2004
+++ io/io_win32.c       Tue Feb 17 08:21:16 2004
@@ -84,6 +84,20 @@
 flags_to_win32(INTVAL flags, DWORD * fdwAccess,
                DWORD * fdwShareMode, DWORD * fdwCreate)
 {
+    static DWORD dwDefaultShareMode;
+    if (!dwDefaultShareMode) {
+        OSVERSIONINFO osvi;
+        osvi.dwOSVersionInfoSize = sizeof(osvi);
+        GetVersionEx(&osvi);
+        if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+            dwDefaultShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+        }
+        else {
+            dwDefaultShareMode =
+                FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
+        }
+    }
+
     if ((flags & (PIO_F_WRITE | PIO_F_READ)) == (PIO_F_WRITE | PIO_F_READ)) {
         *fdwAccess = GENERIC_WRITE | GENERIC_READ;
         if (flags & PIO_F_TRUNC)
@@ -103,7 +117,7 @@
         *fdwCreate = OPEN_EXISTING;
     }
 
-    *fdwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
+    *fdwShareMode = dwDefaultShareMode;
     if (flags & PIO_F_APPEND) {
         /* dealt with specially in _write and _puts */
     }
--- t/src/io.t~ Mon Feb  9 01:10:46 2004
+++ t/src/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