diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/callproc.c | 32 | ||||
| -rw-r--r-- | src/nsterm.h | 1 | ||||
| -rw-r--r-- | src/nsterm.m | 32 |
4 files changed, 60 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1375bbe78d9..1aa5f7df5c3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2012-07-09 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | Stop ns builds polluting the environment with EMACSDATA, EMACSDOC. | ||
| 4 | * nsterm.m (ns_etc_directory): New function, split from ns_init_paths. | ||
| 5 | (ns_init_paths): Do not set EMACSDATA, EMACSDOC. | ||
| 6 | * nsterm.h (ns_etc_directory): Add it. | ||
| 7 | * callproc.c [HAVE_NS]: Include nsterm.h. | ||
| 8 | (init_callproc_1, init_callproc) [HAVE_NS]: Use ns_etc_directory. | ||
| 9 | |||
| 1 | 2012-07-09 Dmitry Antipov <dmantipov@yandex.ru> | 10 | 2012-07-09 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 11 | ||
| 3 | Move marker debugging code under MARKER_DEBUG. | 12 | Move marker debugging code under MARKER_DEBUG. |
diff --git a/src/callproc.c b/src/callproc.c index 39fcb99c4b5..52825bc9dc2 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -61,6 +61,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 61 | #include "msdos.h" | 61 | #include "msdos.h" |
| 62 | #endif | 62 | #endif |
| 63 | 63 | ||
| 64 | #ifdef HAVE_NS | ||
| 65 | #include "nsterm.h" | ||
| 66 | #endif | ||
| 67 | |||
| 64 | #ifndef USE_CRT_DLL | 68 | #ifndef USE_CRT_DLL |
| 65 | extern char **environ; | 69 | extern char **environ; |
| 66 | #endif | 70 | #endif |
| @@ -1513,13 +1517,26 @@ init_callproc_1 (void) | |||
| 1513 | { | 1517 | { |
| 1514 | char *data_dir = egetenv ("EMACSDATA"); | 1518 | char *data_dir = egetenv ("EMACSDATA"); |
| 1515 | char *doc_dir = egetenv ("EMACSDOC"); | 1519 | char *doc_dir = egetenv ("EMACSDOC"); |
| 1520 | #ifdef HAVE_NS | ||
| 1521 | const char *etc_dir = ns_etc_directory (); | ||
| 1522 | #endif | ||
| 1516 | 1523 | ||
| 1517 | Vdata_directory | 1524 | Vdata_directory |
| 1518 | = Ffile_name_as_directory (build_string (data_dir ? data_dir | 1525 | = Ffile_name_as_directory (build_string (data_dir ? data_dir |
| 1519 | : PATH_DATA)); | 1526 | #ifdef HAVE_NS |
| 1527 | : (etc_dir ? etc_dir : PATH_DATA) | ||
| 1528 | #else | ||
| 1529 | : PATH_DATA | ||
| 1530 | #endif | ||
| 1531 | )); | ||
| 1520 | Vdoc_directory | 1532 | Vdoc_directory |
| 1521 | = Ffile_name_as_directory (build_string (doc_dir ? doc_dir | 1533 | = Ffile_name_as_directory (build_string (doc_dir ? doc_dir |
| 1522 | : PATH_DOC)); | 1534 | #ifdef HAVE_NS |
| 1535 | : (etc_dir ? etc_dir : PATH_DOC) | ||
| 1536 | #else | ||
| 1537 | : PATH_DOC | ||
| 1538 | #endif | ||
| 1539 | )); | ||
| 1523 | 1540 | ||
| 1524 | /* Check the EMACSPATH environment variable, defaulting to the | 1541 | /* Check the EMACSPATH environment variable, defaulting to the |
| 1525 | PATH_EXEC path from epaths.h. */ | 1542 | PATH_EXEC path from epaths.h. */ |
| @@ -1537,6 +1554,17 @@ init_callproc (void) | |||
| 1537 | 1554 | ||
| 1538 | register char * sh; | 1555 | register char * sh; |
| 1539 | Lisp_Object tempdir; | 1556 | Lisp_Object tempdir; |
| 1557 | #ifdef HAVE_NS | ||
| 1558 | if (data_dir == 0) | ||
| 1559 | { | ||
| 1560 | const char *etc_dir = ns_etc_directory (); | ||
| 1561 | if (etc_dir) | ||
| 1562 | { | ||
| 1563 | data_dir = alloca (strlen (etc_dir) + 1); | ||
| 1564 | strcpy (data_dir, etc_dir); | ||
| 1565 | } | ||
| 1566 | } | ||
| 1567 | #endif | ||
| 1540 | 1568 | ||
| 1541 | if (!NILP (Vinstallation_directory)) | 1569 | if (!NILP (Vinstallation_directory)) |
| 1542 | { | 1570 | { |
diff --git a/src/nsterm.h b/src/nsterm.h index 80d25d67941..b2f03d08f2c 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -798,6 +798,7 @@ extern void x_free_frame_resources (struct frame *); | |||
| 798 | #define NSAPP_DATA2_RUNASSCRIPT 10 | 798 | #define NSAPP_DATA2_RUNASSCRIPT 10 |
| 799 | extern void ns_run_ascript (void); | 799 | extern void ns_run_ascript (void); |
| 800 | 800 | ||
| 801 | extern char *ns_etc_directory (void); | ||
| 801 | extern void ns_init_paths (void); | 802 | extern void ns_init_paths (void); |
| 802 | extern void syms_of_nsterm (void); | 803 | extern void syms_of_nsterm (void); |
| 803 | extern void syms_of_nsfns (void); | 804 | extern void syms_of_nsfns (void); |
diff --git a/src/nsterm.m b/src/nsterm.m index 1cd4c1c4271..4c4d3de78ff 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -286,6 +286,26 @@ append2 (Lisp_Object list, Lisp_Object item) | |||
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | 288 | ||
| 289 | char * | ||
| 290 | ns_etc_directory (void) | ||
| 291 | { | ||
| 292 | /* If running as a self-contained app bundle, return as a string the | ||
| 293 | filename of the etc directory, if present; else nil. */ | ||
| 294 | |||
| 295 | NSBundle *bundle = [NSBundle mainBundle]; | ||
| 296 | NSString *resourceDir = [bundle resourcePath]; | ||
| 297 | NSString *resourcePath; | ||
| 298 | NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
| 299 | BOOL isDir; | ||
| 300 | |||
| 301 | resourcePath = [resourceDir stringByAppendingPathComponent: @"etc"]; | ||
| 302 | if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) | ||
| 303 | { | ||
| 304 | if (isDir) return [resourcePath UTF8String]; | ||
| 305 | } | ||
| 306 | return nil; | ||
| 307 | } | ||
| 308 | |||
| 289 | void | 309 | void |
| 290 | ns_init_paths (void) | 310 | ns_init_paths (void) |
| 291 | /* -------------------------------------------------------------------------- | 311 | /* -------------------------------------------------------------------------- |
| @@ -369,18 +389,6 @@ ns_init_paths (void) | |||
| 369 | if ([resourcePaths length] > 0) | 389 | if ([resourcePaths length] > 0) |
| 370 | setenv ("EMACSPATH", [resourcePaths UTF8String], 1); | 390 | setenv ("EMACSPATH", [resourcePaths UTF8String], 1); |
| 371 | } | 391 | } |
| 372 | |||
| 373 | resourcePath = [resourceDir stringByAppendingPathComponent: @"etc"]; | ||
| 374 | if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) | ||
| 375 | { | ||
| 376 | if (isDir) | ||
| 377 | { | ||
| 378 | if (!getenv ("EMACSDATA")) | ||
| 379 | setenv ("EMACSDATA", [resourcePath UTF8String], 1); | ||
| 380 | if (!getenv ("EMACSDOC")) | ||
| 381 | setenv ("EMACSDOC", [resourcePath UTF8String], 1); | ||
| 382 | } | ||
| 383 | } | ||
| 384 | } | 392 | } |
| 385 | 393 | ||
| 386 | static void | 394 | static void |