Reformatted.
[chise/xemacs-chise.git.1] / src / nt.c
index 2615d67..1e26fbb 100644 (file)
--- a/src/nt.c
+++ b/src/nt.c
@@ -506,7 +506,7 @@ request_sigio (void)
 }
 #endif /* 0 */
 
-#define REG_ROOT "SOFTWARE\\GNU\\XEmacs"
+#define REG_ROOT "SOFTWARE\\XEmacs\\XEmacs"
 
 LPBYTE 
 nt_get_resource (char *key, LPDWORD lpdwtype)
@@ -629,16 +629,16 @@ init_environment (void)
      renaming or deleting directories.  (We also don't call chdir when
      running subprocesses for the same reason.)  */
   if (!GetCurrentDirectory (MAXPATHLEN, startup_dir))
-    abort ();
+    ABORT ();
 
   {
     char *p;
     char modname[MAX_PATH];
 
     if (!GetModuleFileName (NULL, modname, MAX_PATH))
-      abort ();
+      ABORT ();
     if ((p = strrchr (modname, '\\')) == NULL)
-      abort ();
+      ABORT ();
     *p = 0;
 
     SetCurrentDirectory (modname);
@@ -1356,7 +1356,7 @@ generate_inode_val (const char * name)
      doesn't resolve aliasing due to subst commands, or recognize hard
      links.  */
   if (!win32_get_long_filename ((char *)name, fullname, MAX_PATH))
-    abort ();
+    ABORT ();
 
   parse_root (fullname, &p);
   /* Normal Win32 filesystems are still case insensitive. */
@@ -1449,9 +1449,9 @@ mswindows_fstat (int desc, struct stat * buf)
 
   /* 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;
@@ -1474,6 +1474,7 @@ mswindows_stat (const char * path, struct stat * buf)
   int permission;
   int len;
   int rootdir = FALSE;
+  int errm;
 
   if (path == NULL || buf == NULL)
     {
@@ -1496,13 +1497,16 @@ mswindows_stat (const char * path, struct stat * buf)
   rootdir = (path >= name + len - 1
             && (IS_DIRECTORY_SEP (*path) || *path == 0));
   name = strcpy ((char *)alloca (len + 2), name);
-
+  errm = SetErrorMode (SEM_FAILCRITICALERRORS
+                      | SEM_NOOPENFILEERRORBOX);
   if (rootdir)
     {
       if (!IS_DIRECTORY_SEP (name[len-1]))
        strcat (name, "\\");
+
       if (GetDriveType (name) < 2)
        {
+         SetErrorMode (errm);
          errno = ENOENT;
          return -1;
        }
@@ -1532,14 +1536,15 @@ mswindows_stat (const char * path, struct stat * buf)
        }
       else
        {
-      fh = FindFirstFile (name, &wfd);
-      if (fh == INVALID_HANDLE_VALUE)
-       {
-         errno = ENOENT;
-         return -1;
+         fh = FindFirstFile (name, &wfd);
+         if (fh == INVALID_HANDLE_VALUE)
+           {
+             SetErrorMode (errm);
+             errno = ENOENT;
+             return -1;
+           }
+         FindClose (fh);
        }
-      FindClose (fh);
-    }
     }
 
   if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
@@ -1585,6 +1590,7 @@ mswindows_stat (const char * path, struct stat * buf)
        }
       else
        {
+         SetErrorMode (errm);
          errno = EACCES;
          return -1;
        }
@@ -1597,6 +1603,8 @@ mswindows_stat (const char * path, struct stat * buf)
       fake_inode = 0;
     }
 
+  SetErrorMode (errm);
+
 #if 0
   /* Not sure if there is any point in this.  */
   if (!NILP (Vwin32_generate_fake_inodes))
@@ -1630,22 +1638,12 @@ mswindows_stat (const char * path, struct stat * buf)
 
   /* 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);