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