Index: src/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.290.2.119
diff -a -u -r1.290.2.119 ChangeLog
--- src/ChangeLog	2007/02/10 01:35:21	1.290.2.119
+++ src/ChangeLog	2007/05/03 01:13:53
@@ -1,3 +1,16 @@
+2007-05-02  Vin Shelton  <acs@xemacs.org>
+
+	* dumper.c (pdump): Don't close pdump_fd (already closed by
+	fclose() call.  Patch from Steve Higham.
+	* callproc.c (Fold_call_process_internal): Don't close fd1 if it's
+	already closed.  Patch inspired by Steve Higham.
+
+2007-05-01  Vin Shelton  <acs@xemacs.org>
+
+	* nt.c (mswindows_stat): Tie _S_IEXEC permission to read access.
+	(mswindows_fstat): Ditto.
+	* sysfile.h: Under Windows, define X_OK to be the same as R_OK.
+
 2007-02-08  Adrian Aichner  <adrian@xemacs.org>
 
 	* postgresql.c: Update Steve Baur's email address by his request.
Index: src/callproc.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/Attic/callproc.c,v
retrieving revision 1.37.2.6
diff -a -u -r1.37.2.6 callproc.c
--- src/callproc.c	2005/12/08 01:31:15	1.37.2.6
+++ src/callproc.c	2007/05/03 01:13:53
@@ -399,9 +399,6 @@
 	  }
 #endif
       }
-    /* Close STDERR into the parent process.  We no longer need it. */
-    if (fd_error >= 0)
-      close (fd_error);
 #else  /* not WIN32_NATIVE */
     pid = fork ();
 
@@ -420,17 +417,18 @@
 	child_setup (filefd, fd1, fd_error, new_argv,
 		     (char *) XSTRING_DATA (current_dir));
       }
-    if (fd_error >= 0)
-      close (fd_error);
-
 #endif /* not WIN32_NATIVE */
 
     environ = save_environ;
 
+    /* Close STDERR into the parent process.  We no longer need it. */
+    if (fd_error >= 0)
+      close (fd_error);
+
     /* Close most of our fd's, but not fd[0]
        since we will use that to read input from.  */
     close (filefd);
-    if (fd1 >= 0)
+    if ((fd1 >= 0) && (fd1 != fd_error))
       close (fd1);
   }
 
Index: src/dumper.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/dumper.c,v
retrieving revision 1.2.2.6
diff -a -u -r1.2.2.6 dumper.c
--- src/dumper.c	2006/07/01 05:19:56	1.2.2.6
+++ src/dumper.c	2007/05/03 01:13:54
@@ -1067,7 +1067,8 @@
   pdump_dump_root_objects ();
 
   fclose (pdump_out);
-  close (pdump_fd);
+  /* pdump_fd is already closed by the preceding fclose call
+  close (pdump_fd); */
 
   free (pdump_buf);
 
Index: src/nt.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/nt.c,v
retrieving revision 1.21.2.4
diff -a -u -r1.21.2.4 nt.c
--- src/nt.c	2005/01/31 02:55:24	1.21.2.4
+++ src/nt.c	2007/05/03 01:13:55
@@ -1449,9 +1449,9 @@
 
   /* determine rwx permissions */
   if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
-    permission = _S_IREAD;
+    permission = _S_IREAD | _S_IEXEC;
   else
-    permission = _S_IREAD | _S_IWRITE;
+    permission = _S_IREAD | _S_IEXEC |_S_IWRITE;
   
   if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
     permission |= _S_IEXEC;
@@ -1638,22 +1638,12 @@
 
   /* determine rwx permissions */
   if (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
-    permission = _S_IREAD;
+    permission = _S_IREAD | _S_IEXEC;
   else
-    permission = _S_IREAD | _S_IWRITE;
+    permission = _S_IREAD | _S_IEXEC |_S_IWRITE;
   
   if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
     permission |= _S_IEXEC;
-  else
-    {
-      char * p = strrchr (name, '.');
-      if (p != NULL &&
-	  (stricmp (p, ".exe") == 0 ||
-	   stricmp (p, ".com") == 0 ||
-	   stricmp (p, ".bat") == 0 ||
-	   stricmp (p, ".cmd") == 0))
-	permission |= _S_IEXEC;
-    }
 
   buf->st_mode |= permission | (permission >> 3) | (permission >> 6);
 
Index: src/sysfile.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/sysfile.h,v
retrieving revision 1.9.2.1
diff -a -u -r1.9.2.1 sysfile.h
--- src/sysfile.h	2001/07/25 07:45:39	1.9.2.1
+++ src/sysfile.h	2007/05/03 01:13:55
@@ -261,12 +261,18 @@
 #endif
 
 /* The following definitions are needed under Windows, at least */
-#ifndef X_OK
-# define X_OK 1
-#endif
-
 #ifndef R_OK
 # define R_OK 4
+#endif
+
+/* Under native Windows, there is no concept of execute permission,
+   so redefine execute permissions to be the same as read permission */
+#ifndef X_OK
+# ifdef WIN32_NATIVE
+#  define X_OK R_OK
+# else
+#  define X_OK 1
+# endif
 #endif
 
 #ifndef W_OK
