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