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