This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Rely on C89 variadic prototypes
[perl5.git] / win32 / perlglob.c
index 87e8e90..8add30f 100644 (file)
@@ -1,8 +1,22 @@
 /*
  * Globbing for NT.  Relies on the expansion done by the library
- * startup code
+ * startup code (provided by Visual C++ by linking in setargv.obj).
  */
 
+/* Enable wildcard expansion for gcc's C-runtime library if not enabled by
+ * default (currently necessary with the automated build of the mingw-w64
+ * cross-compiler, but there's no harm in making sure for others too). */
+#ifdef __MINGW32__
+#include <_mingw.h>
+#if defined(__MINGW64_VERSION_MAJOR) && defined(__MINGW64_VERSION_MINOR)
+    // MinGW-w64
+    int _dowildcard = -1;
+#else
+    // MinGW
+    int _CRT_glob = -1;
+#endif
+#endif
+
 #include <stdio.h>
 #include <io.h>
 #include <fcntl.h>
@@ -13,7 +27,7 @@ int
 main(int argc, char *argv[])
 {
     int i;
-    int len;
+    size_t len;
     char root[MAX_PATH];
     char *dummy;
     char volname[MAX_PATH];
@@ -21,9 +35,9 @@ main(int argc, char *argv[])
     BOOL downcase = TRUE;
 
     /* check out the file system characteristics */
-
     if (GetFullPathName(".", MAX_PATH, root, &dummy)) {
-       if (dummy = strchr(root, '\\'))
+        dummy = strchr(root,'\\'); 
+       if (dummy)
            *++dummy = '\0';
        if (GetVolumeInformation(root, volname, MAX_PATH, 
                                 &serial, &maxname, &flags, 0, 0)) {
@@ -31,7 +45,7 @@ main(int argc, char *argv[])
        }
     }
 
-    _setmode(_fileno(stdout), _O_BINARY);
+    setmode(fileno(stdout), O_BINARY);
     for (i = 1; i < argc; i++) {
        len = strlen(argv[i]);
        if (downcase)
@@ -41,3 +55,4 @@ main(int argc, char *argv[])
     }
     return 0;
 }
+