aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32.c
diff options
context:
space:
mode:
authorMiles Bader2006-06-07 18:05:10 +0000
committerMiles Bader2006-06-07 18:05:10 +0000
commitb883cdb2fefa8ea9c3b0d82eba7a9ee792f871bb (patch)
treede3804210a8cd955e0d3b9abc15679480930bc82 /src/w32.c
parent885b7d0991bd4b4b8f4bd1d3cd21c18a697bbce2 (diff)
parent26c9afc3239e18b03537faaea33e3e82e28099e6 (diff)
downloademacs-b883cdb2fefa8ea9c3b0d82eba7a9ee792f871bb.tar.gz
emacs-b883cdb2fefa8ea9c3b0d82eba7a9ee792f871bb.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 285-296) - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: admin/FOR-RELEASE: Update refcard section. * gnus--rel--5.10 (patch 102-104) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-64
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/w32.c b/src/w32.c
index 71799befdbb..f11ffb7a785 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -950,11 +950,11 @@ init_environment (char ** argv)
950 struct stat ignored; 950 struct stat ignored;
951 char default_home[MAX_PATH]; 951 char default_home[MAX_PATH];
952 952
953 static struct env_entry 953 static const struct env_entry
954 { 954 {
955 char * name; 955 char * name;
956 char * def_value; 956 char * def_value;
957 } env_vars[] = 957 } dflt_envvars[] =
958 { 958 {
959 {"HOME", "C:/"}, 959 {"HOME", "C:/"},
960 {"PRELOAD_WINSOCK", NULL}, 960 {"PRELOAD_WINSOCK", NULL},
@@ -971,6 +971,17 @@ init_environment (char ** argv)
971 {"LANG", NULL}, 971 {"LANG", NULL},
972 }; 972 };
973 973
974#define N_ENV_VARS sizeof(dflt_envvars)/sizeof(dflt_envvars[0])
975
976 /* We need to copy dflt_envvars[] and work on the copy because we
977 don't want the dumped Emacs to inherit the values of
978 environment variables we saw during dumping (which could be on
979 a different system). The defaults above must be left intact. */
980 struct env_entry env_vars[N_ENV_VARS];
981
982 for (i = 0; i < N_ENV_VARS; i++)
983 env_vars[i] = dflt_envvars[i];
984
974 /* For backwards compatibility, check if a .emacs file exists in C:/ 985 /* For backwards compatibility, check if a .emacs file exists in C:/
975 If not, then we can try to default to the appdata directory under the 986 If not, then we can try to default to the appdata directory under the
976 user's profile, which is more likely to be writable. */ 987 user's profile, which is more likely to be writable. */
@@ -1005,7 +1016,7 @@ init_environment (char ** argv)
1005 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP, 1016 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,
1006 locale_name, sizeof (locale_name))) 1017 locale_name, sizeof (locale_name)))
1007 { 1018 {
1008 for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++) 1019 for (i = 0; i < N_ENV_VARS; i++)
1009 { 1020 {
1010 if (strcmp (env_vars[i].name, "LANG") == 0) 1021 if (strcmp (env_vars[i].name, "LANG") == 0)
1011 { 1022 {
@@ -1069,7 +1080,7 @@ init_environment (char ** argv)
1069 } 1080 }
1070 } 1081 }
1071 1082
1072 for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++) 1083 for (i = 0; i < N_ENV_VARS; i++)
1073 { 1084 {
1074 if (!getenv (env_vars[i].name)) 1085 if (!getenv (env_vars[i].name))
1075 { 1086 {
@@ -1084,20 +1095,17 @@ init_environment (char ** argv)
1084 1095
1085 if (lpval) 1096 if (lpval)
1086 { 1097 {
1087 if (dwType == REG_EXPAND_SZ) 1098 char buf1[SET_ENV_BUF_SIZE], buf2[SET_ENV_BUF_SIZE];
1088 {
1089 char buf1[SET_ENV_BUF_SIZE], buf2[SET_ENV_BUF_SIZE];
1090 1099
1091 ExpandEnvironmentStrings ((LPSTR) lpval, buf1, sizeof(buf1)); 1100 if (dwType == REG_EXPAND_SZ)
1092 _snprintf (buf2, sizeof(buf2)-1, "%s=%s", env_vars[i].name, buf1); 1101 ExpandEnvironmentStrings ((LPSTR) lpval, buf1, sizeof(buf1));
1093 _putenv (strdup (buf2));
1094 }
1095 else if (dwType == REG_SZ) 1102 else if (dwType == REG_SZ)
1103 strcpy (buf1, lpval);
1104 if (dwType == REG_EXPAND_SZ || dwType == REG_SZ)
1096 { 1105 {
1097 char buf[SET_ENV_BUF_SIZE]; 1106 _snprintf (buf2, sizeof(buf2)-1, "%s=%s", env_vars[i].name,
1098 1107 buf1);
1099 _snprintf (buf, sizeof(buf)-1, "%s=%s", env_vars[i].name, lpval); 1108 _putenv (strdup (buf2));
1100 _putenv (strdup (buf));
1101 } 1109 }
1102 1110
1103 if (!dont_free) 1111 if (!dont_free)