]> code.delx.au - gnu-emacs/blobdiff - src/w32.c
(redisplay_window): Clear force_start field
[gnu-emacs] / src / w32.c
index b466dcecd9f79701a26a44494bbf400d256264e3..ae7f299dd0381bc6f869c90692e732eae420ee1a 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -270,57 +270,57 @@ static char configuration_buffer[32];
 char *
 get_emacs_configuration (void)
 {
-    char *arch, *oem, *os;
+  char *arch, *oem, *os;
 
-    /* Determine the processor type.  */
-    switch (get_processor_type ()) 
-      {
+  /* Determine the processor type.  */
+  switch (get_processor_type ()) 
+    {
 
 #ifdef PROCESSOR_INTEL_386
-      case PROCESSOR_INTEL_386:
-      case PROCESSOR_INTEL_486:
-      case PROCESSOR_INTEL_PENTIUM:
-       arch = "i386";
-       break;
+    case PROCESSOR_INTEL_386:
+    case PROCESSOR_INTEL_486:
+    case PROCESSOR_INTEL_PENTIUM:
+      arch = "i386";
+      break;
 #endif
 
 #ifdef PROCESSOR_INTEL_860
-      case PROCESSOR_INTEL_860:
-       arch = "i860";
-       break;
+    case PROCESSOR_INTEL_860:
+      arch = "i860";
+      break;
 #endif
 
 #ifdef PROCESSOR_MIPS_R2000
-      case PROCESSOR_MIPS_R2000:
-      case PROCESSOR_MIPS_R3000:
-      case PROCESSOR_MIPS_R4000:
-       arch = "mips";
-       break;
+    case PROCESSOR_MIPS_R2000:
+    case PROCESSOR_MIPS_R3000:
+    case PROCESSOR_MIPS_R4000:
+      arch = "mips";
+      break;
 #endif
 
 #ifdef PROCESSOR_ALPHA_21064
-      case PROCESSOR_ALPHA_21064:
-       arch = "alpha";
-       break;
+    case PROCESSOR_ALPHA_21064:
+      arch = "alpha";
+      break;
 #endif
 
-      default:
-       arch = "unknown";
-       break;
-      }
+    default:
+      arch = "unknown";
+      break;
+    }
 
-    /* Let oem be "*" until we figure out how to decode the OEM field.  */
-    oem = "*";
+  /* Let oem be "*" until we figure out how to decode the OEM field.  */
+  oem = "*";
 
 #ifdef WINDOWS95
-    os = "win";
+  os = "win";
 #else
-    os = "nt";
+  os = "nt";
 #endif
 
-    sprintf (configuration_buffer, "%s-%s-%s%d.%d", arch, oem, os,
-            get_nt_major_version (), get_nt_minor_version ());
-    return configuration_buffer;
+  sprintf (configuration_buffer, "%s-%s-%s%d.%d", arch, oem, os,
+          get_nt_major_version (), get_nt_minor_version ());
+  return configuration_buffer;
 }
 
 /* Conjure up inode and device numbers that will serve the purpose
@@ -458,6 +458,7 @@ prepare_standard_handles (int in, int out, int err, HANDLE handles[4])
   stdout_save = GetStdHandle (STD_OUTPUT_HANDLE);
   stderr_save = GetStdHandle (STD_ERROR_HANDLE);
 
+#ifndef HAVE_NTGUI
   if (!DuplicateHandle (parent, 
                       GetStdHandle (STD_INPUT_HANDLE), 
                       parent,
@@ -484,6 +485,7 @@ prepare_standard_handles (int in, int out, int err, HANDLE handles[4])
                       FALSE,
                       DUPLICATE_SAME_ACCESS))
     report_file_error ("Duplicating parent's error handle", Qnil);
+#endif /* !HAVE_NTGUI */
   
   if (!SetStdHandle (STD_INPUT_HANDLE, (HANDLE) _get_osfhandle (in)))
     report_file_error ("Changing stdin handle", Qnil);
@@ -528,6 +530,7 @@ reset_standard_handles (int in, int out, int err, HANDLE handles[4])
   HANDLE err_handle = handles[3];
   int i;
 
+#ifndef HAVE_NTGUI
   if (!SetStdHandle (STD_INPUT_HANDLE, stdin_save))
     report_file_error ("Resetting input handle", Qnil);
   
@@ -539,6 +542,7 @@ reset_standard_handles (int in, int out, int err, HANDLE handles[4])
   
   if (!SetStdHandle (STD_ERROR_HANDLE, stderr_save))
     report_file_error ("Resetting error handle", Qnil);
+#endif /* !HAVE_NTGUI */
   
   if (out == err) 
     {
@@ -662,6 +666,109 @@ crlf_to_lf (n, buf)
   return np - startp;
 }
 
+#define REG_ROOT "SOFTWARE\\GNU\\Emacs\\"
+
+LPBYTE 
+nt_get_resource (key, lpdwtype)
+    char *key;
+    LPDWORD lpdwtype;
+{
+  LPBYTE lpvalue;
+  HKEY hrootkey = NULL;
+  DWORD cbData;
+  BOOL ok = FALSE;
+  
+  /* Check both the current user and the local machine to see if 
+     we have any resources.  */
+  
+  if (RegOpenKeyEx (HKEY_CURRENT_USER, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS)
+    {
+      lpvalue = NULL;
+
+      if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS 
+         && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL 
+         && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS)
+       {
+         return (lpvalue);
+       }
+
+      if (lpvalue) xfree (lpvalue);
+       
+      RegCloseKey (hrootkey);
+    } 
+  
+  if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS)
+    {
+      lpvalue = NULL;
+       
+      if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS &&
+         (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL &&
+         RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS)
+       {
+         return (lpvalue);
+       }
+       
+      if (lpvalue) xfree (lpvalue);
+       
+      RegCloseKey (hrootkey);
+    } 
+  
+  return (NULL);
+}
+
+void
+init_environment ()
+{
+  /* Open a console window to display messages during dumping. */
+  if (!initialized)
+    AllocConsole ();
+
+  /* Check for environment variables and use registry if they don't exist */
+  {
+      int i;
+      LPBYTE lpval;
+      DWORD dwType;
+
+      static char * env_vars[] = 
+      {
+         "emacs_path",
+         "EMACSLOADPATH",
+         "SHELL",
+         "EMACSDATA",
+         "EMACSPATH",
+         "EMACSLOCKDIR",
+         "INFOPATH",
+         "EMACSDOC",
+         "TERM",
+      };
+
+      for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++) 
+       {
+         if (!getenv (env_vars[i]) &&
+             (lpval = nt_get_resource (env_vars[i], &dwType)) != NULL)
+           {
+             if (dwType == REG_EXPAND_SZ)
+               {
+                 char buf1[500], buf2[500];
+
+                 ExpandEnvironmentStrings ((LPSTR) lpval, buf1, 500);
+                 _snprintf (buf2, 499, "%s=%s", env_vars[i], buf1);
+                 putenv (strdup (buf2));
+               }
+             else if (dwType == REG_SZ)
+               {
+                 char buf[500];
+                 
+                 _snprintf (buf, 499, "%s=%s", env_vars[i], lpval);
+                 putenv (strdup (buf));
+               }
+
+             xfree (lpval);
+           }
+       }
+    }
+}
+
 #ifdef HAVE_TIMEVAL
 #include <sys/timeb.h>