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