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