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
|
94
|
70 #ifndef SYSTEM_MALLOC
|
|
71 extern void *(*__malloc_hook)(size_t);
|
|
72 extern void *(*__realloc_hook)(void *, size_t);
|
|
73 extern void (*__free_hook)(void *);
|
|
74 #endif /* not SYSTEM_MALLOC */
|
|
75
|
0
|
76 /* Command line args from shell, as list of strings */
|
|
77 Lisp_Object Vcommand_line_args;
|
|
78
|
|
79 /* Set nonzero after XEmacs has started up the first time.
|
|
80 Prevents reinitialization of the Lisp world and keymaps
|
|
81 on subsequent starts. */
|
|
82 int initialized;
|
|
83
|
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 ();
|
|
944 syms_of_mule_coding ();
|
|
945 #ifdef HAVE_WNN
|
|
946 syms_of_mule_wnn ();
|
|
947 #endif
|
|
948 #ifdef HAVE_CANNA
|
|
949 syms_of_mule_canna ();
|
|
950 #endif /* HAVE_CANNA */
|
|
951 #endif /* MULE */
|
|
952
|
0
|
953 #ifdef SYMS_SYSTEM
|
|
954 SYMS_SYSTEM;
|
|
955 #endif
|
|
956
|
|
957 #ifdef SYMS_MACHINE
|
|
958 SYMS_MACHINE;
|
|
959 #endif
|
|
960
|
|
961 #ifdef EMACS_BTL
|
163
|
962 syms_of_btl ();
|
0
|
963 #endif
|
|
964
|
|
965 #if defined (GNU_MALLOC) && defined (ERROR_CHECK_MALLOC)
|
|
966 #if 0
|
|
967 syms_of_free_hook ();
|
|
968 #endif
|
|
969 #endif
|
|
970
|
|
971 #ifdef TOOLTALK
|
|
972 syms_of_tooltalk ();
|
|
973 #endif
|
|
974
|
|
975 #ifdef SUNPRO
|
|
976 syms_of_sunpro ();
|
|
977 #endif
|
|
978
|
|
979 /* Now create the subtypes for the types that have them.
|
|
980 We do this before the vars_*() because more symbols
|
|
981 may get initialized here. */
|
|
982
|
|
983 /* Now initialize the console types and associated symbols.
|
|
984 Other than the first function below, the functions may
|
|
985 make exactly the following function/macro calls:
|
|
986
|
|
987 INITIALIZE_CONSOLE_TYPE()
|
|
988 CONSOLE_HAS_METHOD()
|
|
989
|
|
990 For any given console type, the former macro must be called
|
|
991 before the any calls to the latter macro. */
|
|
992
|
|
993 console_type_create ();
|
|
994
|
|
995 console_type_create_stream ();
|
|
996
|
|
997 #ifdef HAVE_TTY
|
|
998 console_type_create_tty ();
|
|
999 console_type_create_device_tty ();
|
|
1000 console_type_create_frame_tty ();
|
|
1001 console_type_create_objects_tty ();
|
|
1002 console_type_create_redisplay_tty ();
|
|
1003 #endif
|
|
1004
|
|
1005 #ifdef HAVE_X_WINDOWS
|
|
1006 console_type_create_x ();
|
|
1007 console_type_create_device_x ();
|
|
1008 console_type_create_frame_x ();
|
|
1009 console_type_create_glyphs_x ();
|
|
1010 #ifdef HAVE_MENUBARS
|
|
1011 console_type_create_menubar_x ();
|
|
1012 #endif
|
|
1013 console_type_create_objects_x ();
|
|
1014 console_type_create_redisplay_x ();
|
|
1015 #ifdef HAVE_SCROLLBARS
|
|
1016 console_type_create_scrollbar_x ();
|
|
1017 #endif
|
|
1018 #ifdef HAVE_TOOLBARS
|
|
1019 console_type_create_toolbar_x ();
|
|
1020 #endif
|
|
1021 #endif /* HAVE_X_WINDOWS */
|
|
1022
|
213
|
1023 #ifdef HAVE_MS_WINDOWS
|
|
1024 console_type_create_mswindows ();
|
|
1025 console_type_create_device_mswindows ();
|
|
1026 console_type_create_frame_mswindows ();
|
|
1027 console_type_create_objects_mswindows ();
|
|
1028 console_type_create_redisplay_mswindows ();
|
225
|
1029 # ifdef HAVE_SCROLLBARS
|
|
1030 console_type_create_scrollbar_mswindows ();
|
|
1031 # endif
|
231
|
1032 #ifdef HAVE_MENUBARS
|
|
1033 console_type_create_menubar_mswindows ();
|
|
1034 #endif
|
209
|
1035 #endif
|
|
1036
|
0
|
1037 /* Now initialize the specifier types and associated symbols.
|
|
1038 Other than the first function below, the functions may
|
|
1039 make exactly the following function/macro calls:
|
|
1040
|
|
1041 INITIALIZE_SPECIFIER_TYPE()
|
|
1042 SPECIFIER_HAS_METHOD()
|
|
1043
|
|
1044 For any given specifier type, the former macro must be called
|
|
1045 before the any calls to the latter macro. */
|
|
1046
|
|
1047 specifier_type_create ();
|
|
1048
|
|
1049 specifier_type_create_image ();
|
|
1050 specifier_type_create_objects ();
|
|
1051 #ifdef HAVE_TOOLBARS
|
|
1052 specifier_type_create_toolbar ();
|
|
1053 #endif
|
|
1054
|
|
1055 /* Now initialize the structure types and associated symbols.
|
|
1056 Other than the first function below, the functions may
|
|
1057 make exactly the following function/macro calls:
|
|
1058
|
|
1059 define_structure_type()
|
|
1060 define_structure_type_keyword()
|
|
1061
|
|
1062 */
|
|
1063
|
|
1064 structure_type_create ();
|
|
1065
|
70
|
1066 structure_type_create_chartab ();
|
0
|
1067 structure_type_create_faces ();
|
|
1068 structure_type_create_rangetab ();
|
223
|
1069 structure_type_create_hashtable ();
|
0
|
1070
|
|
1071 /* Now initialize the image instantiator formats and associated symbols.
|
|
1072 Other than the first function below, the functions may
|
|
1073 make exactly the following function/macro calls:
|
|
1074
|
|
1075 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT()
|
|
1076 IIFORMAT_HAS_METHOD()
|
|
1077 IIFORMAT_VALID_KEYWORD()
|
|
1078
|
|
1079 For any given image instantiator format, the first macro must be
|
|
1080 called before the any calls to the other macros. */
|
|
1081
|
|
1082 image_instantiator_format_create ();
|
|
1083 #ifdef HAVE_X_WINDOWS
|
|
1084 image_instantiator_format_create_glyphs_x ();
|
|
1085 #endif /* HAVE_X_WINDOWS */
|
|
1086
|
|
1087 /* Now initialize the lstream types and associated symbols.
|
|
1088 Other than the first function below, the functions may
|
|
1089 make exactly the following function/macro calls:
|
|
1090
|
|
1091 LSTREAM_HAS_METHOD()
|
|
1092
|
|
1093 */
|
|
1094
|
|
1095 lstream_type_create ();
|
70
|
1096 #ifdef MULE
|
|
1097 lstream_type_create_mule_coding ();
|
|
1098 #endif
|
0
|
1099 lstream_type_create_print ();
|
|
1100
|
|
1101 /* Now initialize most variables.
|
|
1102
|
|
1103 These functions may do exactly the following:
|
|
1104
|
|
1105 DEFVAR_INT()
|
|
1106 DEFVAR_LISP()
|
|
1107 DEFVAR_BOOL()
|
|
1108 DEFER_GETTEXT()
|
|
1109 Dynarr_*()
|
|
1110 Blocktype_*()
|
|
1111 staticpro()
|
|
1112 Fprovide(symbol)
|
|
1113 intern()
|
|
1114 pure_put()
|
|
1115 xmalloc()
|
|
1116 defsymbol(), if it's absolutely necessary and you're sure that
|
|
1117 the symbol isn't referenced anywhere else in the initialization
|
|
1118 code
|
|
1119 Fset() on a symbol that is unbound
|
|
1120 assigning a symbol or constant value to a variable
|
|
1121 using a global variable that has been initialized
|
|
1122 earlier on in the same function
|
|
1123
|
|
1124 Any of the object-creating functions on alloc.c: e.g.
|
|
1125
|
|
1126 make_pure_*()
|
|
1127 Fpurecopy()
|
|
1128 make_string()
|
|
1129 build_string()
|
|
1130 make_vector()
|
|
1131 make_int()
|
|
1132 make_extent()
|
|
1133 alloc_lcrecord()
|
|
1134 Fcons()
|
|
1135 listN()
|
|
1136 make_opaque_ptr()
|
|
1137 make_opaque_long()
|
|
1138
|
|
1139 perhaps a few others.
|
|
1140 */
|
|
1141
|
|
1142 /* Now allow Fprovide() statements to be made. */
|
|
1143 init_provide_once ();
|
|
1144
|
|
1145 vars_of_abbrev ();
|
|
1146 vars_of_alloc ();
|
136
|
1147 #ifdef HAVE_X_WINDOWS
|
|
1148 vars_of_balloon_x ();
|
|
1149 #endif
|
0
|
1150 vars_of_buffer ();
|
|
1151 vars_of_bytecode ();
|
|
1152 vars_of_callint ();
|
|
1153 vars_of_callproc ();
|
|
1154 vars_of_cmdloop ();
|
|
1155 vars_of_cmds ();
|
|
1156 vars_of_console ();
|
|
1157 vars_of_data ();
|
|
1158 #ifdef DEBUG_XEMACS
|
|
1159 vars_of_debug ();
|
|
1160 #endif
|
|
1161 vars_of_console_stream ();
|
|
1162 vars_of_device ();
|
|
1163 #ifdef HAVE_DIALOGS
|
|
1164 vars_of_dialog ();
|
|
1165 #endif
|
|
1166 vars_of_dired ();
|
|
1167 vars_of_doc ();
|
|
1168 vars_of_editfns ();
|
|
1169 vars_of_elhash ();
|
|
1170 vars_of_emacs ();
|
|
1171 vars_of_eval ();
|
|
1172 vars_of_event_stream ();
|
|
1173 vars_of_events ();
|
|
1174 vars_of_extents ();
|
|
1175 vars_of_faces ();
|
|
1176 vars_of_fileio ();
|
|
1177 #ifdef CLASH_DETECTION
|
|
1178 vars_of_filelock ();
|
|
1179 #endif
|
|
1180 vars_of_floatfns ();
|
|
1181 vars_of_font_lock ();
|
|
1182 vars_of_frame ();
|
|
1183 vars_of_glyphs ();
|
|
1184 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
|
|
1185 vars_of_gui ();
|
|
1186 #endif
|
|
1187 vars_of_indent ();
|
|
1188 vars_of_insdel ();
|
|
1189 vars_of_intl ();
|
70
|
1190 #ifdef HAVE_XIM
|
|
1191 #ifdef XIM_MOTIF
|
|
1192 vars_of_input_method_motif ();
|
|
1193 #else /* XIM_XLIB */
|
|
1194 vars_of_input_method_xlib ();
|
|
1195 #endif
|
|
1196 #endif /* HAVE_XIM */
|
0
|
1197 vars_of_keymap ();
|
|
1198 vars_of_lread ();
|
|
1199 vars_of_lstream ();
|
|
1200 vars_of_macros ();
|
|
1201 vars_of_md5 ();
|
|
1202 #ifdef HAVE_DATABASE
|
|
1203 vars_of_dbm ();
|
|
1204 #endif
|
|
1205 #ifdef HAVE_MENUBARS
|
|
1206 vars_of_menubar ();
|
|
1207 #endif
|
|
1208 vars_of_minibuf ();
|
|
1209 vars_of_objects ();
|
|
1210 vars_of_print ();
|
|
1211 #ifndef NO_SUBPROCESSES
|
|
1212 vars_of_process ();
|
|
1213 #endif
|
|
1214 vars_of_profile ();
|
255
|
1215 #if defined (HAVE_MMAP) && defined (REL_ALLOC) && !defined(DOUG_LEA_MALLOC)
|
0
|
1216 vars_of_ralloc ();
|
|
1217 #endif /* HAVE_MMAP && REL_ALLOC */
|
|
1218 vars_of_redisplay ();
|
|
1219 #ifdef HAVE_SCROLLBARS
|
|
1220 vars_of_scrollbar ();
|
|
1221 #endif
|
|
1222 vars_of_search ();
|
|
1223 vars_of_sound ();
|
|
1224 vars_of_specifier ();
|
|
1225 vars_of_symbols ();
|
|
1226 vars_of_syntax ();
|
|
1227 #ifdef HAVE_TOOLBARS
|
|
1228 vars_of_toolbar ();
|
|
1229 #endif
|
|
1230 vars_of_undo ();
|
|
1231 vars_of_window ();
|
|
1232
|
|
1233 #ifdef HAVE_TTY
|
|
1234 vars_of_console_tty ();
|
|
1235 vars_of_event_tty ();
|
|
1236 vars_of_frame_tty ();
|
|
1237 vars_of_objects_tty ();
|
|
1238 #endif
|
|
1239
|
|
1240 #ifdef HAVE_X_WINDOWS
|
|
1241 vars_of_device_x ();
|
|
1242 #ifdef HAVE_DIALOGS
|
|
1243 vars_of_dialog_x ();
|
|
1244 #endif
|
|
1245 vars_of_event_Xt ();
|
|
1246 vars_of_frame_x ();
|
|
1247 vars_of_glyphs_x ();
|
|
1248 #ifdef HAVE_MENUBARS
|
|
1249 vars_of_menubar_x ();
|
|
1250 #endif
|
|
1251 vars_of_objects_x ();
|
|
1252 vars_of_xselect ();
|
|
1253 #ifdef EPOCH
|
|
1254 vars_of_epoch ();
|
|
1255 #endif
|
|
1256 #ifdef HAVE_SCROLLBARS
|
|
1257 vars_of_scrollbar_x ();
|
|
1258 #endif
|
|
1259 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
|
|
1260 vars_of_gui_x ();
|
|
1261 #endif
|
|
1262 #endif
|
|
1263
|
213
|
1264 #ifdef HAVE_MS_WINDOWS
|
|
1265 vars_of_device_mswindows ();
|
|
1266 vars_of_console_mswindows ();
|
|
1267 vars_of_event_mswindows ();
|
|
1268 vars_of_frame_mswindows ();
|
|
1269 vars_of_objects_mswindows ();
|
221
|
1270 vars_of_select_mswindows ();
|
225
|
1271 #ifdef HAVE_SCROLLBARS
|
|
1272 vars_of_scrollbar_mswindows ();
|
|
1273 #endif
|
231
|
1274 #ifdef HAVE_MENUBARS
|
|
1275 vars_of_menubar_mswindows ();
|
|
1276 #endif
|
209
|
1277 #endif
|
|
1278
|
70
|
1279 #ifdef MULE
|
|
1280 vars_of_mule ();
|
|
1281 vars_of_mule_charset ();
|
|
1282 vars_of_mule_coding ();
|
|
1283 #ifdef HAVE_WNN
|
|
1284 vars_of_mule_wnn ();
|
|
1285 #endif
|
|
1286 #ifdef HAVE_CANNA
|
|
1287 vars_of_mule_canna ();
|
|
1288 #endif /* HAVE_CANNA */
|
|
1289 #endif /* MULE */
|
|
1290
|
0
|
1291 #ifdef TOOLTALK
|
|
1292 vars_of_tooltalk ();
|
|
1293 #endif
|
|
1294
|
|
1295 #ifdef SUNPRO
|
|
1296 vars_of_sunpro ();
|
|
1297 #endif
|
|
1298
|
|
1299 /* Now initialize any specifier variables. We do this later
|
|
1300 because it has some dependence on the vars initialized
|
|
1301 above.
|
|
1302
|
|
1303 These functions should *only* initialize specifier variables,
|
|
1304 and may make use of the following functions/macros in addition
|
|
1305 to the ones listed above:
|
|
1306
|
|
1307 DEFVAR_SPECIFIER()
|
|
1308 Fmake_specifier()
|
|
1309 set_specifier_fallback()
|
|
1310 set_specifier_caching()
|
|
1311 */
|
|
1312
|
|
1313 specifier_vars_of_glyphs ();
|
|
1314 #ifdef HAVE_MENUBARS
|
|
1315 specifier_vars_of_menubar ();
|
|
1316 #endif
|
|
1317 specifier_vars_of_redisplay ();
|
|
1318 #ifdef HAVE_SCROLLBARS
|
|
1319 specifier_vars_of_scrollbar ();
|
|
1320 #endif
|
|
1321 #ifdef HAVE_TOOLBARS
|
|
1322 specifier_vars_of_toolbar ();
|
|
1323 #endif
|
|
1324 specifier_vars_of_window ();
|
|
1325
|
|
1326 /* Now comes all the rest of the variables that couldn't
|
|
1327 be handled above. There may be dependencies on variables
|
|
1328 initialized above, and dependencies between one complex_vars_()
|
|
1329 function and another. */
|
|
1330
|
|
1331 /* Calls Fmake_range_table(). */
|
|
1332 complex_vars_of_regex ();
|
|
1333 /* Calls Fmake_range_table(). */
|
|
1334 complex_vars_of_search ();
|
|
1335
|
|
1336 /* Calls make_lisp_hashtable(). */
|
|
1337 complex_vars_of_extents ();
|
163
|
1338
|
0
|
1339 /* Depends on hashtables and specifiers. */
|
|
1340 complex_vars_of_faces ();
|
|
1341
|
70
|
1342 #ifdef MULE
|
|
1343 /* These two depend on hashtables and various variables declared
|
|
1344 earlier. The second may also depend on the first. */
|
|
1345 complex_vars_of_mule_charset ();
|
|
1346 complex_vars_of_mule_coding ();
|
|
1347 #endif
|
|
1348
|
0
|
1349 /* This calls allocate_glyph(), which creates specifiers
|
|
1350 and also relies on a variable (Vthe_nothing_vector) initialized
|
70
|
1351 above. It also calls make_ext_string(), which under Mule
|
|
1352 could require that the charsets be initialized. */
|
0
|
1353 complex_vars_of_glyphs ();
|
|
1354
|
175
|
1355 /* These rely on the glyphs just created in the previous function,
|
|
1356 and call Fadd_spec_to_specifier(), which relies on various
|
0
|
1357 variables initialized above. */
|
|
1358 #ifdef HAVE_X_WINDOWS
|
|
1359 complex_vars_of_glyphs_x ();
|
|
1360 #endif
|
|
1361
|
|
1362 /* This calls Fmake_glyph_internal(). */
|
|
1363 complex_vars_of_alloc ();
|
|
1364
|
|
1365 /* This calls Fmake_glyph_internal(). */
|
|
1366 #ifdef HAVE_MENUBARS
|
|
1367 complex_vars_of_menubar ();
|
|
1368 #endif
|
|
1369
|
|
1370 /* This calls Fmake_glyph_internal(). */
|
|
1371 #ifdef HAVE_SCROLLBARS
|
|
1372 complex_vars_of_scrollbar ();
|
|
1373 #endif
|
|
1374
|
|
1375 /* This calls allocate_glyph(). */
|
|
1376 complex_vars_of_frame ();
|
|
1377
|
70
|
1378 /* This calls Fcopy_category_table() under Mule, which calls who
|
|
1379 knows what. */
|
|
1380 complex_vars_of_chartab ();
|
|
1381
|
0
|
1382 /* This calls set_string_char(), which (under Mule) depends on the
|
|
1383 charsets being initialized. */
|
|
1384 complex_vars_of_casetab ();
|
|
1385
|
|
1386 /* This calls Fcopy_syntax_table(), which relies on char tables. */
|
|
1387 complex_vars_of_syntax ();
|
|
1388
|
|
1389 /* This initializes buffer-local variables, sets things up so
|
|
1390 that buffers can be created, and creates a couple of basic
|
|
1391 buffers. This depends on Vstandard_syntax_table and
|
|
1392 Vstandard_category_table (initialized in the previous
|
|
1393 functions), as well as a whole horde of variables that may
|
|
1394 have been initialized above. */
|
|
1395 complex_vars_of_buffer ();
|
|
1396
|
|
1397 /* This initializes console-local variables. */
|
|
1398 complex_vars_of_console ();
|
|
1399
|
|
1400 /* This creates a couple more buffers, and depends on the
|
|
1401 previous function. */
|
|
1402 complex_vars_of_minibuf ();
|
|
1403
|
|
1404 /* These two might call Ffile_name_as_directory(), which
|
|
1405 might depend on all sorts of things; I'm not sure. */
|
|
1406 complex_vars_of_callproc ();
|
|
1407 #ifdef CLASH_DETECTION
|
|
1408 complex_vars_of_filelock ();
|
|
1409 #endif /* CLASH_DETECTION */
|
|
1410
|
|
1411 /* This creates a couple of basic keymaps and depends on Lisp
|
|
1412 hashtables and Ffset() (both of which depend on some variables
|
|
1413 initialized in the vars_of_*() section) and possibly other
|
|
1414 stuff. */
|
|
1415 complex_vars_of_keymap ();
|
175
|
1416 /* Calls Fmake_hashtable() and creates a keymap */
|
|
1417 complex_vars_of_event_stream ();
|
0
|
1418
|
|
1419 if (always_gc) /* purification debugging hack */
|
|
1420 garbage_collect_1 ();
|
|
1421 }
|
|
1422
|
|
1423 /* CONGRATULATIONS!!! We have successfully initialized the Lisp
|
|
1424 engine. */
|
|
1425
|
|
1426 if (initialized)
|
|
1427 {
|
|
1428 /* Stuff that needs to be reset at run time. Order below should
|
|
1429 not matter. */
|
|
1430 reinit_alloc ();
|
|
1431 reinit_eval ();
|
70
|
1432 #ifdef MULE_REGEXP
|
|
1433 reinit_mule_category ();
|
|
1434 #endif
|
0
|
1435 }
|
|
1436
|
|
1437 /* Now do further initialization/setup of stuff that is not needed by the
|
|
1438 syms_of_() routines. This involves stuff that only is enabled in
|
|
1439 an interactive run (redisplay, user input, etc.) and stuff that is
|
|
1440 not needed until we start loading Lisp code (the reader). A lot
|
|
1441 of this stuff involves querying the current environment and needs
|
|
1442 to be done both at dump time and at run time. */
|
|
1443
|
|
1444 init_callproc (); /* Set up the process environment (so that egetenv
|
|
1445 works), the basic directory variables
|
|
1446 (exec-directory and so on), and stuff
|
|
1447 related to subprocesses. This should be
|
|
1448 first because many of the functions below
|
|
1449 call egetenv() to get environment variables. */
|
|
1450 init_lread (); /* Set up the Lisp reader. */
|
|
1451 #ifdef MSDOS
|
|
1452 /* Call early 'cause init_environment needs it. */
|
|
1453 init_dosfns ();
|
|
1454 /* Set defaults for several environment variables. */
|
|
1455 init_environment (argc, argv, skip_args);
|
|
1456 #endif
|
|
1457 init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */
|
|
1458 init_buffer (); /* Init default directory of *scratch* buffer */
|
195
|
1459
|
|
1460 #ifdef WINDOWSNT
|
|
1461 init_environment();
|
|
1462 init_ntproc();
|
|
1463 #endif
|
|
1464
|
0
|
1465 init_redisplay (); /* Determine terminal type.
|
|
1466 init_sys_modes uses results */
|
|
1467 init_event_stream (); /* Set up so we can get user input. */
|
|
1468 init_macros (); /* set up so we can run macros. */
|
|
1469 init_editfns (); /* Determine the name of the user we're running as */
|
|
1470 init_xemacs_process (); /* set up for calling subprocesses */
|
|
1471 #ifdef SUNPRO
|
|
1472 init_sunpro (); /* Set up Sunpro usage tracking */
|
|
1473 #endif
|
|
1474 #if defined (HAVE_NATIVE_SOUND) && defined (hp9000s800)
|
|
1475 init_hpplay ();
|
|
1476 #endif
|
|
1477 #ifdef HAVE_TTY
|
|
1478 init_device_tty ();
|
|
1479 #endif
|
|
1480 #ifdef HAVE_GIF
|
|
1481 init_gif_err ();
|
|
1482 #endif
|
|
1483 init_console_stream (); /* Create the first console */
|
|
1484
|
173
|
1485 /* try to get the actual pathname of the exec file we are running */
|
233
|
1486 if (!restart)
|
0
|
1487 {
|
|
1488 Vinvocation_name = Fcar (Vcommand_line_args);
|
233
|
1489 if (XSTRING_DATA(Vinvocation_name)[0] == '-')
|
|
1490 {
|
|
1491 /* XEmacs as a login shell, oh goody! */
|
|
1492 Vinvocation_name = build_string(getenv("SHELL"));
|
|
1493 }
|
0
|
1494 Vinvocation_directory = Vinvocation_name;
|
|
1495
|
|
1496 if (!NILP (Ffile_name_directory (Vinvocation_name)))
|
|
1497 /* invocation-name includes a directory component -- presumably it
|
|
1498 is relative to cwd, not $PATH */
|
|
1499 Vinvocation_directory = Fexpand_file_name (Vinvocation_name,
|
|
1500 Qnil);
|
|
1501 else
|
|
1502 locate_file (Vexec_path, Vinvocation_name, EXEC_SUFFIXES,
|
|
1503 &Vinvocation_directory, X_OK);
|
|
1504
|
|
1505 if (NILP (Vinvocation_directory))
|
|
1506 Vinvocation_directory = Vinvocation_name;
|
|
1507
|
|
1508 Vinvocation_name = Ffile_name_nondirectory (Vinvocation_directory);
|
|
1509 Vinvocation_directory = Ffile_name_directory (Vinvocation_directory);
|
|
1510 }
|
|
1511
|
|
1512 #if defined (LOCALTIME_CACHE) && defined (HAVE_TZSET)
|
|
1513 /* sun's localtime() has a bug. it caches the value of the time
|
|
1514 zone rather than looking it up every time. Since localtime() is
|
|
1515 called to bolt the undumping time into the undumped emacs, this
|
|
1516 results in localtime() ignoring the TZ environment variable.
|
|
1517 This flushes the new TZ value into localtime(). */
|
|
1518 tzset ();
|
|
1519 #endif /* LOCALTIME_CACHE and TZSET */
|
|
1520
|
|
1521 load_me = Qnil;
|
|
1522 if (!initialized)
|
|
1523 {
|
|
1524 /* Handle -l loadup-and-dump, args passed by Makefile. */
|
|
1525 if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l"))
|
80
|
1526 load_me = build_string (argv[2 + skip_args]);
|
239
|
1527 #if 0 /* CANNOT_DUMP - this can never be right in XEmacs --andyp */
|
0
|
1528 /* Unless next switch is -nl, load "loadup.el" first thing. */
|
|
1529 if (!(argc > 1 + skip_args && !strcmp (argv[1 + skip_args], "-nl")))
|
|
1530 load_me = build_string ("loadup.el");
|
|
1531 #endif /* CANNOT_DUMP */
|
|
1532 }
|
|
1533
|
|
1534 #ifdef QUANTIFY
|
|
1535 if (initialized)
|
|
1536 quantify_start_recording_data ();
|
|
1537 #endif /* QUANTIFY */
|
|
1538
|
|
1539 initialized = 1;
|
|
1540
|
|
1541 /* This never returns. */
|
|
1542 initial_command_loop (load_me);
|
|
1543 /* NOTREACHED */
|
|
1544 }
|
|
1545
|
20
|
1546
|
16
|
1547 /* Sort the args so we can find the most important ones
|
|
1548 at the beginning of argv. */
|
|
1549
|
|
1550 /* First, here's a table of all the standard options. */
|
|
1551
|
|
1552 struct standard_args
|
|
1553 {
|
|
1554 CONST char * CONST name;
|
|
1555 CONST char * CONST longname;
|
|
1556 int priority;
|
|
1557 int nargs;
|
|
1558 };
|
|
1559
|
|
1560 static struct standard_args standard_args[] =
|
|
1561 {
|
|
1562 /* Handled by main_1 above: */
|
|
1563 { "-nl", "--no-shared-memory", 100, 0 },
|
|
1564 { "-t", "--terminal", 95, 1 },
|
|
1565 { "-nw", "--no-windows", 90, 0 },
|
|
1566 { "-batch", "--batch", 85, 0 },
|
|
1567 { "-help", "--help", 80, 0 },
|
|
1568 { "-version", "--version", 75, 0 },
|
|
1569 { "-V", 0, 75, 0 },
|
|
1570 { "-d", "--display", 80, 1 },
|
|
1571 { "-display", 0, 80, 1 },
|
|
1572 { "-NXHost", 0, 79, 0 },
|
|
1573 { "-MachLaunch", 0, 79, 0},
|
|
1574
|
|
1575 /* Handled by command-line-early in startup.el: */
|
|
1576 { "-q", "--no-init-file", 50, 0 },
|
|
1577 { "-unmapped", 0, 50, 0 },
|
|
1578 { "-no-init-file", 0, 50, 0 },
|
207
|
1579 { "-vanilla", "--vanilla", 50, 0 },
|
239
|
1580 { "-no-autoloads", "--no-autoloads", 50, 0 },
|
16
|
1581 { "-no-site-file", "--no-site-file", 40, 0 },
|
207
|
1582 { "-no-packages", "--no-packages", 35, 0 },
|
16
|
1583 { "-u", "--user", 30, 1 },
|
|
1584 { "-user", 0, 30, 1 },
|
|
1585 { "-debug-init", "--debug-init", 20, 0 },
|
|
1586
|
|
1587 /* Xt options: */
|
|
1588 { "-i", "--icon-type", 15, 0 },
|
|
1589 { "-itype", 0, 15, 0 },
|
|
1590 { "-iconic", "--iconic", 15, 0 },
|
|
1591 { "-bg", "--background-color", 10, 1 },
|
|
1592 { "-background", 0, 10, 1 },
|
|
1593 { "-fg", "--foreground-color", 10, 1 },
|
|
1594 { "-foreground", 0, 10, 1 },
|
|
1595 { "-bd", "--border-color", 10, 1 },
|
|
1596 { "-bw", "--border-width", 10, 1 },
|
|
1597 { "-ib", "--internal-border", 10, 1 },
|
|
1598 { "-ms", "--mouse-color", 10, 1 },
|
|
1599 { "-cr", "--cursor-color", 10, 1 },
|
|
1600 { "-fn", "--font", 10, 1 },
|
|
1601 { "-font", 0, 10, 1 },
|
|
1602 { "-g", "--geometry", 10, 1 },
|
|
1603 { "-geometry", 0, 10, 1 },
|
|
1604 { "-T", "--title", 10, 1 },
|
|
1605 { "-title", 0, 10, 1 },
|
|
1606 { "-name", "--name", 10, 1 },
|
|
1607 { "-xrm", "--xrm", 10, 1 },
|
|
1608 { "-r", "--reverse-video", 5, 0 },
|
|
1609 { "-rv", 0, 5, 0 },
|
|
1610 { "-reverse", 0, 5, 0 },
|
|
1611 { "-hb", "--horizontal-scroll-bars", 5, 0 },
|
|
1612 { "-vb", "--vertical-scroll-bars", 5, 0 },
|
163
|
1613
|
16
|
1614 /* These have the same priority as ordinary file name args,
|
|
1615 so they are not reordered with respect to those. */
|
|
1616 { "-L", "--directory", 0, 1 },
|
|
1617 { "-directory", 0, 0, 1 },
|
|
1618 { "-l", "--load", 0, 1 },
|
|
1619 { "-load", 0, 0, 1 },
|
|
1620 { "-f", "--funcall", 0, 1 },
|
|
1621 { "-funcall", 0, 0, 1 },
|
|
1622 { "-eval", "--eval", 0, 1 },
|
|
1623 { "-insert", "--insert", 0, 1 },
|
|
1624 /* This should be processed after ordinary file name args and the like. */
|
|
1625 { "-kill", "--kill", -10, 0 },
|
|
1626 };
|
|
1627
|
|
1628 /* Reorder the elements of ARGV (assumed to have ARGC elements)
|
|
1629 so that the highest priority ones come first.
|
|
1630 Do not change the order of elements of equal priority.
|
|
1631 If an option takes an argument, keep it and its argument together. */
|
|
1632
|
|
1633 static void
|
|
1634 sort_args (int argc, char **argv)
|
|
1635 {
|
185
|
1636 char **new = xnew_array (char *, argc);
|
16
|
1637 /* For each element of argv,
|
|
1638 the corresponding element of options is:
|
|
1639 0 for an option that takes no arguments,
|
|
1640 1 for an option that takes one argument, etc.
|
|
1641 -1 for an ordinary non-option argument. */
|
185
|
1642 int *options = xnew_array (int, argc);
|
|
1643 int *priority = xnew_array (int, argc);
|
16
|
1644 int to = 1;
|
|
1645 int from;
|
|
1646 int i;
|
78
|
1647 int end_of_options_p = 0;
|
16
|
1648
|
|
1649 /* Categorize all the options,
|
|
1650 and figure out which argv elts are option arguments. */
|
|
1651 for (from = 1; from < argc; from++)
|
|
1652 {
|
|
1653 options[from] = -1;
|
|
1654 priority[from] = 0;
|
78
|
1655 /* Pseudo options "--" and "run-temacs" indicate end of options */
|
|
1656 if (!strcmp (argv[from], "--") ||
|
|
1657 !strcmp (argv[from], "run-temacs"))
|
|
1658 end_of_options_p = 1;
|
|
1659 if (!end_of_options_p && argv[from][0] == '-')
|
16
|
1660 {
|
|
1661 int match, thislen;
|
|
1662 char *equals;
|
|
1663
|
|
1664 /* Look for a match with a known old-fashioned option. */
|
|
1665 for (i = 0; i < countof (standard_args); i++)
|
|
1666 if (!strcmp (argv[from], standard_args[i].name))
|
|
1667 {
|
|
1668 options[from] = standard_args[i].nargs;
|
|
1669 priority[from] = standard_args[i].priority;
|
|
1670 if (from + standard_args[i].nargs >= argc)
|
|
1671 fatal ("Option `%s' requires an argument\n", argv[from]);
|
|
1672 from += standard_args[i].nargs;
|
|
1673 goto done;
|
|
1674 }
|
|
1675
|
|
1676 /* Look for a match with a known long option.
|
|
1677 MATCH is -1 if no match so far, -2 if two or more matches so far,
|
|
1678 >= 0 (the table index of the match) if just one match so far. */
|
|
1679 if (argv[from][1] == '-')
|
|
1680 {
|
|
1681 match = -1;
|
|
1682 thislen = strlen (argv[from]);
|
|
1683 equals = strchr (argv[from], '=');
|
|
1684 if (equals != 0)
|
|
1685 thislen = equals - argv[from];
|
|
1686
|
|
1687 for (i = 0; i < countof (standard_args); i++)
|
|
1688 if (standard_args[i].longname
|
|
1689 && !strncmp (argv[from], standard_args[i].longname,
|
|
1690 thislen))
|
|
1691 {
|
|
1692 if (match == -1)
|
|
1693 match = i;
|
|
1694 else
|
|
1695 match = -2;
|
|
1696 }
|
|
1697
|
|
1698 /* If we found exactly one match, use that. */
|
|
1699 if (match >= 0)
|
|
1700 {
|
|
1701 options[from] = standard_args[match].nargs;
|
|
1702 priority[from] = standard_args[match].priority;
|
|
1703 /* If --OPTION=VALUE syntax is used,
|
|
1704 this option uses just one argv element. */
|
|
1705 if (equals != 0)
|
|
1706 options[from] = 0;
|
|
1707 if (from + options[from] >= argc)
|
|
1708 fatal ("Option `%s' requires an argument\n", argv[from]);
|
|
1709 from += options[from];
|
|
1710 }
|
|
1711 }
|
|
1712 done: ;
|
|
1713 }
|
|
1714 }
|
|
1715
|
|
1716 /* Copy the arguments, in order of decreasing priority, to NEW. */
|
|
1717 new[0] = argv[0];
|
|
1718 while (to < argc)
|
|
1719 {
|
|
1720 int best = -1;
|
|
1721 int best_priority = -9999;
|
|
1722
|
|
1723 /* Find the highest priority remaining option.
|
|
1724 If several have equal priority, take the first of them. */
|
|
1725 for (from = 1; from < argc; from++)
|
|
1726 {
|
|
1727 if (argv[from] != 0 && priority[from] > best_priority)
|
|
1728 {
|
|
1729 best_priority = priority[from];
|
|
1730 best = from;
|
|
1731 }
|
|
1732 /* Skip option arguments--they are tied to the options. */
|
|
1733 if (options[from] > 0)
|
|
1734 from += options[from];
|
|
1735 }
|
163
|
1736
|
16
|
1737 if (best < 0)
|
|
1738 abort ();
|
|
1739
|
|
1740 /* Copy the highest priority remaining option, with its args, to NEW. */
|
|
1741 new[to++] = argv[best];
|
|
1742 for (i = 0; i < options[best]; i++)
|
|
1743 new[to++] = argv[best + i + 1];
|
|
1744
|
|
1745 /* Clear out this option in ARGV. */
|
|
1746 argv[best] = 0;
|
|
1747 for (i = 0; i < options[best]; i++)
|
|
1748 argv[best + i + 1] = 0;
|
|
1749 }
|
|
1750
|
|
1751 memcpy (argv, new, sizeof (char *) * argc);
|
|
1752 }
|
|
1753
|
0
|
1754 static JMP_BUF run_temacs_catch;
|
|
1755
|
|
1756 static int run_temacs_argc;
|
|
1757 static char **run_temacs_argv;
|
|
1758 static char *run_temacs_args;
|
|
1759 static int run_temacs_argv_size;
|
|
1760 static int run_temacs_args_size;
|
|
1761
|
|
1762 extern int gc_in_progress;
|
|
1763
|
20
|
1764 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /*
|
0
|
1765 True if running temacs. This means we are in the dumping stage.
|
|
1766 This is false during normal execution of the `xemacs' program, and
|
|
1767 becomes false once `run-emacs-from-temacs' is run.
|
20
|
1768 */
|
|
1769 ())
|
0
|
1770 {
|
|
1771 return run_temacs_argc >= 0 ? Qt : Qnil;
|
|
1772 }
|
|
1773
|
20
|
1774 DEFUN ("run-emacs-from-temacs", Frun_emacs_from_temacs, 0, MANY, 0, /*
|
0
|
1775 Do not call this. It will reinitialize your XEmacs. You'll be sorry.
|
20
|
1776 */
|
0
|
1777 /* If this function is called from startup.el, it will be possible to run
|
|
1778 temacs as an editor using 'temacs -batch -l loadup.el run-temacs', instead
|
|
1779 of having to dump an emacs and then run that (when debugging emacs itself,
|
20
|
1780 this can be much faster)). [Actually, the speed difference isn't that
|
0
|
1781 much as long as your filesystem is local, and you don't end up with
|
|
1782 a dumped version in case you want to rerun it. This function is most
|
|
1783 useful when used as part of the `make all-elc' command. --ben]
|
185
|
1784 This will "restart" emacs with the specified command-line arguments.
|
0
|
1785 */
|
70
|
1786 (int nargs, Lisp_Object *args))
|
0
|
1787 {
|
|
1788 int ac;
|
|
1789 Extbyte *wampum;
|
|
1790 int namesize;
|
|
1791 int total_len;
|
|
1792 Lisp_Object orig_invoc_name = Fcar (Vcommand_line_args);
|
185
|
1793 Extbyte **wampum_all = alloca_array (Extbyte *, nargs);
|
|
1794 int *wampum_all_len = alloca_array (int, nargs);
|
0
|
1795
|
|
1796 assert (!gc_in_progress);
|
|
1797
|
|
1798 if (run_temacs_argc < 0)
|
|
1799 error ("I've lost my temacs-hood.");
|
|
1800
|
|
1801 /* Need to convert the orig_invoc_name and all of the arguments
|
|
1802 to external format. */
|
163
|
1803
|
0
|
1804 GET_STRING_EXT_DATA_ALLOCA (orig_invoc_name, FORMAT_OS, wampum,
|
|
1805 namesize);
|
|
1806 namesize++;
|
|
1807
|
|
1808 for (ac = 0, total_len = namesize; ac < nargs; ac++)
|
|
1809 {
|
|
1810 CHECK_STRING (args[ac]);
|
|
1811 GET_STRING_EXT_DATA_ALLOCA (args[ac], FORMAT_OS,
|
|
1812 wampum_all[ac],
|
|
1813 wampum_all_len[ac]);
|
|
1814 wampum_all_len[ac]++;
|
|
1815 total_len += wampum_all_len[ac];
|
|
1816 }
|
|
1817 DO_REALLOC (run_temacs_args, run_temacs_args_size, total_len, char);
|
|
1818 DO_REALLOC (run_temacs_argv, run_temacs_argv_size, nargs+1, char *);
|
|
1819
|
|
1820 memcpy (run_temacs_args, wampum, namesize);
|
|
1821 run_temacs_argv [0] = run_temacs_args;
|
|
1822 for (ac = 0; ac < nargs; ac++)
|
|
1823 {
|
|
1824 memcpy (run_temacs_args + namesize,
|
|
1825 wampum_all[ac], wampum_all_len[ac]);
|
|
1826 run_temacs_argv [ac + 1] = run_temacs_args + namesize;
|
|
1827 namesize += wampum_all_len[ac];
|
|
1828 }
|
|
1829 run_temacs_argv [nargs + 1] = 0;
|
|
1830 catchlist = NULL; /* Important! Otherwise free_cons() calls in
|
|
1831 condition_case_unwind() may lead to GC death. */
|
|
1832 unbind_to (0, Qnil); /* this closes loadup.el */
|
|
1833 purify_flag = 0;
|
|
1834 run_temacs_argc = nargs + 1;
|
251
|
1835 #ifdef REPORT_PURE_USAGE
|
0
|
1836 report_pure_usage (1, 0);
|
207
|
1837 #else
|
|
1838 report_pure_usage (0, 0);
|
|
1839 #endif
|
0
|
1840 LONGJMP (run_temacs_catch, 1);
|
|
1841 return Qnil; /* not reached; warning suppression */
|
|
1842 }
|
|
1843
|
|
1844 /* ARGSUSED */
|
163
|
1845 int
|
0
|
1846 main (int argc, char **argv, char **envp)
|
|
1847 {
|
16
|
1848 int volatile vol_argc = argc;
|
|
1849 char ** volatile vol_argv = argv;
|
|
1850 char ** volatile vol_envp = envp;
|
233
|
1851 /* This is hairy. We need to compute where the XEmacs binary was invoked */
|
|
1852 /* from because temacs initialization requires it to find the lisp */
|
|
1853 /* directories. The code that recomputes the path is guarded by the */
|
|
1854 /* restarted flag. There are three possible paths I've found so far */
|
|
1855 /* through this: */
|
|
1856 /* temacs -- When running temacs for basic build stuff, the first main_1 */
|
|
1857 /* will be the only one invoked. It must compute the path else there */
|
|
1858 /* will be a very ugly bomb in startup.el (can't find obvious location */
|
|
1859 /* for doc-directory data-directory, etc.). */
|
|
1860 /* temacs w/ run-temacs on the command line -- This is run to bytecompile */
|
|
1861 /* all the out of date dumped lisp. It will execute both of the main_1 */
|
|
1862 /* calls and the second one must not touch the first computation because */
|
|
1863 /* argc/argv are hosed the second time through. */
|
|
1864 /* xemacs -- Only the second main_1 is executed. The invocation path must */
|
|
1865 /* computed but this only matters when running in place or when running */
|
|
1866 /* as a login shell. */
|
|
1867 /* As a bonus for straightening this out, XEmacs can now be run in place */
|
|
1868 /* as a login shell. This never used to work. */
|
|
1869 /* As another bonus, we can now guarantee that */
|
|
1870 /* (concat invocation-directory invocation-name) contains the filename */
|
|
1871 /* of the XEmacs binary we are running. This can now be used in a */
|
|
1872 /* definite test for out of date dumped files. -slb */
|
|
1873 int restarted = 0;
|
0
|
1874 #ifdef QUANTIFY
|
|
1875 quantify_stop_recording_data ();
|
|
1876 quantify_clear_data ();
|
|
1877 #endif /* QUANTIFY */
|
|
1878
|
|
1879 suppress_early_backtrace = 0;
|
|
1880 lim_data = 0; /* force reinitialization of this variable */
|
|
1881
|
78
|
1882 /* Lisp_Object must fit in a word; check VALBITS and GCTYPEBITS */
|
|
1883 assert (sizeof (Lisp_Object) == sizeof (void *));
|
|
1884
|
255
|
1885 #ifdef LINUX_SBRK_BUG
|
|
1886 sbrk (1);
|
|
1887 #endif
|
|
1888
|
0
|
1889 if (!initialized)
|
78
|
1890 {
|
255
|
1891 #ifdef DOUG_LEA_MALLOC
|
|
1892 mallopt (M_MMAP_MAX, 0);
|
|
1893 #endif
|
78
|
1894 run_temacs_argc = 0;
|
|
1895 if (! SETJMP (run_temacs_catch))
|
233
|
1896 {
|
|
1897 main_1 (vol_argc, vol_argv, vol_envp, 0);
|
|
1898 }
|
78
|
1899 /* run-emacs-from-temacs called */
|
233
|
1900 restarted = 1;
|
78
|
1901 vol_argc = run_temacs_argc;
|
|
1902 vol_argv = run_temacs_argv;
|
0
|
1903 #ifdef _SCO_DS
|
78
|
1904 /* This makes absolutely no sense to anyone involved. There are
|
|
1905 several people using this stuff. We've compared versions on
|
|
1906 everything we can think of. We can find no difference.
|
|
1907 However, on both my systems environ is a plain old global
|
|
1908 variable initialized to zero. _environ is the one that
|
|
1909 contains pointers to the actual environment.
|
163
|
1910
|
78
|
1911 Since we can't figure out the difference (and we're hours
|
|
1912 away from a release), this takes a very cowardly approach and
|
|
1913 is bracketed with both a system specific preprocessor test
|
|
1914 and a runtime "do you have this problem" test
|
163
|
1915
|
78
|
1916 06/20/96 robertl@dgii.com */
|
|
1917 {
|
|
1918 extern char *_environ;
|
|
1919 if ((unsigned) environ == 0)
|
|
1920 environ=_environ;
|
|
1921 }
|
16
|
1922 #endif /* _SCO_DS */
|
80
|
1923 vol_envp = environ;
|
|
1924 }
|
245
|
1925 #ifdef RUN_TIME_REMAP
|
|
1926 else
|
|
1927 /* obviously no-one uses this because where it was before initalized was
|
|
1928 *always* true */
|
|
1929 run_time_remap (argv[0]);
|
|
1930 #endif
|
|
1931
|
255
|
1932 #ifdef DOUG_LEA_MALLOC
|
|
1933 if (initialized && (malloc_state_ptr != NULL))
|
|
1934 {
|
|
1935 malloc_set_state (malloc_state_ptr);
|
|
1936 #if 0
|
|
1937 free (malloc_state_ptr);
|
|
1938 #endif
|
|
1939 #if !defined(MULE) && !defined(DEBUG_DOUG_LEA_MALLOC)
|
|
1940 mallopt (M_MMAP_MAX, 64);
|
|
1941 #endif
|
|
1942 #ifdef REL_ALLOC
|
|
1943 r_alloc_reinit ();
|
|
1944 #endif
|
|
1945 }
|
|
1946 #endif
|
|
1947
|
0
|
1948 run_temacs_argc = -1;
|
|
1949
|
233
|
1950 main_1 (vol_argc, vol_argv, vol_envp, restarted);
|
163
|
1951 return 0; /* unreached */
|
0
|
1952 }
|
|
1953
|
|
1954
|
20
|
1955 DEFUN ("kill-emacs", Fkill_emacs, 0, 1, "P", /*
|
0
|
1956 Exit the XEmacs job and kill it. Ask for confirmation, without argument.
|
|
1957 If ARG is an integer, return ARG as the exit program code.
|
|
1958 If ARG is a string, stuff it as keyboard input.
|
|
1959
|
|
1960 The value of `kill-emacs-hook', if not void,
|
|
1961 is a list of functions (of no args),
|
|
1962 all of which are called before XEmacs is actually killed.
|
20
|
1963 */
|
|
1964 (arg))
|
0
|
1965 {
|
|
1966 /* This function can GC */
|
|
1967 struct gcpro gcpro1;
|
|
1968
|
|
1969 GCPRO1 (arg);
|
|
1970
|
|
1971 if (feof (stdin))
|
|
1972 arg = Qt;
|
|
1973
|
|
1974 if (!preparing_for_armageddon && !noninteractive)
|
|
1975 run_hook (Qkill_emacs_hook);
|
|
1976
|
|
1977 /* make sure no quitting from now on!! */
|
|
1978 dont_check_for_quit = 1;
|
|
1979 Vinhibit_quit = Qt;
|
|
1980
|
|
1981 if (!preparing_for_armageddon)
|
|
1982 {
|
|
1983 Lisp_Object concons;
|
|
1984
|
|
1985 /* Normally, go ahead and delete all the consoles now.
|
|
1986 Some unmentionably lame window systems (MS Wwwww...... eek,
|
|
1987 I can't even say it) don't properly clean up after themselves,
|
|
1988 and even for those that do, it might be cleaner this way.
|
|
1989 If we're going down, however, we don't do this (might
|
|
1990 be too dangerous), and if we get a crash somewhere within
|
|
1991 this loop, we'll still autosave and won't try this again. */
|
|
1992 CONSOLE_LOOP (concons)
|
|
1993 delete_console_internal (XCONSOLE (XCAR (concons)), 1, 1, 0);
|
|
1994 }
|
|
1995
|
|
1996 UNGCPRO;
|
|
1997
|
|
1998 shut_down_emacs (0, ((STRINGP (arg)) ? arg : Qnil));
|
|
1999
|
207
|
2000 exit ((INTP (arg)) ? XINT (arg) : 0);
|
0
|
2001 /* NOTREACHED */
|
|
2002 return Qnil; /* I'm sick of the compiler warning */
|
|
2003 }
|
|
2004
|
|
2005 /* Perform an orderly shutdown of XEmacs. Autosave any modified
|
|
2006 buffers, kill any child processes, clean up the terminal modes (if
|
|
2007 we're in the foreground), and other stuff like that. Don't perform
|
|
2008 any redisplay; this may be called when XEmacs is shutting down in
|
|
2009 the background, or after its X connection has died.
|
|
2010
|
|
2011 If SIG is a signal number, print a message for it.
|
|
2012
|
|
2013 This is called by fatal signal handlers, X protocol error handlers,
|
|
2014 and Fkill_emacs. */
|
|
2015 static void
|
|
2016 shut_down_emacs (int sig, Lisp_Object stuff)
|
|
2017 {
|
|
2018 /* This function can GC */
|
|
2019 /* Prevent running of hooks and other non-essential stuff
|
|
2020 from now on. */
|
|
2021 preparing_for_armageddon = 1;
|
|
2022
|
|
2023 /* In case frames or windows are screwed up, avoid assertion
|
|
2024 failures here */
|
|
2025 Vinhibit_quit = Qt;
|
|
2026
|
|
2027 #ifdef QUANTIFY
|
|
2028 quantify_stop_recording_data ();
|
|
2029 #endif /* QUANTIFY */
|
|
2030
|
|
2031 /* This is absolutely the most important thing to do, so make sure
|
|
2032 we do it now, before anything else. We might have crashed and
|
|
2033 be in a weird inconsistent state, and potentially anything could
|
|
2034 set off another protection fault and cause us to bail out
|
|
2035 immediately. */
|
|
2036 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */
|
|
2037
|
|
2038 fflush (stdout);
|
|
2039 reset_all_consoles ();
|
|
2040 if (sig && sig != SIGTERM)
|
|
2041 {
|
|
2042 stderr_out ("\nFatal error (%d).\n", sig);
|
|
2043 stderr_out
|
|
2044 ("Your files have been auto-saved.\n"
|
|
2045 "Use `M-x recover-session' to recover them.\n"
|
|
2046 "\n"
|
126
|
2047 "Please report this bug by running the send-pr script included\n"
|
|
2048 "with XEmacs, or selecting `Send Bug Report' from the help menu.\n"
|
|
2049 "As a last resort send ordinary email to `crashes@xemacs.org'.\n"
|
2
|
2050 "*MAKE SURE* to include as much configuration information as\n"
|
|
2051 "possible; at the very least what OS and hardware you are running\n"
|
|
2052 "on, and hopefully also what compiler and compiler options the\n"
|
|
2053 "binary was compiled with, what options XEmacs was compiled with,\n"
|
|
2054 "whether you are using a prebuilt binary from ftp.xemacs.org or\n"
|
|
2055 "compiled XEmacs yourself for your system, etc.\n"
|
|
2056 "\n"
|
0
|
2057 "If at all possible, *please* try to obtain a C stack backtrace;\n"
|
|
2058 "it will help us immensely in determining what went wrong.\n"
|
|
2059 "To do this, locate the core file that was produced as a result\n"
|
|
2060 "of this crash (it's usually called `core' and is located in the\n"
|
|
2061 "directory in which you started XEmacs, or maybe in your home\n"
|
|
2062 "directory), and type\n"
|
|
2063 "\n"
|
|
2064 " gdb ");
|
|
2065 {
|
2
|
2066 CONST char *name;
|
0
|
2067 char *dir = 0;
|
|
2068
|
|
2069 /* Now try to determine the actual path to the executable,
|
|
2070 to try to make the backtrace-determination process as foolproof
|
|
2071 as possible. */
|
|
2072 if (GC_STRINGP (Vinvocation_name))
|
14
|
2073 name = (char *) XSTRING_DATA (Vinvocation_name);
|
0
|
2074 else
|
|
2075 name = "xemacs";
|
|
2076 if (GC_STRINGP (Vinvocation_directory))
|
14
|
2077 dir = (char *) XSTRING_DATA (Vinvocation_directory);
|
0
|
2078 if (!dir || dir[0] != '/')
|
|
2079 stderr_out ("`which %s`", name);
|
|
2080 else if (dir[strlen (dir) - 1] != '/')
|
|
2081 stderr_out ("%s/%s", dir, name);
|
|
2082 else
|
|
2083 stderr_out ("%s%s", dir, name);
|
|
2084 }
|
|
2085 stderr_out
|
|
2086 (" core\n\n"
|
|
2087 "then type `where' when the debugger prompt comes up.\n"
|
|
2088 "(If you don't have GDB on your system, you might have DBX,\n"
|
|
2089 "or XDB, or SDB. A similar procedure should work for all of\n"
|
|
2090 "these. Ask your system administrator if you need more help.)\n");
|
|
2091 }
|
|
2092
|
|
2093 stuff_buffered_input (stuff);
|
|
2094
|
|
2095 kill_buffer_processes (Qnil);
|
|
2096
|
|
2097 #ifdef CLASH_DETECTION
|
|
2098 unlock_all_files ();
|
|
2099 #endif
|
|
2100
|
|
2101 #ifdef TOOLTALK
|
|
2102 tt_session_quit (tt_default_session ());
|
2
|
2103 #if 0
|
|
2104 /* The following crashes when built on X11R5 and run on X11R6 */
|
0
|
2105 tt_close ();
|
|
2106 #endif
|
2
|
2107 #endif /* TOOLTALK */
|
0
|
2108
|
|
2109 }
|
|
2110
|
|
2111
|
|
2112 #ifndef CANNOT_DUMP
|
|
2113 /* Nothing like this can be implemented on an Apollo.
|
|
2114 What a loss! */
|
|
2115
|
2
|
2116 extern char my_edata[];
|
0
|
2117
|
|
2118 #ifdef HAVE_SHM
|
|
2119
|
20
|
2120 DEFUN ("dump-emacs-data", Fdump_emacs_data, 1, 1, 0, /*
|
0
|
2121 Dump current state of XEmacs into data file FILENAME.
|
|
2122 This function exists on systems that use HAVE_SHM.
|
20
|
2123 */
|
|
2124 (intoname))
|
0
|
2125 {
|
|
2126 /* This function can GC */
|
|
2127 int opurify;
|
|
2128 struct gcpro gcpro1;
|
|
2129 GCPRO1 (intoname);
|
|
2130
|
|
2131 CHECK_STRING (intoname);
|
|
2132 intoname = Fexpand_file_name (intoname, Qnil);
|
|
2133
|
|
2134 opurify = purify_flag;
|
|
2135 purify_flag = 0;
|
|
2136
|
|
2137 fflush (stderr);
|
|
2138 fflush (stdout);
|
|
2139
|
|
2140 disksave_object_finalization ();
|
|
2141 release_breathing_space ();
|
|
2142
|
|
2143 /* Tell malloc where start of impure now is */
|
|
2144 /* Also arrange for warnings when nearly out of space. */
|
|
2145 #ifndef SYSTEM_MALLOC
|
173
|
2146 memory_warnings (my_edata, malloc_warning);
|
0
|
2147 #endif
|
|
2148 UNGCPRO;
|
14
|
2149 map_out_data (XSTRING_DATA (intoname));
|
0
|
2150
|
|
2151 purify_flag = opurify;
|
|
2152
|
|
2153 return Qnil;
|
|
2154 }
|
|
2155
|
|
2156 #else /* not HAVE_SHM */
|
|
2157
|
20
|
2158 DEFUN ("dump-emacs", Fdump_emacs, 2, 2, 0, /*
|
0
|
2159 Dump current state of XEmacs into executable file FILENAME.
|
|
2160 Take symbols from SYMFILE (presumably the file you executed to run XEmacs).
|
|
2161 This is used in the file `loadup.el' when building XEmacs.
|
|
2162
|
|
2163 Remember to set `command-line-processed' to nil before dumping
|
|
2164 if you want the dumped XEmacs to process its command line
|
|
2165 and announce itself normally when it is run.
|
20
|
2166 */
|
|
2167 (intoname, symname))
|
0
|
2168 {
|
|
2169 /* This function can GC */
|
|
2170 struct gcpro gcpro1, gcpro2;
|
|
2171 int opurify;
|
|
2172
|
|
2173 GCPRO2 (intoname, symname);
|
|
2174
|
|
2175 #ifdef FREE_CHECKING
|
|
2176 Freally_free (Qnil);
|
|
2177
|
|
2178 /* When we're dumping, we can't use the debugging free() */
|
|
2179
|
|
2180 disable_free_hook ();
|
|
2181 #endif
|
|
2182
|
|
2183 CHECK_STRING (intoname);
|
|
2184 intoname = Fexpand_file_name (intoname, Qnil);
|
|
2185 if (!NILP (symname))
|
|
2186 {
|
|
2187 CHECK_STRING (symname);
|
14
|
2188 if (XSTRING_LENGTH (symname) > 0)
|
0
|
2189 symname = Fexpand_file_name (symname, Qnil);
|
|
2190 else
|
|
2191 symname = Qnil;
|
|
2192 }
|
|
2193
|
|
2194 opurify = purify_flag;
|
|
2195 purify_flag = 0;
|
|
2196
|
207
|
2197 #ifdef DEBUG_XEMACS
|
0
|
2198 report_pure_usage (1, 1);
|
207
|
2199 #else
|
|
2200 report_pure_usage (0, 1);
|
|
2201 #endif
|
0
|
2202
|
|
2203 fflush (stderr);
|
|
2204 fflush (stdout);
|
|
2205
|
|
2206 disksave_object_finalization ();
|
|
2207 release_breathing_space ();
|
|
2208
|
|
2209 /* Tell malloc where start of impure now is */
|
|
2210 /* Also arrange for warnings when nearly out of space. */
|
|
2211 #ifndef SYSTEM_MALLOC
|
173
|
2212 memory_warnings (my_edata, malloc_warning);
|
0
|
2213 #endif
|
|
2214
|
|
2215 UNGCPRO;
|
|
2216
|
|
2217 #if defined (MSDOS) && defined (EMX)
|
|
2218 {
|
14
|
2219 int fd = open ((char *) XSTRING_DATA (intoname),
|
0
|
2220 O_WRONLY|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE);
|
|
2221 if (!fd) {
|
14
|
2222 error ("Failure operating on %s", XSTRING_DATA (intoname));
|
0
|
2223 } else {
|
|
2224 _core (fd);
|
|
2225 close (fd);
|
|
2226 }
|
|
2227 }
|
|
2228 #else /* not MSDOS and EMX */
|
|
2229 {
|
|
2230 CONST char *intoname_ext;
|
|
2231 CONST char *symname_ext;
|
|
2232
|
|
2233 GET_C_STRING_FILENAME_DATA_ALLOCA (intoname, intoname_ext);
|
|
2234 if (STRINGP (symname))
|
|
2235 GET_C_STRING_FILENAME_DATA_ALLOCA (symname, symname_ext);
|
|
2236 else
|
|
2237 symname_ext = 0;
|
255
|
2238 #ifdef DOUG_LEA_MALLOC
|
|
2239 malloc_state_ptr = malloc_get_state ();
|
|
2240 #endif
|
0
|
2241 /* here we break our rule that the filename conversion should
|
|
2242 be performed at the actual time that the system call is made.
|
|
2243 It's a whole lot easier to do the conversion here than to
|
|
2244 modify all the unexec routines to ensure that filename
|
|
2245 conversion is applied everywhere. Don't worry about memory
|
|
2246 leakage because this call only happens once. */
|
|
2247 unexec ((char *) intoname_ext, (char *) symname_ext,
|
173
|
2248 (uintptr_t) my_edata,
|
0
|
2249 0, 0);
|
255
|
2250 #ifdef DOUG_LEA_MALLOC
|
|
2251 free (malloc_state_ptr);
|
|
2252 #endif
|
0
|
2253 }
|
|
2254 #endif /* not MSDOS and EMX */
|
|
2255
|
|
2256 purify_flag = opurify;
|
|
2257
|
|
2258 return Qnil;
|
|
2259 }
|
|
2260
|
|
2261 #endif /* not HAVE_SHM */
|
|
2262
|
|
2263 #endif /* not CANNOT_DUMP */
|
|
2264
|
|
2265 #ifndef SEPCHAR
|
|
2266 #define SEPCHAR ':'
|
|
2267 #endif
|
|
2268
|
|
2269 Lisp_Object
|
177
|
2270 decode_path (CONST char *path)
|
0
|
2271 {
|
|
2272 REGISTER CONST char *p;
|
|
2273 Lisp_Object lpath = Qnil;
|
|
2274
|
177
|
2275 if (!path || !strlen(path)) return Qnil;
|
0
|
2276
|
|
2277 #if defined (MSDOS) || defined (WIN32)
|
|
2278 dostounix_filename (path);
|
|
2279 #endif
|
|
2280
|
|
2281 while (1)
|
|
2282 {
|
|
2283 p = strchr (path, SEPCHAR);
|
|
2284 if (!p) p = path + strlen (path);
|
|
2285 lpath = Fcons (((p != path)
|
|
2286 ? make_string ((CONST Bufbyte *) path, p - path)
|
|
2287 : Qnil),
|
|
2288 lpath);
|
|
2289 if (*p)
|
|
2290 path = p + 1;
|
|
2291 else
|
|
2292 break;
|
|
2293 }
|
|
2294 return Fnreverse (lpath);
|
|
2295 }
|
|
2296
|
177
|
2297 Lisp_Object
|
|
2298 decode_env_path (CONST char *evarname, CONST char *default_)
|
|
2299 {
|
|
2300 REGISTER CONST char *path = 0;
|
|
2301 if (evarname)
|
|
2302 path = (char *) egetenv (evarname);
|
|
2303 if (!path)
|
|
2304 path = default_;
|
|
2305 if (!path)
|
|
2306 return Qnil;
|
|
2307 else
|
|
2308 return decode_path(path);
|
|
2309 }
|
|
2310
|
20
|
2311 DEFUN ("noninteractive", Fnoninteractive, 0, 0, 0, /*
|
0
|
2312 Non-nil return value means XEmacs is running without interactive terminal.
|
20
|
2313 */
|
|
2314 ())
|
0
|
2315 {
|
173
|
2316 return noninteractive ? Qt : Qnil;
|
0
|
2317 }
|
|
2318
|
|
2319 /* This flag is useful to define if you're under a debugger; this way, you
|
|
2320 can put a breakpoint of assert_failed() and debug multiple problems
|
|
2321 in one session without having to recompile. */
|
|
2322 /* #define ASSERTIONS_DONT_ABORT */
|
|
2323
|
70
|
2324 #ifdef USE_ASSERTIONS
|
0
|
2325 /* This highly dubious kludge ... shut up Jamie, I'm tired of your slagging. */
|
|
2326
|
|
2327 DOESNT_RETURN
|
|
2328 assert_failed (CONST char *file, int line, CONST char *expr)
|
|
2329 {
|
|
2330 stderr_out ("Fatal error: assertion failed, file %s, line %d, %s\n",
|
|
2331 file, line, expr);
|
|
2332 #undef abort /* avoid infinite #define loop... */
|
227
|
2333 #if defined (_WIN32) && defined (DEBUG_XEMACS)
|
|
2334 DebugBreak ();
|
|
2335 #elif !defined (ASSERTIONS_DONT_ABORT)
|
0
|
2336 abort ();
|
|
2337 #endif
|
|
2338 }
|
70
|
2339 #endif /* USE_ASSERTIONS */
|
0
|
2340
|
|
2341 #ifdef QUANTIFY
|
20
|
2342 DEFUN ("quantify-start-recording-data",
|
|
2343 Fquantify_start_recording_data, 0, 0, 0, /*
|
0
|
2344 Start recording Quantify data.
|
20
|
2345 */
|
|
2346 ())
|
0
|
2347 {
|
|
2348 quantify_start_recording_data ();
|
|
2349 return Qnil;
|
|
2350 }
|
|
2351
|
20
|
2352 DEFUN ("quantify-stop-recording-data",
|
|
2353 Fquantify_stop_recording_data, 0, 0, 0, /*
|
0
|
2354 Stop recording Quantify data.
|
20
|
2355 */
|
|
2356 ())
|
0
|
2357 {
|
|
2358 quantify_stop_recording_data ();
|
|
2359 return Qnil;
|
|
2360 }
|
|
2361
|
20
|
2362 DEFUN ("quantify-clear-data", Fquantify_clear_data, 0, 0, 0, /*
|
0
|
2363 Clear all Quantify data.
|
20
|
2364 */
|
|
2365 ())
|
0
|
2366 {
|
|
2367 quantify_clear_data ();
|
|
2368 return Qnil;
|
|
2369 }
|
|
2370 #endif /* QUANTIFY */
|
|
2371
|
|
2372 void
|
|
2373 syms_of_emacs (void)
|
|
2374 {
|
|
2375 #ifndef CANNOT_DUMP
|
|
2376 #ifdef HAVE_SHM
|
20
|
2377 DEFSUBR (Fdump_emacs_data);
|
0
|
2378 #else
|
20
|
2379 DEFSUBR (Fdump_emacs);
|
0
|
2380 #endif
|
|
2381 #endif /* !CANNOT_DUMP */
|
|
2382
|
20
|
2383 DEFSUBR (Frun_emacs_from_temacs);
|
|
2384 DEFSUBR (Frunning_temacs_p);
|
|
2385 DEFSUBR (Finvocation_name);
|
|
2386 DEFSUBR (Finvocation_directory);
|
|
2387 DEFSUBR (Fkill_emacs);
|
|
2388 DEFSUBR (Fnoninteractive);
|
0
|
2389
|
|
2390 #ifdef QUANTIFY
|
20
|
2391 DEFSUBR (Fquantify_start_recording_data);
|
|
2392 DEFSUBR (Fquantify_stop_recording_data);
|
|
2393 DEFSUBR (Fquantify_clear_data);
|
0
|
2394 #endif /* QUANTIFY */
|
|
2395
|
|
2396 defsymbol (&Qkill_emacs_hook, "kill-emacs-hook");
|
|
2397 defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs");
|
|
2398 }
|
|
2399
|
|
2400 void
|
|
2401 vars_of_emacs (void)
|
|
2402 {
|
|
2403 DEFVAR_BOOL ("suppress-early-error-handler-backtrace",
|
|
2404 &suppress_early_backtrace /*
|
|
2405 Non-nil means early error handler shouldn't print a backtrace
|
|
2406 */ );
|
|
2407
|
|
2408 DEFVAR_LISP ("command-line-args", &Vcommand_line_args /*
|
|
2409 Args passed by shell to XEmacs, as a list of strings.
|
|
2410 */ );
|
|
2411
|
|
2412 DEFVAR_LISP ("invocation-name", &Vinvocation_name /*
|
|
2413 The program name that was used to run XEmacs.
|
|
2414 Any directory names are omitted.
|
|
2415 */ );
|
|
2416
|
|
2417 DEFVAR_LISP ("invocation-directory", &Vinvocation_directory /*
|
|
2418 The directory in which the XEmacs executable was found, to run it.
|
|
2419 The value is simply the program name if that directory's name is not known.
|
|
2420 */ );
|
|
2421
|
|
2422 #if 0 /* FSFmacs */
|
|
2423 xxDEFVAR_LISP ("installation-directory", &Vinstallation_directory,
|
|
2424 "A directory within which to look for the `lib-src' and `etc' directories.\n"
|
|
2425 "This is non-nil when we can't find those directories in their standard\n"
|
|
2426 "installed locations, but we can find them\n"
|
|
2427 "near where the XEmacs executable was found.");
|
|
2428 #endif
|
|
2429
|
|
2430 DEFVAR_LISP ("system-type", &Vsystem_type /*
|
|
2431 Value is symbol indicating type of operating system you are using.
|
|
2432 */ );
|
|
2433 Vsystem_type = intern (SYSTEM_TYPE);
|
169
|
2434 Fprovide (intern(SYSTEM_TYPE));
|
0
|
2435
|
|
2436 #ifndef EMACS_CONFIGURATION
|
|
2437 # define EMACS_CONFIGURATION "UNKNOWN"
|
|
2438 #endif
|
|
2439 DEFVAR_LISP ("system-configuration", &Vsystem_configuration /*
|
|
2440 Value is string indicating configuration XEmacs was built for.
|
|
2441 */ );
|
|
2442 Vsystem_configuration = Fpurecopy (build_string (EMACS_CONFIGURATION));
|
|
2443
|
175
|
2444 #ifndef EMACS_CONFIG_OPTIONS
|
|
2445 # define EMACS_CONFIG_OPTIONS "UNKNOWN"
|
|
2446 #endif
|
|
2447 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options /*
|
|
2448 String containing the configuration options XEmacs was built with.
|
|
2449 */ );
|
|
2450 Vsystem_configuration_options = Fpurecopy (build_string
|
|
2451 (EMACS_CONFIG_OPTIONS));
|
|
2452
|
165
|
2453 DEFVAR_LISP ("emacs-major-version", &Vemacs_major_version /*
|
|
2454 Major version number of this version of Emacs, as an integer.
|
|
2455 Warning: this variable did not exist in Emacs versions earlier than:
|
|
2456 FSF Emacs: 19.23
|
|
2457 XEmacs: 19.10
|
|
2458 */ );
|
|
2459 Vemacs_major_version = make_int (EMACS_MAJOR_VERSION);
|
|
2460
|
|
2461 DEFVAR_LISP ("emacs-minor-version", &Vemacs_minor_version /*
|
|
2462 Minor version number of this version of Emacs, as an integer.
|
|
2463 Warning: this variable did not exist in Emacs versions earlier than:
|
|
2464 FSF Emacs: 19.23
|
|
2465 XEmacs: 19.10
|
|
2466 */ );
|
|
2467 Vemacs_minor_version = make_int (EMACS_MINOR_VERSION);
|
|
2468
|
|
2469 DEFVAR_LISP ("emacs-beta-version", &Vemacs_beta_version /*
|
163
|
2470 Beta number of this version of Emacs, as an integer.
|
|
2471 The value is nil if this is an officially released version of XEmacs.
|
|
2472 Warning: this variable does not exist in FSF Emacs or in XEmacs versions
|
|
2473 earlier than 20.3.
|
|
2474 */ );
|
165
|
2475 #ifdef EMACS_BETA_VERSION
|
|
2476 Vemacs_beta_version = make_int (EMACS_BETA_VERSION);
|
|
2477 #else
|
|
2478 Vemacs_beta_version = Qnil;
|
163
|
2479 #endif
|
|
2480
|
|
2481 DEFVAR_LISP ("xemacs-codename", &Vxemacs_codename /*
|
|
2482 Codename of this version of Emacs (a string).
|
|
2483 */ );
|
|
2484 #ifndef XEMACS_CODENAME
|
165
|
2485 #define XEMACS_CODENAME "Noname"
|
163
|
2486 #endif
|
|
2487 Vxemacs_codename = Fpurecopy (build_string (XEMACS_CODENAME));
|
|
2488
|
177
|
2489 DEFVAR_LISP ("package-path", &Vpackage_path /*
|
|
2490 List of directories configured for package searching.
|
|
2491 */ );
|
|
2492 #ifndef PACKAGE_PATH
|
187
|
2493 #define PACKAGE_PATH "~/.xemacs:" PATH_PREFIX "/lib/xemacs/packages"
|
177
|
2494 #endif
|
|
2495 Vpackage_path = decode_path(PACKAGE_PATH);
|
|
2496
|
0
|
2497 DEFVAR_BOOL ("noninteractive", &noninteractive1 /*
|
|
2498 Non-nil means XEmacs is running without interactive terminal.
|
|
2499 */ );
|
|
2500
|
207
|
2501 DEFVAR_BOOL ("inhibit-package-init", &inhibit_package_init /*
|
|
2502 Set to non-nil when the package-path should not be searched at startup.
|
|
2503 */ );
|
|
2504
|
235
|
2505 DEFVAR_BOOL ("inhibit-update-dumped-lisp", &inhibit_update_dumped_lisp /*
|
|
2506 Set to non-nil when modified dumped lisp should not be reloaded at startup.
|
|
2507 */ );
|
|
2508 inhibit_update_dumped_lisp = 1;
|
|
2509
|
|
2510 DEFVAR_BOOL ("inhibit-update-autoloads", &inhibit_update_autoloads /*
|
|
2511 Set to non-nil when modified or new autoloads files should not be reloaded.
|
|
2512 */ );
|
|
2513 inhibit_update_autoloads = 0;
|
|
2514
|
0
|
2515 DEFVAR_INT ("emacs-priority", &emacs_priority /*
|
|
2516 Priority for XEmacs to run at.
|
|
2517 This value is effective only if set before XEmacs is dumped,
|
|
2518 and only if the XEmacs executable is installed with setuid to permit
|
|
2519 it to change priority. (XEmacs sets its uid back to the real uid.)
|
|
2520 Currently, you need to define SET_EMACS_PRIORITY in `config.h'
|
|
2521 before you compile XEmacs, to enable the code for this feature.
|
|
2522 */ );
|
|
2523 emacs_priority = 0;
|
163
|
2524
|
0
|
2525 }
|