diff --git a/src/ChangeLog b/src/ChangeLog
index 5b0a1b23..044390dc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2005-06-23  Hrvoje Niksic  <hniksic@xemacs.org>
+
+	* utils.c (read_file): Ditto.
+
+	* main.c (main): Use struct_fstat.
+
+	* mswindows.h (struct_fstat): Define a struct_fstat to deal with
+	the fact that Borland 5.5 has 64-bit stat, but not 64-bit fstat!
+
 2005-06-23  Hrvoje Niksic  <hniksic@xemacs.org>
 
 	* sysdep.h: Remove code that deals with Watcom.
diff --git a/src/main.c b/src/main.c
index ec8ed325..c39432a2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -883,7 +883,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
 	output_stream = stdout;
       else
 	{
-	  struct_stat st;
+	  struct_fstat st;
 	  output_stream = fopen (opt.output_document,
 				 opt.always_rest ? "ab" : "wb");
 	  if (output_stream == NULL)
diff --git a/src/mswindows.h b/src/mswindows.h
index e273c680..ef4f4fab 100644
--- a/src/mswindows.h
+++ b/src/mswindows.h
@@ -97,28 +97,34 @@ typedef __int64 wgint;
 #define str_to_wgint str_to_int64
 __int64 str_to_int64 (const char *, char **, int);
 
-/* No lstat on Windows.  */
+/* Windows has no symlink, therefore no lstat.  Without symlinks lstat
+   is equivalent to stat anyway.  */
 #define lstat stat
 
-/* On Windows the 64-bit stat requires a different version of struct
-   stat.  (On Unix too, but it happens transparently when stat is
-   remapped to stat64.)  */
-
-#if defined(_MSC_VER) || defined(__MINGW32__)
-# define struct_stat struct _stati64
-#elif defined(__BORLANDC__)
-# define struct_stat struct stati64
-#else
-# define struct_stat struct stat
-#endif
-
 /* Transparently support statting large files, like POSIX's LFS API
-   does.  */
+   does.  All Windows compilers we support use _stati64 (but have
+   different names for 2nd argument type, see below), so we use
+   that.  */
 #define stat(fname, buf) _stati64 (fname, buf)
 
+/* On Windows the 64-bit stat requires an explicitly different type
+   for the 2nd argument, so we define a struct_stat macro that expands
+   to the appropriate type on Windows, and to the regular struct stat
+   on Unix.
+
+   Note that Borland C 5.5 has 64-bit stat (_stati64), but not a
+   64-bit fstat!  Because of that we also need a struct_fstat that
+   points to struct_stat on Unix and on Windows, except under Borland,
+   where it points to the 32-bit struct stat.  */
+
 #ifndef __BORLANDC__
 # define fstat(fd, buf) _fstati64 (fd, buf)
-#endif
+# define struct_stat  struct _stati64
+# define struct_fstat struct _stati64
+#else  /* __BORLANDC__ */
+# define struct_stat  struct stati64
+# define struct_fstat struct stat
+#endif /* __BORLANDC__ */
 
 #define PATH_SEPARATOR '\\'
 
diff --git a/src/sysdep.h b/src/sysdep.h
index f3275e9f..8c3a9a86 100644
--- a/src/sysdep.h
+++ b/src/sysdep.h
@@ -125,10 +125,14 @@ typedef double LARGE_INT;
 # define LARGE_INT_FMT "%.0f"
 #endif
 
-/* Under Windows we #define struct_stat to struct _stati64. */
+/* These are needed so we can #define struct_stat to struct _stati64
+   under Windows. */
 #ifndef struct_stat
 # define struct_stat struct stat
 #endif
+#ifndef struct_fstat
+# define struct_fstat struct stat
+#endif
 
 /* For CHAR_BIT, LONG_MAX, etc. */
 #include <limits.h>
diff --git a/src/utils.c b/src/utils.c
index 33d0eb56..97732496 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -917,7 +917,7 @@ read_file (const char *file)
 
 #ifdef HAVE_MMAP
   {
-    struct_stat buf;
+    struct_fstat buf;
     if (fstat (fd, &buf) < 0)
       goto mmap_lose;
     fm->length = buf.st_size;