aboutsummaryrefslogtreecommitdiffstats
path: root/src/emacs.c
diff options
context:
space:
mode:
authorTom Tromey2012-09-04 10:10:06 -0600
committerTom Tromey2012-09-04 10:10:06 -0600
commitbf69f522a9e135f9aa483cedd53e71e915f2bf75 (patch)
tree3f73c47fb863ef87f420de1d30858da821072bd9 /src/emacs.c
parent303324a9232dbc89369faceb6b3530740d0fc1bd (diff)
parent6ec9a5a7b5efb129807f567709ca858211ed7840 (diff)
downloademacs-bf69f522a9e135f9aa483cedd53e71e915f2bf75.tar.gz
emacs-bf69f522a9e135f9aa483cedd53e71e915f2bf75.zip
merge from trunk
Diffstat (limited to 'src/emacs.c')
-rw-r--r--src/emacs.c84
1 files changed, 31 insertions, 53 deletions
diff --git a/src/emacs.c b/src/emacs.c
index a039e89d48f..3c814a36043 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -31,6 +31,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31 31
32#include "lisp.h" 32#include "lisp.h"
33 33
34#ifdef HAVE_WINDOW_SYSTEM
35#include TERM_HEADER
36#endif /* HAVE_WINDOW_SYSTEM */
37
34#ifdef WINDOWSNT 38#ifdef WINDOWSNT
35#include <fcntl.h> 39#include <fcntl.h>
36#include <windows.h> /* just for w32.h */ 40#include <windows.h> /* just for w32.h */
@@ -62,20 +66,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
62#include "gnutls.h" 66#include "gnutls.h"
63#endif 67#endif
64 68
65#ifdef HAVE_NS
66#include "nsterm.h"
67#endif
68
69#if (defined PROFILING \ 69#if (defined PROFILING \
70 && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__)) 70 && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__))
71# include <sys/gmon.h> 71# include <sys/gmon.h>
72extern void moncontrol (int mode); 72extern void moncontrol (int mode);
73#endif 73#endif
74 74
75#ifdef HAVE_X_WINDOWS
76#include "xterm.h"
77#endif
78
79#ifdef HAVE_SETLOCALE 75#ifdef HAVE_SETLOCALE
80#include <locale.h> 76#include <locale.h>
81#endif 77#endif
@@ -99,10 +95,10 @@ static const char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundati
99/* Empty lisp strings. To avoid having to build any others. */ 95/* Empty lisp strings. To avoid having to build any others. */
100Lisp_Object empty_unibyte_string, empty_multibyte_string; 96Lisp_Object empty_unibyte_string, empty_multibyte_string;
101 97
102/* Set nonzero after Emacs has started up the first time. 98/* Set after Emacs has started up the first time.
103 Prevents reinitialization of the Lisp world and keymaps 99 Prevents reinitialization of the Lisp world and keymaps
104 on subsequent starts. */ 100 on subsequent starts. */
105int initialized; 101bool initialized;
106 102
107#ifdef DARWIN_OS 103#ifdef DARWIN_OS
108extern void unexec_init_emacs_zone (void); 104extern void unexec_init_emacs_zone (void);
@@ -116,9 +112,9 @@ static void *malloc_state_ptr;
116extern void *malloc_get_state (void); 112extern void *malloc_get_state (void);
117/* From glibc, a routine that overwrites the malloc internal state. */ 113/* From glibc, a routine that overwrites the malloc internal state. */
118extern int malloc_set_state (void*); 114extern int malloc_set_state (void*);
119/* Non-zero if the MALLOC_CHECK_ environment variable was set while 115/* True if the MALLOC_CHECK_ environment variable was set while
120 dumping. Used to work around a bug in glibc's malloc. */ 116 dumping. Used to work around a bug in glibc's malloc. */
121static int malloc_using_checking; 117static bool malloc_using_checking;
122#endif 118#endif
123 119
124Lisp_Object Qfile_name_handler_alist; 120Lisp_Object Qfile_name_handler_alist;
@@ -127,17 +123,17 @@ Lisp_Object Qrisky_local_variable;
127 123
128Lisp_Object Qkill_emacs; 124Lisp_Object Qkill_emacs;
129 125
130/* If non-zero, Emacs should not attempt to use a window-specific code, 126/* If true, Emacs should not attempt to use a window-specific code,
131 but instead should use the virtual terminal under which it was started. */ 127 but instead should use the virtual terminal under which it was started. */
132int inhibit_window_system; 128bool inhibit_window_system;
133 129
134/* If non-zero, a filter or a sentinel is running. Tested to save the match 130/* If true, a filter or a sentinel is running. Tested to save the match
135 data on the first attempt to change it inside asynchronous code. */ 131 data on the first attempt to change it inside asynchronous code. */
136int running_asynch_code; 132bool running_asynch_code;
137 133
138#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) 134#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
139/* If non-zero, -d was specified, meaning we're using some window system. */ 135/* If true, -d was specified, meaning we're using some window system. */
140int display_arg; 136bool display_arg;
141#endif 137#endif
142 138
143#if defined (DOUG_LEA_MALLOC) || defined (GNU_LINUX) 139#if defined (DOUG_LEA_MALLOC) || defined (GNU_LINUX)
@@ -150,11 +146,11 @@ static void *my_heap_start;
150static uprintmax_t heap_bss_diff; 146static uprintmax_t heap_bss_diff;
151#endif 147#endif
152 148
153/* Nonzero means running Emacs without interactive terminal. */ 149/* True means running Emacs without interactive terminal. */
154int noninteractive; 150bool noninteractive;
155 151
156/* Nonzero means remove site-lisp directories from load-path. */ 152/* True means remove site-lisp directories from load-path. */
157int no_site_lisp; 153bool no_site_lisp;
158 154
159/* Name for the server started by the daemon.*/ 155/* Name for the server started by the daemon.*/
160static char *daemon_name; 156static char *daemon_name;
@@ -272,13 +268,8 @@ section of the Emacs manual or the file BUGS.\n"
272/* Signal code for the fatal signal that was received. */ 268/* Signal code for the fatal signal that was received. */
273static int fatal_error_code; 269static int fatal_error_code;
274 270
275/* Nonzero if handling a fatal error already. */ 271/* True if handling a fatal error already. */
276int fatal_error_in_progress; 272bool fatal_error_in_progress;
277
278/* If non-null, call this function from fatal_error_signal before
279 committing suicide. */
280
281static void (*fatal_error_signal_hook) (void);
282 273
283#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD 274#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
284/* When compiled with GTK and running under Gnome, 275/* When compiled with GTK and running under Gnome,
@@ -316,7 +307,7 @@ fatal_error_signal (int sig)
316 if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT) 307 if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT)
317 Fkill_emacs (make_number (sig)); 308 Fkill_emacs (make_number (sig));
318 309
319 shut_down_emacs (sig, 0, Qnil); 310 shut_down_emacs (sig, Qnil);
320 } 311 }
321 312
322 /* Signal the same code; this time it will really be fatal. 313 /* Signal the same code; this time it will really be fatal.
@@ -327,9 +318,6 @@ fatal_error_signal (int sig)
327 sigunblock (sigmask (fatal_error_code)); 318 sigunblock (sigmask (fatal_error_code));
328#endif 319#endif
329 320
330 if (fatal_error_signal_hook)
331 fatal_error_signal_hook ();
332
333 kill (getpid (), fatal_error_code); 321 kill (getpid (), fatal_error_code);
334} 322}
335 323
@@ -576,7 +564,7 @@ DEFINE_DUMMY_FUNCTION (__main)
576 Too bad we can't just use getopt for all of this, but we don't have 564 Too bad we can't just use getopt for all of this, but we don't have
577 enough information to do it right. */ 565 enough information to do it right. */
578 566
579static int 567static bool
580argmatch (char **argv, int argc, const char *sstr, const char *lstr, 568argmatch (char **argv, int argc, const char *sstr, const char *lstr,
581 int minlen, char **valptr, int *skipptr) 569 int minlen, char **valptr, int *skipptr)
582{ 570{
@@ -680,12 +668,12 @@ int
680main (int argc, char **argv) 668main (int argc, char **argv)
681{ 669{
682 char stack_bottom_variable; 670 char stack_bottom_variable;
683 int do_initial_setlocale; 671 bool do_initial_setlocale;
684 int skip_args = 0; 672 int skip_args = 0;
685#ifdef HAVE_SETRLIMIT 673#ifdef HAVE_SETRLIMIT
686 struct rlimit rlim; 674 struct rlimit rlim;
687#endif 675#endif
688 int no_loadup = 0; 676 bool no_loadup = 0;
689 char *junk = 0; 677 char *junk = 0;
690 char *dname_arg = 0; 678 char *dname_arg = 0;
691#ifdef NS_IMPL_COCOA 679#ifdef NS_IMPL_COCOA
@@ -1280,6 +1268,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1280 init_data (); 1268 init_data ();
1281 init_atimer (); 1269 init_atimer ();
1282 running_asynch_code = 0; 1270 running_asynch_code = 0;
1271 init_random ();
1283 1272
1284 no_loadup 1273 no_loadup
1285 = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args); 1274 = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args);
@@ -1959,7 +1948,7 @@ all of which are called before Emacs is actually killed. */)
1959 x_clipboard_manager_save_all (); 1948 x_clipboard_manager_save_all ();
1960#endif 1949#endif
1961 1950
1962 shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil); 1951 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil);
1963 1952
1964#ifdef HAVE_NS 1953#ifdef HAVE_NS
1965 ns_release_autorelease_pool (ns_pool); 1954 ns_release_autorelease_pool (ns_pool);
@@ -1995,7 +1984,7 @@ all of which are called before Emacs is actually killed. */)
1995 and Fkill_emacs. */ 1984 and Fkill_emacs. */
1996 1985
1997void 1986void
1998shut_down_emacs (int sig, int no_x, Lisp_Object stuff) 1987shut_down_emacs (int sig, Lisp_Object stuff)
1999{ 1988{
2000 /* Prevent running of hooks from now on. */ 1989 /* Prevent running of hooks from now on. */
2001 Vrun_hooks = Qnil; 1990 Vrun_hooks = Qnil;
@@ -2030,17 +2019,6 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff)
2030 unlock_all_files (); 2019 unlock_all_files ();
2031#endif 2020#endif
2032 2021
2033#if 0 /* This triggers a bug in XCloseDisplay and is not needed. */
2034#ifdef HAVE_X_WINDOWS
2035 /* It's not safe to call intern here. Maybe we are crashing. */
2036 if (!noninteractive && SYMBOLP (Vinitial_window_system)
2037 && SCHARS (SYMBOL_NAME (Vinitial_window_system)) == 1
2038 && SREF (SYMBOL_NAME (Vinitial_window_system), 0) == 'x'
2039 && ! no_x)
2040 Fx_close_current_connection ();
2041#endif /* HAVE_X_WINDOWS */
2042#endif
2043
2044#ifdef SIGIO 2022#ifdef SIGIO
2045 /* There is a tendency for a SIGIO signal to arrive within exit, 2023 /* There is a tendency for a SIGIO signal to arrive within exit,
2046 and cause a SIGHUP because the input descriptor is already closed. */ 2024 and cause a SIGHUP because the input descriptor is already closed. */
@@ -2232,7 +2210,7 @@ decode_env_path (const char *evarname, const char *defalt)
2232 const char *path, *p; 2210 const char *path, *p;
2233 Lisp_Object lpath, element, tem; 2211 Lisp_Object lpath, element, tem;
2234#ifdef WINDOWSNT 2212#ifdef WINDOWSNT
2235 int defaulted = 0; 2213 bool defaulted = 0;
2236 const char *emacs_dir = egetenv ("emacs_dir"); 2214 const char *emacs_dir = egetenv ("emacs_dir");
2237 static const char *emacs_dir_env = "%emacs_dir%/"; 2215 static const char *emacs_dir_env = "%emacs_dir%/";
2238 const size_t emacs_dir_len = strlen (emacs_dir_env); 2216 const size_t emacs_dir_len = strlen (emacs_dir_env);
@@ -2328,7 +2306,7 @@ from the parent process and its tty file descriptors. */)
2328 (void) 2306 (void)
2329{ 2307{
2330 int nfd; 2308 int nfd;
2331 int err = 0; 2309 bool err = 0;
2332 2310
2333 if (!IS_DAEMON) 2311 if (!IS_DAEMON)
2334 error ("This function can only be called if emacs is run as a daemon"); 2312 error ("This function can only be called if emacs is run as a daemon");