MM_Unix patch for use under CVS
[p5sagit/p5-mst-13.2.git] / doio.c
diff --git a/doio.c b/doio.c
index 0db0e1a..a52df3e 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -1,6 +1,6 @@
 /*    doio.c
  *
- *    Copyright (c) 1991-1994, Larry Wall
+ *    Copyright (c) 1991-1997, Larry Wall
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
 #endif
 
 #ifdef I_UTIME
-#include <utime.h>
+#  ifdef WIN32
+#    include <sys/utime.h>
+#  else
+#    include <utime.h>
+#  endif
 #endif
 #ifdef I_FCNTL
 #include <fcntl.h>
 # endif
 #endif
 
+/* Put this after #includes because <unistd.h> defines _XOPEN_*. */
+#ifndef Sock_size_t
+#  if _XOPEN_VERSION >= 5 || defined(_XOPEN_SOURCE_EXTENDED)
+#    define Sock_size_t Size_t
+#  else
+#    define Sock_size_t int
+#  endif
+#endif
+
 bool
 do_open(gv,name,len,as_raw,rawmode,rawperm,supplied_fp)
 GV *gv;
@@ -284,9 +297,10 @@ PerlIO *supplied_fp;
            !statbuf.st_mode
 #endif
        ) {
-           int buflen = sizeof tokenbuf;
-           if (getsockname(PerlIO_fileno(fp), (struct sockaddr *)tokenbuf, &buflen) >= 0
-               || errno != ENOTSOCK)
+           Sock_size_t buflen = sizeof tokenbuf;
+           if (getsockname(PerlIO_fileno(fp), (struct sockaddr *)tokenbuf,
+                           &buflen) >= 0
+                 || errno != ENOTSOCK)
                IoTYPE(io) = 's'; /* some OS's return 0 on fstat()ed socket */
                                /* but some return 0 for streams too, sigh */
        }
@@ -584,8 +598,8 @@ IO* io;
     if (IoIFP(io)) {
        if (IoTYPE(io) == '|') {
            status = my_pclose(IoIFP(io));
-           retval = (status == 0);
            STATUS_NATIVE_SET(status);
+           retval = (STATUS_POSIX == 0);
        }
        else if (IoTYPE(io) == '-')
            retval = TRUE;
@@ -1370,8 +1384,8 @@ SV **sp;
        {
            a = SvPV(astr, len);
            if (len != infosize)
-               croak("Bad arg length for %s, is %d, should be %ld",
-                       op_desc[optype], len, (long)infosize);
+               croak("Bad arg length for %s, is %lu, should be %ld",
+                       op_desc[optype], (unsigned long)len, (long)infosize);
        }
     }
     else