Stop ns builds polluting the environment with EMACSDATA, EMACSDOC
It's bad form for one part of a program to communicate with another part by making persistent changes to the environment of all subsequent child processes. For example, it can cause odd bugs when building Emacs from within Emacs (eg bug#6401, maybe). * nsterm.m (ns_etc_directory): New function, split from ns_init_paths. (ns_init_paths): Do not set EMACSDATA, EMACSDOC. * nsterm.h (ns_etc_directory): Add it. * callproc.c [HAVE_NS]: Include nsterm.h. (init_callproc_1, init_callproc) [HAVE_NS]: Use ns_etc_directory.
This commit is contained in:
parent
61a116066f
commit
d01ba2f149
4 changed files with 60 additions and 14 deletions
|
@ -1,3 +1,12 @@
|
|||
2012-07-09 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
Stop ns builds polluting the environment with EMACSDATA, EMACSDOC.
|
||||
* nsterm.m (ns_etc_directory): New function, split from ns_init_paths.
|
||||
(ns_init_paths): Do not set EMACSDATA, EMACSDOC.
|
||||
* nsterm.h (ns_etc_directory): Add it.
|
||||
* callproc.c [HAVE_NS]: Include nsterm.h.
|
||||
(init_callproc_1, init_callproc) [HAVE_NS]: Use ns_etc_directory.
|
||||
|
||||
2012-07-09 Dmitry Antipov <dmantipov@yandex.ru>
|
||||
|
||||
Move marker debugging code under MARKER_DEBUG.
|
||||
|
|
|
@ -61,6 +61,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
|||
#include "msdos.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NS
|
||||
#include "nsterm.h"
|
||||
#endif
|
||||
|
||||
#ifndef USE_CRT_DLL
|
||||
extern char **environ;
|
||||
#endif
|
||||
|
@ -1513,13 +1517,26 @@ init_callproc_1 (void)
|
|||
{
|
||||
char *data_dir = egetenv ("EMACSDATA");
|
||||
char *doc_dir = egetenv ("EMACSDOC");
|
||||
#ifdef HAVE_NS
|
||||
const char *etc_dir = ns_etc_directory ();
|
||||
#endif
|
||||
|
||||
Vdata_directory
|
||||
= Ffile_name_as_directory (build_string (data_dir ? data_dir
|
||||
: PATH_DATA));
|
||||
#ifdef HAVE_NS
|
||||
: (etc_dir ? etc_dir : PATH_DATA)
|
||||
#else
|
||||
: PATH_DATA
|
||||
#endif
|
||||
));
|
||||
Vdoc_directory
|
||||
= Ffile_name_as_directory (build_string (doc_dir ? doc_dir
|
||||
: PATH_DOC));
|
||||
#ifdef HAVE_NS
|
||||
: (etc_dir ? etc_dir : PATH_DOC)
|
||||
#else
|
||||
: PATH_DOC
|
||||
#endif
|
||||
));
|
||||
|
||||
/* Check the EMACSPATH environment variable, defaulting to the
|
||||
PATH_EXEC path from epaths.h. */
|
||||
|
@ -1537,6 +1554,17 @@ init_callproc (void)
|
|||
|
||||
register char * sh;
|
||||
Lisp_Object tempdir;
|
||||
#ifdef HAVE_NS
|
||||
if (data_dir == 0)
|
||||
{
|
||||
const char *etc_dir = ns_etc_directory ();
|
||||
if (etc_dir)
|
||||
{
|
||||
data_dir = alloca (strlen (etc_dir) + 1);
|
||||
strcpy (data_dir, etc_dir);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!NILP (Vinstallation_directory))
|
||||
{
|
||||
|
|
|
@ -798,6 +798,7 @@ extern void x_free_frame_resources (struct frame *);
|
|||
#define NSAPP_DATA2_RUNASSCRIPT 10
|
||||
extern void ns_run_ascript (void);
|
||||
|
||||
extern char *ns_etc_directory (void);
|
||||
extern void ns_init_paths (void);
|
||||
extern void syms_of_nsterm (void);
|
||||
extern void syms_of_nsfns (void);
|
||||
|
|
32
src/nsterm.m
32
src/nsterm.m
|
@ -286,6 +286,26 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
}
|
||||
|
||||
|
||||
char *
|
||||
ns_etc_directory (void)
|
||||
{
|
||||
/* If running as a self-contained app bundle, return as a string the
|
||||
filename of the etc directory, if present; else nil. */
|
||||
|
||||
NSBundle *bundle = [NSBundle mainBundle];
|
||||
NSString *resourceDir = [bundle resourcePath];
|
||||
NSString *resourcePath;
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
BOOL isDir;
|
||||
|
||||
resourcePath = [resourceDir stringByAppendingPathComponent: @"etc"];
|
||||
if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir])
|
||||
{
|
||||
if (isDir) return [resourcePath UTF8String];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
void
|
||||
ns_init_paths (void)
|
||||
/* --------------------------------------------------------------------------
|
||||
|
@ -369,18 +389,6 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
if ([resourcePaths length] > 0)
|
||||
setenv ("EMACSPATH", [resourcePaths UTF8String], 1);
|
||||
}
|
||||
|
||||
resourcePath = [resourceDir stringByAppendingPathComponent: @"etc"];
|
||||
if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir])
|
||||
{
|
||||
if (isDir)
|
||||
{
|
||||
if (!getenv ("EMACSDATA"))
|
||||
setenv ("EMACSDATA", [resourcePath UTF8String], 1);
|
||||
if (!getenv ("EMACSDOC"))
|
||||
setenv ("EMACSDOC", [resourcePath UTF8String], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Reference in a new issue