Index: /trunk/src/kmk/config.h.win
===================================================================
--- /trunk/src/kmk/config.h.win	(revision 2591)
+++ /trunk/src/kmk/config.h.win	(revision 2592)
@@ -523,8 +523,14 @@
 #endif
 
-/* bird hacks */
+/* bird hacks - similar in mscfakes.h */
 #include <sys/stat.h>
-extern int my_stat(const char *, struct stat *);
-#define stat(_path, _st) my_stat(_path, _st)
+#include <io.h>
+#include <direct.h>
+#ifndef STAT_REDEFINED_ALREADY
+# define STAT_REDEFINED_ALREADY
+# undef stat
+# define stat(_path, _st) bird_w32_stat(_path, _st)
+extern int bird_w32_stat(const char *, struct stat *);
+#endif
 
 /* cygwin sucks to much in one end or the other. */
Index: /trunk/src/kmk/function.c
===================================================================
--- /trunk/src/kmk/function.c	(revision 2591)
+++ /trunk/src/kmk/function.c	(revision 2592)
@@ -82,4 +82,8 @@
 # define STR_N_EQUALS(a_psz, a_cch, a_szConst) \
     ( (a_cch) == sizeof (a_szConst) - 1 && !strncmp ((a_psz), (a_szConst), sizeof (a_szConst) - 1) )
+
+# ifdef _MSC_VER
+#  include "kmkbuiltin/mscfakes.h"
+# endif
 #endif
 
Index: /trunk/src/kmk/job.c
===================================================================
--- /trunk/src/kmk/job.c	(revision 2591)
+++ /trunk/src/kmk/job.c	(revision 2592)
@@ -1129,6 +1129,8 @@
 #else
   char **argv;
+# if !defined(__MSDOS__) && !defined(_AMIGA) && !defined(WINDOWS32) && !defined(VMS)
   char ** volatile volatile_argv;
   int volatile volatile_flags;
+# endif
 #endif
 
Index: /trunk/src/kmk/kmkbuiltin/mscfakes.c
===================================================================
--- /trunk/src/kmk/kmkbuiltin/mscfakes.c	(revision 2591)
+++ /trunk/src/kmk/kmkbuiltin/mscfakes.c	(revision 2592)
@@ -533,11 +533,10 @@
 
 
-#undef stat
 /*
  * Workaround for directory names with trailing slashes.
- * Added by bird reasons stated.
  */
+#undef stat
 int
-my_other_stat(const char *path, struct stat *st)
+bird_w32_stat(const char *path, struct stat *st)
 {
     int rc = stat(path, st);
@@ -564,5 +563,12 @@
         }
     }
-    return rc;
-}
-
+#ifdef KMK_PRF
+    {
+        int err = errno;
+        fprintf(stderr, "stat(%s,) -> %d/%d\n", path, rc, errno);
+        errno = err;
+    }
+#endif
+    return rc;
+}
+
Index: /trunk/src/kmk/kmkbuiltin/mscfakes.h
===================================================================
--- /trunk/src/kmk/kmkbuiltin/mscfakes.h	(revision 2591)
+++ /trunk/src/kmk/kmkbuiltin/mscfakes.h	(revision 2592)
@@ -35,16 +35,22 @@
 #include "getopt.h"
 
+/* Note: Duplicated it config.h.win */
+#include <sys/stat.h>
+#include <io.h>
+#include <direct.h>
 #if defined(MSC_DO_64_BIT_IO) && _MSC_VER >= 1400 /* We want 64-bit file lengths here when possible. */
 # define off_t __int64
+# undef stat
 # define stat  _stat64
 # define fstat _fstat64
 # define lseek _lseeki64
 #else
-# undef stat
-# define stat(_path, _st) my_other_stat(_path, _st)
-extern int my_other_stat(const char *, struct stat *);
+# ifndef STAT_REDEFINED_ALREADY
+#  define STAT_REDEFINED_ALREADY
+#  undef stat
+#  define stat(_path, _st) bird_w32_stat(_path, _st)
+extern int bird_w32_stat(const char *, struct stat *);
+# endif
 #endif
-
-
 
 #ifndef S_ISDIR
Index: /trunk/src/kmk/vpath.c
===================================================================
--- /trunk/src/kmk/vpath.c	(revision 2591)
+++ /trunk/src/kmk/vpath.c	(revision 2592)
@@ -292,5 +292,5 @@
 	 Usually this is maxelem - 1.  If not, shrink down.  */
       if (elem < (maxelem - 1))
-	vpath = xrealloc (vpath, (elem+1) * sizeof (const char *));
+	vpath = (const char **)xrealloc (vpath, (elem+1) * sizeof (const char *));
 
       /* Put the nil-pointer terminator on the end of the VPATH list.  */
Index: /trunk/src/kmk/w32/pathstuff.c
===================================================================
--- /trunk/src/kmk/w32/pathstuff.c	(revision 2591)
+++ /trunk/src/kmk/w32/pathstuff.c	(revision 2592)
@@ -143,45 +143,4 @@
 
 	return p;
-}
-
-#undef stat
-/*
- * Workaround for directory names with trailing slashes.
- * Added by bird reasons stated.
- */
-int
-my_stat(const char *path, struct stat *st)
-{
-    int rc = stat(path, st);
-    if (    rc != 0
-        &&  errno == ENOENT
-        &&  *path != '\0')
-      {
-        char *slash = strchr(path, '\0') - 1;
-        if (*slash == '/' || *slash == '\\')
-          {
-            size_t len_path = slash - path + 1;
-            char *tmp = alloca(len_path + 4);
-            memcpy(tmp, path, len_path);
-            tmp[len_path] = '.';
-            tmp[len_path + 1] = '\0';
-            errno = 0;
-            rc = stat(tmp, st);
-            if (    rc == 0
-                &&  !S_ISDIR(st->st_mode))
-              {
-                errno = ENOTDIR;
-                rc = -1;
-              }
-          }
-      }
-#ifdef KMK_PRF
-    {
-        int err = errno;
-        fprintf(stderr, "stat(%s,) -> %d/%d\n", path, rc, errno);
-        errno = err;
-    }
-#endif
-    return rc;
 }
 
