This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
WinCE makefile will now hypothetically build git_version.h
[perl5.git] / win32 / win32.c
index 3802a54..bf91b76 100644 (file)
@@ -160,6 +160,9 @@ static void win32_csighandler(int sig);
 START_EXTERN_C
 HANDLE w32_perldll_handle = INVALID_HANDLE_VALUE;
 char   w32_module_name[MAX_PATH+1];
+#ifdef WIN32_DYN_IOINFO_SIZE
+Size_t w32_ioinfo_size;/* avoid 0 extend op b4 mul, otherwise could be a U8 */
+#endif
 END_EXTERN_C
 
 static OSVERSIONINFO g_osver = {0, 0, 0, 0, 0, ""};
@@ -2586,7 +2589,9 @@ win32_feof(FILE *fp)
     return (feof(fp));
 }
 
+#ifdef ERRNO_HAS_POSIX_SUPPLEMENT
 extern int convert_errno_to_wsa_error(int err); /* in win32sck.c */
+#endif
 
 /*
  * Since the errors returned by the socket error function
@@ -2607,13 +2612,13 @@ win32_strerror(int e)
         dTHXa(NULL);
        if (e < 0)
            e = GetLastError();
-#if EADDRINUSE != WSAEADDRINUSE
-       /* VC10+ define a "POSIX supplement" of errno values ranging from
-        * EADDRINUSE (100) to EWOULDBLOCK (140), but sys_nerr is still 43 and
-        * strerror() returns "Unknown error" for them. We must therefore still
-        * roll our own messages for these codes, and additionally map them to
-        * corresponding Windows (sockets) error codes first to avoid getting
-        * the wrong system message.
+#ifdef ERRNO_HAS_POSIX_SUPPLEMENT
+       /* VC10+ and some MinGW/gcc-4.8+ define a "POSIX supplement" of errno
+        * values ranging from EADDRINUSE (100) to EWOULDBLOCK (140), but
+        * sys_nerr is still 43 and strerror() returns "Unknown error" for them.
+        * We must therefore still roll our own messages for these codes, and
+        * additionally map them to corresponding Windows (sockets) error codes
+        * first to avoid getting the wrong system message.
         */
        else if (e >= EADDRINUSE && e <= EWOULDBLOCK) {
            e = convert_errno_to_wsa_error(e);
@@ -3136,6 +3141,12 @@ win32_link(const char *oldname, const char *newname)
     case ERROR_NOT_SAME_DEVICE:
       errno = EXDEV;
       break;
+    case ERROR_DISK_FULL:
+      errno = ENOSPC;
+      break;
+    case ERROR_NOT_ENOUGH_QUOTA:
+      errno = EDQUOT;
+      break;
     default:
       /* ERROR_INVALID_FUNCTION - eg. on a FAT volume */
       errno = EINVAL;
@@ -3170,6 +3181,12 @@ win32_rename(const char *oname, const char *newname)
         case ERROR_PATH_NOT_FOUND:
             errno = ENOENT;
             break;
+        case ERROR_DISK_FULL:
+            errno = ENOSPC;
+            break;
+        case ERROR_NOT_ENOUGH_QUOTA:
+            errno = EDQUOT;
+            break;
         default:
             errno = EACCES;
             break;
@@ -4401,6 +4418,18 @@ Perl_win32_init(int *argcp, char ***argvp)
     g_osver.dwOSVersionInfoSize = sizeof(g_osver);
     GetVersionEx(&g_osver);
 
+#ifdef WIN32_DYN_IOINFO_SIZE
+    {
+       Size_t ioinfo_size = _msize((void*)__pioinfo[0]);;
+       if((SSize_t)ioinfo_size <= 0) { /* -1 is err */
+           fprintf(stderr, "panic: invalid size for ioinfo\n"); /* no interp */
+           exit(1);
+       }
+       ioinfo_size /= IOINFO_ARRAY_ELTS;
+       w32_ioinfo_size = ioinfo_size;
+    }
+#endif
+
     ansify_path();
 }