diff options
| author | Glenn Morris | 2012-07-09 21:04:28 -0400 |
|---|---|---|
| committer | Glenn Morris | 2012-07-09 21:04:28 -0400 |
| commit | 9e059e3fde0f95b0b06ebce10f2985201e54c11c (patch) | |
| tree | e52878b1f1fff02dee5b327ab042c35de9ac3f87 | |
| parent | 4107c81e8926223bc8f2c50f4436d8a36d6d5914 (diff) | |
| download | emacs-9e059e3fde0f95b0b06ebce10f2985201e54c11c.tar.gz emacs-9e059e3fde0f95b0b06ebce10f2985201e54c11c.zip | |
Stop ns builds setting the EMACSLOADPATH environment variable
Ref bugs 4309, 6401, etc.
This is the last environment variable (ab)used by the ns port in this way.
* src/nsterm.m (ns_load_path): Rename from ns_init_paths.
Now it does not set EMACSLOADPATH, just returns the load-path string.
* src/nsterm.h: Update accordingly.
* src/lread.c [HAVE_NS]: Include nsterm.h.
(init_lread) [HAVE_NS]: Use ns_load_path.
* src/emacs.c (main) [HAVE_NS]: No longer call ns_init_paths.
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/emacs.c | 7 | ||||
| -rw-r--r-- | src/lread.c | 27 | ||||
| -rw-r--r-- | src/nsterm.h | 2 | ||||
| -rw-r--r-- | src/nsterm.m | 57 |
5 files changed, 64 insertions, 39 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 7e3372bc90d..584d6a33947 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-07-10 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | Stop ns builds setting the EMACSLOADPATH environment variable. | ||
| 4 | * nsterm.m (ns_load_path): Rename from ns_init_paths. | ||
| 5 | Now it does not set EMACSLOADPATH, just returns the load-path string. | ||
| 6 | * nsterm.h: Update accordingly. | ||
| 7 | * lread.c [HAVE_NS]: Include nsterm.h. | ||
| 8 | (init_lread) [HAVE_NS]: Use ns_load_path. | ||
| 9 | * emacs.c (main) [HAVE_NS]: No longer call ns_init_paths. | ||
| 10 | |||
| 1 | 2012-07-09 Glenn Morris <rgm@gnu.org> | 11 | 2012-07-09 Glenn Morris <rgm@gnu.org> |
| 2 | 12 | ||
| 3 | * s/gnu.h (SIGNALS_VIA_CHARACTERS): No need to define it here, | 13 | * s/gnu.h (SIGNALS_VIA_CHARACTERS): No need to define it here, |
diff --git a/src/emacs.c b/src/emacs.c index 2b386bac176..2194cfead16 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1426,13 +1426,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1426 | init_ntproc (); /* must precede init_editfns. */ | 1426 | init_ntproc (); /* must precede init_editfns. */ |
| 1427 | #endif | 1427 | #endif |
| 1428 | 1428 | ||
| 1429 | #ifdef HAVE_NS | ||
| 1430 | #ifndef CANNOT_DUMP | ||
| 1431 | if (initialized) | ||
| 1432 | #endif | ||
| 1433 | ns_init_paths (); | ||
| 1434 | #endif | ||
| 1435 | |||
| 1436 | /* Initialize and GC-protect Vinitial_environment and | 1429 | /* Initialize and GC-protect Vinitial_environment and |
| 1437 | Vprocess_environment before set_initial_environment fills them | 1430 | Vprocess_environment before set_initial_environment fills them |
| 1438 | in. */ | 1431 | in. */ |
diff --git a/src/lread.c b/src/lread.c index 6b6231a8f11..c69190c37b6 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -45,6 +45,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 45 | #include "msdos.h" | 45 | #include "msdos.h" |
| 46 | #endif | 46 | #endif |
| 47 | 47 | ||
| 48 | #ifdef HAVE_NS | ||
| 49 | #include "nsterm.h" | ||
| 50 | #endif | ||
| 51 | |||
| 48 | #include <unistd.h> | 52 | #include <unistd.h> |
| 49 | #include <math.h> | 53 | #include <math.h> |
| 50 | 54 | ||
| @@ -4125,8 +4129,16 @@ init_lread (void) | |||
| 4125 | const char *normal; | 4129 | const char *normal; |
| 4126 | 4130 | ||
| 4127 | #ifdef CANNOT_DUMP | 4131 | #ifdef CANNOT_DUMP |
| 4132 | #ifdef HAVE_NS | ||
| 4133 | const char *loadpath = ns_load_path (); | ||
| 4134 | #endif | ||
| 4135 | |||
| 4128 | normal = PATH_LOADSEARCH; | 4136 | normal = PATH_LOADSEARCH; |
| 4137 | #ifdef HAVE_NS | ||
| 4138 | Vload_path = decode_env_path ("EMACSLOADPATH", loadpath ? loadpath : normal); | ||
| 4139 | #else | ||
| 4129 | Vload_path = decode_env_path ("EMACSLOADPATH", normal); | 4140 | Vload_path = decode_env_path ("EMACSLOADPATH", normal); |
| 4141 | #endif | ||
| 4130 | 4142 | ||
| 4131 | load_path_check (); | 4143 | load_path_check (); |
| 4132 | 4144 | ||
| @@ -4135,7 +4147,12 @@ init_lread (void) | |||
| 4135 | difference between initialized and !initialized in this case, | 4147 | difference between initialized and !initialized in this case, |
| 4136 | so we'll have to do it unconditionally when Vinstallation_directory | 4148 | so we'll have to do it unconditionally when Vinstallation_directory |
| 4137 | is non-nil. */ | 4149 | is non-nil. */ |
| 4150 | #ifdef HAVE_NS | ||
| 4151 | /* loadpath already includes the app-bundle's site-lisp. */ | ||
| 4152 | if (!no_site_lisp && !egetenv ("EMACSLOADPATH") && !loadpath) | ||
| 4153 | #else | ||
| 4138 | if (!no_site_lisp && !egetenv ("EMACSLOADPATH")) | 4154 | if (!no_site_lisp && !egetenv ("EMACSLOADPATH")) |
| 4155 | #endif | ||
| 4139 | { | 4156 | { |
| 4140 | Lisp_Object sitelisp; | 4157 | Lisp_Object sitelisp; |
| 4141 | sitelisp = decode_env_path (0, PATH_SITELOADSEARCH); | 4158 | sitelisp = decode_env_path (0, PATH_SITELOADSEARCH); |
| @@ -4171,7 +4188,12 @@ init_lread (void) | |||
| 4171 | } | 4188 | } |
| 4172 | else | 4189 | else |
| 4173 | { | 4190 | { |
| 4191 | #ifdef HAVE_NS | ||
| 4192 | const char *loadpath = ns_load_path (); | ||
| 4193 | Vload_path = decode_env_path (0, loadpath ? loadpath : normal); | ||
| 4194 | #else | ||
| 4174 | Vload_path = decode_env_path (0, normal); | 4195 | Vload_path = decode_env_path (0, normal); |
| 4196 | #endif | ||
| 4175 | if (!NILP (Vinstallation_directory)) | 4197 | if (!NILP (Vinstallation_directory)) |
| 4176 | { | 4198 | { |
| 4177 | Lisp_Object tem, tem1; | 4199 | Lisp_Object tem, tem1; |
| @@ -4274,7 +4296,12 @@ init_lread (void) | |||
| 4274 | load_path_check (); | 4296 | load_path_check (); |
| 4275 | 4297 | ||
| 4276 | /* Add the site-lisp directories at the front. */ | 4298 | /* Add the site-lisp directories at the front. */ |
| 4299 | #ifdef HAVE_NS | ||
| 4300 | /* loadpath already includes the app-bundle's site-lisp. */ | ||
| 4301 | if (!no_site_lisp && !loadpath) | ||
| 4302 | #else | ||
| 4277 | if (!no_site_lisp) | 4303 | if (!no_site_lisp) |
| 4304 | #endif | ||
| 4278 | { | 4305 | { |
| 4279 | Lisp_Object sitelisp; | 4306 | Lisp_Object sitelisp; |
| 4280 | sitelisp = decode_env_path (0, PATH_SITELOADSEARCH); | 4307 | sitelisp = decode_env_path (0, PATH_SITELOADSEARCH); |
diff --git a/src/nsterm.h b/src/nsterm.h index 939186d0d94..abfdfd4803a 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -800,7 +800,7 @@ extern void ns_run_ascript (void); | |||
| 800 | 800 | ||
| 801 | extern const char *ns_etc_directory (void); | 801 | extern const char *ns_etc_directory (void); |
| 802 | extern const char *ns_exec_path (void); | 802 | extern const char *ns_exec_path (void); |
| 803 | extern void ns_init_paths (void); | 803 | extern const char *ns_load_path (void); |
| 804 | extern void syms_of_nsterm (void); | 804 | extern void syms_of_nsterm (void); |
| 805 | extern void syms_of_nsfns (void); | 805 | extern void syms_of_nsfns (void); |
| 806 | extern void syms_of_nsmenu (void); | 806 | extern void syms_of_nsmenu (void); |
diff --git a/src/nsterm.m b/src/nsterm.m index 6ec9d695334..39725067ec7 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -365,12 +365,11 @@ ns_exec_path (void) | |||
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | 367 | ||
| 368 | void | 368 | const char * |
| 369 | ns_init_paths (void) | 369 | ns_load_path (void) |
| 370 | /* -------------------------------------------------------------------------- | 370 | /* If running as a self-contained app bundle, return as a path string |
| 371 | Used to allow emacs to find its resources under Emacs.app | 371 | the filenames of the site-lisp, lisp and leim directories. |
| 372 | Called from emacs.c at startup. | 372 | Ie, site-lisp:lisp:leim. Otherwise, return nil. */ |
| 373 | -------------------------------------------------------------------------- */ | ||
| 374 | { | 373 | { |
| 375 | NSBundle *bundle = [NSBundle mainBundle]; | 374 | NSBundle *bundle = [NSBundle mainBundle]; |
| 376 | NSString *resourceDir = [bundle resourcePath]; | 375 | NSString *resourceDir = [bundle resourcePath]; |
| @@ -379,34 +378,30 @@ ns_init_paths (void) | |||
| 379 | NSString *pathSeparator = onWindows ? @";" : @":"; | 378 | NSString *pathSeparator = onWindows ? @";" : @":"; |
| 380 | NSFileManager *fileManager = [NSFileManager defaultManager]; | 379 | NSFileManager *fileManager = [NSFileManager defaultManager]; |
| 381 | BOOL isDir; | 380 | BOOL isDir; |
| 382 | /*NSLog (@"ns_init_paths: '%@'\n%@\n", [[NSBundle mainBundle] bundlePath], [[NSBundle mainBundle] resourcePath]); */ | 381 | NSArray *paths = [resourceDir stringsByAppendingPaths: |
| 382 | [NSArray arrayWithObjects: | ||
| 383 | @"site-lisp", @"lisp", @"leim", nil]]; | ||
| 384 | NSEnumerator *pathEnum = [paths objectEnumerator]; | ||
| 385 | resourcePaths = @""; | ||
| 383 | 386 | ||
| 384 | /* the following based on Andrew Choi's init_mac_osx_environment () */ | 387 | /* Hack to skip site-lisp. */ |
| 385 | if (!getenv ("EMACSLOADPATH")) | 388 | if (no_site_lisp) resourcePath = [pathEnum nextObject]; |
| 389 | |||
| 390 | while (resourcePath = [pathEnum nextObject]) | ||
| 386 | { | 391 | { |
| 387 | NSArray *paths = [resourceDir stringsByAppendingPaths: | 392 | if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) |
| 388 | [NSArray arrayWithObjects: | 393 | if (isDir) |
| 389 | @"site-lisp", @"lisp", @"leim", nil]]; | 394 | { |
| 390 | NSEnumerator *pathEnum = [paths objectEnumerator]; | 395 | if ([resourcePaths length] > 0) |
| 391 | resourcePaths = @""; | 396 | resourcePaths |
| 392 | /* Hack to skip site-lisp. */ | 397 | = [resourcePaths stringByAppendingString: pathSeparator]; |
| 393 | if (no_site_lisp) resourcePath = [pathEnum nextObject]; | 398 | resourcePaths |
| 394 | while (resourcePath = [pathEnum nextObject]) | 399 | = [resourcePaths stringByAppendingString: resourcePath]; |
| 395 | { | 400 | } |
| 396 | if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) | ||
| 397 | if (isDir) | ||
| 398 | { | ||
| 399 | if ([resourcePaths length] > 0) | ||
| 400 | resourcePaths | ||
| 401 | = [resourcePaths stringByAppendingString: pathSeparator]; | ||
| 402 | resourcePaths | ||
| 403 | = [resourcePaths stringByAppendingString: resourcePath]; | ||
| 404 | } | ||
| 405 | } | ||
| 406 | if ([resourcePaths length] > 0) | ||
| 407 | setenv ("EMACSLOADPATH", [resourcePaths UTF8String], 1); | ||
| 408 | /*NSLog (@"loadPath: '%@'\n", resourcePaths); */ | ||
| 409 | } | 401 | } |
| 402 | if ([resourcePaths length] > 0) return [resourcePaths UTF8String]; | ||
| 403 | |||
| 404 | return NULL; | ||
| 410 | } | 405 | } |
| 411 | 406 | ||
| 412 | static void | 407 | static void |