0
|
1 /* XEmacs -- Fully extensible Emacs, running on Unix and other platforms.
|
|
2 Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994
|
|
3 Free Software Foundation, Inc.
|
|
4 Copyright (C) 1995 Sun Microsystems, Inc.
|
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Mule 2.0, FSF 19.28. */
|
|
24
|
|
25 /* Note: It is necessary to specify <config.h> and not "config.h" in
|
|
26 order for the --srcdir type of compilation to work properly.
|
|
27 Otherwise the config.h from the srcdir, rather than the one from
|
|
28 the build dir, will be used. */
|
|
29
|
|
30 #include <config.h>
|
|
31 #include "lisp.h"
|
|
32
|
|
33 #include "backtrace.h" /* run-emacs-from-temacs needs this */
|
|
34 #include "buffer.h"
|
|
35 #include "commands.h"
|
|
36 #include "console.h"
|
|
37 #include "process.h"
|
|
38 #include "sysdep.h"
|
|
39
|
|
40 #include <setjmp.h>
|
|
41 #include "syssignal.h" /* Always include before systty.h */
|
|
42 #include "systty.h"
|
|
43 #include "sysfile.h"
|
|
44 #include "systime.h"
|
|
45
|
|
46 #if defined (I18N2) || defined (I18N3) || defined (I18N4)
|
|
47 #include <locale.h>
|
|
48 #endif
|
|
49
|
|
50 #ifdef TOOLTALK
|
|
51 #include <tt_c.h>
|
|
52 #endif
|
|
53
|
|
54 #ifdef VMS
|
|
55 #include <ssdef.h>
|
|
56 #endif
|
|
57
|
|
58 #ifdef APOLLO
|
|
59 #ifndef APOLLO_SR10
|
|
60 #include <default_acl.h>
|
|
61 #endif
|
|
62 #endif
|
|
63
|
|
64 extern void memory_warnings (void *, void (*warnfun) (CONST char *));
|
|
65
|
|
66 /* Command line args from shell, as list of strings */
|
|
67 Lisp_Object Vcommand_line_args;
|
|
68
|
|
69 /* Set nonzero after XEmacs has started up the first time.
|
|
70 Prevents reinitialization of the Lisp world and keymaps
|
|
71 on subsequent starts. */
|
|
72 int initialized;
|
|
73
|
|
74 /* Variable whose value is symbol giving operating system type. */
|
|
75 Lisp_Object Vsystem_type;
|
|
76
|
|
77 /* Variable whose value is string giving configuration built for. */
|
|
78 Lisp_Object Vsystem_configuration;
|
|
79
|
|
80 /* The name under which XEmacs was invoked, with any leading directory
|
|
81 names discarded. */
|
|
82 Lisp_Object Vinvocation_name;
|
|
83
|
|
84 /* The directory name from which XEmacs was invoked. */
|
|
85 Lisp_Object Vinvocation_directory;
|
|
86
|
|
87 #if 0 /* FSFmacs */
|
|
88 /* The directory name in which to find subdirs such as lisp and etc.
|
|
89 nil means get them only from PATH_LOADSEARCH. */
|
|
90 Lisp_Object Vinstallation_directory;
|
|
91 #endif
|
|
92
|
|
93 /* If nonzero, set XEmacs to run at this priority. This is also used
|
|
94 in child_setup and sys_suspend to make sure subshells run at normal
|
|
95 priority. */
|
|
96 int emacs_priority;
|
|
97
|
|
98 /* If non-zero a filter or a sentinel is running. Tested to save the match
|
|
99 data on the first attempt to change it inside asynchronous code. */
|
|
100 int running_asynch_code;
|
|
101
|
|
102 /* If non-zero, a window-system was specified on the command line. */
|
|
103 int display_arg;
|
|
104
|
|
105 /* Type of display specified. We cannot use a Lisp symbol here because
|
|
106 Lisp symbols may not initialized at the time that we set this
|
|
107 variable. */
|
|
108 CONST char *display_use;
|
|
109
|
|
110 /* If non-zero, then the early error handler will only print the error
|
|
111 message and exit. */
|
|
112 int suppress_early_backtrace;
|
|
113
|
|
114 /* An address near the bottom of the stack.
|
|
115 Tells GC how to save a copy of the stack. */
|
|
116 char *stack_bottom;
|
|
117
|
|
118 #ifdef USG_SHARED_LIBRARIES
|
|
119 /* If nonzero, this is the place to put the end of the writable segment
|
|
120 at startup. */
|
|
121
|
|
122 unsigned int bss_end = 0;
|
|
123 #endif
|
|
124
|
|
125 /* Number of bytes of writable memory we can expect to be able to get */
|
|
126 unsigned int lim_data;
|
|
127
|
|
128 /* Nonzero means running XEmacs without interactive terminal. */
|
|
129
|
|
130 int noninteractive;
|
|
131
|
|
132 /* Value of Lisp variable `noninteractive'.
|
|
133 Normally same as C variable `noninteractive'
|
|
134 but nothing terrible happens if user sets this one. */
|
|
135
|
|
136 int noninteractive1;
|
|
137
|
|
138 /* Save argv and argc. */
|
|
139 char **initial_argv;
|
|
140 int initial_argc;
|
|
141
|
|
142 extern int always_gc; /* hack */
|
|
143
|
|
144 Lisp_Object Qkill_emacs_hook;
|
|
145 Lisp_Object Qsave_buffers_kill_emacs;
|
|
146
|
|
147
|
|
148 /* Signal code for the fatal signal that was received */
|
|
149 static int fatal_error_code;
|
|
150
|
|
151 /* Nonzero if handling a fatal error already */
|
|
152 static int fatal_error_in_progress;
|
|
153
|
|
154 static void shut_down_emacs (int sig, Lisp_Object stuff);
|
|
155
|
|
156 /* Handle bus errors, illegal instruction, etc. */
|
|
157 SIGTYPE
|
|
158 fatal_error_signal (int sig)
|
|
159 {
|
|
160 fatal_error_code = sig;
|
|
161 signal (sig, SIG_DFL);
|
|
162 /* Unblock the signal so that if the same signal gets sent in the
|
|
163 code below, we avoid a deadlock. */
|
|
164 EMACS_UNBLOCK_SIGNAL (fatal_error_code);
|
|
165
|
|
166 /* If fatal error occurs in code below, avoid infinite recursion. */
|
|
167 if (! fatal_error_in_progress)
|
|
168 {
|
|
169 fatal_error_in_progress = 1;
|
|
170 shut_down_emacs (sig, Qnil);
|
|
171 stderr_out("\nLisp backtrace follows:\n\n");
|
|
172 Fbacktrace(Qexternal_debugging_output, Qt);
|
|
173
|
|
174 /* Check for Sun-style stack printing via /proc */
|
|
175 {
|
2
|
176 CONST char *pstack = "/usr/proc/bin/pstack";
|
0
|
177 if (access(pstack, X_OK) == 0)
|
|
178 {
|
|
179 char buf[100];
|
|
180 stderr_out("\nC backtrace follows:\n"
|
|
181 "(A real debugger may provide better information)\n\n");
|
|
182 sprintf(buf, "%s %d >&2", pstack, (int)getpid());
|
|
183 system(buf);
|
|
184 }
|
|
185 }
|
|
186 }
|
|
187 #ifdef VMS
|
|
188 LIB$STOP (SS$_ABORT);
|
|
189 #else
|
|
190 /* Signal the same code; this time it will really be fatal. */
|
|
191 kill (getpid (), fatal_error_code);
|
|
192 #endif /* not VMS */
|
|
193 SIGRETURN;
|
|
194 }
|
|
195
|
|
196
|
|
197 DOESNT_RETURN
|
|
198 fatal (CONST char *fmt, ...)
|
|
199 {
|
|
200 va_list args;
|
|
201 va_start (args, fmt);
|
|
202
|
|
203 fprintf (stderr, "\nXEmacs: ");
|
|
204 vfprintf (stderr, GETTEXT (fmt), args);
|
|
205 fprintf (stderr, "\n");
|
|
206
|
|
207 va_end (args);
|
|
208 fflush (stderr);
|
|
209 exit (1);
|
|
210 }
|
|
211
|
|
212 /* #### The following two functions should be replaced with
|
|
213 calls to emacs_doprnt_*() functions, with STREAM set to send out
|
|
214 to stdout or stderr. This is the only way to ensure that
|
|
215 I18N3 works properly (many implementations of the *printf()
|
|
216 functions, including the ones included in glibc, do not implement
|
|
217 the %###$ argument-positioning syntax). */
|
|
218
|
|
219 /* exactly equivalent to fprintf (stderr, fmt, ...) except that it calls
|
|
220 GETTEXT on the format string. */
|
|
221
|
|
222 int
|
|
223 stderr_out (CONST char *fmt, ...)
|
|
224 {
|
|
225 int retval;
|
|
226 va_list args;
|
|
227 va_start (args, fmt);
|
|
228
|
|
229 retval = vfprintf (stderr, GETTEXT (fmt), args);
|
|
230
|
|
231 va_end (args);
|
|
232 /* fflush (stderr); */
|
|
233 return retval;
|
|
234 }
|
|
235
|
|
236 /* exactly equivalent to fprintf (stdout, fmt, ...) except that it calls
|
|
237 GETTEXT on the format string. */
|
|
238
|
|
239 int
|
|
240 stdout_out (CONST char *fmt, ...)
|
|
241 {
|
|
242 int retval;
|
|
243 va_list args;
|
|
244 va_start (args, fmt);
|
|
245
|
|
246 retval = vfprintf (stdout, GETTEXT (fmt), args);
|
|
247
|
|
248 va_end (args);
|
|
249 return retval;
|
|
250 }
|
|
251
|
|
252 #ifdef SIGDANGER
|
|
253
|
|
254 /* Handler for SIGDANGER. */
|
|
255 SIGTYPE
|
|
256 memory_warning_signal (int sig)
|
|
257 {
|
|
258 /* #### bad bad bad; this function shouldn't do anything except
|
|
259 set a flag, or weird corruption could happen. */
|
|
260 signal (sig, memory_warning_signal);
|
|
261
|
|
262 malloc_warning
|
|
263 (GETTEXT ("Operating system warns that virtual memory is running low.\n"));
|
|
264
|
|
265 /* It might be unsafe to call do_auto_save now. */
|
|
266 force_auto_save_soon ();
|
|
267 }
|
|
268 #endif
|
|
269
|
|
270 /* Code for dealing with Lisp access to the Unix command line */
|
|
271
|
|
272 static Lisp_Object
|
|
273 make_arg_list_1 (int argc, char **argv, int skip_args)
|
|
274 {
|
|
275 Lisp_Object result = Qnil;
|
|
276 REGISTER int i;
|
|
277
|
|
278 for (i = argc - 1; i >= 0; i--)
|
|
279 {
|
|
280 if (i == 0 || i > skip_args)
|
|
281 result = Fcons (build_ext_string (argv [i], FORMAT_OS), result);
|
|
282 }
|
|
283 return result;
|
|
284 }
|
|
285
|
|
286 Lisp_Object
|
|
287 make_arg_list (int argc, char **argv)
|
|
288 {
|
|
289 return make_arg_list_1 (argc, argv, 0);
|
|
290 }
|
|
291
|
|
292 /* Calling functions are also responsible for calling free_argc_argv
|
|
293 when they are done with the generated list. */
|
|
294 void
|
|
295 make_argc_argv (Lisp_Object argv_list, int *argc, char ***argv)
|
|
296 {
|
|
297 Lisp_Object next;
|
|
298 int n = XINT (Flength (argv_list));
|
|
299 REGISTER int i;
|
|
300 *argv = (char**) xmalloc ((n+1) * sizeof (char*));
|
|
301
|
|
302 for (i = 0, next = argv_list; i < n; i++, next = XCDR (next))
|
|
303 {
|
|
304 CONST char *temp;
|
|
305 CHECK_STRING (XCAR (next));
|
|
306
|
|
307 GET_C_STRING_EXT_DATA_ALLOCA (XCAR (next), FORMAT_OS, temp);
|
|
308 (*argv) [i] = xstrdup (temp);
|
|
309 }
|
|
310 (*argv) [n] = 0;
|
|
311 *argc = i;
|
|
312 }
|
|
313
|
|
314 void
|
|
315 free_argc_argv (char **argv)
|
|
316 {
|
|
317 int elt = 0;
|
|
318
|
|
319 while (argv[elt])
|
|
320 {
|
|
321 xfree (argv[elt]);
|
|
322 elt++;
|
|
323 }
|
|
324 xfree (argv);
|
|
325 }
|
|
326
|
|
327 static void
|
|
328 init_cmdargs (int argc, char **argv, int skip_args)
|
|
329 {
|
|
330 initial_argv = argv;
|
|
331 initial_argc = argc;
|
|
332
|
|
333 Vcommand_line_args = make_arg_list_1 (argc, argv, skip_args);
|
|
334 }
|
|
335
|
|
336 DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0 /*
|
|
337 Return the program name that was used to run XEmacs.
|
|
338 Any directory names are omitted.
|
|
339 */ )
|
|
340 ()
|
|
341 {
|
|
342 return Fcopy_sequence (Vinvocation_name);
|
|
343 }
|
|
344
|
|
345
|
|
346 #ifdef I18N4
|
|
347 /* #### - don't know why I18N4 on SunOS/JLE
|
|
348 can't deal with this. It's a potential
|
|
349 bug that needs to be looked at. */
|
|
350 # undef RUN_TIME_REMAP
|
|
351 #endif
|
|
352
|
|
353 static DOESNT_RETURN
|
|
354 main_1 (int argc, char **argv, char **envp)
|
|
355 {
|
|
356 char stack_bottom_variable;
|
|
357 int skip_args = 0;
|
|
358 Lisp_Object load_me;
|
|
359 int inhibit_window_system;
|
|
360
|
|
361 #ifdef NeXT
|
|
362 extern int malloc_cookie;
|
|
363
|
|
364 /* 19-Jun-1995 -baw
|
|
365 * NeXT secret magic, ripped from Emacs-for-NS by Carl Edman
|
|
366 * <cedman@princton.edu>. Note that even Carl doesn't know what this
|
|
367 * does; it was provided by NeXT, and it presumable makes NS's mallocator
|
|
368 * work with dumping. But malloc_jumpstart() and malloc_freezedry() in
|
|
369 * unexnext.c are both completely undocumented, even in NS header files!
|
|
370 * But hey, it solves all NS related memory problems, so who's
|
|
371 * complaining?
|
|
372 */
|
|
373 if (initialized)
|
|
374 if (malloc_jumpstart (malloc_cookie) != 0)
|
|
375 printf ("malloc jumpstart failed!\n");
|
|
376 #endif /* NeXT */
|
|
377
|
|
378 #if defined (GNU_MALLOC) && defined (ERROR_CHECK_MALLOC)
|
|
379 #if 0
|
|
380 if (!initialized)
|
|
381 init_free_hook ();
|
|
382 #endif
|
|
383 #endif
|
|
384
|
|
385 /* Map in shared memory, if we are using that. */
|
|
386 #ifdef HAVE_SHM
|
|
387 if (argc > 1 && !strcmp (argv[1], "-nl"))
|
|
388 {
|
|
389 map_in_data (0);
|
|
390 /* The shared memory was just restored, which clobbered this. */
|
|
391 skip_args = 1;
|
|
392 }
|
|
393 else
|
|
394 {
|
|
395 map_in_data (1);
|
|
396 /* The shared memory was just restored, which clobbered this. */
|
|
397 skip_args = 0;
|
|
398 }
|
|
399 #endif
|
|
400
|
|
401 #ifdef VMS
|
|
402 /* If -map specified, map the data file in */
|
|
403 if (argc > 2 && ! strcmp (argv[1], "-map"))
|
|
404 {
|
|
405 skip_args = 2;
|
|
406 mapin_data (argv[2]);
|
|
407 }
|
|
408
|
|
409 #ifdef LINK_CRTL_SHARE
|
|
410 #ifdef SHAREABLE_LIB_BUG
|
|
411 /* Bletcherous shared libraries! */
|
|
412 if (!stdin)
|
|
413 stdin = fdopen (0, "r");
|
|
414 if (!stdout)
|
|
415 stdout = fdopen (1, "w");
|
|
416 if (!stderr)
|
|
417 stderr = fdopen (2, "w");
|
|
418 if (!environ)
|
|
419 environ = envp;
|
|
420 #endif /* SHAREABLE_LIB_BUG */
|
|
421 #endif /* LINK_CRTL_SHARE */
|
|
422 #endif /* VMS */
|
|
423 #if (defined (MSDOS) && defined (EMX)) || defined (WIN32) || defined (_SCO_DS)
|
|
424 environ = envp;
|
|
425 #endif
|
|
426
|
|
427 /* Record (approximately) where the stack begins. */
|
|
428 stack_bottom = &stack_bottom_variable;
|
|
429
|
|
430 #ifdef RUN_TIME_REMAP
|
|
431 if (initialized)
|
|
432 run_time_remap (argv[0]);
|
|
433 #endif
|
|
434
|
|
435 #ifdef USG_SHARED_LIBRARIES
|
|
436 if (bss_end)
|
|
437 brk ((void *) bss_end);
|
|
438 #endif
|
|
439
|
|
440 clearerr (stdin);
|
|
441
|
|
442 #ifdef APOLLO
|
|
443 #ifndef APOLLO_SR10
|
|
444 /* If USE_DOMAIN_ACLS environment variable exists,
|
|
445 use ACLs rather than UNIX modes. */
|
|
446 if (egetenv ("USE_DOMAIN_ACLS"))
|
|
447 default_acl (USE_DEFACL);
|
|
448 #endif
|
|
449 #endif /* APOLLO */
|
|
450
|
|
451 #if defined (HAVE_MMAP) && defined (REL_ALLOC)
|
|
452 /* ralloc can only be used if using the GNU memory allocator. */
|
|
453 init_ralloc ();
|
|
454 #endif
|
|
455
|
|
456 #ifdef HAVE_SOCKS
|
|
457 if (initialized)
|
|
458 SOCKSinit (argv[0]);
|
|
459 #endif /* HAVE_SOCKS */
|
|
460
|
|
461 #ifndef SYSTEM_MALLOC
|
|
462
|
|
463 if (!initialized)
|
|
464 {
|
|
465 /* Arrange to get warning messages as memory fills up. */
|
|
466 memory_warnings (0, malloc_warning);
|
|
467 }
|
|
468 #endif /* not SYSTEM_MALLOC */
|
|
469
|
|
470 #ifdef MSDOS
|
|
471 /* We do all file input/output as binary files. When we need to translate
|
|
472 newlines, we do that manually. */
|
|
473 _fmode = O_BINARY;
|
|
474 (stdin)->_flag &= ~_IOTEXT;
|
|
475 (stdout)->_flag &= ~_IOTEXT;
|
|
476 (stderr)->_flag &= ~_IOTEXT;
|
|
477 #endif /* MSDOS */
|
|
478
|
|
479 #ifdef SET_EMACS_PRIORITY
|
|
480 if (emacs_priority != 0)
|
|
481 nice (-emacs_priority);
|
|
482 setuid (getuid ());
|
|
483 #endif /* SET_EMACS_PRIORITY */
|
|
484
|
|
485 #ifdef EXTRA_INITIALIZE
|
|
486 EXTRA_INITIALIZE;
|
|
487 #endif
|
|
488
|
|
489 #ifdef HAVE_WINDOW_SYSTEM
|
|
490 inhibit_window_system = 0;
|
|
491 #else
|
|
492 inhibit_window_system = 1;
|
|
493 #endif
|
|
494
|
|
495 /* Handle the -t switch, which specifies filename to use as terminal */
|
|
496 if (skip_args + 2 < argc && !strcmp (argv[skip_args + 1], "-t"))
|
|
497 {
|
|
498 int result;
|
|
499
|
|
500 skip_args += 2;
|
|
501 close (0);
|
|
502 close (1);
|
|
503 result = open (argv[skip_args], O_RDWR, 2 );
|
|
504 if (result < 0)
|
|
505 {
|
|
506 fatal ("%s: %s", argv[skip_args], strerror (errno));
|
|
507 }
|
|
508 dup (0);
|
|
509 if (! isatty (0))
|
|
510 fatal ("%s: not a tty", argv[skip_args]);
|
|
511
|
|
512 stderr_out ("Using %s", ttyname (0));
|
|
513 #if 0
|
|
514 stderr_out ("Using %s", argv[skip_args]);
|
|
515 #endif
|
|
516 inhibit_window_system = 1; /* -t => -nw */
|
|
517 }
|
|
518
|
|
519 if (skip_args + 1 < argc
|
|
520 && (!strcmp (argv[skip_args + 1], "-nw")))
|
|
521 {
|
|
522 skip_args += 1;
|
|
523 inhibit_window_system = 1;
|
|
524 }
|
|
525
|
|
526 /* Handle the -batch switch, which means don't do interactive display. */
|
|
527 noninteractive = 0;
|
|
528 if (skip_args + 1 < argc &&
|
|
529 (!strcmp (argv[skip_args + 1], "-batch") ||
|
|
530 !strcmp (argv[skip_args + 1], "--batch")))
|
|
531 {
|
|
532 skip_args += 1;
|
|
533 noninteractive = 1;
|
|
534 }
|
|
535
|
|
536 /* Partially handle the -version and -help switches: they imply -batch,
|
|
537 but are not removed from the list.
|
|
538 */
|
|
539 if (skip_args + 1 < argc &&
|
|
540 (!strcmp (argv[skip_args + 1], "-version") ||
|
|
541 !strcmp (argv[skip_args + 1], "--version") ||
|
|
542 !strcmp (argv[skip_args + 1], "-help") ||
|
|
543 !strcmp (argv[skip_args + 1], "--help")))
|
|
544 noninteractive = 1;
|
|
545
|
|
546 /* Now, figure out which type of console is our first console. */
|
|
547
|
|
548 display_arg = 0;
|
|
549
|
|
550 if (noninteractive)
|
|
551 display_use = "stream";
|
|
552 else
|
|
553 display_use = "tty";
|
|
554
|
|
555 #ifndef HAVE_TTY
|
|
556 if (inhibit_window_system)
|
|
557 fatal ("Sorry, this XEmacs was not compiled with TTY support");
|
|
558 #endif
|
|
559
|
|
560 #ifdef HAVE_WINDOW_SYSTEM
|
|
561 /* Stupid kludge to catch command-line display spec. We can't
|
|
562 handle this argument entirely in window system dependent code
|
|
563 because we don't even know which window system dependent code
|
|
564 to run until we've recognized this argument. */
|
|
565 if (!inhibit_window_system && !noninteractive)
|
|
566 {
|
|
567 int i;
|
|
568 char *disp;
|
|
569
|
|
570 for (i = 1; (i < argc && !display_arg); i++)
|
|
571 {
|
|
572 #ifdef HAVE_X_WINDOWS
|
|
573 if (!strcmp (argv[i], "-d") || !strcmp (argv[i], "-display"))
|
|
574 {
|
|
575 display_arg = 1;
|
|
576 display_use = "x";
|
|
577 }
|
|
578 #endif /* HAVE_X_WINDOWS */
|
|
579 #ifdef HAVE_NEXTSTEP
|
|
580 if (!strcmp (argv[i], "-NXHost") || !strcmp (argv[i], "-MachLaunch"))
|
|
581 {
|
|
582 display_arg = 1;
|
|
583 display_use = "ns";
|
|
584 }
|
|
585 #endif /* HAVE_NEXTSTEP */
|
|
586 }
|
|
587
|
|
588 #ifdef HAVE_X_WINDOWS
|
|
589 disp = getenv ("DISPLAY");
|
|
590
|
|
591 /* null string doesn't count as a display */
|
|
592 if (disp && disp[0])
|
|
593 display_use = "x";
|
|
594
|
|
595 /* Do not set display_arg here. It is only to be set if the display
|
|
596 was specified on the command line. */
|
|
597 #endif
|
|
598 }
|
|
599 #endif /* HAVE_WINDOW_SYSTEM */
|
|
600
|
|
601 noninteractive1 = noninteractive;
|
|
602
|
|
603 /****** Now initialize everything *******/
|
|
604
|
|
605 /* First, do really basic environment initialization -- catching signals
|
|
606 and the like. These functions have no dependence on any part of
|
|
607 the Lisp engine and need to be done both at dump time and at run time. */
|
|
608
|
|
609 init_signals_very_early ();
|
|
610 init_data_very_early (); /* Catch math errors. */
|
|
611 #ifdef LISP_FLOAT_TYPE
|
|
612 init_floatfns_very_early (); /* Catch floating-point math errors. */
|
|
613 #endif
|
|
614 init_process_times_very_early (); /* Initialize our process timers.
|
|
615 As early as possible, of course,
|
|
616 so we can be fairly accurate. */
|
|
617 init_intl_very_early (); /* set up the locale and domain for gettext and
|
|
618 such. */
|
|
619
|
|
620 /* Now initialize the Lisp engine and the like. Done only during
|
|
621 dumping. No dependence on anything that may be in the user's
|
|
622 environment when the dumped XEmacs is run.
|
|
623
|
|
624 We try to do things in an order that minimizes the non-obvious
|
|
625 dependencies between functions. */
|
|
626
|
|
627 if (!initialized)
|
|
628 {
|
|
629 /* Initialize things so that new Lisp objects
|
|
630 can be created and objects can be staticpro'd.
|
|
631 Must be basically the very first thing done
|
|
632 because pretty much all of the initialization
|
|
633 routines below create new objects. */
|
|
634 init_alloc_once_early ();
|
|
635
|
|
636 /* Initialize Qnil, Qt, Qunbound, and the
|
|
637 obarray. After this, symbols can be
|
|
638 interned. This depends on init_alloc_once(). */
|
|
639 init_symbols_once_early ();
|
|
640
|
|
641 /* Declare the basic symbols pertaining to errors,
|
|
642 So that deferror() can be called. */
|
|
643 init_errors_once_early ();
|
|
644
|
|
645 /* Make sure that opaque pointers can be created. */
|
|
646 init_opaque_once_early ();
|
|
647
|
|
648 /* Now declare all the symbols and define all the Lisp primitives.
|
|
649
|
|
650 The *only* thing that the syms_of_*() functions are allowed to do
|
|
651 is call one of the following three functions:
|
|
652
|
|
653 defsymbol()
|
|
654 defsubr()
|
|
655 deferror()
|
|
656 defkeyword()
|
|
657
|
|
658 Order does not matter in these functions.
|
|
659 */
|
|
660
|
|
661 syms_of_abbrev ();
|
|
662 syms_of_alloc ();
|
|
663 syms_of_buffer ();
|
|
664 syms_of_bytecode ();
|
|
665 syms_of_callint ();
|
|
666 syms_of_callproc ();
|
|
667 syms_of_casefiddle ();
|
|
668 syms_of_casetab ();
|
|
669 syms_of_cmdloop ();
|
|
670 syms_of_cmds ();
|
|
671 syms_of_console ();
|
|
672 syms_of_data ();
|
|
673 #ifdef DEBUG_XEMACS
|
|
674 syms_of_debug ();
|
|
675 #endif /* DEBUG_XEMACS */
|
|
676 syms_of_device ();
|
|
677 #ifdef HAVE_DIALOGS
|
|
678 syms_of_dialog ();
|
|
679 #endif
|
|
680 syms_of_dired ();
|
|
681 syms_of_doc ();
|
|
682 syms_of_editfns ();
|
|
683 syms_of_elhash ();
|
|
684 syms_of_emacs ();
|
|
685 syms_of_eval ();
|
|
686 syms_of_event_stream ();
|
|
687 syms_of_events ();
|
|
688 syms_of_extents ();
|
|
689 syms_of_faces ();
|
|
690 syms_of_fileio ();
|
|
691 #ifdef CLASH_DETECTION
|
|
692 syms_of_filelock ();
|
|
693 #endif /* CLASH_DETECTION */
|
|
694 syms_of_floatfns ();
|
|
695 syms_of_fns ();
|
|
696 syms_of_font_lock ();
|
|
697 syms_of_frame ();
|
|
698 syms_of_general ();
|
|
699 syms_of_glyphs ();
|
|
700 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
|
|
701 syms_of_gui ();
|
|
702 #endif
|
|
703 syms_of_indent ();
|
|
704 syms_of_intl ();
|
|
705 syms_of_keymap ();
|
|
706 syms_of_lread ();
|
|
707 syms_of_macros ();
|
|
708 syms_of_marker ();
|
|
709 syms_of_md5 ();
|
|
710 #ifdef HAVE_DATABASE
|
|
711 syms_of_dbm ();
|
|
712 #endif
|
|
713 #ifdef HAVE_MENUBARS
|
|
714 syms_of_menubar ();
|
|
715 #endif
|
|
716 syms_of_minibuf ();
|
|
717 #ifdef MOCKLISP_SUPPORT
|
|
718 syms_of_mocklisp ();
|
|
719 #endif
|
|
720 syms_of_objects ();
|
|
721 syms_of_print ();
|
|
722 #if !defined (NO_SUBPROCESSES)
|
|
723 syms_of_process ();
|
|
724 #endif
|
|
725 syms_of_profile ();
|
|
726 #if defined (HAVE_MMAP) && defined (REL_ALLOC)
|
|
727 syms_of_ralloc ();
|
|
728 #endif /* HAVE_MMAP && REL_ALLOC */
|
|
729 syms_of_rangetab ();
|
|
730 syms_of_redisplay ();
|
|
731 syms_of_search ();
|
|
732 syms_of_signal ();
|
|
733 syms_of_sound ();
|
|
734 syms_of_specifier ();
|
|
735 syms_of_symbols ();
|
|
736 syms_of_syntax ();
|
|
737 #ifdef HAVE_SCROLLBARS
|
|
738 syms_of_scrollbar ();
|
|
739 #endif
|
|
740 #ifdef HAVE_TOOLBARS
|
|
741 syms_of_toolbar ();
|
|
742 #endif
|
|
743 syms_of_undo ();
|
|
744 syms_of_window ();
|
|
745 #ifdef HAVE_TTY
|
|
746 syms_of_console_tty ();
|
|
747 syms_of_device_tty ();
|
|
748 syms_of_objects_tty ();
|
|
749 #endif
|
|
750 #ifdef HAVE_X_WINDOWS
|
|
751 syms_of_device_x ();
|
|
752 #ifdef HAVE_DIALOGS
|
|
753 syms_of_dialog_x ();
|
|
754 #endif
|
|
755 syms_of_event_Xt ();
|
|
756 syms_of_frame_x ();
|
|
757 syms_of_glyphs_x ();
|
|
758 syms_of_objects_x ();
|
|
759 #ifdef HAVE_MENUBARS
|
|
760 syms_of_menubar_x ();
|
|
761 #endif
|
|
762 syms_of_xselect ();
|
|
763 #ifdef EPOCH
|
|
764 syms_of_epoch ();
|
|
765 #endif
|
|
766 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
|
|
767 syms_of_gui_x ();
|
|
768 #endif
|
|
769 #endif /* HAVE_X_WINDOWS */
|
|
770
|
|
771 #ifdef HAVE_NEXTSTEP
|
|
772 syms_of_device_ns ();
|
|
773 syms_of_frame_ns ();
|
|
774 syms_of_glyphs_ns ();
|
|
775 syms_of_objects_ns ();
|
|
776 #ifdef HAVE_MENUBARS
|
|
777 syms_of_menubar_ns ();
|
|
778 #endif
|
|
779 syms_of_nsselect ();
|
|
780 #ifdef HAVE_SCROLLBARS
|
|
781 syms_of_scrollbar_ns ();
|
|
782 #endif
|
|
783 #endif /* HAVE_NEXTSTEP */
|
|
784
|
|
785 #ifdef SYMS_SYSTEM
|
|
786 SYMS_SYSTEM;
|
|
787 #endif
|
|
788
|
|
789 #ifdef SYMS_MACHINE
|
|
790 SYMS_MACHINE;
|
|
791 #endif
|
|
792
|
|
793 #ifdef EMACS_BTL
|
|
794 syms_of_btl ();
|
|
795 #endif
|
|
796
|
|
797 #ifdef ENERGIZE
|
|
798 syms_of_energize ();
|
|
799 #endif
|
|
800
|
|
801 #if defined (GNU_MALLOC) && defined (ERROR_CHECK_MALLOC)
|
|
802 #if 0
|
|
803 syms_of_free_hook ();
|
|
804 #endif
|
|
805 #endif
|
|
806
|
|
807 #ifdef TOOLTALK
|
|
808 syms_of_tooltalk ();
|
|
809 #endif
|
|
810
|
|
811 #ifdef SUNPRO
|
|
812 syms_of_sunpro ();
|
|
813 #endif
|
|
814
|
|
815 /* Now create the subtypes for the types that have them.
|
|
816 We do this before the vars_*() because more symbols
|
|
817 may get initialized here. */
|
|
818
|
|
819 /* Now initialize the console types and associated symbols.
|
|
820 Other than the first function below, the functions may
|
|
821 make exactly the following function/macro calls:
|
|
822
|
|
823 INITIALIZE_CONSOLE_TYPE()
|
|
824 CONSOLE_HAS_METHOD()
|
|
825
|
|
826 For any given console type, the former macro must be called
|
|
827 before the any calls to the latter macro. */
|
|
828
|
|
829 console_type_create ();
|
|
830
|
|
831 console_type_create_stream ();
|
|
832
|
|
833 #ifdef HAVE_TTY
|
|
834 console_type_create_tty ();
|
|
835 console_type_create_device_tty ();
|
|
836 console_type_create_frame_tty ();
|
|
837 console_type_create_objects_tty ();
|
|
838 console_type_create_redisplay_tty ();
|
|
839 #endif
|
|
840
|
|
841 #ifdef HAVE_X_WINDOWS
|
|
842 console_type_create_x ();
|
|
843 console_type_create_device_x ();
|
|
844 console_type_create_frame_x ();
|
|
845 console_type_create_glyphs_x ();
|
|
846 #ifdef HAVE_MENUBARS
|
|
847 console_type_create_menubar_x ();
|
|
848 #endif
|
|
849 console_type_create_objects_x ();
|
|
850 console_type_create_redisplay_x ();
|
|
851 #ifdef HAVE_SCROLLBARS
|
|
852 console_type_create_scrollbar_x ();
|
|
853 #endif
|
|
854 #ifdef HAVE_TOOLBARS
|
|
855 console_type_create_toolbar_x ();
|
|
856 #endif
|
|
857 #endif /* HAVE_X_WINDOWS */
|
|
858
|
|
859 /* Now initialize the specifier types and associated symbols.
|
|
860 Other than the first function below, the functions may
|
|
861 make exactly the following function/macro calls:
|
|
862
|
|
863 INITIALIZE_SPECIFIER_TYPE()
|
|
864 SPECIFIER_HAS_METHOD()
|
|
865
|
|
866 For any given specifier type, the former macro must be called
|
|
867 before the any calls to the latter macro. */
|
|
868
|
|
869 specifier_type_create ();
|
|
870
|
|
871 specifier_type_create_image ();
|
|
872 specifier_type_create_objects ();
|
|
873 #ifdef HAVE_TOOLBARS
|
|
874 specifier_type_create_toolbar ();
|
|
875 #endif
|
|
876
|
|
877 /* Now initialize the structure types and associated symbols.
|
|
878 Other than the first function below, the functions may
|
|
879 make exactly the following function/macro calls:
|
|
880
|
|
881 define_structure_type()
|
|
882 define_structure_type_keyword()
|
|
883
|
|
884 */
|
|
885
|
|
886 structure_type_create ();
|
|
887
|
|
888 structure_type_create_faces ();
|
|
889 structure_type_create_rangetab ();
|
|
890
|
|
891 /* Now initialize the image instantiator formats and associated symbols.
|
|
892 Other than the first function below, the functions may
|
|
893 make exactly the following function/macro calls:
|
|
894
|
|
895 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT()
|
|
896 IIFORMAT_HAS_METHOD()
|
|
897 IIFORMAT_VALID_KEYWORD()
|
|
898
|
|
899 For any given image instantiator format, the first macro must be
|
|
900 called before the any calls to the other macros. */
|
|
901
|
|
902 image_instantiator_format_create ();
|
|
903 #ifdef HAVE_X_WINDOWS
|
|
904 image_instantiator_format_create_glyphs_x ();
|
|
905 #endif /* HAVE_X_WINDOWS */
|
|
906
|
|
907 /* Now initialize the lstream types and associated symbols.
|
|
908 Other than the first function below, the functions may
|
|
909 make exactly the following function/macro calls:
|
|
910
|
|
911 LSTREAM_HAS_METHOD()
|
|
912
|
|
913 */
|
|
914
|
|
915 lstream_type_create ();
|
|
916 lstream_type_create_print ();
|
|
917
|
|
918 /* Now initialize most variables.
|
|
919
|
|
920 These functions may do exactly the following:
|
|
921
|
|
922 DEFVAR_INT()
|
|
923 DEFVAR_LISP()
|
|
924 DEFVAR_BOOL()
|
|
925 DEFER_GETTEXT()
|
|
926 Dynarr_*()
|
|
927 Blocktype_*()
|
|
928 staticpro()
|
|
929 Fprovide(symbol)
|
|
930 intern()
|
|
931 pure_put()
|
|
932 xmalloc()
|
|
933 defsymbol(), if it's absolutely necessary and you're sure that
|
|
934 the symbol isn't referenced anywhere else in the initialization
|
|
935 code
|
|
936 Fset() on a symbol that is unbound
|
|
937 assigning a symbol or constant value to a variable
|
|
938 using a global variable that has been initialized
|
|
939 earlier on in the same function
|
|
940
|
|
941 Any of the object-creating functions on alloc.c: e.g.
|
|
942
|
|
943 make_pure_*()
|
|
944 Fpurecopy()
|
|
945 make_string()
|
|
946 build_string()
|
|
947 make_vector()
|
|
948 make_int()
|
|
949 make_extent()
|
|
950 alloc_lcrecord()
|
|
951 Fcons()
|
|
952 listN()
|
|
953 make_opaque_ptr()
|
|
954 make_opaque_long()
|
|
955
|
|
956 perhaps a few others.
|
|
957 */
|
|
958
|
|
959 /* Now allow Fprovide() statements to be made. */
|
|
960 init_provide_once ();
|
|
961
|
|
962 vars_of_abbrev ();
|
|
963 vars_of_alloc ();
|
|
964 vars_of_buffer ();
|
|
965 vars_of_bytecode ();
|
|
966 vars_of_callint ();
|
|
967 vars_of_callproc ();
|
|
968 vars_of_cmdloop ();
|
|
969 vars_of_cmds ();
|
|
970 vars_of_console ();
|
|
971 vars_of_data ();
|
|
972 #ifdef DEBUG_XEMACS
|
|
973 vars_of_debug ();
|
|
974 #endif
|
|
975 vars_of_console_stream ();
|
|
976 vars_of_device ();
|
|
977 #ifdef HAVE_DIALOGS
|
|
978 vars_of_dialog ();
|
|
979 #endif
|
|
980 vars_of_dired ();
|
|
981 vars_of_doc ();
|
|
982 vars_of_editfns ();
|
|
983 vars_of_elhash ();
|
|
984 vars_of_emacs ();
|
|
985 vars_of_eval ();
|
|
986 vars_of_event_stream ();
|
|
987 vars_of_events ();
|
|
988 vars_of_extents ();
|
|
989 vars_of_faces ();
|
|
990 vars_of_fileio ();
|
|
991 #ifdef CLASH_DETECTION
|
|
992 vars_of_filelock ();
|
|
993 #endif
|
|
994 vars_of_floatfns ();
|
|
995 vars_of_font_lock ();
|
|
996 vars_of_frame ();
|
|
997 vars_of_glyphs ();
|
|
998 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
|
|
999 vars_of_gui ();
|
|
1000 #endif
|
|
1001 vars_of_indent ();
|
|
1002 vars_of_insdel ();
|
|
1003 vars_of_intl ();
|
|
1004 vars_of_keymap ();
|
|
1005 vars_of_lread ();
|
|
1006 vars_of_lstream ();
|
|
1007 vars_of_macros ();
|
|
1008 vars_of_md5 ();
|
|
1009 #ifdef HAVE_DATABASE
|
|
1010 vars_of_dbm ();
|
|
1011 #endif
|
|
1012 #ifdef HAVE_MENUBARS
|
|
1013 vars_of_menubar ();
|
|
1014 #endif
|
|
1015 vars_of_minibuf ();
|
|
1016 #ifdef MOCKLISP_SUPPORT
|
|
1017 vars_of_mocklisp ();
|
|
1018 #endif
|
|
1019 vars_of_objects ();
|
|
1020 vars_of_print ();
|
|
1021 #ifndef NO_SUBPROCESSES
|
|
1022 vars_of_process ();
|
|
1023 #endif
|
|
1024 vars_of_profile ();
|
|
1025 #if defined (HAVE_MMAP) && defined (REL_ALLOC)
|
|
1026 vars_of_ralloc ();
|
|
1027 #endif /* HAVE_MMAP && REL_ALLOC */
|
|
1028 vars_of_redisplay ();
|
|
1029 #ifdef HAVE_SCROLLBARS
|
|
1030 vars_of_scrollbar ();
|
|
1031 #endif
|
|
1032 vars_of_search ();
|
|
1033 vars_of_sound ();
|
|
1034 vars_of_specifier ();
|
|
1035 vars_of_symbols ();
|
|
1036 vars_of_syntax ();
|
|
1037 #ifdef HAVE_TOOLBARS
|
|
1038 vars_of_toolbar ();
|
|
1039 #endif
|
|
1040 vars_of_undo ();
|
|
1041 vars_of_window ();
|
|
1042
|
|
1043 #ifdef HAVE_TTY
|
|
1044 vars_of_console_tty ();
|
|
1045 vars_of_event_tty ();
|
|
1046 vars_of_frame_tty ();
|
|
1047 vars_of_objects_tty ();
|
|
1048 #endif
|
|
1049
|
|
1050 #ifdef HAVE_X_WINDOWS
|
|
1051 vars_of_device_x ();
|
|
1052 #ifdef HAVE_DIALOGS
|
|
1053 vars_of_dialog_x ();
|
|
1054 #endif
|
|
1055 vars_of_event_Xt ();
|
|
1056 vars_of_frame_x ();
|
|
1057 vars_of_glyphs_x ();
|
|
1058 #ifdef HAVE_MENUBARS
|
|
1059 vars_of_menubar_x ();
|
|
1060 #endif
|
|
1061 vars_of_objects_x ();
|
|
1062 vars_of_xselect ();
|
|
1063 #ifdef EPOCH
|
|
1064 vars_of_epoch ();
|
|
1065 #endif
|
|
1066 #ifdef HAVE_SCROLLBARS
|
|
1067 vars_of_scrollbar_x ();
|
|
1068 #endif
|
|
1069 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
|
|
1070 vars_of_gui_x ();
|
|
1071 #endif
|
|
1072 #endif
|
|
1073
|
|
1074 #ifdef ENERGIZE
|
|
1075 vars_of_energize ();
|
|
1076 #endif
|
|
1077
|
|
1078 #ifdef TOOLTALK
|
|
1079 vars_of_tooltalk ();
|
|
1080 #endif
|
|
1081
|
|
1082 #ifdef SUNPRO
|
|
1083 vars_of_sunpro ();
|
|
1084 #endif
|
|
1085
|
|
1086 /* Now initialize any specifier variables. We do this later
|
|
1087 because it has some dependence on the vars initialized
|
|
1088 above.
|
|
1089
|
|
1090 These functions should *only* initialize specifier variables,
|
|
1091 and may make use of the following functions/macros in addition
|
|
1092 to the ones listed above:
|
|
1093
|
|
1094 DEFVAR_SPECIFIER()
|
|
1095 Fmake_specifier()
|
|
1096 set_specifier_fallback()
|
|
1097 set_specifier_caching()
|
|
1098 */
|
|
1099
|
|
1100 specifier_vars_of_glyphs ();
|
|
1101 #ifdef HAVE_MENUBARS
|
|
1102 specifier_vars_of_menubar ();
|
|
1103 #endif
|
|
1104 specifier_vars_of_redisplay ();
|
|
1105 #ifdef HAVE_SCROLLBARS
|
|
1106 specifier_vars_of_scrollbar ();
|
|
1107 #endif
|
|
1108 #ifdef HAVE_TOOLBARS
|
|
1109 specifier_vars_of_toolbar ();
|
|
1110 #endif
|
|
1111 specifier_vars_of_window ();
|
|
1112
|
|
1113 /* Now comes all the rest of the variables that couldn't
|
|
1114 be handled above. There may be dependencies on variables
|
|
1115 initialized above, and dependencies between one complex_vars_()
|
|
1116 function and another. */
|
|
1117
|
|
1118 /* Calls Fmake_range_table(). */
|
|
1119 complex_vars_of_regex ();
|
|
1120 /* Calls Fmake_range_table(). */
|
|
1121 complex_vars_of_search ();
|
|
1122
|
|
1123 /* Calls Fmake_hashtable(). */
|
|
1124 complex_vars_of_event_stream ();
|
|
1125 /* Calls make_lisp_hashtable(). */
|
|
1126 complex_vars_of_extents ();
|
|
1127
|
|
1128 /* Depends on hashtables and specifiers. */
|
|
1129 complex_vars_of_faces ();
|
|
1130
|
|
1131 /* This calls allocate_glyph(), which creates specifiers
|
|
1132 and also relies on a variable (Vthe_nothing_vector) initialized
|
|
1133 above. */
|
|
1134 complex_vars_of_glyphs ();
|
|
1135
|
|
1136 /* This relies on the glyphs just created in the previous function,
|
|
1137 and calls Fadd_spec_to_specifier(), which relies on various
|
|
1138 variables initialized above. */
|
|
1139 #ifdef HAVE_X_WINDOWS
|
|
1140 complex_vars_of_glyphs_x ();
|
|
1141 #endif
|
|
1142
|
|
1143 /* This calls Fmake_glyph_internal(). */
|
|
1144 complex_vars_of_alloc ();
|
|
1145
|
|
1146 /* This calls Fmake_glyph_internal(). */
|
|
1147 #ifdef HAVE_MENUBARS
|
|
1148 complex_vars_of_menubar ();
|
|
1149 #endif
|
|
1150
|
|
1151 /* This calls Fmake_glyph_internal(). */
|
|
1152 #ifdef HAVE_SCROLLBARS
|
|
1153 complex_vars_of_scrollbar ();
|
|
1154 #endif
|
|
1155
|
|
1156 /* This calls allocate_glyph(). */
|
|
1157 complex_vars_of_frame ();
|
|
1158
|
|
1159 /* Depends on hashtables. */
|
|
1160 #ifdef ENERGIZE
|
|
1161 complex_vars_of_energize ();
|
|
1162 #endif
|
|
1163
|
|
1164 /* This calls set_string_char(), which (under Mule) depends on the
|
|
1165 charsets being initialized. */
|
|
1166 complex_vars_of_casetab ();
|
|
1167
|
|
1168 /* This calls Fcopy_syntax_table(), which relies on char tables. */
|
|
1169 complex_vars_of_syntax ();
|
|
1170
|
|
1171 /* This initializes buffer-local variables, sets things up so
|
|
1172 that buffers can be created, and creates a couple of basic
|
|
1173 buffers. This depends on Vstandard_syntax_table and
|
|
1174 Vstandard_category_table (initialized in the previous
|
|
1175 functions), as well as a whole horde of variables that may
|
|
1176 have been initialized above. */
|
|
1177 complex_vars_of_buffer ();
|
|
1178
|
|
1179 /* This initializes console-local variables. */
|
|
1180 complex_vars_of_console ();
|
|
1181
|
|
1182 /* This creates a couple more buffers, and depends on the
|
|
1183 previous function. */
|
|
1184 complex_vars_of_minibuf ();
|
|
1185
|
|
1186 /* These two might call Ffile_name_as_directory(), which
|
|
1187 might depend on all sorts of things; I'm not sure. */
|
|
1188 complex_vars_of_callproc ();
|
|
1189 #ifdef CLASH_DETECTION
|
|
1190 complex_vars_of_filelock ();
|
|
1191 #endif /* CLASH_DETECTION */
|
|
1192
|
|
1193 /* This creates a couple of basic keymaps and depends on Lisp
|
|
1194 hashtables and Ffset() (both of which depend on some variables
|
|
1195 initialized in the vars_of_*() section) and possibly other
|
|
1196 stuff. */
|
|
1197 complex_vars_of_keymap ();
|
|
1198
|
|
1199 if (always_gc) /* purification debugging hack */
|
|
1200 garbage_collect_1 ();
|
|
1201 }
|
|
1202
|
|
1203 /* CONGRATULATIONS!!! We have successfully initialized the Lisp
|
|
1204 engine. */
|
|
1205
|
|
1206 if (initialized)
|
|
1207 {
|
|
1208 /* Stuff that needs to be reset at run time. Order below should
|
|
1209 not matter. */
|
|
1210 reinit_alloc ();
|
|
1211 reinit_eval ();
|
|
1212 }
|
|
1213
|
|
1214 /* Now do further initialization/setup of stuff that is not needed by the
|
|
1215 syms_of_() routines. This involves stuff that only is enabled in
|
|
1216 an interactive run (redisplay, user input, etc.) and stuff that is
|
|
1217 not needed until we start loading Lisp code (the reader). A lot
|
|
1218 of this stuff involves querying the current environment and needs
|
|
1219 to be done both at dump time and at run time. */
|
|
1220
|
|
1221 init_callproc (); /* Set up the process environment (so that egetenv
|
|
1222 works), the basic directory variables
|
|
1223 (exec-directory and so on), and stuff
|
|
1224 related to subprocesses. This should be
|
|
1225 first because many of the functions below
|
|
1226 call egetenv() to get environment variables. */
|
|
1227 init_lread (); /* Set up the Lisp reader. */
|
|
1228 #ifdef MSDOS
|
|
1229 /* Call early 'cause init_environment needs it. */
|
|
1230 init_dosfns ();
|
|
1231 /* Set defaults for several environment variables. */
|
|
1232 init_environment (argc, argv, skip_args);
|
|
1233 #endif
|
|
1234 init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */
|
|
1235 init_buffer (); /* Init default directory of *scratch* buffer */
|
|
1236 #ifdef VMS
|
|
1237 init_vms_input (); /* init_redisplay calls get_tty_device_size,
|
|
1238 that needs this */
|
|
1239 #endif /* VMS */
|
|
1240 init_redisplay (); /* Determine terminal type.
|
|
1241 init_sys_modes uses results */
|
|
1242 #ifdef VMS
|
|
1243 init_vmsproc ();
|
|
1244 init_vmsfns ();
|
|
1245 #endif /* VMS */
|
|
1246 init_event_stream (); /* Set up so we can get user input. */
|
|
1247 init_macros (); /* set up so we can run macros. */
|
|
1248 init_editfns (); /* Determine the name of the user we're running as */
|
|
1249 init_xemacs_process (); /* set up for calling subprocesses */
|
|
1250 #ifdef SUNPRO
|
|
1251 init_sunpro (); /* Set up Sunpro usage tracking */
|
|
1252 #endif
|
|
1253 #if defined (HAVE_NATIVE_SOUND) && defined (hp9000s800)
|
|
1254 init_hpplay ();
|
|
1255 #endif
|
|
1256 #ifdef HAVE_TTY
|
|
1257 init_device_tty ();
|
|
1258 #endif
|
|
1259 #ifdef HAVE_GIF
|
|
1260 init_gif_err ();
|
|
1261 #endif
|
|
1262 init_console_stream (); /* Create the first console */
|
|
1263
|
|
1264 /* try to get the actually pathname of the exec file we are running */
|
|
1265 {
|
|
1266 Vinvocation_name = Fcar (Vcommand_line_args);
|
|
1267 Vinvocation_directory = Vinvocation_name;
|
|
1268
|
|
1269 if (!NILP (Ffile_name_directory (Vinvocation_name)))
|
|
1270 /* invocation-name includes a directory component -- presumably it
|
|
1271 is relative to cwd, not $PATH */
|
|
1272 Vinvocation_directory = Fexpand_file_name (Vinvocation_name,
|
|
1273 Qnil);
|
|
1274 else
|
|
1275 locate_file (Vexec_path, Vinvocation_name, EXEC_SUFFIXES,
|
|
1276 &Vinvocation_directory, X_OK);
|
|
1277
|
|
1278 if (NILP (Vinvocation_directory))
|
|
1279 Vinvocation_directory = Vinvocation_name;
|
|
1280
|
|
1281 Vinvocation_name = Ffile_name_nondirectory (Vinvocation_directory);
|
|
1282 Vinvocation_directory = Ffile_name_directory (Vinvocation_directory);
|
|
1283 }
|
|
1284
|
|
1285 #if defined (LOCALTIME_CACHE) && defined (HAVE_TZSET)
|
|
1286 /* sun's localtime() has a bug. it caches the value of the time
|
|
1287 zone rather than looking it up every time. Since localtime() is
|
|
1288 called to bolt the undumping time into the undumped emacs, this
|
|
1289 results in localtime() ignoring the TZ environment variable.
|
|
1290 This flushes the new TZ value into localtime(). */
|
|
1291 tzset ();
|
|
1292 #endif /* LOCALTIME_CACHE and TZSET */
|
|
1293
|
|
1294 load_me = Qnil;
|
|
1295 if (!initialized)
|
|
1296 {
|
|
1297 /* Handle -l loadup-and-dump, args passed by Makefile. */
|
|
1298 if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l"))
|
|
1299 load_me = build_string (argv[2 + skip_args]);
|
|
1300 #ifdef CANNOT_DUMP
|
|
1301 /* Unless next switch is -nl, load "loadup.el" first thing. */
|
|
1302 if (!(argc > 1 + skip_args && !strcmp (argv[1 + skip_args], "-nl")))
|
|
1303 load_me = build_string ("loadup.el");
|
|
1304 #endif /* CANNOT_DUMP */
|
|
1305 }
|
|
1306
|
|
1307 #ifdef QUANTIFY
|
|
1308 if (initialized)
|
|
1309 quantify_start_recording_data ();
|
|
1310 #endif /* QUANTIFY */
|
|
1311
|
|
1312 initialized = 1;
|
|
1313
|
|
1314 /* This never returns. */
|
|
1315 initial_command_loop (load_me);
|
|
1316 /* NOTREACHED */
|
|
1317 }
|
|
1318
|
|
1319 static JMP_BUF run_temacs_catch;
|
|
1320
|
|
1321 static int run_temacs_argc;
|
|
1322 static char **run_temacs_argv;
|
|
1323 static char *run_temacs_args;
|
|
1324 static int run_temacs_argv_size;
|
|
1325 static int run_temacs_args_size;
|
|
1326
|
|
1327 extern int gc_in_progress;
|
|
1328
|
|
1329 DEFUN ("running-temacs-p",
|
|
1330 Frunning_temacs_p, Srunning_temacs_p, 0, 0, 0 /*
|
|
1331 True if running temacs. This means we are in the dumping stage.
|
|
1332 This is false during normal execution of the `xemacs' program, and
|
|
1333 becomes false once `run-emacs-from-temacs' is run.
|
|
1334 */ )
|
|
1335 ()
|
|
1336 {
|
|
1337 return run_temacs_argc >= 0 ? Qt : Qnil;
|
|
1338 }
|
|
1339
|
|
1340 DEFUN ("run-emacs-from-temacs",
|
|
1341 Frun_emacs_from_temacs, Srun_emacs_from_temacs, 0, MANY, 0 /*
|
|
1342 Do not call this. It will reinitialize your XEmacs. You'll be sorry.
|
|
1343 */ )
|
|
1344 /* If this function is called from startup.el, it will be possible to run
|
|
1345 temacs as an editor using 'temacs -batch -l loadup.el run-temacs', instead
|
|
1346 of having to dump an emacs and then run that (when debugging emacs itself,
|
|
1347 this can be much faster). [Actually, the speed difference isn't that
|
|
1348 much as long as your filesystem is local, and you don't end up with
|
|
1349 a dumped version in case you want to rerun it. This function is most
|
|
1350 useful when used as part of the `make all-elc' command. --ben]
|
|
1351 This will \"restart\" emacs with the specified command-line arguments.
|
|
1352 */
|
|
1353 (nargs, args)
|
|
1354 int nargs;
|
|
1355 Lisp_Object *args;
|
|
1356 {
|
|
1357 int ac;
|
|
1358 Extbyte *wampum;
|
|
1359 int namesize;
|
|
1360 int total_len;
|
|
1361 Lisp_Object orig_invoc_name = Fcar (Vcommand_line_args);
|
|
1362 Extbyte **wampum_all = (Extbyte **) alloca (nargs * sizeof (Extbyte *));
|
|
1363 int *wampum_all_len = (int *) alloca (nargs * sizeof (int));
|
|
1364
|
|
1365 assert (!gc_in_progress);
|
|
1366
|
|
1367 if (run_temacs_argc < 0)
|
|
1368 error ("I've lost my temacs-hood.");
|
|
1369
|
|
1370 /* Need to convert the orig_invoc_name and all of the arguments
|
|
1371 to external format. */
|
|
1372
|
|
1373 GET_STRING_EXT_DATA_ALLOCA (orig_invoc_name, FORMAT_OS, wampum,
|
|
1374 namesize);
|
|
1375 namesize++;
|
|
1376
|
|
1377 for (ac = 0, total_len = namesize; ac < nargs; ac++)
|
|
1378 {
|
|
1379 CHECK_STRING (args[ac]);
|
|
1380 GET_STRING_EXT_DATA_ALLOCA (args[ac], FORMAT_OS,
|
|
1381 wampum_all[ac],
|
|
1382 wampum_all_len[ac]);
|
|
1383 wampum_all_len[ac]++;
|
|
1384 total_len += wampum_all_len[ac];
|
|
1385 }
|
|
1386 DO_REALLOC (run_temacs_args, run_temacs_args_size, total_len, char);
|
|
1387 DO_REALLOC (run_temacs_argv, run_temacs_argv_size, nargs+1, char *);
|
|
1388
|
|
1389 memcpy (run_temacs_args, wampum, namesize);
|
|
1390 run_temacs_argv [0] = run_temacs_args;
|
|
1391 for (ac = 0; ac < nargs; ac++)
|
|
1392 {
|
|
1393 memcpy (run_temacs_args + namesize,
|
|
1394 wampum_all[ac], wampum_all_len[ac]);
|
|
1395 run_temacs_argv [ac + 1] = run_temacs_args + namesize;
|
|
1396 namesize += wampum_all_len[ac];
|
|
1397 }
|
|
1398 run_temacs_argv [nargs + 1] = 0;
|
|
1399 catchlist = NULL; /* Important! Otherwise free_cons() calls in
|
|
1400 condition_case_unwind() may lead to GC death. */
|
|
1401 unbind_to (0, Qnil); /* this closes loadup.el */
|
|
1402 purify_flag = 0;
|
|
1403 run_temacs_argc = nargs + 1;
|
|
1404 report_pure_usage (1, 0);
|
|
1405 LONGJMP (run_temacs_catch, 1);
|
|
1406 return Qnil; /* not reached; warning suppression */
|
|
1407 }
|
|
1408
|
|
1409 /* ARGSUSED */
|
|
1410 DOESNT_RETURN
|
|
1411 main (int argc, char **argv, char **envp)
|
|
1412 {
|
|
1413 #ifdef QUANTIFY
|
|
1414 quantify_stop_recording_data ();
|
|
1415 quantify_clear_data ();
|
|
1416 #endif /* QUANTIFY */
|
|
1417
|
|
1418 suppress_early_backtrace = 0;
|
|
1419 lim_data = 0; /* force reinitialization of this variable */
|
|
1420
|
|
1421 if (sizeof (Lisp_Object) != sizeof (void *))
|
|
1422 abort (); /* Lisp_Object must fit in a word;
|
|
1423 check VALBITS and GCTYPEBITS */
|
|
1424 if (!initialized)
|
|
1425 {
|
|
1426 run_temacs_argc = 0;
|
|
1427 if (! SETJMP (run_temacs_catch))
|
|
1428 main_1 (argc, argv, envp);
|
|
1429 /* run-emacs-from-temacs called */
|
|
1430 argc = run_temacs_argc;
|
|
1431 run_temacs_argc = 0;
|
|
1432 argv = run_temacs_argv;
|
|
1433 #ifdef _SCO_DS
|
|
1434 /*
|
|
1435 This makes absolutely no sense to anyone involved.
|
|
1436 There are several people using this stuff. We've
|
|
1437 compared versions on everything we can think of. We
|
|
1438 can find no difference. However, on both my systems
|
|
1439 environ is a plain old global variable initialized to
|
|
1440 zero. _environ is the one that contains pointers to
|
|
1441 the actual environment.
|
|
1442 Since we can't figure out the difference (and we're
|
|
1443 hours away from a release), this takes a very cowardly
|
|
1444 approach and is bracketed with both a system specific
|
|
1445 preprocessor test and a runtime "do you have this
|
|
1446 problem" test
|
|
1447 06/20/96 robertl@dgii.com
|
|
1448 */
|
|
1449 {
|
|
1450 extern char *_environ ;
|
|
1451 if ((unsigned) environ == 0)
|
|
1452 environ=_environ;
|
|
1453 }
|
|
1454 #endif
|
|
1455 envp = environ;
|
|
1456 }
|
|
1457 run_temacs_argc = -1;
|
|
1458
|
|
1459 main_1 (argc, argv, envp);
|
|
1460 }
|
|
1461
|
|
1462
|
|
1463 DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P" /*
|
|
1464 Exit the XEmacs job and kill it. Ask for confirmation, without argument.
|
|
1465 If ARG is an integer, return ARG as the exit program code.
|
|
1466 If ARG is a string, stuff it as keyboard input.
|
|
1467
|
|
1468 The value of `kill-emacs-hook', if not void,
|
|
1469 is a list of functions (of no args),
|
|
1470 all of which are called before XEmacs is actually killed.
|
|
1471 */ )
|
|
1472 (arg)
|
|
1473 Lisp_Object arg;
|
|
1474 {
|
|
1475 /* This function can GC */
|
|
1476 struct gcpro gcpro1;
|
|
1477
|
|
1478 GCPRO1 (arg);
|
|
1479
|
|
1480 if (feof (stdin))
|
|
1481 arg = Qt;
|
|
1482
|
|
1483 if (!preparing_for_armageddon && !noninteractive)
|
|
1484 run_hook (Qkill_emacs_hook);
|
|
1485
|
|
1486 /* make sure no quitting from now on!! */
|
|
1487 dont_check_for_quit = 1;
|
|
1488 Vinhibit_quit = Qt;
|
|
1489
|
|
1490 if (!preparing_for_armageddon)
|
|
1491 {
|
|
1492 Lisp_Object concons;
|
|
1493
|
|
1494 /* Normally, go ahead and delete all the consoles now.
|
|
1495 Some unmentionably lame window systems (MS Wwwww...... eek,
|
|
1496 I can't even say it) don't properly clean up after themselves,
|
|
1497 and even for those that do, it might be cleaner this way.
|
|
1498 If we're going down, however, we don't do this (might
|
|
1499 be too dangerous), and if we get a crash somewhere within
|
|
1500 this loop, we'll still autosave and won't try this again. */
|
|
1501 CONSOLE_LOOP (concons)
|
|
1502 delete_console_internal (XCONSOLE (XCAR (concons)), 1, 1, 0);
|
|
1503 }
|
|
1504
|
|
1505 UNGCPRO;
|
|
1506
|
|
1507 shut_down_emacs (0, ((STRINGP (arg)) ? arg : Qnil));
|
|
1508
|
|
1509 exit ((INTP (arg)) ? XINT (arg)
|
|
1510 #ifdef VMS
|
|
1511 : 1
|
|
1512 #else
|
|
1513 : 0
|
|
1514 #endif
|
|
1515 );
|
|
1516 /* NOTREACHED */
|
|
1517 return Qnil; /* I'm sick of the compiler warning */
|
|
1518 }
|
|
1519
|
|
1520 /* Perform an orderly shutdown of XEmacs. Autosave any modified
|
|
1521 buffers, kill any child processes, clean up the terminal modes (if
|
|
1522 we're in the foreground), and other stuff like that. Don't perform
|
|
1523 any redisplay; this may be called when XEmacs is shutting down in
|
|
1524 the background, or after its X connection has died.
|
|
1525
|
|
1526 If SIG is a signal number, print a message for it.
|
|
1527
|
|
1528 This is called by fatal signal handlers, X protocol error handlers,
|
|
1529 and Fkill_emacs. */
|
|
1530 static void
|
|
1531 shut_down_emacs (int sig, Lisp_Object stuff)
|
|
1532 {
|
|
1533 /* This function can GC */
|
|
1534 /* Prevent running of hooks and other non-essential stuff
|
|
1535 from now on. */
|
|
1536 preparing_for_armageddon = 1;
|
|
1537
|
|
1538 /* In case frames or windows are screwed up, avoid assertion
|
|
1539 failures here */
|
|
1540 Vinhibit_quit = Qt;
|
|
1541
|
|
1542 #ifdef QUANTIFY
|
|
1543 quantify_stop_recording_data ();
|
|
1544 #endif /* QUANTIFY */
|
|
1545
|
|
1546 /* This is absolutely the most important thing to do, so make sure
|
|
1547 we do it now, before anything else. We might have crashed and
|
|
1548 be in a weird inconsistent state, and potentially anything could
|
|
1549 set off another protection fault and cause us to bail out
|
|
1550 immediately. */
|
|
1551 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */
|
|
1552
|
|
1553 fflush (stdout);
|
|
1554 reset_all_consoles ();
|
|
1555 if (sig && sig != SIGTERM)
|
|
1556 {
|
|
1557 stderr_out ("\nFatal error (%d).\n", sig);
|
|
1558 stderr_out
|
|
1559 ("Your files have been auto-saved.\n"
|
|
1560 "Use `M-x recover-session' to recover them.\n"
|
|
1561 "\n"
|
|
1562 "Please report this bug to the address `crashes@xemacs.org'.\n"
|
2
|
1563 "*MAKE SURE* to include as much configuration information as\n"
|
|
1564 "possible; at the very least what OS and hardware you are running\n"
|
|
1565 "on, and hopefully also what compiler and compiler options the\n"
|
|
1566 "binary was compiled with, what options XEmacs was compiled with,\n"
|
|
1567 "whether you are using a prebuilt binary from ftp.xemacs.org or\n"
|
|
1568 "compiled XEmacs yourself for your system, etc.\n"
|
|
1569 "\n"
|
0
|
1570 "If at all possible, *please* try to obtain a C stack backtrace;\n"
|
|
1571 "it will help us immensely in determining what went wrong.\n"
|
|
1572 "To do this, locate the core file that was produced as a result\n"
|
|
1573 "of this crash (it's usually called `core' and is located in the\n"
|
|
1574 "directory in which you started XEmacs, or maybe in your home\n"
|
|
1575 "directory), and type\n"
|
|
1576 "\n"
|
|
1577 " gdb ");
|
|
1578 {
|
2
|
1579 CONST char *name;
|
0
|
1580 char *dir = 0;
|
|
1581
|
|
1582 /* Now try to determine the actual path to the executable,
|
|
1583 to try to make the backtrace-determination process as foolproof
|
|
1584 as possible. */
|
|
1585 if (GC_STRINGP (Vinvocation_name))
|
|
1586 name = (char *) string_data (XSTRING (Vinvocation_name));
|
|
1587 else
|
|
1588 name = "xemacs";
|
|
1589 if (GC_STRINGP (Vinvocation_directory))
|
|
1590 dir = (char *) string_data (XSTRING (Vinvocation_directory));
|
|
1591 if (!dir || dir[0] != '/')
|
|
1592 stderr_out ("`which %s`", name);
|
|
1593 else if (dir[strlen (dir) - 1] != '/')
|
|
1594 stderr_out ("%s/%s", dir, name);
|
|
1595 else
|
|
1596 stderr_out ("%s%s", dir, name);
|
|
1597 }
|
|
1598 stderr_out
|
|
1599 (" core\n\n"
|
|
1600 "then type `where' when the debugger prompt comes up.\n"
|
|
1601 "(If you don't have GDB on your system, you might have DBX,\n"
|
|
1602 "or XDB, or SDB. A similar procedure should work for all of\n"
|
|
1603 "these. Ask your system administrator if you need more help.)\n");
|
|
1604 }
|
|
1605
|
|
1606 stuff_buffered_input (stuff);
|
|
1607
|
|
1608 kill_buffer_processes (Qnil);
|
|
1609
|
|
1610 #ifdef CLASH_DETECTION
|
|
1611 unlock_all_files ();
|
|
1612 #endif
|
|
1613
|
|
1614 #ifdef TOOLTALK
|
|
1615 tt_session_quit (tt_default_session ());
|
2
|
1616 #if 0
|
|
1617 /* The following crashes when built on X11R5 and run on X11R6 */
|
0
|
1618 tt_close ();
|
|
1619 #endif
|
2
|
1620 #endif /* TOOLTALK */
|
0
|
1621
|
|
1622 #ifdef VMS
|
|
1623 kill_vms_processes ();
|
|
1624 #endif
|
|
1625 }
|
|
1626
|
|
1627
|
|
1628 #ifndef CANNOT_DUMP
|
|
1629 /* Nothing like this can be implemented on an Apollo.
|
|
1630 What a loss! */
|
|
1631
|
2
|
1632 extern char my_edata[];
|
0
|
1633
|
|
1634 #ifdef HAVE_SHM
|
|
1635
|
|
1636 DEFUN ("dump-emacs-data", Fdump_emacs_data, Sdump_emacs_data, 1, 1, 0 /*
|
|
1637 Dump current state of XEmacs into data file FILENAME.
|
|
1638 This function exists on systems that use HAVE_SHM.
|
|
1639 */ )
|
|
1640 (intoname)
|
|
1641 Lisp_Object intoname;
|
|
1642 {
|
|
1643 /* This function can GC */
|
|
1644 int opurify;
|
|
1645 struct gcpro gcpro1;
|
|
1646 GCPRO1 (intoname);
|
|
1647
|
|
1648 CHECK_STRING (intoname);
|
|
1649 intoname = Fexpand_file_name (intoname, Qnil);
|
|
1650
|
|
1651 opurify = purify_flag;
|
|
1652 purify_flag = 0;
|
|
1653
|
|
1654 fflush (stderr);
|
|
1655 fflush (stdout);
|
|
1656
|
|
1657 disksave_object_finalization ();
|
|
1658 release_breathing_space ();
|
|
1659
|
|
1660 /* Tell malloc where start of impure now is */
|
|
1661 /* Also arrange for warnings when nearly out of space. */
|
|
1662 #ifndef SYSTEM_MALLOC
|
|
1663 memory_warnings (&my_edata, malloc_warning);
|
|
1664 #endif
|
|
1665 UNGCPRO;
|
|
1666 map_out_data (string_data (XSTRING (intoname)));
|
|
1667
|
|
1668 purify_flag = opurify;
|
|
1669
|
|
1670 return Qnil;
|
|
1671 }
|
|
1672
|
|
1673 #else /* not HAVE_SHM */
|
|
1674
|
|
1675 DEFUN ("dump-emacs", Fdump_emacs, Sdump_emacs, 2, 2, 0 /*
|
|
1676 Dump current state of XEmacs into executable file FILENAME.
|
|
1677 Take symbols from SYMFILE (presumably the file you executed to run XEmacs).
|
|
1678 This is used in the file `loadup.el' when building XEmacs.
|
|
1679
|
|
1680 Remember to set `command-line-processed' to nil before dumping
|
|
1681 if you want the dumped XEmacs to process its command line
|
|
1682 and announce itself normally when it is run.
|
|
1683 */ )
|
|
1684 (intoname, symname)
|
|
1685 Lisp_Object intoname, symname;
|
|
1686 {
|
|
1687 /* This function can GC */
|
|
1688 struct gcpro gcpro1, gcpro2;
|
|
1689 int opurify;
|
|
1690
|
|
1691 GCPRO2 (intoname, symname);
|
|
1692
|
|
1693 #ifdef FREE_CHECKING
|
|
1694 Freally_free (Qnil);
|
|
1695
|
|
1696 /* When we're dumping, we can't use the debugging free() */
|
|
1697
|
|
1698 disable_free_hook ();
|
|
1699 #endif
|
|
1700
|
|
1701 CHECK_STRING (intoname);
|
|
1702 intoname = Fexpand_file_name (intoname, Qnil);
|
|
1703 if (!NILP (symname))
|
|
1704 {
|
|
1705 CHECK_STRING (symname);
|
|
1706 if (string_length (XSTRING (symname)) > 0)
|
|
1707 symname = Fexpand_file_name (symname, Qnil);
|
|
1708 else
|
|
1709 symname = Qnil;
|
|
1710 }
|
|
1711
|
|
1712 opurify = purify_flag;
|
|
1713 purify_flag = 0;
|
|
1714
|
|
1715 report_pure_usage (1, 1);
|
|
1716
|
|
1717 fflush (stderr);
|
|
1718 fflush (stdout);
|
|
1719
|
|
1720 disksave_object_finalization ();
|
|
1721 release_breathing_space ();
|
|
1722
|
|
1723 #ifdef VMS
|
|
1724 mapout_data (string_data (XSTRING (intoname)));
|
|
1725 #else
|
|
1726 /* Tell malloc where start of impure now is */
|
|
1727 /* Also arrange for warnings when nearly out of space. */
|
|
1728 #ifndef SYSTEM_MALLOC
|
|
1729 memory_warnings (&my_edata, malloc_warning);
|
|
1730 #endif
|
|
1731
|
|
1732 UNGCPRO;
|
|
1733
|
|
1734 #if defined (MSDOS) && defined (EMX)
|
|
1735 {
|
|
1736 int fd = open ((char *) string_data (XSTRING (intoname)),
|
|
1737 O_WRONLY|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE);
|
|
1738 if (!fd) {
|
|
1739 error ("Failure operating on %s", string_data (XSTRING (intoname)));
|
|
1740 } else {
|
|
1741 _core (fd);
|
|
1742 close (fd);
|
|
1743 }
|
|
1744 }
|
|
1745 #else /* not MSDOS and EMX */
|
|
1746 {
|
|
1747 CONST char *intoname_ext;
|
|
1748 CONST char *symname_ext;
|
|
1749
|
|
1750 GET_C_STRING_FILENAME_DATA_ALLOCA (intoname, intoname_ext);
|
|
1751 if (STRINGP (symname))
|
|
1752 GET_C_STRING_FILENAME_DATA_ALLOCA (symname, symname_ext);
|
|
1753 else
|
|
1754 symname_ext = 0;
|
|
1755 /* here we break our rule that the filename conversion should
|
|
1756 be performed at the actual time that the system call is made.
|
|
1757 It's a whole lot easier to do the conversion here than to
|
|
1758 modify all the unexec routines to ensure that filename
|
|
1759 conversion is applied everywhere. Don't worry about memory
|
|
1760 leakage because this call only happens once. */
|
|
1761 unexec ((char *) intoname_ext, (char *) symname_ext,
|
|
1762 (unsigned int) &my_edata,
|
|
1763 0, 0);
|
|
1764 }
|
|
1765 #endif /* not MSDOS and EMX */
|
|
1766 #endif /* not VMS */
|
|
1767
|
|
1768 purify_flag = opurify;
|
|
1769
|
|
1770 return Qnil;
|
|
1771 }
|
|
1772
|
|
1773 #endif /* not HAVE_SHM */
|
|
1774
|
|
1775 #endif /* not CANNOT_DUMP */
|
|
1776
|
|
1777 #ifndef SEPCHAR
|
|
1778 #define SEPCHAR ':'
|
|
1779 #endif
|
|
1780
|
|
1781 Lisp_Object
|
|
1782 decode_env_path (CONST char *evarname, CONST char *defalt)
|
|
1783 {
|
|
1784 REGISTER CONST char *path = 0;
|
|
1785 REGISTER CONST char *p;
|
|
1786 Lisp_Object lpath = Qnil;
|
|
1787
|
|
1788 if (evarname)
|
|
1789 path = (char *) egetenv (evarname);
|
|
1790 if (!path)
|
|
1791 path = defalt;
|
|
1792 if (!path)
|
|
1793 return (Qnil);
|
|
1794
|
|
1795 #if defined (MSDOS) || defined (WIN32)
|
|
1796 dostounix_filename (path);
|
|
1797 #endif
|
|
1798
|
|
1799 while (1)
|
|
1800 {
|
|
1801 p = strchr (path, SEPCHAR);
|
|
1802 if (!p) p = path + strlen (path);
|
|
1803 lpath = Fcons (((p != path)
|
|
1804 ? make_string ((CONST Bufbyte *) path, p - path)
|
|
1805 : Qnil),
|
|
1806 lpath);
|
|
1807 if (*p)
|
|
1808 path = p + 1;
|
|
1809 else
|
|
1810 break;
|
|
1811 }
|
|
1812 return Fnreverse (lpath);
|
|
1813 }
|
|
1814
|
|
1815 DEFUN ("noninteractive", Fnoninteractive, Snoninteractive, 0, 0, 0 /*
|
|
1816 Non-nil return value means XEmacs is running without interactive terminal.
|
|
1817 */ )
|
|
1818 ()
|
|
1819 {
|
|
1820 return ((noninteractive) ? Qt : Qnil);
|
|
1821 }
|
|
1822
|
|
1823 /* This flag is useful to define if you're under a debugger; this way, you
|
|
1824 can put a breakpoint of assert_failed() and debug multiple problems
|
|
1825 in one session without having to recompile. */
|
|
1826 /* #define ASSERTIONS_DONT_ABORT */
|
|
1827
|
|
1828 #ifdef USE_ASSERTIONS
|
|
1829 /* This highly dubious kludge ... shut up Jamie, I'm tired of your slagging. */
|
|
1830
|
|
1831 DOESNT_RETURN
|
|
1832 assert_failed (CONST char *file, int line, CONST char *expr)
|
|
1833 {
|
|
1834 stderr_out ("Fatal error: assertion failed, file %s, line %d, %s\n",
|
|
1835 file, line, expr);
|
|
1836 #undef abort /* avoid infinite #define loop... */
|
|
1837 #ifndef ASSERTIONS_DONT_ABORT
|
|
1838 abort ();
|
|
1839 #endif
|
|
1840 }
|
|
1841 #endif /* USE_ASSERTIONS */
|
|
1842
|
|
1843 #ifdef QUANTIFY
|
|
1844 DEFUN ("quantify-start-recording-data", Fquantify_start_recording_data,
|
|
1845 Squantify_start_recording_data, 0, 0, 0 /*
|
|
1846 Start recording Quantify data.
|
|
1847 */)
|
|
1848 ()
|
|
1849 {
|
|
1850 quantify_start_recording_data ();
|
|
1851 return Qnil;
|
|
1852 }
|
|
1853
|
|
1854 DEFUN ("quantify-stop-recording-data", Fquantify_stop_recording_data,
|
|
1855 Squantify_stop_recording_data, 0, 0, 0 /*
|
|
1856 Stop recording Quantify data.
|
|
1857 */)
|
|
1858 ()
|
|
1859 {
|
|
1860 quantify_stop_recording_data ();
|
|
1861 return Qnil;
|
|
1862 }
|
|
1863
|
|
1864 DEFUN ("quantify-clear-data", Fquantify_clear_data,
|
|
1865 Squantify_clear_data, 0, 0, 0 /*
|
|
1866 Clear all Quantify data.
|
|
1867 */)
|
|
1868 ()
|
|
1869 {
|
|
1870 quantify_clear_data ();
|
|
1871 return Qnil;
|
|
1872 }
|
|
1873 #endif /* QUANTIFY */
|
|
1874
|
|
1875 void
|
|
1876 syms_of_emacs (void)
|
|
1877 {
|
|
1878 #ifndef CANNOT_DUMP
|
|
1879 #ifdef HAVE_SHM
|
|
1880 defsubr (&Sdump_emacs_data);
|
|
1881 #else
|
|
1882 defsubr (&Sdump_emacs);
|
|
1883 #endif
|
|
1884 #endif /* !CANNOT_DUMP */
|
|
1885
|
|
1886 defsubr (&Srun_emacs_from_temacs);
|
|
1887 defsubr (&Srunning_temacs_p);
|
|
1888 defsubr (&Sinvocation_name);
|
|
1889 defsubr (&Skill_emacs);
|
|
1890 defsubr (&Snoninteractive);
|
|
1891
|
|
1892 #ifdef QUANTIFY
|
|
1893 defsubr (&Squantify_start_recording_data);
|
|
1894 defsubr (&Squantify_stop_recording_data);
|
|
1895 defsubr (&Squantify_clear_data);
|
|
1896 #endif /* QUANTIFY */
|
|
1897
|
|
1898 defsymbol (&Qkill_emacs_hook, "kill-emacs-hook");
|
|
1899 defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs");
|
|
1900 }
|
|
1901
|
|
1902 void
|
|
1903 vars_of_emacs (void)
|
|
1904 {
|
|
1905 DEFVAR_BOOL ("suppress-early-error-handler-backtrace",
|
|
1906 &suppress_early_backtrace /*
|
|
1907 Non-nil means early error handler shouldn't print a backtrace
|
|
1908 */ );
|
|
1909
|
|
1910 DEFVAR_LISP ("command-line-args", &Vcommand_line_args /*
|
|
1911 Args passed by shell to XEmacs, as a list of strings.
|
|
1912 */ );
|
|
1913
|
|
1914 DEFVAR_LISP ("invocation-name", &Vinvocation_name /*
|
|
1915 The program name that was used to run XEmacs.
|
|
1916 Any directory names are omitted.
|
|
1917 */ );
|
|
1918
|
|
1919 DEFVAR_LISP ("invocation-directory", &Vinvocation_directory /*
|
|
1920 The directory in which the XEmacs executable was found, to run it.
|
|
1921 The value is simply the program name if that directory's name is not known.
|
|
1922 */ );
|
|
1923
|
|
1924 #if 0 /* FSFmacs */
|
|
1925 xxDEFVAR_LISP ("installation-directory", &Vinstallation_directory,
|
|
1926 "A directory within which to look for the `lib-src' and `etc' directories.\n"
|
|
1927 "This is non-nil when we can't find those directories in their standard\n"
|
|
1928 "installed locations, but we can find them\n"
|
|
1929 "near where the XEmacs executable was found.");
|
|
1930 #endif
|
|
1931
|
|
1932 DEFVAR_LISP ("system-type", &Vsystem_type /*
|
|
1933 Value is symbol indicating type of operating system you are using.
|
|
1934 */ );
|
|
1935 Vsystem_type = intern (SYSTEM_TYPE);
|
|
1936
|
|
1937 #ifndef EMACS_CONFIGURATION
|
|
1938 # define EMACS_CONFIGURATION "UNKNOWN"
|
|
1939 #endif
|
|
1940 DEFVAR_LISP ("system-configuration", &Vsystem_configuration /*
|
|
1941 Value is string indicating configuration XEmacs was built for.
|
|
1942 */ );
|
|
1943 Vsystem_configuration = Fpurecopy (build_string (EMACS_CONFIGURATION));
|
|
1944
|
|
1945 DEFVAR_BOOL ("noninteractive", &noninteractive1 /*
|
|
1946 Non-nil means XEmacs is running without interactive terminal.
|
|
1947 */ );
|
|
1948
|
|
1949 DEFVAR_INT ("emacs-priority", &emacs_priority /*
|
|
1950 Priority for XEmacs to run at.
|
|
1951 This value is effective only if set before XEmacs is dumped,
|
|
1952 and only if the XEmacs executable is installed with setuid to permit
|
|
1953 it to change priority. (XEmacs sets its uid back to the real uid.)
|
|
1954 Currently, you need to define SET_EMACS_PRIORITY in `config.h'
|
|
1955 before you compile XEmacs, to enable the code for this feature.
|
|
1956 */ );
|
|
1957 emacs_priority = 0;
|
|
1958 }
|