diff options
Diffstat (limited to 'src/emacs.c')
| -rw-r--r-- | src/emacs.c | 109 |
1 files changed, 37 insertions, 72 deletions
diff --git a/src/emacs.c b/src/emacs.c index a53b4cfd4ed..90182e53e70 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -83,6 +83,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 83 | #include "charset.h" | 83 | #include "charset.h" |
| 84 | #include "composite.h" | 84 | #include "composite.h" |
| 85 | #include "dispextern.h" | 85 | #include "dispextern.h" |
| 86 | #include "regex.h" | ||
| 86 | #include "syntax.h" | 87 | #include "syntax.h" |
| 87 | #include "sysselect.h" | 88 | #include "sysselect.h" |
| 88 | #include "systime.h" | 89 | #include "systime.h" |
| @@ -145,7 +146,7 @@ extern int malloc_set_state (void *); | |||
| 145 | /* True if the MALLOC_CHECK_ environment variable was set while | 146 | /* True if the MALLOC_CHECK_ environment variable was set while |
| 146 | dumping. Used to work around a bug in glibc's malloc. */ | 147 | dumping. Used to work around a bug in glibc's malloc. */ |
| 147 | static bool malloc_using_checking; | 148 | static bool malloc_using_checking; |
| 148 | #elif defined HAVE_PTHREAD && !defined SYSTEM_MALLOC | 149 | #elif defined HAVE_PTHREAD && !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC |
| 149 | extern void malloc_enable_thread (void); | 150 | extern void malloc_enable_thread (void); |
| 150 | #endif | 151 | #endif |
| 151 | 152 | ||
| @@ -395,10 +396,11 @@ terminate_due_to_signal (int sig, int backtrace_limit) | |||
| 395 | static void | 396 | static void |
| 396 | init_cmdargs (int argc, char **argv, int skip_args, char *original_pwd) | 397 | init_cmdargs (int argc, char **argv, int skip_args, char *original_pwd) |
| 397 | { | 398 | { |
| 398 | register int i; | 399 | int i; |
| 399 | Lisp_Object name, dir, handler; | 400 | Lisp_Object name, dir, handler; |
| 400 | ptrdiff_t count = SPECPDL_INDEX (); | 401 | ptrdiff_t count = SPECPDL_INDEX (); |
| 401 | Lisp_Object raw_name; | 402 | Lisp_Object raw_name; |
| 403 | AUTO_STRING (slash_colon, "/:"); | ||
| 402 | 404 | ||
| 403 | initial_argv = argv; | 405 | initial_argv = argv; |
| 404 | initial_argc = argc; | 406 | initial_argc = argc; |
| @@ -422,7 +424,7 @@ init_cmdargs (int argc, char **argv, int skip_args, char *original_pwd) | |||
| 422 | if it would otherwise be treated as magic. */ | 424 | if it would otherwise be treated as magic. */ |
| 423 | handler = Ffind_file_name_handler (raw_name, Qt); | 425 | handler = Ffind_file_name_handler (raw_name, Qt); |
| 424 | if (! NILP (handler)) | 426 | if (! NILP (handler)) |
| 425 | raw_name = concat2 (build_string ("/:"), raw_name); | 427 | raw_name = concat2 (slash_colon, raw_name); |
| 426 | 428 | ||
| 427 | Vinvocation_name = Ffile_name_nondirectory (raw_name); | 429 | Vinvocation_name = Ffile_name_nondirectory (raw_name); |
| 428 | Vinvocation_directory = Ffile_name_directory (raw_name); | 430 | Vinvocation_directory = Ffile_name_directory (raw_name); |
| @@ -440,7 +442,7 @@ init_cmdargs (int argc, char **argv, int skip_args, char *original_pwd) | |||
| 440 | if it would otherwise be treated as magic. */ | 442 | if it would otherwise be treated as magic. */ |
| 441 | handler = Ffind_file_name_handler (found, Qt); | 443 | handler = Ffind_file_name_handler (found, Qt); |
| 442 | if (! NILP (handler)) | 444 | if (! NILP (handler)) |
| 443 | found = concat2 (build_string ("/:"), found); | 445 | found = concat2 (slash_colon, found); |
| 444 | Vinvocation_directory = Ffile_name_directory (found); | 446 | Vinvocation_directory = Ffile_name_directory (found); |
| 445 | } | 447 | } |
| 446 | } | 448 | } |
| @@ -576,12 +578,6 @@ DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory, | |||
| 576 | } | 578 | } |
| 577 | 579 | ||
| 578 | 580 | ||
| 579 | #ifdef HAVE_TZSET | ||
| 580 | /* A valid but unlikely value for the TZ environment value. | ||
| 581 | It is OK (though a bit slower) if the user actually chooses this value. */ | ||
| 582 | static char const dump_tz[] = "UtC0"; | ||
| 583 | #endif | ||
| 584 | |||
| 585 | /* Test whether the next argument in ARGV matches SSTR or a prefix of | 581 | /* Test whether the next argument in ARGV matches SSTR or a prefix of |
| 586 | LSTR (at least MINLEN characters). If so, then if VALPTR is non-null | 582 | LSTR (at least MINLEN characters). If so, then if VALPTR is non-null |
| 587 | (the argument is supposed to have a value) store in *VALPTR either | 583 | (the argument is supposed to have a value) store in *VALPTR either |
| @@ -734,12 +730,6 @@ main (int argc, char **argv) | |||
| 734 | stack_base = &dummy; | 730 | stack_base = &dummy; |
| 735 | #endif | 731 | #endif |
| 736 | 732 | ||
| 737 | #ifdef G_SLICE_ALWAYS_MALLOC | ||
| 738 | /* This is used by the Cygwin build. It's not needed starting with | ||
| 739 | cygwin-1.7.24, but it doesn't do any harm. */ | ||
| 740 | xputenv ("G_SLICE=always-malloc"); | ||
| 741 | #endif | ||
| 742 | |||
| 743 | #ifndef CANNOT_DUMP | 733 | #ifndef CANNOT_DUMP |
| 744 | might_dump = !initialized; | 734 | might_dump = !initialized; |
| 745 | #endif | 735 | #endif |
| @@ -747,9 +737,6 @@ main (int argc, char **argv) | |||
| 747 | #ifdef GNU_LINUX | 737 | #ifdef GNU_LINUX |
| 748 | if (!initialized) | 738 | if (!initialized) |
| 749 | { | 739 | { |
| 750 | extern char my_endbss[]; | ||
| 751 | extern char *my_endbss_static; | ||
| 752 | |||
| 753 | if (my_heap_start == 0) | 740 | if (my_heap_start == 0) |
| 754 | my_heap_start = sbrk (0); | 741 | my_heap_start = sbrk (0); |
| 755 | 742 | ||
| @@ -878,7 +865,6 @@ main (int argc, char **argv) | |||
| 878 | && !getrlimit (RLIMIT_STACK, &rlim)) | 865 | && !getrlimit (RLIMIT_STACK, &rlim)) |
| 879 | { | 866 | { |
| 880 | long newlim; | 867 | long newlim; |
| 881 | extern size_t re_max_failures; | ||
| 882 | /* Approximate the amount regex.c needs per unit of re_max_failures. */ | 868 | /* Approximate the amount regex.c needs per unit of re_max_failures. */ |
| 883 | int ratio = 20 * sizeof (char *); | 869 | int ratio = 20 * sizeof (char *); |
| 884 | /* Then add 33% to cover the size of the smaller stacks that regex.c | 870 | /* Then add 33% to cover the size of the smaller stacks that regex.c |
| @@ -912,7 +898,7 @@ main (int argc, char **argv) | |||
| 912 | 898 | ||
| 913 | clearerr (stdin); | 899 | clearerr (stdin); |
| 914 | 900 | ||
| 915 | #ifndef SYSTEM_MALLOC | 901 | #if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC |
| 916 | /* Arrange to get warning messages as memory fills up. */ | 902 | /* Arrange to get warning messages as memory fills up. */ |
| 917 | memory_warnings (0, malloc_warning); | 903 | memory_warnings (0, malloc_warning); |
| 918 | 904 | ||
| @@ -920,7 +906,7 @@ main (int argc, char **argv) | |||
| 920 | Also call realloc and free for consistency. */ | 906 | Also call realloc and free for consistency. */ |
| 921 | free (realloc (malloc (4), 4)); | 907 | free (realloc (malloc (4), 4)); |
| 922 | 908 | ||
| 923 | #endif /* not SYSTEM_MALLOC */ | 909 | #endif /* not SYSTEM_MALLOC and not HYBRID_MALLOC */ |
| 924 | 910 | ||
| 925 | #ifdef MSDOS | 911 | #ifdef MSDOS |
| 926 | SET_BINARY (fileno (stdin)); | 912 | SET_BINARY (fileno (stdin)); |
| @@ -1145,12 +1131,13 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1145 | #endif /* DOS_NT */ | 1131 | #endif /* DOS_NT */ |
| 1146 | } | 1132 | } |
| 1147 | 1133 | ||
| 1148 | #if defined HAVE_PTHREAD && !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC | 1134 | #if defined HAVE_PTHREAD && !defined SYSTEM_MALLOC \ |
| 1135 | && !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC | ||
| 1149 | # ifndef CANNOT_DUMP | 1136 | # ifndef CANNOT_DUMP |
| 1150 | /* Do not make gmalloc thread-safe when creating bootstrap-emacs, as | 1137 | /* Do not make gmalloc thread-safe when creating bootstrap-emacs, as |
| 1151 | that causes an infinite recursive loop with FreeBSD. But do make | 1138 | that causes an infinite recursive loop with FreeBSD. See |
| 1152 | it thread-safe when creating emacs, otherwise bootstrap-emacs | 1139 | Bug#14569. The part of this bug involving Cygwin is no longer |
| 1153 | fails on Cygwin. See Bug#14569. */ | 1140 | relevant, now that Cygwin defines HYBRID_MALLOC. */ |
| 1154 | if (!noninteractive || initialized) | 1141 | if (!noninteractive || initialized) |
| 1155 | # endif | 1142 | # endif |
| 1156 | malloc_enable_thread (); | 1143 | malloc_enable_thread (); |
| @@ -1555,8 +1542,23 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1555 | 1542 | ||
| 1556 | init_charset (); | 1543 | init_charset (); |
| 1557 | 1544 | ||
| 1558 | init_editfns (); /* init_process_emacs uses Voperating_system_release. */ | 1545 | /* This calls putenv and so must precede init_process_emacs. Also, |
| 1559 | init_process_emacs (); /* init_display uses add_keyboard_wait_descriptor. */ | 1546 | it sets Voperating_system_release, which init_process_emacs uses. */ |
| 1547 | init_editfns (); | ||
| 1548 | |||
| 1549 | /* These two call putenv. */ | ||
| 1550 | #ifdef HAVE_DBUS | ||
| 1551 | init_dbusbind (); | ||
| 1552 | #endif | ||
| 1553 | #ifdef USE_GTK | ||
| 1554 | init_xterm (); | ||
| 1555 | #endif | ||
| 1556 | |||
| 1557 | /* This can create a thread that may call getenv, so it must follow | ||
| 1558 | all calls to putenv and setenv. Also, this sets up | ||
| 1559 | add_keyboard_wait_descriptor, which init_display uses. */ | ||
| 1560 | init_process_emacs (); | ||
| 1561 | |||
| 1560 | init_keyboard (); /* This too must precede init_sys_modes. */ | 1562 | init_keyboard (); /* This too must precede init_sys_modes. */ |
| 1561 | if (!noninteractive) | 1563 | if (!noninteractive) |
| 1562 | init_display (); /* Determine terminal type. Calls init_sys_modes. */ | 1564 | init_display (); /* Determine terminal type. Calls init_sys_modes. */ |
| @@ -1593,26 +1595,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1593 | build_string ("loadup.el")); | 1595 | build_string ("loadup.el")); |
| 1594 | } | 1596 | } |
| 1595 | 1597 | ||
| 1596 | if (initialized) | ||
| 1597 | { | ||
| 1598 | #ifdef HAVE_TZSET | ||
| 1599 | { | ||
| 1600 | /* If the execution TZ happens to be the same as the dump TZ, | ||
| 1601 | change it to some other value and then change it back, | ||
| 1602 | to force the underlying implementation to reload the TZ info. | ||
| 1603 | This is needed on implementations that load TZ info from files, | ||
| 1604 | since the TZ file contents may differ between dump and execution. */ | ||
| 1605 | char *tz = getenv ("TZ"); | ||
| 1606 | if (tz && !strcmp (tz, dump_tz)) | ||
| 1607 | { | ||
| 1608 | ++*tz; | ||
| 1609 | tzset (); | ||
| 1610 | --*tz; | ||
| 1611 | } | ||
| 1612 | } | ||
| 1613 | #endif | ||
| 1614 | } | ||
| 1615 | |||
| 1616 | /* Set up for profiling. This is known to work on FreeBSD, | 1598 | /* Set up for profiling. This is known to work on FreeBSD, |
| 1617 | GNU/Linux and MinGW. It might work on some other systems too. | 1599 | GNU/Linux and MinGW. It might work on some other systems too. |
| 1618 | Give it a try and tell us if it works on your system. To compile | 1600 | Give it a try and tell us if it works on your system. To compile |
| @@ -1637,15 +1619,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1637 | 1619 | ||
| 1638 | initialized = 1; | 1620 | initialized = 1; |
| 1639 | 1621 | ||
| 1640 | #ifdef LOCALTIME_CACHE | ||
| 1641 | /* Some versions of localtime have a bug. They cache the value of the time | ||
| 1642 | zone rather than looking it up every time. Since localtime() is | ||
| 1643 | called to bolt the undumping time into the undumped emacs, this | ||
| 1644 | results in localtime ignoring the TZ environment variable. | ||
| 1645 | This flushes the new TZ value into localtime. */ | ||
| 1646 | tzset (); | ||
| 1647 | #endif /* defined (LOCALTIME_CACHE) */ | ||
| 1648 | |||
| 1649 | /* Enter editor command loop. This never returns. */ | 1622 | /* Enter editor command loop. This never returns. */ |
| 1650 | Frecursive_edit (); | 1623 | Frecursive_edit (); |
| 1651 | /* NOTREACHED */ | 1624 | /* NOTREACHED */ |
| @@ -2126,27 +2099,16 @@ You must run Emacs in batch mode in order to dump it. */) | |||
| 2126 | tem = Vpurify_flag; | 2099 | tem = Vpurify_flag; |
| 2127 | Vpurify_flag = Qnil; | 2100 | Vpurify_flag = Qnil; |
| 2128 | 2101 | ||
| 2129 | #ifdef HAVE_TZSET | ||
| 2130 | set_time_zone_rule (dump_tz); | ||
| 2131 | #ifndef LOCALTIME_CACHE | ||
| 2132 | /* Force a tz reload, since set_time_zone_rule doesn't. */ | ||
| 2133 | tzset (); | ||
| 2134 | #endif | ||
| 2135 | #endif | ||
| 2136 | |||
| 2137 | fflush (stdout); | 2102 | fflush (stdout); |
| 2138 | /* Tell malloc where start of impure now is. */ | 2103 | /* Tell malloc where start of impure now is. */ |
| 2139 | /* Also arrange for warnings when nearly out of space. */ | 2104 | /* Also arrange for warnings when nearly out of space. */ |
| 2140 | #ifndef SYSTEM_MALLOC | 2105 | #if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC |
| 2141 | #ifndef WINDOWSNT | 2106 | #ifndef WINDOWSNT |
| 2142 | /* On Windows, this was done before dumping, and that once suffices. | 2107 | /* On Windows, this was done before dumping, and that once suffices. |
| 2143 | Meanwhile, my_edata is not valid on Windows. */ | 2108 | Meanwhile, my_edata is not valid on Windows. */ |
| 2144 | { | 2109 | memory_warnings (my_edata, malloc_warning); |
| 2145 | extern char my_edata[]; | ||
| 2146 | memory_warnings (my_edata, malloc_warning); | ||
| 2147 | } | ||
| 2148 | #endif /* not WINDOWSNT */ | 2110 | #endif /* not WINDOWSNT */ |
| 2149 | #endif /* not SYSTEM_MALLOC */ | 2111 | #endif /* not SYSTEM_MALLOC and not HYBRID_MALLOC */ |
| 2150 | #ifdef DOUG_LEA_MALLOC | 2112 | #ifdef DOUG_LEA_MALLOC |
| 2151 | malloc_state_ptr = malloc_get_state (); | 2113 | malloc_state_ptr = malloc_get_state (); |
| 2152 | #endif | 2114 | #endif |
| @@ -2334,7 +2296,10 @@ decode_env_path (const char *evarname, const char *defalt, bool empty) | |||
| 2334 | } | 2296 | } |
| 2335 | 2297 | ||
| 2336 | if (! NILP (tem)) | 2298 | if (! NILP (tem)) |
| 2337 | element = concat2 (build_string ("/:"), element); | 2299 | { |
| 2300 | AUTO_STRING (slash_colon, "/:"); | ||
| 2301 | element = concat2 (slash_colon, element); | ||
| 2302 | } | ||
| 2338 | } /* !NILP (element) */ | 2303 | } /* !NILP (element) */ |
| 2339 | 2304 | ||
| 2340 | lpath = Fcons (element, lpath); | 2305 | lpath = Fcons (element, lpath); |