struct stat ignored;
char default_home[MAX_PATH];
- static struct env_entry
+ static const struct env_entry
{
char * name;
char * def_value;
- } env_vars[] =
+ } dflt_envvars[] =
{
{"HOME", "C:/"},
{"PRELOAD_WINSOCK", NULL},
{"LANG", NULL},
};
+#define N_ENV_VARS sizeof(dflt_envvars)/sizeof(dflt_envvars[0])
+
+ /* We need to copy dflt_envvars[] and work on the copy because we
+ don't want the dumped Emacs to inherit the values of
+ environment variables we saw during dumping (which could be on
+ a different system). The defaults above must be left intact. */
+ struct env_entry env_vars[N_ENV_VARS];
+
+ for (i = 0; i < N_ENV_VARS; i++)
+ env_vars[i] = dflt_envvars[i];
+
/* For backwards compatibility, check if a .emacs file exists in C:/
If not, then we can try to default to the appdata directory under the
user's profile, which is more likely to be writable. */
LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,
locale_name, sizeof (locale_name)))
{
- for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++)
+ for (i = 0; i < N_ENV_VARS; i++)
{
if (strcmp (env_vars[i].name, "LANG") == 0)
{
}
}
- for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++)
+ for (i = 0; i < N_ENV_VARS; i++)
{
if (!getenv (env_vars[i].name))
{
if (lpval)
{
- if (dwType == REG_EXPAND_SZ)
- {
- char buf1[SET_ENV_BUF_SIZE], buf2[SET_ENV_BUF_SIZE];
+ char buf1[SET_ENV_BUF_SIZE], buf2[SET_ENV_BUF_SIZE];
- ExpandEnvironmentStrings ((LPSTR) lpval, buf1, sizeof(buf1));
- _snprintf (buf2, sizeof(buf2)-1, "%s=%s", env_vars[i].name, buf1);
- _putenv (strdup (buf2));
- }
+ if (dwType == REG_EXPAND_SZ)
+ ExpandEnvironmentStrings ((LPSTR) lpval, buf1, sizeof(buf1));
else if (dwType == REG_SZ)
+ strcpy (buf1, lpval);
+ if (dwType == REG_EXPAND_SZ || dwType == REG_SZ)
{
- char buf[SET_ENV_BUF_SIZE];
-
- _snprintf (buf, sizeof(buf)-1, "%s=%s", env_vars[i].name, lpval);
- _putenv (strdup (buf));
+ _snprintf (buf2, sizeof(buf2)-1, "%s=%s", env_vars[i].name,
+ buf1);
+ _putenv (strdup (buf2));
}
if (!dont_free)
objs[1] = decode_env_path (0, (getenv ("EMACSLOADPATH")));
full_load_path = Fappend (2, objs);
init_file = build_string ("term/w32-win");
- fd = openp (full_load_path, init_file, Vload_suffixes, NULL, Qnil);
+ fd = openp (full_load_path, init_file, Fget_load_suffixes (), NULL, Qnil);
if (fd < 0)
{
Lisp_Object load_path_print = Fprin1_to_string (full_load_path, Qnil);