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