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