aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32.c
diff options
context:
space:
mode:
authorEli Zaretskii2013-04-15 16:39:41 +0300
committerEli Zaretskii2013-04-15 16:39:41 +0300
commit7d9fb4de782c3ff316c6ffc26f6ea291be2f653b (patch)
tree384f50c67bf57e887e0e2c33dbb0c807ceccda5d /src/w32.c
parenteb7a410c147507ffdf0e84d163a014acb82b19a2 (diff)
downloademacs-7d9fb4de782c3ff316c6ffc26f6ea291be2f653b.tar.gz
emacs-7d9fb4de782c3ff316c6ffc26f6ea291be2f653b.zip
Fixed problems with default paths and with shell-file-name.
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c67
1 files changed, 62 insertions, 5 deletions
diff --git a/src/w32.c b/src/w32.c
index 0fa5970124a..7d63c73eb18 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -65,6 +65,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
65#undef localtime 65#undef localtime
66 66
67#include "lisp.h" 67#include "lisp.h"
68#include "epaths.h" /* for SHELL */
68 69
69#include <pwd.h> 70#include <pwd.h>
70#include <grp.h> 71#include <grp.h>
@@ -2018,7 +2019,7 @@ init_environment (char ** argv)
2018 {"PRELOAD_WINSOCK", NULL}, 2019 {"PRELOAD_WINSOCK", NULL},
2019 {"emacs_dir", "C:/emacs"}, 2020 {"emacs_dir", "C:/emacs"},
2020 {"EMACSLOADPATH", NULL}, 2021 {"EMACSLOADPATH", NULL},
2021 {"SHELL", "%emacs_dir%/bin/cmdproxy.exe"}, 2022 {"SHELL", "cmdproxy.exe"}, /* perhaps it is somewhere on PATH */
2022 {"EMACSDATA", NULL}, 2023 {"EMACSDATA", NULL},
2023 {"EMACSPATH", NULL}, 2024 {"EMACSPATH", NULL},
2024 {"INFOPATH", NULL}, 2025 {"INFOPATH", NULL},
@@ -2094,9 +2095,12 @@ init_environment (char ** argv)
2094 emacs_abort (); 2095 emacs_abort ();
2095 *p = 0; 2096 *p = 0;
2096 2097
2097 if ((p = _mbsrchr (modname, '\\')) && xstrcasecmp (p, "\\bin") == 0) 2098 if ((p = _mbsrchr (modname, '\\'))
2099 /* From bin means installed Emacs, from src means uninstalled. */
2100 && (xstrcasecmp (p, "\\bin") == 0 || xstrcasecmp (p, "\\src") == 0))
2098 { 2101 {
2099 char buf[SET_ENV_BUF_SIZE]; 2102 char buf[SET_ENV_BUF_SIZE];
2103 int within_build_tree = xstrcasecmp (p, "\\src") == 0;
2100 2104
2101 *p = 0; 2105 *p = 0;
2102 for (p = modname; *p; p = CharNext (p)) 2106 for (p = modname; *p; p = CharNext (p))
@@ -2104,6 +2108,15 @@ init_environment (char ** argv)
2104 2108
2105 _snprintf (buf, sizeof (buf)-1, "emacs_dir=%s", modname); 2109 _snprintf (buf, sizeof (buf)-1, "emacs_dir=%s", modname);
2106 _putenv (strdup (buf)); 2110 _putenv (strdup (buf));
2111 /* If we are running from the Posix-like build tree, define
2112 SHELL to point to our own cmdproxy. The loop below will
2113 then disregard PATH_EXEC and the default value. */
2114 if (within_build_tree)
2115 {
2116 _snprintf (buf, sizeof (buf) - 1,
2117 "SHELL=%s/nt/cmdproxy.exe", modname);
2118 _putenv (strdup (buf));
2119 }
2107 } 2120 }
2108 /* Handle running emacs from the build directory: src/oo-spd/i386/ */ 2121 /* Handle running emacs from the build directory: src/oo-spd/i386/ */
2109 2122
@@ -2139,16 +2152,60 @@ init_environment (char ** argv)
2139 if (!getenv (env_vars[i].name)) 2152 if (!getenv (env_vars[i].name))
2140 { 2153 {
2141 int dont_free = 0; 2154 int dont_free = 0;
2155 char bufc[SET_ENV_BUF_SIZE];
2142 2156
2143 if ((lpval = w32_get_resource (env_vars[i].name, &dwType)) == NULL 2157 if ((lpval = w32_get_resource (env_vars[i].name, &dwType)) == NULL
2144 /* Also ignore empty environment variables. */ 2158 /* Also ignore empty environment variables. */
2145 || *lpval == 0) 2159 || *lpval == 0)
2146 { 2160 {
2147 xfree (lpval); 2161 xfree (lpval);
2148 lpval = env_vars[i].def_value;
2149 dwType = REG_EXPAND_SZ;
2150 dont_free = 1; 2162 dont_free = 1;
2151 if (!strcmp (env_vars[i].name, "HOME") && !appdata) 2163 if (strcmp (env_vars[i].name, "SHELL") == 0)
2164 {
2165 /* Look for cmdproxy.exe in every directory in
2166 PATH_EXEC. FIXME: This does not find cmdproxy
2167 in nt/ when we run uninstalled. */
2168 char fname[MAX_PATH];
2169 const char *pstart = PATH_EXEC, *pend;
2170
2171 do {
2172 pend = _mbschr (pstart, ';');
2173 if (!pend)
2174 pend = pstart + strlen (pstart);
2175 /* Be defensive against series of ;;; characters. */
2176 if (pend > pstart)
2177 {
2178 strncpy (fname, pstart, pend - pstart);
2179 fname[pend - pstart] = '/';
2180 strcpy (&fname[pend - pstart + 1], "cmdproxy.exe");
2181 ExpandEnvironmentStrings ((LPSTR) fname, bufc,
2182 sizeof (bufc));
2183 if (check_existing (bufc))
2184 {
2185 lpval = bufc;
2186 dwType = REG_SZ;
2187 break;
2188 }
2189 }
2190 if (*pend)
2191 pstart = pend + 1;
2192 else
2193 pstart = pend;
2194 if (!*pstart)
2195 {
2196 /* If not found in any directory, use the
2197 default as the last resort. */
2198 lpval = env_vars[i].def_value;
2199 dwType = REG_EXPAND_SZ;
2200 }
2201 } while (*pstart);
2202 }
2203 else
2204 {
2205 lpval = env_vars[i].def_value;
2206 dwType = REG_EXPAND_SZ;
2207 }
2208 if (strcmp (env_vars[i].name, "HOME") == 0 && !appdata)
2152 Vdelayed_warnings_list 2209 Vdelayed_warnings_list
2153 = Fcons (listn (CONSTYPE_HEAP, 2, 2210 = Fcons (listn (CONSTYPE_HEAP, 2,
2154 intern ("initialization"), 2211 intern ("initialization"),