Commit 9e059e3f authored by Glenn Morris's avatar Glenn Morris

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.
parent 4107c81e
2012-07-10 Glenn Morris <rgm@gnu.org>
Stop ns builds setting the EMACSLOADPATH environment variable.
* nsterm.m (ns_load_path): Rename from ns_init_paths.
Now it does not set EMACSLOADPATH, just returns the load-path string.
* nsterm.h: Update accordingly.
* lread.c [HAVE_NS]: Include nsterm.h.
(init_lread) [HAVE_NS]: Use ns_load_path.
* emacs.c (main) [HAVE_NS]: No longer call ns_init_paths.
2012-07-09 Glenn Morris <rgm@gnu.org>
* s/gnu.h (SIGNALS_VIA_CHARACTERS): No need to define it here,
......
......@@ -1426,13 +1426,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
init_ntproc (); /* must precede init_editfns. */
#endif
#ifdef HAVE_NS
#ifndef CANNOT_DUMP
if (initialized)
#endif
ns_init_paths ();
#endif
/* Initialize and GC-protect Vinitial_environment and
Vprocess_environment before set_initial_environment fills them
in. */
......
......@@ -45,6 +45,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "msdos.h"
#endif
#ifdef HAVE_NS
#include "nsterm.h"
#endif
#include <unistd.h>
#include <math.h>
......@@ -4125,8 +4129,16 @@ init_lread (void)
const char *normal;
#ifdef CANNOT_DUMP
#ifdef HAVE_NS
const char *loadpath = ns_load_path ();
#endif
normal = PATH_LOADSEARCH;
#ifdef HAVE_NS
Vload_path = decode_env_path ("EMACSLOADPATH", loadpath ? loadpath : normal);
#else
Vload_path = decode_env_path ("EMACSLOADPATH", normal);
#endif
load_path_check ();
......@@ -4135,7 +4147,12 @@ init_lread (void)
difference between initialized and !initialized in this case,
so we'll have to do it unconditionally when Vinstallation_directory
is non-nil. */
#ifdef HAVE_NS
/* loadpath already includes the app-bundle's site-lisp. */
if (!no_site_lisp && !egetenv ("EMACSLOADPATH") && !loadpath)
#else
if (!no_site_lisp && !egetenv ("EMACSLOADPATH"))
#endif
{
Lisp_Object sitelisp;
sitelisp = decode_env_path (0, PATH_SITELOADSEARCH);
......@@ -4171,7 +4188,12 @@ init_lread (void)
}
else
{
#ifdef HAVE_NS
const char *loadpath = ns_load_path ();
Vload_path = decode_env_path (0, loadpath ? loadpath : normal);
#else
Vload_path = decode_env_path (0, normal);
#endif
if (!NILP (Vinstallation_directory))
{
Lisp_Object tem, tem1;
......@@ -4274,7 +4296,12 @@ init_lread (void)
load_path_check ();
/* Add the site-lisp directories at the front. */
#ifdef HAVE_NS
/* loadpath already includes the app-bundle's site-lisp. */
if (!no_site_lisp && !loadpath)
#else
if (!no_site_lisp)
#endif
{
Lisp_Object sitelisp;
sitelisp = decode_env_path (0, PATH_SITELOADSEARCH);
......
......@@ -800,7 +800,7 @@ extern void ns_run_ascript (void);
extern const char *ns_etc_directory (void);
extern const char *ns_exec_path (void);
extern void ns_init_paths (void);
extern const char *ns_load_path (void);
extern void syms_of_nsterm (void);
extern void syms_of_nsfns (void);
extern void syms_of_nsmenu (void);
......
......@@ -365,12 +365,11 @@ Updated by Christian Limpach (chris@nice.ch)
}
void
ns_init_paths (void)
/* --------------------------------------------------------------------------
Used to allow emacs to find its resources under Emacs.app
Called from emacs.c at startup.
-------------------------------------------------------------------------- */
const char *
ns_load_path (void)
/* If running as a self-contained app bundle, return as a path string
the filenames of the site-lisp, lisp and leim directories.
Ie, site-lisp:lisp:leim. Otherwise, return nil. */
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *resourceDir = [bundle resourcePath];
......@@ -379,34 +378,30 @@ Updated by Christian Limpach (chris@nice.ch)
NSString *pathSeparator = onWindows ? @";" : @":";
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDir;
/*NSLog (@"ns_init_paths: '%@'\n%@\n", [[NSBundle mainBundle] bundlePath], [[NSBundle mainBundle] resourcePath]); */
NSArray *paths = [resourceDir stringsByAppendingPaths:
[NSArray arrayWithObjects:
@"site-lisp", @"lisp", @"leim", nil]];
NSEnumerator *pathEnum = [paths objectEnumerator];
resourcePaths = @"";
/* the following based on Andrew Choi's init_mac_osx_environment () */
if (!getenv ("EMACSLOADPATH"))
/* Hack to skip site-lisp. */
if (no_site_lisp) resourcePath = [pathEnum nextObject];
while (resourcePath = [pathEnum nextObject])
{
NSArray *paths = [resourceDir stringsByAppendingPaths:
[NSArray arrayWithObjects:
@"site-lisp", @"lisp", @"leim", nil]];
NSEnumerator *pathEnum = [paths objectEnumerator];
resourcePaths = @"";
/* Hack to skip site-lisp. */
if (no_site_lisp) resourcePath = [pathEnum nextObject];
while (resourcePath = [pathEnum nextObject])
{
if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir])
if (isDir)
{
if ([resourcePaths length] > 0)
resourcePaths
= [resourcePaths stringByAppendingString: pathSeparator];
resourcePaths
= [resourcePaths stringByAppendingString: resourcePath];
}
}
if ([resourcePaths length] > 0)
setenv ("EMACSLOADPATH", [resourcePaths UTF8String], 1);
/*NSLog (@"loadPath: '%@'\n", resourcePaths); */
if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir])
if (isDir)
{
if ([resourcePaths length] > 0)
resourcePaths
= [resourcePaths stringByAppendingString: pathSeparator];
resourcePaths
= [resourcePaths stringByAppendingString: resourcePath];
}
}
if ([resourcePaths length] > 0) return [resourcePaths UTF8String];
return NULL;
}
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment