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.
6 This file is part of XEmacs.
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
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
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. */
23 /* Synched up with: Mule 2.0, FSF 19.28. */
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. */
33 #include "backtrace.h" /* run-emacs-from-temacs needs this */
38 #include "redisplay.h"
42 #include "syssignal.h" /* Always include before systty.h */
55 #if defined (HAVE_LOCALE_H) && \
56 (defined (I18N2) || defined (I18N3) || defined (I18N4))
64 #if defined (WINDOWSNT)
72 void report_sheap_usage (int die_if_pure_storage_exceeded);
75 #if !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC)
76 extern void *(*__malloc_hook)(size_t);
77 extern void *(*__realloc_hook)(void *, size_t);
78 extern void (*__free_hook)(void *);
79 #endif /* not SYSTEM_MALLOC && not DOUG_LEA_MALLOC */
81 /* Command line args from shell, as list of strings */
82 Lisp_Object Vcommand_line_args;
84 /* Set nonzero after XEmacs has started up the first time.
85 Prevents reinitialization of the Lisp world and keymaps
86 on subsequent starts. */
89 #ifdef DOUG_LEA_MALLOC
91 /* Preserves a pointer to the memory allocated that copies that
92 static data inside glibc's malloc. */
93 static void *malloc_state_ptr;
94 #endif /* DOUG_LEA_MALLOC */
97 void r_alloc_reinit (void);
100 /* Variable whose value is symbol giving operating system type. */
101 Lisp_Object Vsystem_type;
103 /* Variable whose value is string giving configuration built for. */
104 Lisp_Object Vsystem_configuration;
106 /* Variable whose value is string containing the configuration options
107 XEmacs was built with. */
108 Lisp_Object Vsystem_configuration_options;
110 /* Version numbers and strings */
111 Lisp_Object Vemacs_major_version;
112 Lisp_Object Vemacs_minor_version;
113 Lisp_Object Vemacs_patch_level;
114 Lisp_Object Vemacs_beta_version;
115 Lisp_Object Vxemacs_codename;
117 Lisp_Object Vinfodock_major_version;
118 Lisp_Object Vinfodock_minor_version;
119 Lisp_Object Vinfodock_build_version;
122 /* The path under which XEmacs was invoked. */
123 Lisp_Object Vinvocation_path;
125 /* The name under which XEmacs was invoked, with any leading directory
127 Lisp_Object Vinvocation_name;
129 /* The directory name from which XEmacs was invoked. */
130 Lisp_Object Vinvocation_directory;
133 /* The directory name in which to find subdirs such as lisp and etc.
134 nil means get them only from PATH_LOADSEARCH. */
135 Lisp_Object Vinstallation_directory;
138 Lisp_Object Vemacs_program_name, Vemacs_program_version;
139 Lisp_Object Vexec_path;
140 Lisp_Object Vexec_directory, Vconfigure_exec_directory;
141 Lisp_Object Vlisp_directory, Vconfigure_lisp_directory;
142 Lisp_Object Vmodule_directory, Vconfigure_module_directory;
143 Lisp_Object Vsite_module_directory, Vconfigure_site_module_directory;
144 Lisp_Object Vconfigure_package_path;
145 Lisp_Object Vdata_directory, Vconfigure_data_directory;
146 Lisp_Object Vdoc_directory, Vconfigure_doc_directory;
147 Lisp_Object Vconfigure_lock_directory;
148 Lisp_Object Vdata_directory_list;
149 Lisp_Object Vconfigure_info_directory;
150 Lisp_Object Vsite_directory, Vconfigure_site_directory;
151 Lisp_Object Vconfigure_info_path;
152 Lisp_Object Vinternal_error_checking;
153 Lisp_Object Vmail_lock_methods, Vconfigure_mail_lock_method;
154 Lisp_Object Vpath_separator;
156 /* The default base directory XEmacs is installed under. */
157 Lisp_Object Vconfigure_exec_prefix_directory, Vconfigure_prefix_directory;
159 /* If nonzero, set XEmacs to run at this priority. This is also used
160 in child_setup and sys_suspend to make sure subshells run at normal
164 /* If non-zero a filter or a sentinel is running. Tested to save the match
165 data on the first attempt to change it inside asynchronous code. */
166 int running_asynch_code;
168 /* If non-zero, a window-system was specified on the command line. */
171 /* Type of display specified. We cannot use a Lisp symbol here because
172 Lisp symbols may not initialized at the time that we set this
174 const char *display_use;
176 /* If non-zero, then the early error handler will only print the error
178 int suppress_early_error_handler_backtrace;
180 /* An address near the bottom of the stack.
181 Tells GC how to save a copy of the stack. */
184 #ifdef USG_SHARED_LIBRARIES
185 /* If nonzero, this is the place to put the end of the writable segment
188 uintptr_t bss_end = 0;
191 /* Number of bytes of writable memory we can expect to be able to get */
192 unsigned int lim_data;
194 /* Nonzero means running XEmacs without interactive terminal. */
198 /* Value of Lisp variable `noninteractive'.
199 Normally same as C variable `noninteractive'
200 but nothing terrible happens if user sets this one. */
204 /* Nonzero means don't perform site-lisp searches at startup */
205 int inhibit_site_lisp;
207 /* Nonzero means don't perform site-modules searches at startup */
208 int inhibit_site_modules;
210 /* Nonzero means don't respect early packages at startup */
211 int inhibit_early_packages;
213 /* Nonzero means don't load package autoloads at startup */
214 int inhibit_autoloads;
216 /* Nonzero means print debug information about path searching */
219 /* Save argv and argc. */
220 static char **initial_argv;
221 static int initial_argc;
223 static void sort_args (int argc, char **argv);
225 Lisp_Object Qkill_emacs_hook;
226 Lisp_Object Qsave_buffers_kill_emacs;
228 extern Lisp_Object Vlisp_EXEC_SUFFIXES;
231 /* Signal code for the fatal signal that was received */
232 static int fatal_error_code;
234 /* Nonzero if handling a fatal error already */
235 static int fatal_error_in_progress;
237 static void shut_down_emacs (int sig, Lisp_Object stuff);
239 /* Handle bus errors, illegal instruction, etc. */
241 fatal_error_signal (int sig)
243 fatal_error_code = sig;
244 signal (sig, SIG_DFL);
245 /* Unblock the signal so that if the same signal gets sent in the
246 code below, we avoid a deadlock. */
247 EMACS_UNBLOCK_SIGNAL (fatal_error_code);
249 /* If fatal error occurs in code below, avoid infinite recursion. */
250 if (! fatal_error_in_progress)
252 fatal_error_in_progress = dont_check_for_quit = 1;
253 shut_down_emacs (sig, Qnil);
254 stderr_out ("\nLisp backtrace follows:\n\n");
255 Fbacktrace (Qexternal_debugging_output, Qt);
256 # if 0 /* This is evil, rarely useful, and causes grief in some cases. */
257 /* Check for Sun-style stack printing via /proc */
259 const char *pstack = "/usr/proc/bin/pstack";
260 if (access (pstack, X_OK) == 0)
263 stderr_out ("\nC backtrace follows:\n"
264 "(A real debugger may provide better information)\n\n");
265 sprintf (buf, "%s %d >&2", pstack, (int)getpid());
271 /* Signal the same code; this time it will really be fatal. */
272 kill (getpid (), fatal_error_code);
278 fatal (const char *fmt, ...)
281 va_start (args, fmt);
283 fprintf (stderr, "\nXEmacs: ");
284 vfprintf (stderr, GETTEXT (fmt), args);
285 fprintf (stderr, "\n");
292 /* #### The following two functions should be replaced with
293 calls to emacs_doprnt_*() functions, with STREAM set to send out
294 to stdout or stderr. This is the only way to ensure that
295 I18N3 works properly (many implementations of the *printf()
296 functions, including the ones included in glibc, do not implement
297 the %###$ argument-positioning syntax). */
299 /* exactly equivalent to fprintf (stderr, fmt, ...) except that it calls
300 GETTEXT on the format string. */
303 stderr_out (const char *fmt, ...)
307 va_start (args, fmt);
309 retval = vfprintf (stderr, GETTEXT (fmt), args);
312 /* fflush (stderr); */
316 /* exactly equivalent to fprintf (stdout, fmt, ...) except that it calls
317 GETTEXT on the format string. */
320 stdout_out (const char *fmt, ...)
324 va_start (args, fmt);
326 retval = vfprintf (stdout, GETTEXT (fmt), args);
334 /* Handler for SIGDANGER. */
336 memory_warning_signal (int sig)
338 /* #### bad bad bad; this function shouldn't do anything except
339 set a flag, or weird corruption could happen. */
340 signal (sig, memory_warning_signal);
343 (GETTEXT ("Operating system warns that virtual memory is running low.\n"));
345 /* It might be unsafe to call do_auto_save now. */
346 force_auto_save_soon ();
348 #endif /* SIGDANGER */
350 /* Code for dealing with Lisp access to the Unix command line */
353 make_arg_list_1 (int argc, char **argv, int skip_args)
355 Lisp_Object result = Qnil;
358 for (i = argc - 1; i >= 0; i--)
360 if (i == 0 || i > skip_args)
365 /* Do not trust to what crt0 has stuffed into argv[0] */
366 char full_exe_path [MAX_PATH];
367 GetModuleFileName (NULL, full_exe_path, MAX_PATH);
368 result = Fcons (build_ext_string (full_exe_path, Qfile_name),
370 #if defined(HAVE_SHLIB)
371 (void)dll_init(full_exe_path);
376 result = Fcons (build_ext_string (argv [i], Qfile_name),
384 make_arg_list (int argc, char **argv)
386 return make_arg_list_1 (argc, argv, 0);
389 /* Calling functions are also responsible for calling free_argc_argv
390 when they are done with the generated list. */
392 make_argc_argv (Lisp_Object argv_list, int *argc, char ***argv)
395 int n = XINT (Flength (argv_list));
397 *argv = (char**) xmalloc ((n+1) * sizeof (char*));
399 for (i = 0, next = argv_list; i < n; i++, next = XCDR (next))
402 CHECK_STRING (XCAR (next));
404 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (next),
405 C_STRING_ALLOCA, temp,
407 (*argv) [i] = xstrdup (temp);
414 free_argc_argv (char **argv)
427 init_cmdargs (int argc, char **argv, int skip_args)
432 Vcommand_line_args = make_arg_list_1 (argc, argv, skip_args);
435 DEFUN ("invocation-name", Finvocation_name, 0, 0, 0, /*
436 Return the program name that was used to run XEmacs.
437 Any directory names are omitted.
441 return Fcopy_sequence (Vinvocation_name);
444 DEFUN ("invocation-directory", Finvocation_directory, 0, 0, 0, /*
445 Return the directory name in which the Emacs executable was located.
449 return Fcopy_sequence (Vinvocation_directory);
454 /* #### - don't know why I18N4 on SunOS/JLE
455 can't deal with this. It's a potential
456 bug that needs to be looked at. */
457 # undef RUN_TIME_REMAP
460 #if defined (MULE) && defined (MSDOS) && defined (EMX)
461 /* Setup all of files be input/output'ed with binary translation mode. */
463 asm ("L_setbinmode:");
464 asm (" movl $1, __fmode_bin");
466 asm (" .stabs \"___CTOR_LIST__\", 23, 0, 0, L_setbinmode");
469 /* Test whether the next argument in ARGV matches SSTR or a prefix of
470 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
471 (the argument is supposed to have a value) store in *VALPTR either
472 the next argument or the portion of this one after the equal sign.
473 ARGV is read starting at position *SKIPPTR; this index is advanced
474 by the number of arguments used.
476 Too bad we can't just use getopt for all of this, but we don't have
477 enough information to do it right. */
480 argmatch (char **argv, int argc, char *sstr, char *lstr,
481 int minlen, char **valptr, int *skipptr)
487 /* Don't access argv[argc]; give up in advance. */
488 if (argc <= *skipptr + 1)
491 arg = argv[*skipptr+1];
494 if (strcmp (arg, sstr) == 0)
498 *valptr = argv[*skipptr+2];
505 arglen = (valptr != NULL && (p = strchr (arg, '=')) != NULL
506 ? p - arg : strlen (arg));
507 if (lstr == 0 || arglen < minlen || strncmp (arg, lstr, arglen) != 0)
509 else if (valptr == NULL)
520 else if (argv[*skipptr+2] != NULL)
522 *valptr = argv[*skipptr+2];
532 /* Make stack traces always identify version + configuration */
533 #define main_1 STACK_TRACE_EYE_CATCHER
535 /* This function is not static, so that the compiler is less likely to
536 inline it, which would make it not show up in stack traces. */
537 DECLARE_DOESNT_RETURN (main_1 (int, char **, char **, int));
539 main_1 (int argc, char **argv, char **envp, int restart)
541 char stack_bottom_variable;
544 int inhibit_window_system;
546 extern int malloc_cookie;
549 #if (!defined (SYSTEM_MALLOC) && !defined (HAVE_LIBMCHECK) \
550 && !defined (DOUG_LEA_MALLOC))
551 /* Make sure that any libraries we link against haven't installed a
552 hook for a gmalloc of a potentially incompatible version. */
553 /* If we're using libmcheck, the hooks have already been initialized, */
554 /* don't touch them. -slb */
555 __malloc_hook = NULL;
556 __realloc_hook = NULL;
558 #endif /* not SYSTEM_MALLOC or HAVE_LIBMCHECK or DOUG_LEA_MALLOC */
564 * NeXT secret magic, ripped from Emacs-for-NS by Carl Edman
565 * <cedman@princeton.edu>. Note that even Carl doesn't know what this
566 * does; it was provided by NeXT, and it presumable makes NS's mallocator
567 * work with dumping. But malloc_jumpstart() and malloc_freezedry() in
568 * unexnext.c are both completely undocumented, even in NS header files!
569 * But hey, it solves all NS related memory problems, so who's
571 if (initialized && malloc_jumpstart (malloc_cookie) != 0)
572 fprintf (stderr, "malloc jumpstart failed!\n");
576 #if defined (GNU_MALLOC) && \
577 defined (ERROR_CHECK_MALLOC) && \
578 !defined (HAVE_LIBMCHECK)
580 #if defined(LOSING_GCC_DESTRUCTOR_FREE_BUG)
581 /* Prior to XEmacs 21, this was `#if 0'ed out. */
582 /* I'm enabling this because it is the only reliable way I've found to */
583 /* prevent a very annoying problem where GCC will attempt to free(3) */
584 /* memory at exit() and cause a coredump. */
588 sort_args (argc, argv);
590 #if (defined (MSDOS) && defined (EMX)) || defined (WIN32) || defined (_SCO_DS)
594 /* Record (approximately) where the stack begins. */
595 stack_bottom = &stack_bottom_variable;
597 #ifdef USG_SHARED_LIBRARIES
599 brk ((void *) bss_end);
604 #if defined (HAVE_MMAP) && defined (REL_ALLOC)
605 /* ralloc can only be used if using the GNU memory allocator. */
607 #elif defined (REL_ALLOC) && !defined(DOUG_LEA_MALLOC)
615 #endif /* HAVE_SOCKS */
617 #ifndef SYSTEM_MALLOC
619 /* Arrange to get warning messages as memory fills up. */
620 memory_warnings (0, malloc_warning);
621 #endif /* not SYSTEM_MALLOC */
624 /* We do all file input/output as binary files. When we need to translate
625 newlines, we do that manually. */
627 (stdin) ->_flag &= ~_IOTEXT;
628 (stdout)->_flag &= ~_IOTEXT;
629 (stderr)->_flag &= ~_IOTEXT;
632 #ifdef SET_EMACS_PRIORITY
633 if (emacs_priority != 0)
634 nice (-emacs_priority);
636 #endif /* SET_EMACS_PRIORITY */
638 #ifdef EXTRA_INITIALIZE
642 #ifdef HAVE_WINDOW_SYSTEM
643 inhibit_window_system = 0;
645 inhibit_window_system = 1;
648 /* Handle the -t switch, which specifies filename to use as terminal */
651 if (argmatch (argv, argc, "-t", "--terminal", 4, &term, &skip_args))
655 if (open (term, O_RDWR | OPEN_BINARY, 2) < 0)
656 fatal ("%s: %s", term, strerror (errno));
659 fatal ("%s: not a tty", term);
662 stderr_out ("Using %s", ttyname (0));
664 stderr_out ("Using %s", term);
665 inhibit_window_system = 1; /* -t => -nw */
669 /* Handle -nw switch */
670 if (argmatch (argv, argc, "-nw", "--no-windows", 6, NULL, &skip_args))
671 inhibit_window_system = 1;
673 /* Handle the -batch switch, which means don't do interactive display. */
674 if (argmatch (argv, argc, "-batch", "--batch", 5, NULL, &skip_args))
676 #if 0 /* I don't think this is correct. */
677 inhibit_autoloads = 1;
682 if (argmatch (argv, argc, "-debug-paths", "--debug-paths",
683 11, NULL, &skip_args))
686 /* Partially handle -no-autoloads, -no-early-packages and -vanilla. Packages */
687 /* are searched prior to the rest of the command line being parsed in */
689 if (argmatch (argv, argc, "-no-early-packages", "--no-early-packages",
690 6, NULL, &skip_args))
692 inhibit_early_packages = 1;
696 if (argmatch (argv, argc, "-no-site-modules", "--no-site-modules",
697 9, NULL, &skip_args))
699 inhibit_site_modules = 1;
703 inhibit_site_modules = 1;
705 if (argmatch (argv, argc, "-vanilla", "--vanilla",
706 7, NULL, &skip_args))
708 inhibit_early_packages = 1;
712 if (argmatch (argv, argc, "-no-autoloads", "--no-autoloads",
713 7, NULL, &skip_args))
715 /* Inhibit everything */
716 inhibit_autoloads = 1;
720 if (argmatch (argv, argc, "-debug-paths", "--debug-paths",
721 6, NULL, &skip_args))
728 /* Partially handle the -version and -help switches: they imply -batch,
729 but are not removed from the list. */
730 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
731 noninteractive = 1, skip_args--;
733 if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args) ||
734 argmatch (argv, argc, "-V", 0, 2, NULL, &skip_args))
735 noninteractive = 1, skip_args--;
737 /* Now, figure out which type of console is our first console. */
742 display_use = "stream";
747 if (inhibit_window_system)
748 fatal ("Sorry, this XEmacs was not compiled with TTY support");
751 #ifdef HAVE_WINDOW_SYSTEM
752 /* Stupid kludge to catch command-line display spec. We can't
753 handle this argument entirely in window-system-dependent code
754 because we don't even know which window-system-dependent code
755 to run until we've recognized this argument. */
756 if (!inhibit_window_system && !noninteractive)
758 #ifdef HAVE_X_WINDOWS
760 int count_before = skip_args;
762 if (argmatch (argv, argc, "-d", "--display", 3, &dpy, &skip_args) ||
763 argmatch (argv, argc, "-display", 0, 3, &dpy, &skip_args))
768 /* If we have the form --display=NAME,
769 convert it into -d name.
770 This requires inserting a new element into argv. */
771 if (dpy != 0 && skip_args - count_before == 1)
773 char **new = (char **) xmalloc (sizeof (char *) * (argc + 2));
776 for (j = 0; j < count_before + 1; j++)
778 new[count_before + 1] = "-d";
779 new[count_before + 2] = dpy;
780 for (j = count_before + 2; j <argc; j++)
781 new[j + 1] = argv[j];
785 /* Change --display to -d, when its arg is separate. */
786 else if (dpy != 0 && skip_args > count_before
787 && argv[count_before + 1][1] == '-')
788 argv[count_before + 1] = "-d";
790 /* Don't actually discard this arg. */
791 skip_args = count_before;
793 /* If there is a non-empty environment var DISPLAY, set
794 `display_use', but not `display_arg', which is only to be set
795 if the display was specified on the command line. */
796 if ((dpy = getenv ("DISPLAY")) && dpy[0])
799 #endif /* HAVE_X_WINDOWS */
800 #ifdef HAVE_MS_WINDOWS
801 if (strcmp(display_use, "x") != 0)
802 display_use = "mswindows";
803 #endif /* HAVE_MS_WINDOWS */
805 #endif /* HAVE_WINDOW_SYSTEM */
807 noninteractive1 = noninteractive;
809 /****** Now initialize everything *******/
811 /* First, do really basic environment initialization -- catching signals
812 and the like. These functions have no dependence on any part of
813 the Lisp engine and need to be done both at dump time and at run time. */
815 init_signals_very_early ();
816 init_data_very_early (); /* Catch math errors. */
817 #ifdef LISP_FLOAT_TYPE
818 init_floatfns_very_early (); /* Catch floating-point math errors. */
820 init_process_times_very_early (); /* Initialize our process timers.
821 As early as possible, of course,
822 so we can be fairly accurate. */
823 init_intl_very_early (); /* set up the locale and domain for gettext and
826 /* Now initialize the Lisp engine and the like. Done only during
827 dumping. No dependence on anything that may be in the user's
828 environment when the dumped XEmacs is run.
830 We try to do things in an order that minimizes the non-obvious
831 dependencies between functions. */
833 /* purify_flag 1 is correct even if CANNOT_DUMP.
834 * loadup.el will set to nil at end. */
841 initialized = pdump_load ();
842 purify_flag = !initialized;
851 /* Initialize things so that new Lisp objects
852 can be created and objects can be staticpro'd.
853 Must be basically the very first thing done
854 because pretty much all of the initialization
855 routines below create new objects. */
856 init_alloc_once_early ();
858 /* Initialize Qnil, Qt, Qunbound, and the
859 obarray. After this, symbols can be
860 interned. This depends on init_alloc_once_early(). */
861 init_symbols_once_early ();
863 /* Declare the basic symbols pertaining to errors,
864 So that deferror() can be called. */
865 init_errors_once_early ();
867 /* Make sure that opaque pointers can be created. */
868 init_opaque_once_early ();
870 /* Now declare all the symbols and define all the Lisp primitives.
872 The *only* thing that the syms_of_*() functions are allowed to do
873 is call one of the following three functions:
875 INIT_LRECORD_IMPLEMENTATION()
877 defsubr() (i.e. DEFSUBR)
881 Order does not matter in these functions.
890 syms_of_casefiddle ();
900 #endif /* DEBUG_XEMACS */
911 #ifdef HAVE_X_WINDOWS
914 #ifdef HAVE_DRAGNDROP
917 syms_of_event_stream ();
922 #ifdef CLASH_DETECTION
924 #endif /* CLASH_DETECTION */
927 syms_of_font_lock ();
931 syms_of_glyphs_eimage ();
932 syms_of_glyphs_widget ();
933 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
956 #if !defined (NO_SUBPROCESSES)
958 #ifdef HAVE_WIN32_PROCESSES
959 syms_of_process_nt ();
963 #if defined (HAVE_MMAP) && defined (REL_ALLOC) && !defined(DOUG_LEA_MALLOC)
965 #endif /* HAVE_MMAP && REL_ALLOC */
967 syms_of_redisplay ();
972 syms_of_specifier ();
975 #ifdef HAVE_SCROLLBARS
976 syms_of_scrollbar ();
986 syms_of_console_tty ();
987 syms_of_device_tty ();
988 syms_of_objects_tty ();
991 #ifdef HAVE_X_WINDOWS
992 syms_of_balloon_x ();
999 syms_of_objects_x ();
1000 #ifdef HAVE_MENUBARS
1001 syms_of_menubar_x ();
1003 syms_of_select_x ();
1004 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1009 syms_of_input_method_xlib ();
1011 #endif /* HAVE_XIM */
1012 #endif /* HAVE_X_WINDOWS */
1014 #ifdef HAVE_MS_WINDOWS
1015 syms_of_console_mswindows ();
1016 syms_of_device_mswindows ();
1017 syms_of_frame_mswindows ();
1018 syms_of_objects_mswindows ();
1019 syms_of_select_mswindows ();
1020 syms_of_glyphs_mswindows ();
1021 syms_of_gui_mswindows ();
1022 #ifdef HAVE_MENUBARS
1023 syms_of_menubar_mswindows ();
1025 #ifdef HAVE_SCROLLBARS
1026 syms_of_scrollbar_mswindows ();
1028 #ifdef HAVE_MSW_C_DIRED
1029 syms_of_dired_mswindows ();
1034 #endif /* HAVE_MS_WINDOWS */
1038 syms_of_mule_ccl ();
1039 syms_of_mule_charset ();
1042 syms_of_file_coding ();
1046 syms_of_mule_wnn ();
1049 syms_of_mule_canna ();
1050 #endif /* HAVE_CANNA */
1062 #if defined (GNU_MALLOC) && \
1063 defined (ERROR_CHECK_MALLOC) && \
1064 !defined (HAVE_LIBMCHECK)
1066 /* Prior to XEmacs 21, this was `#if 0'ed out. -slb */
1067 #if defined (LOSING_GCC_DESTRUCTOR_FREE_BUG)
1068 syms_of_free_hook ();
1072 syms_of_tooltalk ();
1084 syms_of_gpmevent ();
1087 /* Now create the subtypes for the types that have them.
1088 We do this before the vars_*() because more symbols
1089 may get initialized here. */
1091 /* Now initialize the console types and associated symbols.
1092 Other than the first function below, the functions may
1093 make exactly the following function/macro calls:
1095 INITIALIZE_CONSOLE_TYPE()
1096 CONSOLE_HAS_METHOD()
1098 For any given console type, the former macro must be called
1099 before the any calls to the latter macro. */
1101 console_type_create ();
1103 console_type_create_stream ();
1106 console_type_create_tty ();
1107 console_type_create_device_tty ();
1108 console_type_create_frame_tty ();
1109 console_type_create_objects_tty ();
1110 console_type_create_redisplay_tty ();
1113 #ifdef HAVE_X_WINDOWS
1114 console_type_create_x ();
1115 console_type_create_device_x ();
1116 console_type_create_frame_x ();
1117 console_type_create_glyphs_x ();
1118 console_type_create_select_x ();
1119 #ifdef HAVE_MENUBARS
1120 console_type_create_menubar_x ();
1122 console_type_create_objects_x ();
1123 console_type_create_redisplay_x ();
1124 #ifdef HAVE_SCROLLBARS
1125 console_type_create_scrollbar_x ();
1127 #ifdef HAVE_TOOLBARS
1128 console_type_create_toolbar_x ();
1131 console_type_create_dialog_x ();
1133 #endif /* HAVE_X_WINDOWS */
1135 #ifdef HAVE_MS_WINDOWS
1136 console_type_create_mswindows ();
1137 console_type_create_device_mswindows ();
1138 console_type_create_frame_mswindows ();
1139 console_type_create_objects_mswindows ();
1140 console_type_create_redisplay_mswindows ();
1141 console_type_create_glyphs_mswindows ();
1142 console_type_create_select_mswindows ();
1143 # ifdef HAVE_SCROLLBARS
1144 console_type_create_scrollbar_mswindows ();
1146 #ifdef HAVE_MENUBARS
1147 console_type_create_menubar_mswindows ();
1149 #ifdef HAVE_TOOLBARS
1150 console_type_create_toolbar_mswindows ();
1153 console_type_create_dialog_mswindows ();
1157 /* Now initialize the specifier types and associated symbols.
1158 Other than the first function below, the functions may
1159 make exactly the following function/macro calls:
1161 INITIALIZE_SPECIFIER_TYPE()
1162 SPECIFIER_HAS_METHOD()
1164 For any given specifier type, the former macro must be called
1165 before the any calls to the latter macro. */
1167 specifier_type_create ();
1169 specifier_type_create_image ();
1170 specifier_type_create_gutter ();
1171 specifier_type_create_objects ();
1172 #ifdef HAVE_TOOLBARS
1173 specifier_type_create_toolbar ();
1176 /* Now initialize the structure types and associated symbols.
1177 Other than the first function below, the functions may
1178 make exactly the following function/macro calls:
1180 define_structure_type()
1181 define_structure_type_keyword()
1185 structure_type_create ();
1187 structure_type_create_chartab ();
1188 structure_type_create_faces ();
1189 structure_type_create_rangetab ();
1190 structure_type_create_hash_table ();
1192 /* Now initialize the image instantiator formats and associated symbols.
1193 Other than the first function below, the functions may
1194 make exactly the following function/macro calls:
1196 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT()
1197 IIFORMAT_HAS_METHOD()
1198 IIFORMAT_VALID_KEYWORD()
1200 For any given image instantiator format, the first macro must be
1201 called before the any calls to the other macros. */
1203 image_instantiator_format_create ();
1204 image_instantiator_format_create_glyphs_eimage ();
1205 image_instantiator_format_create_glyphs_widget ();
1207 image_instantiator_format_create_glyphs_tty ();
1209 #ifdef HAVE_X_WINDOWS
1210 image_instantiator_format_create_glyphs_x ();
1211 #endif /* HAVE_X_WINDOWS */
1212 #ifdef HAVE_MS_WINDOWS
1213 image_instantiator_format_create_glyphs_mswindows ();
1214 #endif /* HAVE_MSWINDOWS_WINDOWS */
1216 /* Now initialize the lstream types and associated symbols.
1217 Other than the first function below, the functions may
1218 make exactly the following function/macro calls:
1220 LSTREAM_HAS_METHOD()
1224 lstream_type_create ();
1226 lstream_type_create_file_coding ();
1228 #if defined (HAVE_MS_WINDOWS) && !defined(HAVE_MSG_SELECT)
1229 lstream_type_create_mswindows_selectable ();
1232 /* Initialize processes implementation.
1233 The functions may make exactly the following function/macro calls:
1235 PROCESS_HAS_METHOD()
1237 #ifdef HAVE_UNIX_PROCESSES
1238 process_type_create_unix ();
1240 #ifdef HAVE_WIN32_PROCESSES
1241 process_type_create_nt ();
1244 /* Now initialize most variables.
1246 These functions may do exactly the following:
1259 defsymbol(), if it's absolutely necessary and you're sure that
1260 the symbol isn't referenced anywhere else in the initialization
1262 Fset() on a symbol that is unbound
1263 assigning a symbol or constant value to a variable
1264 using a global variable that has been initialized
1265 earlier on in the same function
1267 Any of the object-creating functions on alloc.c: e.g.
1280 perhaps a few others.
1283 /* Now allow Fprovide() statements to be made. */
1284 init_provide_once ();
1286 /* Do that before any specifier creation (esp. vars_of_glyphs()) */
1287 vars_of_specifier ();
1292 vars_of_bytecode ();
1294 vars_of_callproc ();
1304 vars_of_console_stream ();
1311 #ifdef HAVE_DRAGNDROP
1312 vars_of_dragdrop ();
1319 #ifdef HAVE_X_WINDOWS
1320 vars_of_event_Xt ();
1322 #if defined(HAVE_TTY) && (defined (DEBUG_TTY_EVENT_STREAM) || !defined (HAVE_X_WINDOWS))
1323 vars_of_event_tty ();
1325 #ifdef HAVE_MS_WINDOWS
1326 vars_of_event_mswindows ();
1328 vars_of_event_stream ();
1334 vars_of_floatfns ();
1335 vars_of_font_lock ();
1338 vars_of_glyphs_eimage ();
1339 vars_of_glyphs_widget ();
1340 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1349 vars_of_input_method_motif ();
1350 #else /* XIM_XLIB */
1351 vars_of_input_method_xlib ();
1353 #endif /* HAVE_XIM */
1359 #ifdef HAVE_DATABASE
1360 vars_of_database ();
1362 #ifdef HAVE_MENUBARS
1376 #ifndef NO_SUBPROCESSES
1378 #ifdef HAVE_UNIX_PROCESSES
1379 vars_of_process_unix ();
1381 #ifdef HAVE_WIN32_PROCESSES
1382 vars_of_process_nt ();
1387 #if defined (HAVE_MMAP) && defined (REL_ALLOC) && !defined(DOUG_LEA_MALLOC)
1389 #endif /* HAVE_MMAP && REL_ALLOC */
1390 vars_of_redisplay ();
1391 #ifdef HAVE_SCROLLBARS
1392 vars_of_scrollbar ();
1399 #ifdef HAVE_TOOLBARS
1406 vars_of_console_tty ();
1407 vars_of_frame_tty ();
1408 vars_of_objects_tty ();
1411 #ifdef HAVE_X_WINDOWS
1412 vars_of_balloon_x ();
1413 vars_of_device_x ();
1415 vars_of_dialog_x ();
1418 vars_of_glyphs_x ();
1419 #ifdef HAVE_MENUBARS
1420 vars_of_menubar_x ();
1422 vars_of_objects_x ();
1423 vars_of_select_x ();
1424 #ifdef HAVE_SCROLLBARS
1425 vars_of_scrollbar_x ();
1427 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1430 #endif /* HAVE_X_WINDOWS */
1432 #ifdef HAVE_MS_WINDOWS
1433 vars_of_device_mswindows ();
1434 vars_of_console_mswindows ();
1435 vars_of_frame_mswindows ();
1436 vars_of_objects_mswindows ();
1437 vars_of_select_mswindows ();
1438 vars_of_glyphs_mswindows ();
1439 #ifdef HAVE_SCROLLBARS
1440 vars_of_scrollbar_mswindows ();
1442 #ifdef HAVE_MENUBARS
1443 vars_of_menubar_mswindows ();
1445 #ifdef HAVE_MSW_C_DIRED
1446 vars_of_dired_mswindows ();
1449 vars_of_dialog_mswindows ();
1451 #endif /* HAVE_MS_WINDOWS */
1455 vars_of_mule_ccl ();
1456 vars_of_mule_charset ();
1459 vars_of_file_coding ();
1463 vars_of_mule_wnn ();
1466 vars_of_mule_canna ();
1467 #endif /* HAVE_CANNA */
1471 vars_of_tooltalk ();
1483 vars_of_gpmevent ();
1486 /* Now initialize any specifier variables. We do this later
1487 because it has some dependence on the vars initialized
1490 These functions should *only* initialize specifier variables,
1491 and may make use of the following functions/macros in addition
1492 to the ones listed above:
1496 set_specifier_fallback()
1497 set_specifier_caching()
1500 specifier_vars_of_glyphs ();
1501 specifier_vars_of_gutter ();
1502 #ifdef HAVE_MENUBARS
1503 specifier_vars_of_menubar ();
1505 specifier_vars_of_redisplay ();
1506 #ifdef HAVE_SCROLLBARS
1507 specifier_vars_of_scrollbar ();
1509 #ifdef HAVE_TOOLBARS
1510 specifier_vars_of_toolbar ();
1512 specifier_vars_of_window ();
1514 /* Now comes all the rest of the variables that couldn't
1515 be handled above. There may be dependencies on variables
1516 initialized above, and dependencies between one complex_vars_()
1517 function and another. */
1519 /* Calls Fmake_range_table(). */
1520 complex_vars_of_regex ();
1521 /* Calls Fmake_range_table(). */
1522 complex_vars_of_search ();
1524 /* Calls make_lisp_hash_table(). */
1525 complex_vars_of_extents ();
1527 /* Depends on hash tables and specifiers. */
1528 complex_vars_of_faces ();
1531 /* These two depend on hash tables and various variables declared
1532 earlier. The second may also depend on the first. */
1533 complex_vars_of_mule_charset ();
1536 complex_vars_of_file_coding ();
1539 /* This calls allocate_glyph(), which creates specifiers
1540 and also relies on a variable (Vthe_nothing_vector) initialized
1541 above. It also calls make_ext_string(), which under Mule
1542 could require that the charsets be initialized. */
1543 complex_vars_of_glyphs ();
1545 /* These rely on the glyphs just created in the previous function,
1546 and call Fadd_spec_to_specifier(), which relies on various
1547 variables initialized above. */
1548 #ifdef HAVE_X_WINDOWS
1549 complex_vars_of_glyphs_x ();
1551 #ifdef HAVE_MS_WINDOWS
1552 complex_vars_of_glyphs_mswindows ();
1555 /* This calls Fmake_glyph_internal(). */
1556 complex_vars_of_alloc ();
1558 /* This calls Fmake_glyph_internal(). */
1559 #ifdef HAVE_MENUBARS
1560 complex_vars_of_menubar ();
1563 /* This calls Fmake_glyph_internal(). */
1564 #ifdef HAVE_SCROLLBARS
1565 complex_vars_of_scrollbar ();
1568 /* This calls allocate_glyph(). */
1569 complex_vars_of_frame ();
1571 /* This calls Fcopy_category_table() under Mule, which calls who
1573 complex_vars_of_chartab ();
1575 /* This calls set_string_char(), which (under Mule) depends on the
1576 charsets being initialized. */
1577 complex_vars_of_casetab ();
1579 /* This calls Fcopy_syntax_table(), which relies on char tables. */
1580 complex_vars_of_syntax ();
1582 /* This initializes buffer-local variables, sets things up so
1583 that buffers can be created, and creates a couple of basic
1584 buffers. This depends on Vstandard_syntax_table and
1585 Vstandard_category_table (initialized in the previous
1586 functions), as well as a whole horde of variables that may
1587 have been initialized above. */
1588 complex_vars_of_buffer ();
1590 /* This initializes console-local variables. */
1591 complex_vars_of_console ();
1593 /* This creates a couple more buffers, and depends on the
1594 previous function. */
1595 complex_vars_of_minibuf ();
1597 /* These two might call Ffile_name_as_directory(), which
1598 might depend on all sorts of things; I'm not sure. */
1599 complex_vars_of_emacs ();
1601 /* This creates a couple of basic keymaps and depends on Lisp
1602 hash tables and Ffset() (both of which depend on some variables
1603 initialized in the vars_of_*() section) and possibly other
1605 complex_vars_of_keymap ();
1607 /* Calls make_lisp_hash_table() and creates a keymap */
1608 complex_vars_of_event_stream ();
1610 #ifdef ERROR_CHECK_GC
1612 extern int always_gc;
1613 if (always_gc) /* purification debugging hack */
1614 garbage_collect_1 ();
1618 } else if (!restart) {
1619 reinit_alloc_once_early ();
1620 reinit_symbols_once_early ();
1621 reinit_opaque_once_early ();
1623 reinit_console_type_create_stream ();
1625 reinit_console_type_create_tty ();
1627 #ifdef HAVE_X_WINDOWS
1628 reinit_console_type_create_x ();
1629 reinit_console_type_create_device_x ();
1631 #ifdef HAVE_MS_WINDOWS
1632 reinit_console_type_create_mswindows ();
1635 reinit_specifier_type_create ();
1636 reinit_specifier_type_create_image ();
1637 reinit_specifier_type_create_gutter ();
1638 reinit_specifier_type_create_objects ();
1639 #ifdef HAVE_TOOLBARS
1640 reinit_specifier_type_create_toolbar ();
1643 structure_type_create ();
1645 structure_type_create_chartab ();
1646 structure_type_create_faces ();
1647 structure_type_create_rangetab ();
1648 structure_type_create_hash_table ();
1650 lstream_type_create ();
1652 lstream_type_create_file_coding ();
1654 #if defined (HAVE_MS_WINDOWS) && !defined(HAVE_MSG_SELECT)
1655 lstream_type_create_mswindows_selectable ();
1657 #ifdef HAVE_UNIX_PROCESSES
1658 process_type_create_unix ();
1660 #ifdef HAVE_WIN32_PROCESSES
1661 process_type_create_nt ();
1664 reinit_vars_of_buffer ();
1665 reinit_vars_of_console ();
1667 reinit_vars_of_debug ();
1669 reinit_vars_of_device ();
1670 reinit_vars_of_eval ();
1671 #ifdef HAVE_X_WINDOWS
1672 reinit_vars_of_event_Xt ();
1674 #if defined(HAVE_TTY) && (defined (DEBUG_TTY_EVENT_STREAM) || !defined (HAVE_X_WINDOWS))
1675 reinit_vars_of_event_tty ();
1677 #ifdef HAVE_MS_WINDOWS
1678 reinit_vars_of_event_mswindows ();
1680 reinit_vars_of_event_stream ();
1681 reinit_vars_of_events ();
1682 reinit_vars_of_extents ();
1683 reinit_vars_of_font_lock ();
1684 reinit_vars_of_glyphs ();
1685 reinit_vars_of_glyphs_widget ();
1686 reinit_vars_of_insdel ();
1687 reinit_vars_of_lread ();
1688 reinit_vars_of_lstream ();
1689 reinit_vars_of_minibuf ();
1691 reinit_vars_of_module ();
1693 reinit_vars_of_objects ();
1694 reinit_vars_of_print ();
1695 reinit_vars_of_redisplay ();
1696 reinit_vars_of_search ();
1697 reinit_vars_of_undo ();
1698 reinit_vars_of_window ();
1700 #ifdef HAVE_MS_WINDOWS
1701 reinit_vars_of_frame_mswindows ();
1704 #ifdef HAVE_X_WINDOWS
1705 reinit_vars_of_device_x ();
1706 #ifdef HAVE_SCROLLBARS
1707 reinit_vars_of_scrollbar_x ();
1709 #ifdef HAVE_MENUBARS
1710 reinit_vars_of_menubar_x ();
1712 reinit_vars_of_select_x ();
1713 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1714 reinit_vars_of_gui_x ();
1716 #endif /* HAVE_X_WINDOWS */
1718 #if defined(MULE) && defined(HAVE_WNN)
1719 reinit_vars_of_mule_wnn ();
1722 reinit_complex_vars_of_buffer ();
1723 reinit_complex_vars_of_console ();
1724 reinit_complex_vars_of_minibuf ();
1729 /* CONGRATULATIONS!!! We have successfully initialized the Lisp
1734 /* Stuff that needs to be reset at run time. Order below should
1739 reinit_mule_category ();
1743 /* Now do further initialization/setup of stuff that is not needed by the
1744 syms_of_() routines. This involves stuff that only is enabled in
1745 an interactive run (redisplay, user input, etc.) and stuff that is
1746 not needed until we start loading Lisp code (the reader). A lot
1747 of this stuff involves querying the current environment and needs
1748 to be done both at dump time and at run time. */
1750 init_initial_directory(); /* get the directory to use for the
1751 "*scratch*" buffer, etc. */
1755 * For Win32, call init_environment() now, so that environment/registry
1756 * variables will be properly entered into Vprocess_environment.
1761 init_callproc (); /* Set up the process environment (so that egetenv
1762 works), the basic directory variables
1763 (exec-directory and so on), and stuff
1764 related to subprocesses. This should be
1765 first because many of the functions below
1766 call egetenv() to get environment variables. */
1767 init_lread (); /* Set up the Lisp reader. */
1769 /* Call early 'cause init_environment needs it. */
1771 /* Set defaults for several environment variables. */
1772 init_environment (argc, argv, skip_args);
1774 init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */
1775 init_buffer (); /* Set default directory of *scratch* buffer */
1781 init_redisplay (); /* Determine terminal type.
1782 init_sys_modes uses results */
1784 init_event_stream (); /* Set up so we can get user input. */
1785 init_macros (); /* set up so we can run macros. */
1786 init_editfns (); /* Determine the name of the user we're running as */
1787 init_xemacs_process (); /* set up for calling subprocesses */
1789 init_sunpro (); /* Set up Sunpro usage tracking */
1791 #if defined (HAVE_NATIVE_SOUND) && defined (hp9000s800)
1797 init_console_stream (); /* Create the first console */
1799 /* try to get the actual pathname of the exec file we are running */
1802 Vinvocation_name = Fcar (Vcommand_line_args);
1803 if (XSTRING_DATA(Vinvocation_name)[0] == '-')
1805 /* XEmacs as a login shell, oh goody! */
1806 Vinvocation_name = build_string(getenv("SHELL"));
1808 Vinvocation_directory = Vinvocation_name;
1810 if (!NILP (Ffile_name_directory (Vinvocation_name)))
1812 /* invocation-name includes a directory component -- presumably it
1813 is relative to cwd, not $PATH */
1814 Vinvocation_directory = Fexpand_file_name (Vinvocation_name,
1816 Vinvocation_path = Qnil;
1820 Vinvocation_path = decode_env_path ("PATH", NULL);
1821 locate_file (Vinvocation_path, Vinvocation_name,
1822 Vlisp_EXEC_SUFFIXES,
1823 &Vinvocation_directory, X_OK);
1826 if (NILP (Vinvocation_directory))
1827 Vinvocation_directory = Vinvocation_name;
1829 Vinvocation_name = Ffile_name_nondirectory (Vinvocation_directory);
1830 Vinvocation_directory = Ffile_name_directory (Vinvocation_directory);
1833 #if defined(HAVE_SHLIB) && !defined(WINDOWSNT)
1834 /* This is Unix only. MS Windows NT has a library call that does
1835 The Right Thing on that system. Rumor has it, this must be
1836 called for GNU dld in temacs and xemacs. */
1838 char *buf = (char *)alloca (XSTRING_LENGTH (Vinvocation_directory)
1839 + XSTRING_LENGTH (Vinvocation_name)
1841 sprintf (buf, "%s/%s", XSTRING_DATA (Vinvocation_directory),
1842 XSTRING_DATA (Vinvocation_name));
1844 /* All we can do is cry if an error happens, so ignore it. */
1845 (void) dll_init (buf);
1849 #if defined (LOCALTIME_CACHE) && defined (HAVE_TZSET)
1850 /* sun's localtime() has a bug. it caches the value of the time
1851 zone rather than looking it up every time. Since localtime() is
1852 called to bolt the undumping time into the undumped emacs, this
1853 results in localtime() ignoring the TZ environment variable.
1854 This flushes the new TZ value into localtime(). */
1856 #endif /* LOCALTIME_CACHE and TZSET */
1861 /* Handle -l loadup-and-dump, args passed by Makefile. */
1862 if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l"))
1863 load_me = build_string (argv[2 + skip_args]);
1864 #if 0 /* CANNOT_DUMP - this can never be right in XEmacs --andyp */
1865 /* Unless next switch is -nl, load "loadup.el" first thing. */
1866 if (!(argc > 1 + skip_args && !strcmp (argv[1 + skip_args], "-nl")))
1867 load_me = build_string ("loadup.el");
1868 #endif /* CANNOT_DUMP */
1873 quantify_start_recording_data ();
1874 #endif /* QUANTIFY */
1878 /* This never returns. */
1879 initial_command_loop (load_me);
1884 /* Sort the args so we can find the most important ones
1885 at the beginning of argv. */
1887 /* First, here's a table of all the standard options. */
1889 struct standard_args
1892 const char *longname;
1897 static const struct standard_args standard_args[] =
1899 /* Handled by main_1 above: */
1900 { "-nl", "--no-shared-memory", 100, 0 },
1901 { "-t", "--terminal", 95, 1 },
1902 { "-nw", "--no-windows", 90, 0 },
1903 { "-batch", "--batch", 85, 0 },
1904 { "-debug-paths", "--debug-paths", 82, 0 },
1905 { "-help", "--help", 80, 0 },
1906 { "-version", "--version", 75, 0 },
1908 { "-d", "--display", 80, 1 },
1909 { "-display", 0, 80, 1 },
1910 { "-NXHost", 0, 79, 0 },
1911 { "-MachLaunch", 0, 79, 0},
1913 /* Handled by command-line-early in startup.el: */
1914 { "-q", "--no-init-file", 50, 0 },
1915 { "-unmapped", 0, 50, 0 },
1916 { "-no-init-file", 0, 50, 0 },
1917 { "-vanilla", "--vanilla", 50, 0 },
1918 { "-no-autoloads", "--no-autoloads", 50, 0 },
1919 { "-no-site-file", "--no-site-file", 40, 0 },
1920 { "-no-early-packages", "--no-early-packages", 35, 0 },
1921 { "-u", "--user", 30, 1 },
1922 { "-user", 0, 30, 1 },
1923 { "-debug-init", "--debug-init", 20, 0 },
1924 { "-debug-paths", "--debug-paths", 20, 0 },
1927 { "-i", "--icon-type", 15, 0 },
1928 { "-itype", 0, 15, 0 },
1929 { "-iconic", "--iconic", 15, 0 },
1930 { "-bg", "--background-color", 10, 1 },
1931 { "-background", 0, 10, 1 },
1932 { "-fg", "--foreground-color", 10, 1 },
1933 { "-foreground", 0, 10, 1 },
1934 { "-bd", "--border-color", 10, 1 },
1935 { "-bw", "--border-width", 10, 1 },
1936 { "-ib", "--internal-border", 10, 1 },
1937 { "-ms", "--mouse-color", 10, 1 },
1938 { "-cr", "--cursor-color", 10, 1 },
1939 { "-fn", "--font", 10, 1 },
1940 { "-font", 0, 10, 1 },
1941 { "-g", "--geometry", 10, 1 },
1942 { "-geometry", 0, 10, 1 },
1943 { "-T", "--title", 10, 1 },
1944 { "-title", 0, 10, 1 },
1945 { "-name", "--name", 10, 1 },
1946 { "-xrm", "--xrm", 10, 1 },
1947 { "-r", "--reverse-video", 5, 0 },
1949 { "-reverse", 0, 5, 0 },
1950 { "-hb", "--horizontal-scroll-bars", 5, 0 },
1951 { "-vb", "--vertical-scroll-bars", 5, 0 },
1953 /* These have the same priority as ordinary file name args,
1954 so they are not reordered with respect to those. */
1955 { "-L", "--directory", 0, 1 },
1956 { "-directory", 0, 0, 1 },
1957 { "-l", "--load", 0, 1 },
1958 { "-load", 0, 0, 1 },
1959 { "-f", "--funcall", 0, 1 },
1960 { "-funcall", 0, 0, 1 },
1961 { "-eval", "--eval", 0, 1 },
1962 { "-insert", "--insert", 0, 1 },
1963 /* This should be processed after ordinary file name args and the like. */
1964 { "-kill", "--kill", -10, 0 },
1967 /* Reorder the elements of ARGV (assumed to have ARGC elements)
1968 so that the highest priority ones come first.
1969 Do not change the order of elements of equal priority.
1970 If an option takes an argument, keep it and its argument together. */
1973 sort_args (int argc, char **argv)
1975 char **new_argv = xnew_array (char *, argc);
1976 /* For each element of argv,
1977 the corresponding element of options is:
1978 0 for an option that takes no arguments,
1979 1 for an option that takes one argument, etc.
1980 -1 for an ordinary non-option argument. */
1981 int *options = xnew_array (int, argc);
1982 int *priority = xnew_array (int, argc);
1986 int end_of_options_p = 0;
1988 /* Categorize all the options,
1989 and figure out which argv elts are option arguments. */
1990 for (from = 1; from < argc; from++)
1994 /* Pseudo options "--" and "run-temacs" indicate end of options */
1995 if (!strcmp (argv[from], "--") ||
1996 !strcmp (argv[from], "run-temacs"))
1997 end_of_options_p = 1;
1998 if (!end_of_options_p && argv[from][0] == '-')
2003 /* Look for a match with a known old-fashioned option. */
2004 for (i = 0; i < countof (standard_args); i++)
2005 if (!strcmp (argv[from], standard_args[i].name))
2007 options[from] = standard_args[i].nargs;
2008 priority[from] = standard_args[i].priority;
2009 if (from + standard_args[i].nargs >= argc)
2010 fatal ("Option `%s' requires an argument\n", argv[from]);
2011 from += standard_args[i].nargs;
2015 /* Look for a match with a known long option.
2016 MATCH is -1 if no match so far, -2 if two or more matches so far,
2017 >= 0 (the table index of the match) if just one match so far. */
2018 if (argv[from][1] == '-')
2021 thislen = strlen (argv[from]);
2022 equals = strchr (argv[from], '=');
2024 thislen = equals - argv[from];
2026 for (i = 0; i < countof (standard_args); i++)
2027 if (standard_args[i].longname
2028 && !strncmp (argv[from], standard_args[i].longname,
2037 /* If we found exactly one match, use that. */
2040 options[from] = standard_args[match].nargs;
2041 priority[from] = standard_args[match].priority;
2042 /* If --OPTION=VALUE syntax is used,
2043 this option uses just one argv element. */
2046 if (from + options[from] >= argc)
2047 fatal ("Option `%s' requires an argument\n", argv[from]);
2048 from += options[from];
2055 /* Copy the arguments, in order of decreasing priority, to NEW_ARGV. */
2056 new_argv[0] = argv[0];
2060 int best_priority = -9999;
2062 /* Find the highest priority remaining option.
2063 If several have equal priority, take the first of them. */
2064 for (from = 1; from < argc; from++)
2066 if (argv[from] != 0 && priority[from] > best_priority)
2068 best_priority = priority[from];
2071 /* Skip option arguments--they are tied to the options. */
2072 if (options[from] > 0)
2073 from += options[from];
2079 /* Copy the highest priority remaining option, with its args, to NEW_ARGV. */
2080 new_argv[to++] = argv[best];
2081 for (i = 0; i < options[best]; i++)
2082 new_argv[to++] = argv[best + i + 1];
2084 /* Clear out this option in ARGV. */
2086 for (i = 0; i < options[best]; i++)
2087 argv[best + i + 1] = 0;
2090 memcpy (argv, new_argv, sizeof (char *) * argc);
2096 static JMP_BUF run_temacs_catch;
2098 static int run_temacs_argc;
2099 static char **run_temacs_argv;
2100 static char *run_temacs_args;
2101 static size_t run_temacs_argv_size;
2102 static size_t run_temacs_args_size;
2104 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /*
2105 True if running temacs. This means we are in the dumping stage.
2106 This is false during normal execution of the `xemacs' program, and
2107 becomes false once `run-emacs-from-temacs' is run.
2111 return run_temacs_argc >= 0 ? Qt : Qnil;
2114 DEFUN ("run-emacs-from-temacs", Frun_emacs_from_temacs, 0, MANY, 0, /*
2115 Do not call this. It will reinitialize your XEmacs. You'll be sorry.
2117 /* If this function is called from startup.el, it will be possible to run
2118 temacs as an editor using 'temacs -batch -l loadup.el run-temacs', instead
2119 of having to dump an emacs and then run that (when debugging emacs itself,
2120 this can be much faster)). [Actually, the speed difference isn't that
2121 much as long as your filesystem is local, and you don't end up with
2122 a dumped version in case you want to rerun it. This function is most
2123 useful when used as part of the `make all-elc' command. --ben]
2124 This will "restart" emacs with the specified command-line arguments.
2126 Martin thinks this function is most useful when using debugging
2127 tools like Purify or tcov that get confused by XEmacs' dumping. */
2128 (int nargs, Lisp_Object *args))
2131 const Extbyte *wampum;
2134 Lisp_Object orig_invoc_name = Fcar (Vcommand_line_args);
2135 const Extbyte **wampum_all = alloca_array (const Extbyte *, nargs);
2136 int *wampum_all_len = alloca_array (int, nargs);
2138 assert (!gc_in_progress);
2140 if (run_temacs_argc < 0)
2141 error ("I've lost my temacs-hood.");
2143 /* Need to convert the orig_invoc_name and all of the arguments
2144 to external format. */
2146 TO_EXTERNAL_FORMAT (LISP_STRING, orig_invoc_name,
2147 ALLOCA, (wampum, namesize),
2151 for (ac = 0, total_len = namesize; ac < nargs; ac++)
2153 CHECK_STRING (args[ac]);
2154 TO_EXTERNAL_FORMAT (LISP_STRING, args[ac],
2155 ALLOCA, (wampum_all[ac], wampum_all_len[ac]),
2157 wampum_all_len[ac]++;
2158 total_len += wampum_all_len[ac];
2160 DO_REALLOC (run_temacs_args, run_temacs_args_size, total_len, char);
2161 DO_REALLOC (run_temacs_argv, run_temacs_argv_size, nargs+2, char *);
2163 memcpy (run_temacs_args, wampum, namesize);
2164 run_temacs_argv [0] = run_temacs_args;
2165 for (ac = 0; ac < nargs; ac++)
2167 memcpy (run_temacs_args + namesize,
2168 wampum_all[ac], wampum_all_len[ac]);
2169 run_temacs_argv [ac + 1] = run_temacs_args + namesize;
2170 namesize += wampum_all_len[ac];
2172 run_temacs_argv [nargs + 1] = 0;
2173 catchlist = NULL; /* Important! Otherwise free_cons() calls in
2174 condition_case_unwind() may lead to GC death. */
2175 unbind_to (0, Qnil); /* this closes loadup.el */
2177 run_temacs_argc = nargs + 1;
2179 report_sheap_usage (0);
2181 LONGJMP (run_temacs_catch, 1);
2182 return Qnil; /* not reached; warning suppression */
2187 main (int argc, char **argv, char **envp)
2189 int volatile vol_argc = argc;
2190 char ** volatile vol_argv = argv;
2191 char ** volatile vol_envp = envp;
2192 /* This is hairy. We need to compute where the XEmacs binary was invoked
2193 from because temacs initialization requires it to find the lisp
2194 directories. The code that recomputes the path is guarded by the
2195 restarted flag. There are three possible paths I've found so far
2198 temacs -- When running temacs for basic build stuff, the first main_1
2199 will be the only one invoked. It must compute the path else there
2200 will be a very ugly bomb in startup.el (can't find obvious location
2201 for doc-directory data-directory, etc.).
2203 temacs w/ run-temacs on the command line -- This is run to bytecompile
2204 all the out of date dumped lisp. It will execute both of the main_1
2205 calls and the second one must not touch the first computation because
2206 argc/argv are hosed the second time through.
2208 xemacs -- Only the second main_1 is executed. The invocation path must
2209 computed but this only matters when running in place or when running
2212 As a bonus for straightening this out, XEmacs can now be run in place
2213 as a login shell. This never used to work.
2215 As another bonus, we can now guarantee that
2216 (concat invocation-directory invocation-name) contains the filename
2217 of the XEmacs binary we are running. This can now be used in a
2218 definite test for out of date dumped files. -slb */
2221 quantify_stop_recording_data ();
2222 quantify_clear_data ();
2223 #endif /* QUANTIFY */
2225 suppress_early_error_handler_backtrace = 0;
2226 lim_data = 0; /* force reinitialization of this variable */
2228 /* Lisp_Object must fit in a word; check VALBITS and GCTYPEBITS */
2229 assert (sizeof (Lisp_Object) == sizeof (void *));
2231 #ifdef LINUX_SBRK_BUG
2237 #ifdef DOUG_LEA_MALLOC
2238 mallopt (M_MMAP_MAX, 0);
2240 run_temacs_argc = 0;
2241 if (! SETJMP (run_temacs_catch))
2243 main_1 (vol_argc, vol_argv, vol_envp, 0);
2245 /* run-emacs-from-temacs called */
2247 vol_argc = run_temacs_argc;
2248 vol_argv = run_temacs_argv;
2250 /* This makes absolutely no sense to anyone involved. There are
2251 several people using this stuff. We've compared versions on
2252 everything we can think of. We can find no difference.
2253 However, on both my systems environ is a plain old global
2254 variable initialized to zero. _environ is the one that
2255 contains pointers to the actual environment.
2257 Since we can't figure out the difference (and we're hours
2258 away from a release), this takes a very cowardly approach and
2259 is bracketed with both a system specific preprocessor test
2260 and a runtime "do you have this problem" test
2262 06/20/96 robertl@dgii.com */
2264 extern char *_environ;
2265 if ((unsigned) environ == 0)
2268 #endif /* _SCO_DS */
2271 #ifdef RUN_TIME_REMAP
2273 /* obviously no-one uses this because where it was before initialized was
2275 run_time_remap (argv[0]);
2278 #ifdef DOUG_LEA_MALLOC
2279 if (initialized && (malloc_state_ptr != NULL))
2281 int rc = malloc_set_state (malloc_state_ptr);
2284 fprintf (stderr, "malloc_set_state failed, rc = %d\n", rc);
2288 free (malloc_state_ptr);
2290 /* mmap works in glibc-2.1, glibc-2.0 (Non-Mule only) and Linux libc5 */
2291 #if (defined(__GLIBC__) && __GLIBC_MINOR__ >= 1) || \
2292 defined(_NO_MALLOC_WARNING_) || \
2293 (defined(__GLIBC__) && __GLIBC_MINOR__ < 1 && !defined(MULE)) || \
2294 defined(DEBUG_DOUG_LEA_MALLOC)
2295 mallopt (M_MMAP_MAX, 64);
2301 #endif /* DOUG_LEA_MALLOC */
2303 run_temacs_argc = -1;
2305 main_1 (vol_argc, vol_argv, vol_envp, restarted);
2306 return 0; /* unreached */
2310 /* Dumping apparently isn't supported by versions of GCC >= 2.8. */
2311 /* The following needs conditionalization on whether either XEmacs or */
2312 /* various system shared libraries have been built and linked with */
2313 /* GCC >= 2.8. -slb */
2314 #if defined(GNU_MALLOC)
2316 voodoo_free_hook (void *mem)
2318 /* Disable all calls to free() when XEmacs is exiting and it doesn't */
2321 #ifdef __GNUC__ /* prototype of __free_hook varies with glibc version */
2322 (__typeof__ (__free_hook))
2326 #endif /* GNU_MALLOC */
2328 DEFUN ("kill-emacs", Fkill_emacs, 0, 1, "P", /*
2329 Exit the XEmacs job and kill it. Ask for confirmation, without argument.
2330 If ARG is an integer, return ARG as the exit program code.
2331 If ARG is a string, stuff it as keyboard input.
2333 The value of `kill-emacs-hook', if not void,
2334 is a list of functions (of no args),
2335 all of which are called before XEmacs is actually killed.
2339 /* This function can GC */
2340 struct gcpro gcpro1;
2347 if (!preparing_for_armageddon && !noninteractive)
2348 run_hook (Qkill_emacs_hook);
2350 /* make sure no quitting from now on!! */
2351 dont_check_for_quit = 1;
2354 if (!preparing_for_armageddon)
2356 Lisp_Object concons, nextcons;
2358 /* Normally, go ahead and delete all the consoles now.
2359 Some unmentionably lame window systems (MS Wwwww...... eek,
2360 I can't even say it) don't properly clean up after themselves,
2361 and even for those that do, it might be cleaner this way.
2362 If we're going down, however, we don't do this (might
2363 be too dangerous), and if we get a crash somewhere within
2364 this loop, we'll still autosave and won't try this again. */
2366 LIST_LOOP_DELETING(concons, nextcons, Vconsole_list)
2368 /* There is very little point in deleting the stream console.
2369 It uses stdio, which should flush any buffered output and
2370 something can only go wrong. -slb */
2371 /* I changed my mind. There's a stupid hack in close to add
2372 a trailing newline. */
2373 /*if (!CONSOLE_STREAM_P (XCONSOLE (XCAR (concons))))*/
2374 delete_console_internal (XCONSOLE (XCAR (concons)), 1, 1, 0);
2380 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil);
2382 #if defined(GNU_MALLOC)
2384 #ifdef __GNUC__ /* prototype of __free_hook varies with glibc version */
2385 (__typeof__ (__free_hook))
2390 exit (INTP (arg) ? XINT (arg) : 0);
2392 return Qnil; /* I'm sick of the compiler warning */
2395 /* Perform an orderly shutdown of XEmacs. Autosave any modified
2396 buffers, kill any child processes, clean up the terminal modes (if
2397 we're in the foreground), and other stuff like that. Don't perform
2398 any redisplay; this may be called when XEmacs is shutting down in
2399 the background, or after its X connection has died.
2401 If SIG is a signal number, print a message for it.
2403 This is called by fatal signal handlers, X protocol error handlers,
2406 shut_down_emacs (int sig, Lisp_Object stuff)
2408 /* This function can GC */
2409 /* Prevent running of hooks and other non-essential stuff
2411 preparing_for_armageddon = 1;
2413 /* In case frames or windows are screwed up, avoid assertion
2418 quantify_stop_recording_data ();
2419 #endif /* QUANTIFY */
2422 /* This is absolutely the most important thing to do, so make sure
2423 we do it now, before anything else. We might have crashed and
2424 be in a weird inconsistent state, and potentially anything could
2425 set off another protection fault and cause us to bail out
2427 /* I'm not removing the code entirely, yet. We have run up against
2428 a spate of problems in diagnosing crashes due to crashes within
2429 crashes. It has very definitely been determined that code called
2430 during auto-saving cannot work if XEmacs crashed inside of GC.
2431 We already auto-save on an itimer so there cannot be too much
2432 unsaved stuff around, and if we get better crash reports we might
2433 be able to get more problems fixed so I'm disabling this. -slb */
2434 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */
2438 reset_all_consoles ();
2439 if (sig && sig != SIGTERM)
2441 stderr_out ("\nFatal error (%d).\n", sig);
2443 ("Your files have been auto-saved.\n"
2444 "Use `M-x recover-session' to recover them.\n"
2446 "If you have access to the PROBLEMS file that came with your\n"
2447 "version of XEmacs, please check to see if your crash is described\n"
2448 "there, as there may be a workaround available.\n"
2450 "Otherwise, please report this bug by selecting `Report-Bug'\n"
2451 "in the InfoDock menu.\n"
2453 "Otherwise, please report this bug by running the send-pr\n"
2454 "script included with XEmacs, or selecting `Send Bug Report'\n"
2455 "from the help menu.\n"
2456 "As a last resort send ordinary email to `crashes@xemacs.org'.\n"
2458 "*MAKE SURE* to include the information in the command\n"
2459 "M-x describe-installation.\n"
2461 "If at all possible, *please* try to obtain a C stack backtrace;\n"
2462 "it will help us immensely in determining what went wrong.\n"
2463 "To do this, locate the core file that was produced as a result\n"
2464 "of this crash (it's usually called `core' and is located in the\n"
2465 "directory in which you started the editor, or maybe in your home\n"
2466 "directory), and type\n"
2473 /* Now try to determine the actual path to the executable,
2474 to try to make the backtrace-determination process as foolproof
2476 if (STRINGP (Vinvocation_name))
2477 name = (char *) XSTRING_DATA (Vinvocation_name);
2480 if (STRINGP (Vinvocation_directory))
2481 dir = (char *) XSTRING_DATA (Vinvocation_directory);
2482 if (!dir || dir[0] != '/')
2483 stderr_out ("`which %s`", name);
2484 else if (dir[strlen (dir) - 1] != '/')
2485 stderr_out ("%s/%s", dir, name);
2487 stderr_out ("%s%s", dir, name);
2491 "then type `where' when the debugger prompt comes up.\n"
2492 "(If you don't have GDB on your system, you might have DBX,\n"
2493 "or XDB, or SDB. A similar procedure should work for all of\n"
2494 "these. Ask your system administrator if you need more help.)\n");
2497 stuff_buffered_input (stuff);
2499 kill_buffer_processes (Qnil);
2501 #ifdef CLASH_DETECTION
2502 unlock_all_files ();
2506 tt_session_quit (tt_default_session ());
2508 /* The following crashes when built on X11R5 and run on X11R6 */
2511 #endif /* TOOLTALK */
2518 #if !defined(PDUMP) || !defined(SYSTEM_MALLOC)
2519 extern char my_edata[];
2522 extern void disable_free_hook (void);
2524 DEFUN ("dump-emacs", Fdump_emacs, 2, 2, 0, /*
2525 Dump current state of XEmacs into executable file FILENAME.
2526 Take symbols from SYMFILE (presumably the file you executed to run XEmacs).
2527 This is used in the file `loadup.el' when building XEmacs.
2529 Remember to set `command-line-processed' to nil before dumping
2530 if you want the dumped XEmacs to process its command line
2531 and announce itself normally when it is run.
2533 (intoname, symname))
2535 /* This function can GC */
2536 struct gcpro gcpro1, gcpro2;
2539 GCPRO2 (intoname, symname);
2541 #ifdef FREE_CHECKING
2542 Freally_free (Qnil);
2544 /* When we're dumping, we can't use the debugging free() */
2545 disable_free_hook ();
2548 CHECK_STRING (intoname);
2549 intoname = Fexpand_file_name (intoname, Qnil);
2550 if (!NILP (symname))
2552 CHECK_STRING (symname);
2553 if (XSTRING_LENGTH (symname) > 0)
2554 symname = Fexpand_file_name (symname, Qnil);
2559 opurify = purify_flag;
2563 report_sheap_usage (1);
2571 disksave_object_finalization ();
2572 release_breathing_space ();
2574 /* Tell malloc where start of impure now is */
2575 /* Also arrange for warnings when nearly out of space. */
2576 #ifndef SYSTEM_MALLOC
2577 memory_warnings (my_edata, malloc_warning);
2582 #if defined (MSDOS) && defined (EMX)
2584 int fd = open ((char *) XSTRING_DATA (intoname),
2585 O_WRONLY|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE);
2587 error ("Failure operating on %s", XSTRING_DATA (intoname));
2593 #else /* not MSDOS and EMX */
2598 TO_EXTERNAL_FORMAT (LISP_STRING, intoname,
2599 C_STRING_ALLOCA, intoname_ext,
2602 if (STRINGP (symname))
2603 TO_EXTERNAL_FORMAT (LISP_STRING, symname,
2604 C_STRING_ALLOCA, symname_ext,
2609 garbage_collect_1 ();
2615 #ifdef DOUG_LEA_MALLOC
2616 malloc_state_ptr = malloc_get_state ();
2618 /* here we break our rule that the filename conversion should
2619 be performed at the actual time that the system call is made.
2620 It's a whole lot easier to do the conversion here than to
2621 modify all the unexec routines to ensure that filename
2622 conversion is applied everywhere. Don't worry about memory
2623 leakage because this call only happens once. */
2624 unexec (intoname_ext, symname_ext, (uintptr_t) my_edata, 0, 0);
2625 #ifdef DOUG_LEA_MALLOC
2626 free (malloc_state_ptr);
2628 #endif /* not PDUMP */
2630 #endif /* not MSDOS and EMX */
2632 purify_flag = opurify;
2637 #endif /* not CANNOT_DUMP */
2643 /* Split STRING into a list of substrings. The substrings are the
2644 parts of original STRING separated by SEPCHAR. */
2646 split_string_by_emchar_1 (const Bufbyte *string, Bytecount size,
2649 Lisp_Object result = Qnil;
2650 const Bufbyte *end = string + size;
2654 const Bufbyte *p = string;
2657 if (charptr_emchar (p) == sepchar)
2661 result = Fcons (make_string (string, p - string), result);
2665 INC_CHARPTR (string); /* skip sepchar */
2670 return Fnreverse (result);
2673 /* The same as the above, except PATH is an external C string (it is
2674 converted using Qfile_name), and sepchar is hardcoded to SEPCHAR
2675 (':' or whatever). */
2677 decode_path (const char *path)
2684 TO_INTERNAL_FORMAT (C_STRING, path, ALLOCA, (newpath, newlen), Qfile_name);
2686 /* #### Does this make sense? It certainly does for
2687 decode_env_path(), but it looks dubious here. Does any code
2688 depend on decode_path("") returning nil instead of an empty
2693 return split_string_by_emchar_1 (newpath, newlen, SEPCHAR);
2697 decode_env_path (const char *evarname, const char *default_)
2699 const char *path = 0;
2701 path = egetenv (evarname);
2704 return decode_path (path);
2707 /* Ben thinks this function should not exist or be exported to Lisp.
2708 We use it to define split-path-string in subr.el (not!). */
2710 DEFUN ("split-string-by-char", Fsplit_string_by_char, 1, 2, 0, /*
2711 Split STRING into a list of substrings originally separated by SEPCHAR.
2715 CHECK_STRING (string);
2716 CHECK_CHAR (sepchar);
2717 return split_string_by_emchar_1 (XSTRING_DATA (string),
2718 XSTRING_LENGTH (string),
2722 /* #### This was supposed to be in subr.el, but is used VERY early in
2723 the bootstrap process, so it goes here. Damn. */
2725 DEFUN ("split-path", Fsplit_path, 1, 1, 0, /*
2726 Explode a search path into a list of strings.
2727 The path components are separated with the characters specified
2728 with `path-separator'.
2732 CHECK_STRING (path);
2734 while (!STRINGP (Vpath_separator)
2735 || (XSTRING_CHAR_LENGTH (Vpath_separator) != 1))
2736 Vpath_separator = signal_simple_continuable_error
2737 ("`path-separator' should be set to a single-character string",
2740 return (split_string_by_emchar_1
2741 (XSTRING_DATA (path), XSTRING_LENGTH (path),
2742 charptr_emchar (XSTRING_DATA (Vpath_separator))));
2745 DEFUN ("noninteractive", Fnoninteractive, 0, 0, 0, /*
2746 Non-nil return value means XEmacs is running without interactive terminal.
2750 return noninteractive ? Qt : Qnil;
2753 /* This flag is useful to define if you're under a debugger; this way, you
2754 can put a breakpoint of assert_failed() and debug multiple problems
2755 in one session without having to recompile. */
2756 /* #define ASSERTIONS_DONT_ABORT */
2758 #ifdef USE_ASSERTIONS
2759 /* This highly dubious kludge ... shut up Jamie, I'm tired of your slagging. */
2762 assert_failed (const char *file, int line, const char *expr)
2764 stderr_out ("Fatal error: assertion failed, file %s, line %d, %s\n",
2766 #undef abort /* avoid infinite #define loop... */
2767 #if defined (WINDOWSNT) && defined (DEBUG_XEMACS)
2769 #elif !defined (ASSERTIONS_DONT_ABORT)
2773 #endif /* USE_ASSERTIONS */
2776 DEFUN ("quantify-start-recording-data", Fquantify_start_recording_data,
2778 Start recording Quantify data.
2782 quantify_start_recording_data ();
2786 DEFUN ("quantify-stop-recording-data", Fquantify_stop_recording_data,
2788 Stop recording Quantify data.
2792 quantify_stop_recording_data ();
2796 DEFUN ("quantify-clear-data", Fquantify_clear_data, 0, 0, "", /*
2797 Clear all Quantify data.
2801 quantify_clear_data ();
2804 #endif /* QUANTIFY */
2807 syms_of_emacs (void)
2810 DEFSUBR (Fdump_emacs);
2811 #endif /* !CANNOT_DUMP */
2813 DEFSUBR (Frun_emacs_from_temacs);
2814 DEFSUBR (Frunning_temacs_p);
2815 DEFSUBR (Finvocation_name);
2816 DEFSUBR (Finvocation_directory);
2817 DEFSUBR (Fkill_emacs);
2818 DEFSUBR (Fnoninteractive);
2821 DEFSUBR (Fquantify_start_recording_data);
2822 DEFSUBR (Fquantify_stop_recording_data);
2823 DEFSUBR (Fquantify_clear_data);
2824 #endif /* QUANTIFY */
2826 DEFSUBR (Fsplit_string_by_char);
2827 DEFSUBR (Fsplit_path); /* #### */
2829 defsymbol (&Qkill_emacs_hook, "kill-emacs-hook");
2830 defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs");
2834 vars_of_emacs (void)
2836 DEFVAR_BOOL ("suppress-early-error-handler-backtrace",
2837 &suppress_early_error_handler_backtrace /*
2838 Non-nil means early error handler shouldn't print a backtrace.
2841 DEFVAR_LISP ("command-line-args", &Vcommand_line_args /*
2842 Args passed by shell to XEmacs, as a list of strings.
2845 DEFVAR_LISP ("invocation-name", &Vinvocation_name /*
2846 The program name that was used to run XEmacs.
2847 Any directory names are omitted.
2850 DEFVAR_LISP ("invocation-directory", &Vinvocation_directory /*
2851 The directory in which the XEmacs executable was found, to run it.
2852 The value is simply the program name if that directory's name is not known.
2855 DEFVAR_LISP ("invocation-path", &Vinvocation_path /*
2856 The path in which the XEmacs executable was found, to run it.
2857 The value is simply the value of environment variable PATH on startup
2858 if XEmacs was found there.
2862 xxDEFVAR_LISP ("installation-directory", &Vinstallation_directory,
2863 "A directory within which to look for the `lib-src' and `etc' directories.\n"
2864 "This is non-nil when we can't find those directories in their standard\n"
2865 "installed locations, but we can find them\n"
2866 "near where the XEmacs executable was found.");
2869 DEFVAR_LISP ("system-type", &Vsystem_type /*
2870 Symbol indicating type of operating system you are using.
2872 Vsystem_type = intern (SYSTEM_TYPE);
2873 Fprovide (intern(SYSTEM_TYPE));
2875 #ifndef EMACS_CONFIGURATION
2876 # define EMACS_CONFIGURATION "UNKNOWN"
2878 DEFVAR_LISP ("system-configuration", &Vsystem_configuration /*
2879 String naming the configuration XEmacs was built for.
2881 Vsystem_configuration = build_string (EMACS_CONFIGURATION);
2883 #ifndef EMACS_CONFIG_OPTIONS
2884 # define EMACS_CONFIG_OPTIONS "UNKNOWN"
2886 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options /*
2887 String containing the configuration options XEmacs was built with.
2889 Vsystem_configuration_options = build_string (EMACS_CONFIG_OPTIONS);
2891 DEFVAR_LISP ("emacs-major-version", &Vemacs_major_version /*
2892 Major version number of this version of Emacs, as an integer.
2893 Warning: this variable did not exist in Emacs versions earlier than:
2897 Vemacs_major_version = make_int (EMACS_MAJOR_VERSION);
2899 DEFVAR_LISP ("emacs-minor-version", &Vemacs_minor_version /*
2900 Minor version number of this version of Emacs, as an integer.
2901 Warning: this variable did not exist in Emacs versions earlier than:
2905 Vemacs_minor_version = make_int (EMACS_MINOR_VERSION);
2907 DEFVAR_LISP ("emacs-patch-level", &Vemacs_patch_level /*
2908 The patch level of this version of Emacs, as an integer.
2909 The value is non-nil if this version of XEmacs is part of a series of
2910 stable XEmacsen, but has bug fixes applied.
2911 Warning: this variable does not exist in FSF Emacs or in XEmacs versions
2914 #ifdef EMACS_PATCH_LEVEL
2915 Vemacs_patch_level = make_int (EMACS_PATCH_LEVEL);
2917 Vemacs_patch_level = Qnil;
2920 DEFVAR_LISP ("emacs-beta-version", &Vemacs_beta_version /*
2921 Beta number of this version of Emacs, as an integer.
2922 The value is nil if this is an officially released version of XEmacs.
2923 Warning: this variable does not exist in FSF Emacs or in XEmacs versions
2926 #ifdef EMACS_BETA_VERSION
2927 Vemacs_beta_version = make_int (EMACS_BETA_VERSION);
2929 Vemacs_beta_version = Qnil;
2933 DEFVAR_LISP ("infodock-major-version", &Vinfodock_major_version /*
2934 Major version number of this InfoDock release.
2936 Vinfodock_major_version = make_int (INFODOCK_MAJOR_VERSION);
2938 DEFVAR_LISP ("infodock-minor-version", &Vinfodock_minor_version /*
2939 Minor version number of this InfoDock release.
2941 Vinfodock_minor_version = make_int (INFODOCK_MINOR_VERSION);
2943 DEFVAR_LISP ("infodock-build-version", &Vinfodock_build_version /*
2944 Build version of this InfoDock release.
2946 Vinfodock_build_version = make_int (INFODOCK_BUILD_VERSION);
2949 DEFVAR_LISP ("xemacs-codename", &Vxemacs_codename /*
2950 Codename of this version of Emacs (a string).
2952 #ifndef XEMACS_CODENAME
2953 #define XEMACS_CODENAME "Noname"
2955 Vxemacs_codename = build_string (XEMACS_CODENAME);
2957 DEFVAR_BOOL ("noninteractive", &noninteractive1 /*
2958 Non-nil means XEmacs is running without interactive terminal.
2961 DEFVAR_BOOL ("inhibit-early-packages", &inhibit_early_packages /*
2962 Set to non-nil when the early packages should not be respected at startup.
2965 DEFVAR_BOOL ("inhibit-autoloads", &inhibit_autoloads /*
2966 Set to non-nil when autoloads should not be loaded at startup.
2969 DEFVAR_BOOL ("debug-paths", &debug_paths /*
2970 Set to non-nil when debug information about paths should be printed.
2973 DEFVAR_BOOL ("inhibit-site-lisp", &inhibit_site_lisp /*
2974 Set to non-nil when the site-lisp should not be searched at startup.
2976 #ifdef INHIBIT_SITE_LISP
2977 inhibit_site_lisp = 1;
2980 DEFVAR_BOOL ("inhibit-site-modules", &inhibit_site_modules /*
2981 Set to non-nil when site-modules should not be searched at startup.
2983 #ifdef INHIBIT_SITE_MODULES
2984 inhibit_site_modules = 1;
2987 DEFVAR_INT ("emacs-priority", &emacs_priority /*
2988 Priority for XEmacs to run at.
2989 This value is effective only if set before XEmacs is dumped,
2990 and only if the XEmacs executable is installed with setuid to permit
2991 it to change priority. (XEmacs sets its uid back to the real uid.)
2992 Currently, you need to define SET_EMACS_PRIORITY in `config.h'
2993 before you compile XEmacs, to enable the code for this feature.
2997 DEFVAR_CONST_LISP ("internal-error-checking", &Vinternal_error_checking /*
2998 Internal error checking built-in into this instance of XEmacs.
2999 This is a list of symbols, initialized at build-time. Legal symbols
3002 extents - check extents prior to each extent change;
3003 typecheck - check types strictly, aborting in case of error;
3004 malloc - check operation of malloc;
3005 gc - check garbage collection;
3006 bufpos - check buffer positions.
3008 Vinternal_error_checking = Qnil;
3009 #ifdef ERROR_CHECK_EXTENTS
3010 Vinternal_error_checking = Fcons (intern ("extents"),
3011 Vinternal_error_checking);
3013 #ifdef ERROR_CHECK_TYPECHECK
3014 Vinternal_error_checking = Fcons (intern ("typecheck"),
3015 Vinternal_error_checking);
3017 #ifdef ERROR_CHECK_MALLOC
3018 Vinternal_error_checking = Fcons (intern ("malloc"),
3019 Vinternal_error_checking);
3021 #ifdef ERROR_CHECK_GC
3022 Vinternal_error_checking = Fcons (intern ("gc"),
3023 Vinternal_error_checking);
3025 #ifdef ERROR_CHECK_BUFPOS
3026 Vinternal_error_checking = Fcons (intern ("bufpos"),
3027 Vinternal_error_checking);
3030 DEFVAR_CONST_LISP ("mail-lock-methods", &Vmail_lock_methods /*
3031 Mail spool locking methods supported by this instance of XEmacs.
3032 This is a list of symbols. Each of the symbols is one of the
3033 following: dot, lockf, flock, locking, mmdf.
3036 Vmail_lock_methods = Qnil;
3037 Vmail_lock_methods = Fcons (intern ("dot"), Vmail_lock_methods);
3039 Vmail_lock_methods = Fcons (intern ("lockf"), Vmail_lock_methods);
3042 Vmail_lock_methods = Fcons (intern ("flock"), Vmail_lock_methods);
3045 Vmail_lock_methods = Fcons (intern ("mmdf"), Vmail_lock_methods);
3048 Vmail_lock_methods = Fcons (intern ("locking"), Vmail_lock_methods);
3052 DEFVAR_CONST_LISP ("configure-mail-lock-method", &Vconfigure_mail_lock_method /*
3053 Mail spool locking method suggested by configure. This is one
3054 of the symbols in MAIL-LOCK-METHODS.
3057 #if defined(MAIL_LOCK_FLOCK) && defined(HAVE_FLOCK)
3058 Vconfigure_mail_lock_method = intern("flock");
3059 #elif defined(MAIL_LOCK_LOCKF) && defined(HAVE_LOCKF)
3060 Vconfigure_mail_lock_method = intern("lockf");
3061 #elif defined(MAIL_LOCK_MMDF) && defined(HAVE_MMDF)
3062 Vconfigure_mail_lock_method = intern("mmdf");
3063 #elif defined(MAIL_LOCK_LOCKING) && defined(HAVE_LOCKING)
3064 Vconfigure_mail_lock_method = intern("locking");
3066 Vconfigure_mail_lock_method = intern("dot");
3070 DEFVAR_LISP ("path-separator", &Vpath_separator /*
3071 The directory separator in search paths, as a string.
3075 Vpath_separator = make_string ((Bufbyte *)&c, 1);
3080 complex_vars_of_emacs (void)
3082 /* This is all related to path searching. */
3084 DEFVAR_LISP ("emacs-program-name", &Vemacs_program_name /*
3085 *Name of the Emacs variant.
3086 For example, this may be \"xemacs\" or \"infodock\".
3087 This is mainly meant for use in path searching.
3089 Vemacs_program_name = build_string ((char *) PATH_PROGNAME);
3091 DEFVAR_LISP ("emacs-program-version", &Vemacs_program_version /*
3092 *Version of the Emacs variant.
3093 This typically has the form XX.XX[-bXX].
3094 This is mainly meant for use in path searching.
3096 Vemacs_program_version = build_string ((char *) PATH_VERSION);
3098 DEFVAR_LISP ("exec-path", &Vexec_path /*
3099 *List of directories to search programs to run in subprocesses.
3100 Each element is a string (directory name) or nil (try default directory).
3104 DEFVAR_LISP ("exec-directory", &Vexec_directory /*
3105 *Directory of architecture-dependent files that come with XEmacs,
3106 especially executable programs intended for XEmacs to invoke.
3108 Vexec_directory = Qnil;
3110 DEFVAR_LISP ("configure-exec-directory", &Vconfigure_exec_directory /*
3111 For internal use by the build procedure only.
3112 configure's idea of what EXEC-DIRECTORY will be.
3115 Vconfigure_exec_directory = Ffile_name_as_directory
3116 (build_string ((char *) PATH_EXEC));
3118 Vconfigure_exec_directory = Qnil;
3121 DEFVAR_LISP ("lisp-directory", &Vlisp_directory /*
3122 *Directory of core Lisp files that come with XEmacs.
3124 Vlisp_directory = Qnil;
3126 DEFVAR_LISP ("configure-lisp-directory", &Vconfigure_lisp_directory /*
3127 For internal use by the build procedure only.
3128 configure's idea of what LISP-DIRECTORY will be.
3130 #ifdef PATH_LOADSEARCH
3131 Vconfigure_lisp_directory = Ffile_name_as_directory
3132 (build_string ((char *) PATH_LOADSEARCH));
3134 Vconfigure_lisp_directory = Qnil;
3137 DEFVAR_LISP ("module-directory", &Vmodule_directory /*
3138 *Directory of core dynamic modules that come with XEmacs.
3140 Vmodule_directory = Qnil;
3142 DEFVAR_LISP ("configure-module-directory", &Vconfigure_module_directory /*
3143 For internal use by the build procedure only.
3144 configure's idea of what MODULE-DIRECTORY will be.
3146 #ifdef PATH_MODULESEARCH
3147 Vconfigure_module_directory = Ffile_name_as_directory
3148 (build_string ((char *) PATH_MODULESEARCH));
3150 Vconfigure_module_directory = Qnil;
3153 DEFVAR_LISP ("configure-package-path", &Vconfigure_package_path /*
3154 For internal use by the build procedure only.
3155 configure's idea of what the package path will be.
3157 #ifdef PATH_PACKAGEPATH
3158 Vconfigure_package_path = decode_path (PATH_PACKAGEPATH);
3160 Vconfigure_package_path = Qnil;
3163 DEFVAR_LISP ("data-directory", &Vdata_directory /*
3164 *Directory of architecture-independent files that come with XEmacs,
3165 intended for XEmacs to use.
3166 Use of this variable in new code is almost never correct. See the
3167 function `locate-data-directory' and the variable `data-directory-list'.
3169 Vdata_directory = Qnil;
3171 DEFVAR_LISP ("configure-data-directory", &Vconfigure_data_directory /*
3172 For internal use by the build procedure only.
3173 configure's idea of what DATA-DIRECTORY will be.
3176 Vconfigure_data_directory = Ffile_name_as_directory
3177 (build_string ((char *) PATH_DATA));
3179 Vconfigure_data_directory = Qnil;
3182 DEFVAR_LISP ("data-directory-list", &Vdata_directory_list /*
3183 *List of directories of architecture-independent files that come with XEmacs
3184 or were installed as packages, and are intended for XEmacs to use.
3186 Vdata_directory_list = Qnil;
3188 #ifdef CLASH_DETECTION
3189 DEFVAR_LISP ("configure-lock-directory", &Vconfigure_lock_directory /*
3190 For internal use by the build procedure only.
3191 configure's idea of what LOCK-DIRECTORY will be.
3194 Vconfigure_lock_directory = Ffile_name_as_directory
3195 (build_string ((char *) PATH_LOCK));
3197 Vconfigure_lock_directory = Qnil;
3199 #endif /* CLASH_DETECTION */
3201 DEFVAR_LISP ("site-directory", &Vsite_directory /*
3202 *Directory of site-specific Lisp files that come with XEmacs.
3204 Vsite_directory = Qnil;
3206 DEFVAR_LISP ("configure-site-directory", &Vconfigure_site_directory /*
3207 For internal use by the build procedure only.
3208 configure's idea of what SITE-DIRECTORY will be.
3211 Vconfigure_site_directory = Ffile_name_as_directory
3212 (build_string ((char *) PATH_SITE));
3214 Vconfigure_site_directory = Qnil;
3217 DEFVAR_LISP ("site-module-directory", &Vsite_module_directory /*
3218 *Directory of site-specific loadable modules that come with XEmacs.
3220 Vsite_module_directory = Qnil;
3222 DEFVAR_LISP ("configure-site-module-directory", &Vconfigure_site_module_directory /*
3223 For internal use by the build procedure only.
3224 configure's idea of what SITE-DIRECTORY will be.
3226 #ifdef PATH_SITE_MODULES
3227 Vconfigure_site_module_directory = Ffile_name_as_directory
3228 (build_string ((char *) PATH_SITE_MODULES));
3230 Vconfigure_site_module_directory = Qnil;
3233 DEFVAR_LISP ("doc-directory", &Vdoc_directory /*
3234 *Directory containing the DOC file that comes with XEmacs.
3235 This is usually the same as exec-directory.
3237 Vdoc_directory = Qnil;
3239 DEFVAR_LISP ("configure-doc-directory", &Vconfigure_doc_directory /*
3240 For internal use by the build procedure only.
3241 configure's idea of what DOC-DIRECTORY will be.
3244 Vconfigure_doc_directory = Ffile_name_as_directory
3245 (build_string ((char *) PATH_DOC));
3247 Vconfigure_doc_directory = Qnil;
3250 DEFVAR_LISP ("configure-exec-prefix-directory", &Vconfigure_exec_prefix_directory /*
3251 For internal use by the build procedure only.
3252 configure's idea of what EXEC-PREFIX-DIRECTORY will be.
3254 #ifdef PATH_EXEC_PREFIX
3255 Vconfigure_exec_prefix_directory = Ffile_name_as_directory
3256 (build_string ((char *) PATH_EXEC_PREFIX));
3258 Vconfigure_exec_prefix_directory = Qnil;
3261 DEFVAR_LISP ("configure-prefix-directory", &Vconfigure_prefix_directory /*
3262 For internal use by the build procedure only.
3263 configure's idea of what PREFIX-DIRECTORY will be.
3266 Vconfigure_prefix_directory = Ffile_name_as_directory
3267 (build_string ((char *) PATH_PREFIX));
3269 Vconfigure_prefix_directory = Qnil;
3272 DEFVAR_LISP ("configure-info-directory", &Vconfigure_info_directory /*
3273 For internal use by the build procedure only.
3274 This is the name of the directory in which the build procedure installed
3275 Emacs's info files; the default value for Info-default-directory-list
3279 Vconfigure_info_directory =
3280 Ffile_name_as_directory (build_string (PATH_INFO));
3282 Vconfigure_info_directory = Qnil;
3285 DEFVAR_LISP ("configure-info-path", &Vconfigure_info_path /*
3286 The configured initial path for info documentation.
3288 #ifdef PATH_INFOPATH
3289 Vconfigure_info_path = decode_path (PATH_INFOPATH);
3291 Vconfigure_info_path = Qnil;
3295 #if defined(__sgi) && !defined(PDUMP)
3296 /* This is so tremendously ugly I'd puke. But then, it works.
3297 * The target is to override the static constructor from the
3298 * libiflPNG.so library which is maskerading as libz, and
3299 * cores on us when re-started from the dumped executable.
3300 * This will have to go for 21.1 -- OG.
3302 void __sti__iflPNGFile_c___(void);
3303 void __sti__iflPNGFile_c___()