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"
41 #include "syssignal.h" /* Always include before systty.h */
54 #if defined (HAVE_LOCALE_H) && \
55 (defined (I18N2) || defined (I18N3) || defined (I18N4))
65 #include <default_acl.h>
69 #if defined (WINDOWSNT)
76 #if !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC
77 extern void *(*__malloc_hook)(size_t);
78 extern void *(*__realloc_hook)(void *, size_t);
79 extern void (*__free_hook)(void *);
80 #endif /* not SYSTEM_MALLOC && not DOUG_LEA_MALLOC */
82 /* Command line args from shell, as list of strings */
83 Lisp_Object Vcommand_line_args;
85 /* Set nonzero after XEmacs has started up the first time.
86 Prevents reinitialization of the Lisp world and keymaps
87 on subsequent starts. */
90 #ifdef DOUG_LEA_MALLOC
92 /* Preserves a pointer to the memory allocated that copies that
93 static data inside glibc's malloc. */
94 static void *malloc_state_ptr;
95 #endif /* DOUG_LEA_MALLOC */
98 void r_alloc_reinit (void);
101 /* Variable whose value is symbol giving operating system type. */
102 Lisp_Object Vsystem_type;
104 /* Variable whose value is string giving configuration built for. */
105 Lisp_Object Vsystem_configuration;
107 /* Variable whose value is string containing the configuration options
108 XEmacs was built with. */
109 Lisp_Object Vsystem_configuration_options;
111 /* Version numbers and strings */
112 Lisp_Object Vemacs_major_version;
113 Lisp_Object Vemacs_minor_version;
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 Vinfo_directory, 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 Vpath_separator;
155 /* The default base directory XEmacs is installed under. */
156 Lisp_Object Vconfigure_exec_prefix_directory, Vconfigure_prefix_directory;
158 /* If nonzero, set XEmacs to run at this priority. This is also used
159 in child_setup and sys_suspend to make sure subshells run at normal
163 /* If non-zero a filter or a sentinel is running. Tested to save the match
164 data on the first attempt to change it inside asynchronous code. */
165 int running_asynch_code;
167 /* If non-zero, a window-system was specified on the command line. */
170 /* Type of display specified. We cannot use a Lisp symbol here because
171 Lisp symbols may not initialized at the time that we set this
173 CONST char *display_use;
175 /* If non-zero, then the early error handler will only print the error
177 int suppress_early_error_handler_backtrace;
179 /* An address near the bottom of the stack.
180 Tells GC how to save a copy of the stack. */
183 #ifdef USG_SHARED_LIBRARIES
184 /* If nonzero, this is the place to put the end of the writable segment
187 uintptr_t bss_end = 0;
190 /* Number of bytes of writable memory we can expect to be able to get */
191 unsigned int lim_data;
193 /* Nonzero means running XEmacs without interactive terminal. */
197 /* Value of Lisp variable `noninteractive'.
198 Normally same as C variable `noninteractive'
199 but nothing terrible happens if user sets this one. */
203 /* Nonzero means don't perform site-lisp searches at startup */
204 int inhibit_site_lisp;
206 /* Nonzero means don't perform site-modules searches at startup */
207 int inhibit_site_modules;
209 /* Nonzero means don't respect early packages at startup */
210 int inhibit_early_packages;
212 /* Nonzero means don't load package autoloads at startup */
213 int inhibit_autoloads;
215 /* Nonzero means print debug information about path searching */
218 /* Save argv and argc. */
222 static void sort_args (int argc, char **argv);
224 Lisp_Object Qkill_emacs_hook;
225 Lisp_Object Qsave_buffers_kill_emacs;
227 extern Lisp_Object Vlisp_EXEC_SUFFIXES;
230 /* Signal code for the fatal signal that was received */
231 static int fatal_error_code;
233 /* Nonzero if handling a fatal error already */
234 static int fatal_error_in_progress;
236 static void shut_down_emacs (int sig, Lisp_Object stuff);
238 /* Handle bus errors, illegal instruction, etc. */
240 fatal_error_signal (int sig)
242 fatal_error_code = sig;
243 signal (sig, SIG_DFL);
244 /* Unblock the signal so that if the same signal gets sent in the
245 code below, we avoid a deadlock. */
246 EMACS_UNBLOCK_SIGNAL (fatal_error_code);
248 /* If fatal error occurs in code below, avoid infinite recursion. */
249 if (! fatal_error_in_progress)
251 fatal_error_in_progress = dont_check_for_quit = 1;
252 shut_down_emacs (sig, Qnil);
253 stderr_out ("\nLisp backtrace follows:\n\n");
254 Fbacktrace (Qexternal_debugging_output, Qt);
255 # if 0 /* This is evil, rarely useful, and causes grief in some cases. */
256 /* Check for Sun-style stack printing via /proc */
258 CONST char *pstack = "/usr/proc/bin/pstack";
259 if (access (pstack, X_OK) == 0)
262 stderr_out ("\nC backtrace follows:\n"
263 "(A real debugger may provide better information)\n\n");
264 sprintf (buf, "%s %d >&2", pstack, (int)getpid());
270 /* Signal the same code; this time it will really be fatal. */
271 kill (getpid (), fatal_error_code);
277 fatal (CONST char *fmt, ...)
280 va_start (args, fmt);
282 fprintf (stderr, "\nXEmacs: ");
283 vfprintf (stderr, GETTEXT (fmt), args);
284 fprintf (stderr, "\n");
291 /* #### The following two functions should be replaced with
292 calls to emacs_doprnt_*() functions, with STREAM set to send out
293 to stdout or stderr. This is the only way to ensure that
294 I18N3 works properly (many implementations of the *printf()
295 functions, including the ones included in glibc, do not implement
296 the %###$ argument-positioning syntax). */
298 /* exactly equivalent to fprintf (stderr, fmt, ...) except that it calls
299 GETTEXT on the format string. */
302 stderr_out (CONST char *fmt, ...)
306 va_start (args, fmt);
308 retval = vfprintf (stderr, GETTEXT (fmt), args);
311 /* fflush (stderr); */
315 /* exactly equivalent to fprintf (stdout, fmt, ...) except that it calls
316 GETTEXT on the format string. */
319 stdout_out (CONST char *fmt, ...)
323 va_start (args, fmt);
325 retval = vfprintf (stdout, GETTEXT (fmt), args);
333 /* Handler for SIGDANGER. */
335 memory_warning_signal (int sig)
337 /* #### bad bad bad; this function shouldn't do anything except
338 set a flag, or weird corruption could happen. */
339 signal (sig, memory_warning_signal);
342 (GETTEXT ("Operating system warns that virtual memory is running low.\n"));
344 /* It might be unsafe to call do_auto_save now. */
345 force_auto_save_soon ();
347 #endif /* SIGDANGER */
349 /* Code for dealing with Lisp access to the Unix command line */
352 make_arg_list_1 (int argc, char **argv, int skip_args)
354 Lisp_Object result = Qnil;
357 for (i = argc - 1; i >= 0; i--)
359 if (i == 0 || i > skip_args)
364 /* Do not trust to what crt0 has stuffed into argv[0] */
365 char full_exe_path [MAX_PATH];
366 GetModuleFileName (NULL, full_exe_path, MAX_PATH);
367 result = Fcons (build_ext_string (full_exe_path, FORMAT_FILENAME),
369 #if defined(HAVE_SHLIB)
370 (void)dll_init(full_exe_path);
375 result = Fcons (build_ext_string (argv [i], FORMAT_FILENAME), result);
382 make_arg_list (int argc, char **argv)
384 return make_arg_list_1 (argc, argv, 0);
387 /* Calling functions are also responsible for calling free_argc_argv
388 when they are done with the generated list. */
390 make_argc_argv (Lisp_Object argv_list, int *argc, char ***argv)
393 int n = XINT (Flength (argv_list));
395 *argv = (char**) xmalloc ((n+1) * sizeof (char*));
397 for (i = 0, next = argv_list; i < n; i++, next = XCDR (next))
400 CHECK_STRING (XCAR (next));
402 GET_C_STRING_EXT_DATA_ALLOCA (XCAR (next), FORMAT_OS, temp);
403 (*argv) [i] = xstrdup (temp);
410 free_argc_argv (char **argv)
423 init_cmdargs (int argc, char **argv, int skip_args)
428 Vcommand_line_args = make_arg_list_1 (argc, argv, skip_args);
431 DEFUN ("invocation-name", Finvocation_name, 0, 0, 0, /*
432 Return the program name that was used to run XEmacs.
433 Any directory names are omitted.
437 return Fcopy_sequence (Vinvocation_name);
440 DEFUN ("invocation-directory", Finvocation_directory, 0, 0, 0, /*
441 Return the directory name in which the Emacs executable was located.
445 return Fcopy_sequence (Vinvocation_directory);
450 /* #### - don't know why I18N4 on SunOS/JLE
451 can't deal with this. It's a potential
452 bug that needs to be looked at. */
453 # undef RUN_TIME_REMAP
456 #if defined (MULE) && defined (MSDOS) && defined (EMX)
457 /* Setup all of files be input/output'ed with binary translation mode. */
459 asm ("L_setbinmode:");
460 asm (" movl $1, __fmode_bin");
462 asm (" .stabs \"___CTOR_LIST__\", 23, 0, 0, L_setbinmode");
465 /* Test whether the next argument in ARGV matches SSTR or a prefix of
466 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
467 (the argument is supposed to have a value) store in *VALPTR either
468 the next argument or the portion of this one after the equal sign.
469 ARGV is read starting at position *SKIPPTR; this index is advanced
470 by the number of arguments used.
472 Too bad we can't just use getopt for all of this, but we don't have
473 enough information to do it right. */
476 argmatch (char **argv, int argc, char *sstr, char *lstr,
477 int minlen, char **valptr, int *skipptr)
483 /* Don't access argv[argc]; give up in advance. */
484 if (argc <= *skipptr + 1)
487 arg = argv[*skipptr+1];
490 if (strcmp (arg, sstr) == 0)
494 *valptr = argv[*skipptr+2];
501 arglen = (valptr != NULL && (p = strchr (arg, '=')) != NULL
502 ? p - arg : strlen (arg));
503 if (lstr == 0 || arglen < minlen || strncmp (arg, lstr, arglen) != 0)
505 else if (valptr == NULL)
516 else if (argv[*skipptr+2] != NULL)
518 *valptr = argv[*skipptr+2];
528 /* Make stack traces always identify version + configuration */
529 #define main_1 STACK_TRACE_EYE_CATCHER
531 /* This function is not static, so that the compiler is less likely to
532 inline it, which would make it not show up in stack traces. */
533 DECLARE_DOESNT_RETURN (main_1 (int, char **, char **, int));
535 main_1 (int argc, char **argv, char **envp, int restart)
537 char stack_bottom_variable;
540 int inhibit_window_system;
542 extern int malloc_cookie;
545 #if !defined(SYSTEM_MALLOC) && !defined(HAVE_LIBMCHECK)
546 /* Make sure that any libraries we link against haven't installed a
547 hook for a gmalloc of a potentially incompatible version. */
548 /* If we're using libmcheck, the hooks have already been initialized, */
549 /* don't touch them. -slb */
550 __malloc_hook = NULL;
551 __realloc_hook = NULL;
553 #endif /* not SYSTEM_MALLOC */
559 * NeXT secret magic, ripped from Emacs-for-NS by Carl Edman
560 * <cedman@princeton.edu>. Note that even Carl doesn't know what this
561 * does; it was provided by NeXT, and it presumable makes NS's mallocator
562 * work with dumping. But malloc_jumpstart() and malloc_freezedry() in
563 * unexnext.c are both completely undocumented, even in NS header files!
564 * But hey, it solves all NS related memory problems, so who's
566 if (initialized && malloc_jumpstart (malloc_cookie) != 0)
567 fprintf (stderr, "malloc jumpstart failed!\n");
571 #if defined (GNU_MALLOC) && \
572 defined (ERROR_CHECK_MALLOC) && \
573 !defined (HAVE_LIBMCHECK)
575 #if defined(LOSING_GCC_DESTRUCTOR_FREE_BUG)
576 /* Prior to XEmacs 21, this was `#if 0'ed out. */
577 /* I'm enabling this because it is the only reliable way I've found to */
578 /* prevent a very annoying problem where GCC will attempt to free(3) */
579 /* memory at exit() and cause a coredump. */
583 sort_args (argc, argv);
585 /* Map in shared memory, if we are using that. */
587 if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
590 /* The shared memory was just restored, which clobbered this. */
596 /* The shared memory was just restored, which clobbered this. */
599 #endif /* HAVE_SHM */
601 #if (defined (MSDOS) && defined (EMX)) || defined (WIN32) || defined (_SCO_DS)
605 /* Record (approximately) where the stack begins. */
606 stack_bottom = &stack_bottom_variable;
608 #ifdef USG_SHARED_LIBRARIES
610 brk ((void *) bss_end);
617 /* If USE_DOMAIN_ACLS environment variable exists,
618 use ACLs rather than UNIX modes. */
619 if (egetenv ("USE_DOMAIN_ACLS"))
620 default_acl (USE_DEFACL);
624 #if defined (HAVE_MMAP) && defined (REL_ALLOC)
625 /* ralloc can only be used if using the GNU memory allocator. */
627 #elif defined (REL_ALLOC) && !defined(DOUG_LEA_MALLOC)
635 #endif /* HAVE_SOCKS */
637 #ifndef SYSTEM_MALLOC
639 /* Arrange to get warning messages as memory fills up. */
640 memory_warnings (0, malloc_warning);
641 #endif /* not SYSTEM_MALLOC */
644 /* We do all file input/output as binary files. When we need to translate
645 newlines, we do that manually. */
647 (stdin) ->_flag &= ~_IOTEXT;
648 (stdout)->_flag &= ~_IOTEXT;
649 (stderr)->_flag &= ~_IOTEXT;
652 #ifdef SET_EMACS_PRIORITY
653 if (emacs_priority != 0)
654 nice (-emacs_priority);
656 #endif /* SET_EMACS_PRIORITY */
658 #ifdef EXTRA_INITIALIZE
662 #ifdef HAVE_WINDOW_SYSTEM
663 inhibit_window_system = 0;
665 inhibit_window_system = 1;
668 /* Handle the -t switch, which specifies filename to use as terminal */
671 if (argmatch (argv, argc, "-t", "--terminal", 4, &term, &skip_args))
675 if (open (term, O_RDWR | OPEN_BINARY, 2) < 0)
676 fatal ("%s: %s", term, strerror (errno));
679 fatal ("%s: not a tty", term);
682 stderr_out ("Using %s", ttyname (0));
684 stderr_out ("Using %s", term);
685 inhibit_window_system = 1; /* -t => -nw */
689 /* Handle -nw switch */
690 if (argmatch (argv, argc, "-nw", "--no-windows", 6, NULL, &skip_args))
691 inhibit_window_system = 1;
693 /* Handle the -batch switch, which means don't do interactive display. */
694 if (argmatch (argv, argc, "-batch", "--batch", 5, NULL, &skip_args))
696 #if 0 /* I don't think this is correct. */
697 inhibit_autoloads = 1;
702 if (argmatch (argv, argc, "-debug-paths", "--debug-paths",
703 11, NULL, &skip_args))
706 /* Partially handle -no-autoloads, -no-early-packages and -vanilla. Packages */
707 /* are searched prior to the rest of the command line being parsed in */
709 if (argmatch (argv, argc, "-no-early-packages", "--no-early-packages",
710 6, NULL, &skip_args))
712 inhibit_early_packages = 1;
716 if (argmatch (argv, argc, "-no-site-modules", "--no-site-modules",
717 9, NULL, &skip_args))
719 inhibit_site_modules = 1;
723 inhibit_site_modules = 1;
725 if (argmatch (argv, argc, "-vanilla", "--vanilla",
726 7, NULL, &skip_args))
728 inhibit_early_packages = 1;
732 if (argmatch (argv, argc, "-no-autoloads", "--no-autoloads",
733 7, NULL, &skip_args))
735 /* Inhibit everything */
736 inhibit_autoloads = 1;
740 if (argmatch (argv, argc, "-debug-paths", "--debug-paths",
741 6, NULL, &skip_args))
748 /* Partially handle the -version and -help switches: they imply -batch,
749 but are not removed from the list. */
750 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
751 noninteractive = 1, skip_args--;
753 if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args) ||
754 argmatch (argv, argc, "-V", 0, 2, NULL, &skip_args))
755 noninteractive = 1, skip_args--;
757 /* Now, figure out which type of console is our first console. */
762 display_use = "stream";
767 if (inhibit_window_system)
768 fatal ("Sorry, this XEmacs was not compiled with TTY support");
771 #ifdef HAVE_WINDOW_SYSTEM
772 /* Stupid kludge to catch command-line display spec. We can't
773 handle this argument entirely in window-system-dependent code
774 because we don't even know which window-system-dependent code
775 to run until we've recognized this argument. */
776 if (!inhibit_window_system && !noninteractive)
778 #ifdef HAVE_X_WINDOWS
780 int count_before = skip_args;
782 if (argmatch (argv, argc, "-d", "--display", 3, &dpy, &skip_args) ||
783 argmatch (argv, argc, "-display", 0, 3, &dpy, &skip_args))
788 /* If we have the form --display=NAME,
789 convert it into -d name.
790 This requires inserting a new element into argv. */
791 if (dpy != 0 && skip_args - count_before == 1)
793 char **new = (char **) xmalloc (sizeof (char *) * (argc + 2));
796 for (j = 0; j < count_before + 1; j++)
798 new[count_before + 1] = "-d";
799 new[count_before + 2] = dpy;
800 for (j = count_before + 2; j <argc; j++)
801 new[j + 1] = argv[j];
805 /* Change --display to -d, when its arg is separate. */
806 else if (dpy != 0 && skip_args > count_before
807 && argv[count_before + 1][1] == '-')
808 argv[count_before + 1] = "-d";
810 /* Don't actually discard this arg. */
811 skip_args = count_before;
813 /* If there is a non-empty environment var DISPLAY, set
814 `display_use', but not `display_arg', which is only to be set
815 if the display was specified on the command line. */
816 if ((dpy = getenv ("DISPLAY")) && dpy[0])
819 #endif /* HAVE_X_WINDOWS */
820 #ifdef HAVE_MS_WINDOWS
821 if (strcmp(display_use, "x") != 0)
822 display_use = "mswindows";
823 #endif /* HAVE_MS_WINDOWS */
825 #endif /* HAVE_WINDOW_SYSTEM */
827 noninteractive1 = noninteractive;
829 /****** Now initialize everything *******/
831 /* First, do really basic environment initialization -- catching signals
832 and the like. These functions have no dependence on any part of
833 the Lisp engine and need to be done both at dump time and at run time. */
835 init_signals_very_early ();
836 init_data_very_early (); /* Catch math errors. */
837 #ifdef LISP_FLOAT_TYPE
838 init_floatfns_very_early (); /* Catch floating-point math errors. */
840 init_process_times_very_early (); /* Initialize our process timers.
841 As early as possible, of course,
842 so we can be fairly accurate. */
843 init_intl_very_early (); /* set up the locale and domain for gettext and
846 /* Now initialize the Lisp engine and the like. Done only during
847 dumping. No dependence on anything that may be in the user's
848 environment when the dumped XEmacs is run.
850 We try to do things in an order that minimizes the non-obvious
851 dependencies between functions. */
855 /* Initialize things so that new Lisp objects
856 can be created and objects can be staticpro'd.
857 Must be basically the very first thing done
858 because pretty much all of the initialization
859 routines below create new objects. */
860 init_alloc_once_early ();
862 /* Initialize Qnil, Qt, Qunbound, and the
863 obarray. After this, symbols can be
864 interned. This depends on init_alloc_once(). */
865 init_symbols_once_early ();
867 /* Declare the basic symbols pertaining to errors,
868 So that deferror() can be called. */
869 init_errors_once_early ();
871 /* Make sure that opaque pointers can be created. */
872 init_opaque_once_early ();
874 /* Now declare all the symbols and define all the Lisp primitives.
876 The *only* thing that the syms_of_*() functions are allowed to do
877 is call one of the following three functions:
880 defsubr() (i.e. DEFSUBR)
884 Order does not matter in these functions.
889 #ifdef HAVE_X_WINDOWS
890 syms_of_balloon_x ();
896 syms_of_casefiddle ();
905 #endif /* DEBUG_XEMACS */
916 #ifdef HAVE_X_WINDOWS
919 #ifdef HAVE_DRAGNDROP
922 syms_of_event_stream ();
927 #ifdef CLASH_DETECTION
929 #endif /* CLASH_DETECTION */
932 syms_of_font_lock ();
936 syms_of_glyphs_eimage ();
937 syms_of_glyphs_widget ();
938 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
960 #if !defined (NO_SUBPROCESSES)
962 #ifdef HAVE_WIN32_PROCESSES
963 syms_of_process_nt ();
967 #if defined (HAVE_MMAP) && defined (REL_ALLOC) && !defined(DOUG_LEA_MALLOC)
969 #endif /* HAVE_MMAP && REL_ALLOC */
971 syms_of_redisplay ();
975 syms_of_specifier ();
978 #ifdef HAVE_SCROLLBARS
979 syms_of_scrollbar ();
989 syms_of_console_tty ();
990 syms_of_device_tty ();
991 syms_of_objects_tty ();
994 #ifdef HAVE_X_WINDOWS
1000 syms_of_glyphs_x ();
1001 syms_of_objects_x ();
1002 #ifdef HAVE_MENUBARS
1003 syms_of_menubar_x ();
1006 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1009 #endif /* HAVE_X_WINDOWS */
1011 #ifdef HAVE_MS_WINDOWS
1012 syms_of_console_mswindows ();
1013 syms_of_device_mswindows ();
1014 syms_of_frame_mswindows ();
1015 syms_of_objects_mswindows ();
1016 syms_of_select_mswindows ();
1017 syms_of_glyphs_mswindows ();
1018 #ifdef HAVE_MENUBARS
1019 syms_of_menubar_mswindows ();
1021 #ifdef HAVE_SCROLLBARS
1022 syms_of_scrollbar_mswindows ();
1024 #ifdef HAVE_MSW_C_DIRED
1025 syms_of_dired_mswindows ();
1030 #endif /* HAVE_MS_WINDOWS */
1034 syms_of_mule_ccl ();
1035 syms_of_mule_charset ();
1038 syms_of_mule_coding ();
1042 syms_of_mule_wnn ();
1045 syms_of_mule_canna ();
1046 #endif /* HAVE_CANNA */
1058 #if defined (GNU_MALLOC) && \
1059 defined (ERROR_CHECK_MALLOC) && \
1060 !defined (HAVE_LIBMCHECK)
1062 /* Prior to XEmacs 21, this was `#if 0'ed out. -slb */
1063 #if defined (LOSING_GCC_DESTRUCTOR_FREE_BUG)
1064 syms_of_free_hook ();
1068 syms_of_tooltalk ();
1079 /* Now create the subtypes for the types that have them.
1080 We do this before the vars_*() because more symbols
1081 may get initialized here. */
1083 /* Now initialize the console types and associated symbols.
1084 Other than the first function below, the functions may
1085 make exactly the following function/macro calls:
1087 INITIALIZE_CONSOLE_TYPE()
1088 CONSOLE_HAS_METHOD()
1090 For any given console type, the former macro must be called
1091 before the any calls to the latter macro. */
1093 console_type_create ();
1095 console_type_create_stream ();
1098 console_type_create_tty ();
1099 console_type_create_device_tty ();
1100 console_type_create_frame_tty ();
1101 console_type_create_objects_tty ();
1102 console_type_create_redisplay_tty ();
1105 #ifdef HAVE_X_WINDOWS
1106 console_type_create_x ();
1107 console_type_create_device_x ();
1108 console_type_create_frame_x ();
1109 console_type_create_glyphs_x ();
1110 #ifdef HAVE_MENUBARS
1111 console_type_create_menubar_x ();
1113 console_type_create_objects_x ();
1114 console_type_create_redisplay_x ();
1115 #ifdef HAVE_SCROLLBARS
1116 console_type_create_scrollbar_x ();
1118 #ifdef HAVE_TOOLBARS
1119 console_type_create_toolbar_x ();
1122 console_type_create_dialog_x ();
1124 #endif /* HAVE_X_WINDOWS */
1126 #ifdef HAVE_MS_WINDOWS
1127 console_type_create_mswindows ();
1128 console_type_create_device_mswindows ();
1129 console_type_create_frame_mswindows ();
1130 console_type_create_objects_mswindows ();
1131 console_type_create_redisplay_mswindows ();
1132 console_type_create_glyphs_mswindows ();
1133 # ifdef HAVE_SCROLLBARS
1134 console_type_create_scrollbar_mswindows ();
1136 #ifdef HAVE_MENUBARS
1137 console_type_create_menubar_mswindows ();
1139 #ifdef HAVE_TOOLBARS
1140 console_type_create_toolbar_mswindows ();
1143 console_type_create_dialog_mswindows ();
1147 /* Now initialize the specifier types and associated symbols.
1148 Other than the first function below, the functions may
1149 make exactly the following function/macro calls:
1151 INITIALIZE_SPECIFIER_TYPE()
1152 SPECIFIER_HAS_METHOD()
1154 For any given specifier type, the former macro must be called
1155 before the any calls to the latter macro. */
1157 specifier_type_create ();
1159 specifier_type_create_image ();
1160 specifier_type_create_objects ();
1161 #ifdef HAVE_TOOLBARS
1162 specifier_type_create_toolbar ();
1165 /* Now initialize the structure types and associated symbols.
1166 Other than the first function below, the functions may
1167 make exactly the following function/macro calls:
1169 define_structure_type()
1170 define_structure_type_keyword()
1174 structure_type_create ();
1176 structure_type_create_chartab ();
1177 structure_type_create_faces ();
1178 structure_type_create_rangetab ();
1179 structure_type_create_hash_table ();
1181 /* Now initialize the image instantiator formats and associated symbols.
1182 Other than the first function below, the functions may
1183 make exactly the following function/macro calls:
1185 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT()
1186 IIFORMAT_HAS_METHOD()
1187 IIFORMAT_VALID_KEYWORD()
1189 For any given image instantiator format, the first macro must be
1190 called before the any calls to the other macros. */
1192 image_instantiator_format_create ();
1193 image_instantiator_format_create_glyphs_eimage ();
1194 image_instantiator_format_create_glyphs_widget ();
1195 #ifdef HAVE_X_WINDOWS
1196 image_instantiator_format_create_glyphs_x ();
1197 #endif /* HAVE_X_WINDOWS */
1198 #ifdef HAVE_MS_WINDOWS
1199 image_instantiator_format_create_glyphs_mswindows ();
1200 #endif /* HAVE_MSWINDOWS_WINDOWS */
1202 /* Now initialize the lstream types and associated symbols.
1203 Other than the first function below, the functions may
1204 make exactly the following function/macro calls:
1206 LSTREAM_HAS_METHOD()
1210 lstream_type_create ();
1212 lstream_type_create_mule_coding ();
1214 #if defined (HAVE_MS_WINDOWS) && !defined(HAVE_MSG_SELECT)
1215 lstream_type_create_mswindows_selectable ();
1218 /* Initialize processes implementation.
1219 The functions may make exactly the following function/macro calls:
1221 PROCESS_HAS_METHOD()
1223 #ifdef HAVE_UNIX_PROCESSES
1224 process_type_create_unix ();
1226 #ifdef HAVE_WIN32_PROCESSES
1227 process_type_create_nt ();
1230 /* Now initialize most variables.
1232 These functions may do exactly the following:
1245 defsymbol(), if it's absolutely necessary and you're sure that
1246 the symbol isn't referenced anywhere else in the initialization
1248 Fset() on a symbol that is unbound
1249 assigning a symbol or constant value to a variable
1250 using a global variable that has been initialized
1251 earlier on in the same function
1253 Any of the object-creating functions on alloc.c: e.g.
1268 perhaps a few others.
1271 /* Now allow Fprovide() statements to be made. */
1272 init_provide_once ();
1276 #ifdef HAVE_X_WINDOWS
1277 vars_of_balloon_x ();
1280 vars_of_bytecode ();
1282 vars_of_callproc ();
1290 vars_of_console_stream ();
1297 #ifdef HAVE_DRAGNDROP
1298 vars_of_dragdrop ();
1305 #ifdef HAVE_X_WINDOWS
1306 vars_of_event_Xt ();
1308 #if defined(HAVE_TTY) && (defined (DEBUG_TTY_EVENT_STREAM) || !defined (HAVE_X_WINDOWS))
1309 vars_of_event_tty ();
1311 #ifdef HAVE_MS_WINDOWS
1312 vars_of_event_mswindows ();
1314 vars_of_event_stream ();
1320 vars_of_floatfns ();
1321 vars_of_font_lock ();
1324 vars_of_glyphs_eimage ();
1325 vars_of_glyphs_widget ();
1326 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1334 vars_of_input_method_motif ();
1335 #else /* XIM_XLIB */
1336 vars_of_input_method_xlib ();
1338 #endif /* HAVE_XIM */
1344 #ifdef HAVE_DATABASE
1345 vars_of_database ();
1347 #ifdef HAVE_MENUBARS
1357 #ifndef NO_SUBPROCESSES
1359 #ifdef HAVE_UNIX_PROCESSES
1360 vars_of_process_unix ();
1362 #ifdef HAVE_WIN32_PROCESSES
1363 vars_of_process_nt ();
1368 #if defined (HAVE_MMAP) && defined (REL_ALLOC) && !defined(DOUG_LEA_MALLOC)
1370 #endif /* HAVE_MMAP && REL_ALLOC */
1371 vars_of_redisplay ();
1372 #ifdef HAVE_SCROLLBARS
1373 vars_of_scrollbar ();
1377 vars_of_specifier ();
1380 #ifdef HAVE_TOOLBARS
1387 vars_of_console_tty ();
1388 vars_of_frame_tty ();
1389 vars_of_objects_tty ();
1392 #ifdef HAVE_X_WINDOWS
1393 vars_of_device_x ();
1395 vars_of_dialog_x ();
1398 vars_of_glyphs_x ();
1399 #ifdef HAVE_MENUBARS
1400 vars_of_menubar_x ();
1402 vars_of_objects_x ();
1404 #ifdef HAVE_SCROLLBARS
1405 vars_of_scrollbar_x ();
1407 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1412 #ifdef HAVE_MS_WINDOWS
1413 vars_of_device_mswindows ();
1414 vars_of_console_mswindows ();
1415 vars_of_frame_mswindows ();
1416 vars_of_objects_mswindows ();
1417 vars_of_select_mswindows ();
1418 vars_of_glyphs_mswindows ();
1419 #ifdef HAVE_SCROLLBARS
1420 vars_of_scrollbar_mswindows ();
1422 #ifdef HAVE_MENUBARS
1423 vars_of_menubar_mswindows ();
1425 #ifdef HAVE_MSW_C_DIRED
1426 vars_of_dired_mswindows ();
1429 vars_of_dialog_mswindows ();
1431 #endif /* HAVE_MS_WINDOWS */
1435 vars_of_mule_charset ();
1438 vars_of_mule_coding ();
1442 vars_of_mule_wnn ();
1445 vars_of_mule_canna ();
1446 #endif /* HAVE_CANNA */
1450 vars_of_tooltalk ();
1461 /* Now initialize any specifier variables. We do this later
1462 because it has some dependence on the vars initialized
1465 These functions should *only* initialize specifier variables,
1466 and may make use of the following functions/macros in addition
1467 to the ones listed above:
1471 set_specifier_fallback()
1472 set_specifier_caching()
1475 specifier_vars_of_glyphs ();
1476 #ifdef HAVE_MENUBARS
1477 specifier_vars_of_menubar ();
1479 specifier_vars_of_redisplay ();
1480 #ifdef HAVE_SCROLLBARS
1481 specifier_vars_of_scrollbar ();
1483 #ifdef HAVE_TOOLBARS
1484 specifier_vars_of_toolbar ();
1486 specifier_vars_of_window ();
1488 /* Now comes all the rest of the variables that couldn't
1489 be handled above. There may be dependencies on variables
1490 initialized above, and dependencies between one complex_vars_()
1491 function and another. */
1493 /* Calls Fmake_range_table(). */
1494 complex_vars_of_regex ();
1495 /* Calls Fmake_range_table(). */
1496 complex_vars_of_search ();
1498 /* Calls make_lisp_hash_table(). */
1499 complex_vars_of_extents ();
1501 /* Depends on hash tables and specifiers. */
1502 complex_vars_of_faces ();
1505 /* These two depend on hash tables and various variables declared
1506 earlier. The second may also depend on the first. */
1507 complex_vars_of_mule_charset ();
1509 #if defined(FILE_CODING)
1510 complex_vars_of_mule_coding ();
1513 /* This calls allocate_glyph(), which creates specifiers
1514 and also relies on a variable (Vthe_nothing_vector) initialized
1515 above. It also calls make_ext_string(), which under Mule
1516 could require that the charsets be initialized. */
1517 complex_vars_of_glyphs ();
1519 /* These rely on the glyphs just created in the previous function,
1520 and call Fadd_spec_to_specifier(), which relies on various
1521 variables initialized above. */
1522 #ifdef HAVE_X_WINDOWS
1523 complex_vars_of_glyphs_x ();
1525 #ifdef HAVE_MS_WINDOWS
1526 complex_vars_of_glyphs_mswindows ();
1529 /* This calls Fmake_glyph_internal(). */
1530 complex_vars_of_alloc ();
1532 /* This calls Fmake_glyph_internal(). */
1533 #ifdef HAVE_MENUBARS
1534 complex_vars_of_menubar ();
1537 /* This calls Fmake_glyph_internal(). */
1538 #ifdef HAVE_SCROLLBARS
1539 complex_vars_of_scrollbar ();
1542 /* This calls allocate_glyph(). */
1543 complex_vars_of_frame ();
1545 /* This calls Fcopy_category_table() under Mule, which calls who
1547 complex_vars_of_chartab ();
1549 /* This calls set_string_char(), which (under Mule) depends on the
1550 charsets being initialized. */
1551 complex_vars_of_casetab ();
1553 /* This calls Fcopy_syntax_table(), which relies on char tables. */
1554 complex_vars_of_syntax ();
1556 /* This initializes buffer-local variables, sets things up so
1557 that buffers can be created, and creates a couple of basic
1558 buffers. This depends on Vstandard_syntax_table and
1559 Vstandard_category_table (initialized in the previous
1560 functions), as well as a whole horde of variables that may
1561 have been initialized above. */
1562 complex_vars_of_buffer ();
1564 /* This initializes console-local variables. */
1565 complex_vars_of_console ();
1567 /* This creates a couple more buffers, and depends on the
1568 previous function. */
1569 complex_vars_of_minibuf ();
1571 /* These two might call Ffile_name_as_directory(), which
1572 might depend on all sorts of things; I'm not sure. */
1573 complex_vars_of_emacs ();
1575 /* This creates a couple of basic keymaps and depends on Lisp
1576 hash tables and Ffset() (both of which depend on some variables
1577 initialized in the vars_of_*() section) and possibly other
1579 complex_vars_of_keymap ();
1581 /* Calls make_lisp_hash_table() and creates a keymap */
1582 complex_vars_of_event_stream ();
1584 #ifdef ERROR_CHECK_GC
1586 extern int always_gc;
1587 if (always_gc) /* purification debugging hack */
1588 garbage_collect_1 ();
1593 /* CONGRATULATIONS!!! We have successfully initialized the Lisp
1598 /* Stuff that needs to be reset at run time. Order below should
1603 reinit_mule_category ();
1607 /* Now do further initialization/setup of stuff that is not needed by the
1608 syms_of_() routines. This involves stuff that only is enabled in
1609 an interactive run (redisplay, user input, etc.) and stuff that is
1610 not needed until we start loading Lisp code (the reader). A lot
1611 of this stuff involves querying the current environment and needs
1612 to be done both at dump time and at run time. */
1614 init_initial_directory(); /* get the directory to use for the
1615 "*scratch*" buffer, etc. */
1619 * For Win32, call init_environment() now, so that environment/registry
1620 * variables will be properly entered into Vprocess_environment.
1625 init_callproc (); /* Set up the process environment (so that egetenv
1626 works), the basic directory variables
1627 (exec-directory and so on), and stuff
1628 related to subprocesses. This should be
1629 first because many of the functions below
1630 call egetenv() to get environment variables. */
1631 init_lread (); /* Set up the Lisp reader. */
1633 /* Call early 'cause init_environment needs it. */
1635 /* Set defaults for several environment variables. */
1636 init_environment (argc, argv, skip_args);
1638 init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */
1639 init_buffer (); /* Set default directory of *scratch* buffer */
1645 init_redisplay (); /* Determine terminal type.
1646 init_sys_modes uses results */
1647 init_event_stream (); /* Set up so we can get user input. */
1648 init_macros (); /* set up so we can run macros. */
1649 init_editfns (); /* Determine the name of the user we're running as */
1650 init_xemacs_process (); /* set up for calling subprocesses */
1652 init_sunpro (); /* Set up Sunpro usage tracking */
1654 #if defined (HAVE_NATIVE_SOUND) && defined (hp9000s800)
1660 init_console_stream (); /* Create the first console */
1662 /* try to get the actual pathname of the exec file we are running */
1665 Vinvocation_name = Fcar (Vcommand_line_args);
1666 if (XSTRING_DATA(Vinvocation_name)[0] == '-')
1668 /* XEmacs as a login shell, oh goody! */
1669 Vinvocation_name = build_string(getenv("SHELL"));
1671 Vinvocation_directory = Vinvocation_name;
1673 if (!NILP (Ffile_name_directory (Vinvocation_name)))
1675 /* invocation-name includes a directory component -- presumably it
1676 is relative to cwd, not $PATH */
1677 Vinvocation_directory = Fexpand_file_name (Vinvocation_name,
1679 Vinvocation_path = Qnil;
1683 Vinvocation_path = decode_env_path ("PATH", NULL);
1684 locate_file (Vinvocation_path, Vinvocation_name,
1685 Vlisp_EXEC_SUFFIXES,
1686 &Vinvocation_directory, X_OK);
1689 if (NILP (Vinvocation_directory))
1690 Vinvocation_directory = Vinvocation_name;
1692 Vinvocation_name = Ffile_name_nondirectory (Vinvocation_directory);
1693 Vinvocation_directory = Ffile_name_directory (Vinvocation_directory);
1696 #if defined(HAVE_SHLIB) && !defined(WINDOWSNT)
1697 /* This is Unix only. MS Windows NT has a library call that does
1698 The Right Thing on that system. Rumor has it, this must be
1699 called for GNU dld in temacs and xemacs. */
1701 char *buf = (char *)alloca (XSTRING_LENGTH (Vinvocation_directory)
1702 + XSTRING_LENGTH (Vinvocation_name)
1704 sprintf (buf, "%s/%s", XSTRING_DATA (Vinvocation_directory),
1705 XSTRING_DATA (Vinvocation_name));
1707 /* All we can do is cry if an error happens, so ignore it. */
1708 (void) dll_init (buf);
1712 #if defined (LOCALTIME_CACHE) && defined (HAVE_TZSET)
1713 /* sun's localtime() has a bug. it caches the value of the time
1714 zone rather than looking it up every time. Since localtime() is
1715 called to bolt the undumping time into the undumped emacs, this
1716 results in localtime() ignoring the TZ environment variable.
1717 This flushes the new TZ value into localtime(). */
1719 #endif /* LOCALTIME_CACHE and TZSET */
1724 /* Handle -l loadup-and-dump, args passed by Makefile. */
1725 if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l"))
1726 load_me = build_string (argv[2 + skip_args]);
1727 #if 0 /* CANNOT_DUMP - this can never be right in XEmacs --andyp */
1728 /* Unless next switch is -nl, load "loadup.el" first thing. */
1729 if (!(argc > 1 + skip_args && !strcmp (argv[1 + skip_args], "-nl")))
1730 load_me = build_string ("loadup.el");
1731 #endif /* CANNOT_DUMP */
1736 quantify_start_recording_data ();
1737 #endif /* QUANTIFY */
1741 /* This never returns. */
1742 initial_command_loop (load_me);
1747 /* Sort the args so we can find the most important ones
1748 at the beginning of argv. */
1750 /* First, here's a table of all the standard options. */
1752 struct standard_args
1754 CONST char * CONST name;
1755 CONST char * CONST longname;
1760 static struct standard_args standard_args[] =
1762 /* Handled by main_1 above: */
1763 { "-nl", "--no-shared-memory", 100, 0 },
1764 { "-t", "--terminal", 95, 1 },
1765 { "-nw", "--no-windows", 90, 0 },
1766 { "-batch", "--batch", 85, 0 },
1767 { "-debug-paths", "--debug-paths", 82, 0 },
1768 { "-help", "--help", 80, 0 },
1769 { "-version", "--version", 75, 0 },
1771 { "-d", "--display", 80, 1 },
1772 { "-display", 0, 80, 1 },
1773 { "-NXHost", 0, 79, 0 },
1774 { "-MachLaunch", 0, 79, 0},
1776 /* Handled by command-line-early in startup.el: */
1777 { "-q", "--no-init-file", 50, 0 },
1778 { "-unmapped", 0, 50, 0 },
1779 { "-no-init-file", 0, 50, 0 },
1780 { "-vanilla", "--vanilla", 50, 0 },
1781 { "-no-autoloads", "--no-autoloads", 50, 0 },
1782 { "-no-site-file", "--no-site-file", 40, 0 },
1783 { "-no-early-packages", "--no-early-packages", 35, 0 },
1784 { "-u", "--user", 30, 1 },
1785 { "-user", 0, 30, 1 },
1786 { "-debug-init", "--debug-init", 20, 0 },
1787 { "-debug-paths", "--debug-paths", 20, 0 },
1790 { "-i", "--icon-type", 15, 0 },
1791 { "-itype", 0, 15, 0 },
1792 { "-iconic", "--iconic", 15, 0 },
1793 { "-bg", "--background-color", 10, 1 },
1794 { "-background", 0, 10, 1 },
1795 { "-fg", "--foreground-color", 10, 1 },
1796 { "-foreground", 0, 10, 1 },
1797 { "-bd", "--border-color", 10, 1 },
1798 { "-bw", "--border-width", 10, 1 },
1799 { "-ib", "--internal-border", 10, 1 },
1800 { "-ms", "--mouse-color", 10, 1 },
1801 { "-cr", "--cursor-color", 10, 1 },
1802 { "-fn", "--font", 10, 1 },
1803 { "-font", 0, 10, 1 },
1804 { "-g", "--geometry", 10, 1 },
1805 { "-geometry", 0, 10, 1 },
1806 { "-T", "--title", 10, 1 },
1807 { "-title", 0, 10, 1 },
1808 { "-name", "--name", 10, 1 },
1809 { "-xrm", "--xrm", 10, 1 },
1810 { "-r", "--reverse-video", 5, 0 },
1812 { "-reverse", 0, 5, 0 },
1813 { "-hb", "--horizontal-scroll-bars", 5, 0 },
1814 { "-vb", "--vertical-scroll-bars", 5, 0 },
1816 /* These have the same priority as ordinary file name args,
1817 so they are not reordered with respect to those. */
1818 { "-L", "--directory", 0, 1 },
1819 { "-directory", 0, 0, 1 },
1820 { "-l", "--load", 0, 1 },
1821 { "-load", 0, 0, 1 },
1822 { "-f", "--funcall", 0, 1 },
1823 { "-funcall", 0, 0, 1 },
1824 { "-eval", "--eval", 0, 1 },
1825 { "-insert", "--insert", 0, 1 },
1826 /* This should be processed after ordinary file name args and the like. */
1827 { "-kill", "--kill", -10, 0 },
1830 /* Reorder the elements of ARGV (assumed to have ARGC elements)
1831 so that the highest priority ones come first.
1832 Do not change the order of elements of equal priority.
1833 If an option takes an argument, keep it and its argument together. */
1836 sort_args (int argc, char **argv)
1838 char **new_argv = xnew_array (char *, argc);
1839 /* For each element of argv,
1840 the corresponding element of options is:
1841 0 for an option that takes no arguments,
1842 1 for an option that takes one argument, etc.
1843 -1 for an ordinary non-option argument. */
1844 int *options = xnew_array (int, argc);
1845 int *priority = xnew_array (int, argc);
1849 int end_of_options_p = 0;
1851 /* Categorize all the options,
1852 and figure out which argv elts are option arguments. */
1853 for (from = 1; from < argc; from++)
1857 /* Pseudo options "--" and "run-temacs" indicate end of options */
1858 if (!strcmp (argv[from], "--") ||
1859 !strcmp (argv[from], "run-temacs"))
1860 end_of_options_p = 1;
1861 if (!end_of_options_p && argv[from][0] == '-')
1866 /* Look for a match with a known old-fashioned option. */
1867 for (i = 0; i < countof (standard_args); i++)
1868 if (!strcmp (argv[from], standard_args[i].name))
1870 options[from] = standard_args[i].nargs;
1871 priority[from] = standard_args[i].priority;
1872 if (from + standard_args[i].nargs >= argc)
1873 fatal ("Option `%s' requires an argument\n", argv[from]);
1874 from += standard_args[i].nargs;
1878 /* Look for a match with a known long option.
1879 MATCH is -1 if no match so far, -2 if two or more matches so far,
1880 >= 0 (the table index of the match) if just one match so far. */
1881 if (argv[from][1] == '-')
1884 thislen = strlen (argv[from]);
1885 equals = strchr (argv[from], '=');
1887 thislen = equals - argv[from];
1889 for (i = 0; i < countof (standard_args); i++)
1890 if (standard_args[i].longname
1891 && !strncmp (argv[from], standard_args[i].longname,
1900 /* If we found exactly one match, use that. */
1903 options[from] = standard_args[match].nargs;
1904 priority[from] = standard_args[match].priority;
1905 /* If --OPTION=VALUE syntax is used,
1906 this option uses just one argv element. */
1909 if (from + options[from] >= argc)
1910 fatal ("Option `%s' requires an argument\n", argv[from]);
1911 from += options[from];
1918 /* Copy the arguments, in order of decreasing priority, to NEW_ARGV. */
1919 new_argv[0] = argv[0];
1923 int best_priority = -9999;
1925 /* Find the highest priority remaining option.
1926 If several have equal priority, take the first of them. */
1927 for (from = 1; from < argc; from++)
1929 if (argv[from] != 0 && priority[from] > best_priority)
1931 best_priority = priority[from];
1934 /* Skip option arguments--they are tied to the options. */
1935 if (options[from] > 0)
1936 from += options[from];
1942 /* Copy the highest priority remaining option, with its args, to NEW_ARGV. */
1943 new_argv[to++] = argv[best];
1944 for (i = 0; i < options[best]; i++)
1945 new_argv[to++] = argv[best + i + 1];
1947 /* Clear out this option in ARGV. */
1949 for (i = 0; i < options[best]; i++)
1950 argv[best + i + 1] = 0;
1953 memcpy (argv, new_argv, sizeof (char *) * argc);
1959 static JMP_BUF run_temacs_catch;
1961 static int run_temacs_argc;
1962 static char **run_temacs_argv;
1963 static char *run_temacs_args;
1964 static size_t run_temacs_argv_size;
1965 static size_t run_temacs_args_size;
1967 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /*
1968 True if running temacs. This means we are in the dumping stage.
1969 This is false during normal execution of the `xemacs' program, and
1970 becomes false once `run-emacs-from-temacs' is run.
1974 return run_temacs_argc >= 0 ? Qt : Qnil;
1977 DEFUN ("run-emacs-from-temacs", Frun_emacs_from_temacs, 0, MANY, 0, /*
1978 Do not call this. It will reinitialize your XEmacs. You'll be sorry.
1980 /* If this function is called from startup.el, it will be possible to run
1981 temacs as an editor using 'temacs -batch -l loadup.el run-temacs', instead
1982 of having to dump an emacs and then run that (when debugging emacs itself,
1983 this can be much faster)). [Actually, the speed difference isn't that
1984 much as long as your filesystem is local, and you don't end up with
1985 a dumped version in case you want to rerun it. This function is most
1986 useful when used as part of the `make all-elc' command. --ben]
1987 This will "restart" emacs with the specified command-line arguments.
1989 Martin thinks this function is most useful when using debugging
1990 tools like Purify or tcov that get confused by XEmacs' dumping. */
1991 (int nargs, Lisp_Object *args))
1994 CONST Extbyte *wampum;
1997 Lisp_Object orig_invoc_name = Fcar (Vcommand_line_args);
1998 CONST Extbyte **wampum_all = alloca_array (CONST Extbyte *, nargs);
1999 int *wampum_all_len = alloca_array (int, nargs);
2001 assert (!gc_in_progress);
2003 if (run_temacs_argc < 0)
2004 error ("I've lost my temacs-hood.");
2006 /* Need to convert the orig_invoc_name and all of the arguments
2007 to external format. */
2009 GET_STRING_EXT_DATA_ALLOCA (orig_invoc_name, FORMAT_OS, wampum,
2013 for (ac = 0, total_len = namesize; ac < nargs; ac++)
2015 CHECK_STRING (args[ac]);
2016 GET_STRING_EXT_DATA_ALLOCA (args[ac], FORMAT_OS,
2018 wampum_all_len[ac]);
2019 wampum_all_len[ac]++;
2020 total_len += wampum_all_len[ac];
2022 DO_REALLOC (run_temacs_args, run_temacs_args_size, total_len, char);
2023 DO_REALLOC (run_temacs_argv, run_temacs_argv_size, nargs+2, char *);
2025 memcpy (run_temacs_args, wampum, namesize);
2026 run_temacs_argv [0] = run_temacs_args;
2027 for (ac = 0; ac < nargs; ac++)
2029 memcpy (run_temacs_args + namesize,
2030 wampum_all[ac], wampum_all_len[ac]);
2031 run_temacs_argv [ac + 1] = run_temacs_args + namesize;
2032 namesize += wampum_all_len[ac];
2034 run_temacs_argv [nargs + 1] = 0;
2035 catchlist = NULL; /* Important! Otherwise free_cons() calls in
2036 condition_case_unwind() may lead to GC death. */
2037 unbind_to (0, Qnil); /* this closes loadup.el */
2039 run_temacs_argc = nargs + 1;
2040 LONGJMP (run_temacs_catch, 1);
2041 return Qnil; /* not reached; warning suppression */
2046 main (int argc, char **argv, char **envp)
2048 int volatile vol_argc = argc;
2049 char ** volatile vol_argv = argv;
2050 char ** volatile vol_envp = envp;
2051 /* This is hairy. We need to compute where the XEmacs binary was invoked
2052 from because temacs initialization requires it to find the lisp
2053 directories. The code that recomputes the path is guarded by the
2054 restarted flag. There are three possible paths I've found so far
2057 temacs -- When running temacs for basic build stuff, the first main_1
2058 will be the only one invoked. It must compute the path else there
2059 will be a very ugly bomb in startup.el (can't find obvious location
2060 for doc-directory data-directory, etc.).
2062 temacs w/ run-temacs on the command line -- This is run to bytecompile
2063 all the out of date dumped lisp. It will execute both of the main_1
2064 calls and the second one must not touch the first computation because
2065 argc/argv are hosed the second time through.
2067 xemacs -- Only the second main_1 is executed. The invocation path must
2068 computed but this only matters when running in place or when running
2071 As a bonus for straightening this out, XEmacs can now be run in place
2072 as a login shell. This never used to work.
2074 As another bonus, we can now guarantee that
2075 (concat invocation-directory invocation-name) contains the filename
2076 of the XEmacs binary we are running. This can now be used in a
2077 definite test for out of date dumped files. -slb */
2080 quantify_stop_recording_data ();
2081 quantify_clear_data ();
2082 #endif /* QUANTIFY */
2084 suppress_early_error_handler_backtrace = 0;
2085 lim_data = 0; /* force reinitialization of this variable */
2087 /* Lisp_Object must fit in a word; check VALBITS and GCTYPEBITS */
2088 assert (sizeof (Lisp_Object) == sizeof (void *));
2090 #ifdef LINUX_SBRK_BUG
2096 #ifdef DOUG_LEA_MALLOC
2097 mallopt (M_MMAP_MAX, 0);
2099 run_temacs_argc = 0;
2100 if (! SETJMP (run_temacs_catch))
2102 main_1 (vol_argc, vol_argv, vol_envp, 0);
2104 /* run-emacs-from-temacs called */
2106 vol_argc = run_temacs_argc;
2107 vol_argv = run_temacs_argv;
2109 /* This makes absolutely no sense to anyone involved. There are
2110 several people using this stuff. We've compared versions on
2111 everything we can think of. We can find no difference.
2112 However, on both my systems environ is a plain old global
2113 variable initialized to zero. _environ is the one that
2114 contains pointers to the actual environment.
2116 Since we can't figure out the difference (and we're hours
2117 away from a release), this takes a very cowardly approach and
2118 is bracketed with both a system specific preprocessor test
2119 and a runtime "do you have this problem" test
2121 06/20/96 robertl@dgii.com */
2123 extern char *_environ;
2124 if ((unsigned) environ == 0)
2127 #endif /* _SCO_DS */
2130 #ifdef RUN_TIME_REMAP
2132 /* obviously no-one uses this because where it was before initialized was
2134 run_time_remap (argv[0]);
2137 #ifdef DOUG_LEA_MALLOC
2138 if (initialized && (malloc_state_ptr != NULL))
2140 int rc = malloc_set_state (malloc_state_ptr);
2143 fprintf (stderr, "malloc_set_state failed, rc = %d\n", rc);
2147 free (malloc_state_ptr);
2149 /* mmap works in glibc-2.1, glibc-2.0 (Non-Mule only) and Linux libc5 */
2150 #if (defined(__GLIBC__) && __GLIBC_MINOR__ >= 1) || \
2151 defined(_NO_MALLOC_WARNING_) || \
2152 (defined(__GLIBC__) && __GLIBC_MINOR__ < 1 && !defined(MULE)) || \
2153 defined(DEBUG_DOUG_LEA_MALLOC)
2154 mallopt (M_MMAP_MAX, 64);
2160 #endif /* DOUG_LEA_MALLOC */
2162 run_temacs_argc = -1;
2164 main_1 (vol_argc, vol_argv, vol_envp, restarted);
2165 return 0; /* unreached */
2169 /* Dumping apparently isn't supported by versions of GCC >= 2.8. */
2170 /* The following needs conditionalization on whether either XEmacs or */
2171 /* various system shared libraries have been built and linked with */
2172 /* GCC >= 2.8. -slb */
2173 #if defined(GNU_MALLOC)
2175 voodoo_free_hook (void *mem)
2177 /* Disable all calls to free() when XEmacs is exiting and it doesn't */
2179 __free_hook = voodoo_free_hook;
2183 DEFUN ("kill-emacs", Fkill_emacs, 0, 1, "P", /*
2184 Exit the XEmacs job and kill it. Ask for confirmation, without argument.
2185 If ARG is an integer, return ARG as the exit program code.
2186 If ARG is a string, stuff it as keyboard input.
2188 The value of `kill-emacs-hook', if not void,
2189 is a list of functions (of no args),
2190 all of which are called before XEmacs is actually killed.
2194 /* This function can GC */
2195 struct gcpro gcpro1;
2202 if (!preparing_for_armageddon && !noninteractive)
2203 run_hook (Qkill_emacs_hook);
2205 /* make sure no quitting from now on!! */
2206 dont_check_for_quit = 1;
2209 if (!preparing_for_armageddon)
2211 Lisp_Object concons, nextcons;
2213 /* Normally, go ahead and delete all the consoles now.
2214 Some unmentionably lame window systems (MS Wwwww...... eek,
2215 I can't even say it) don't properly clean up after themselves,
2216 and even for those that do, it might be cleaner this way.
2217 If we're going down, however, we don't do this (might
2218 be too dangerous), and if we get a crash somewhere within
2219 this loop, we'll still autosave and won't try this again. */
2221 LIST_LOOP_DELETING(concons, nextcons, Vconsole_list)
2223 /* There is very little point in deleting the stream console.
2224 It uses stdio, which should flush any buffered output and
2225 something can only go wrong. -slb */
2226 /* I changed my mind. There's a stupid hack in close to add
2227 a trailing newline. */
2228 /*if (!CONSOLE_STREAM_P (XCONSOLE (XCAR (concons))))*/
2229 delete_console_internal (XCONSOLE (XCAR (concons)), 1, 1, 0);
2235 shut_down_emacs (0, ((STRINGP (arg)) ? arg : Qnil));
2237 #if defined(GNU_MALLOC)
2238 __free_hook = voodoo_free_hook;
2241 exit ((INTP (arg)) ? XINT (arg) : 0);
2243 return Qnil; /* I'm sick of the compiler warning */
2246 /* Perform an orderly shutdown of XEmacs. Autosave any modified
2247 buffers, kill any child processes, clean up the terminal modes (if
2248 we're in the foreground), and other stuff like that. Don't perform
2249 any redisplay; this may be called when XEmacs is shutting down in
2250 the background, or after its X connection has died.
2252 If SIG is a signal number, print a message for it.
2254 This is called by fatal signal handlers, X protocol error handlers,
2257 shut_down_emacs (int sig, Lisp_Object stuff)
2259 /* This function can GC */
2260 /* Prevent running of hooks and other non-essential stuff
2262 preparing_for_armageddon = 1;
2264 /* In case frames or windows are screwed up, avoid assertion
2269 quantify_stop_recording_data ();
2270 #endif /* QUANTIFY */
2273 /* This is absolutely the most important thing to do, so make sure
2274 we do it now, before anything else. We might have crashed and
2275 be in a weird inconsistent state, and potentially anything could
2276 set off another protection fault and cause us to bail out
2278 /* I'm not removing the code entirely, yet. We have run up against
2279 a spate of problems in diagnosing crashes due to crashes within
2280 crashes. It has very definitely been determined that code called
2281 during auto-saving cannot work if XEmacs crashed inside of GC.
2282 We already auto-save on an itimer so there cannot be too much
2283 unsaved stuff around, and if we get better crash reports we might
2284 be able to get more problems fixed so I'm disabling this. -slb */
2285 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */
2289 reset_all_consoles ();
2290 if (sig && sig != SIGTERM)
2292 stderr_out ("\nFatal error (%d).\n", sig);
2294 ("Your files have been auto-saved.\n"
2295 "Use `M-x recover-session' to recover them.\n"
2298 "Please report this bug by selecting `Report-Bug' in the InfoDock\n"
2301 "Please report this bug by running the send-pr script included\n"
2302 "with XEmacs, or selecting `Send Bug Report' from the help menu.\n"
2303 "As a last resort send ordinary email to `crashes@xemacs.org'.\n"
2305 "*MAKE SURE* to include the information in the command\n"
2306 "M-x describe-installation.\n"
2308 "If at all possible, *please* try to obtain a C stack backtrace;\n"
2309 "it will help us immensely in determining what went wrong.\n"
2310 "To do this, locate the core file that was produced as a result\n"
2311 "of this crash (it's usually called `core' and is located in the\n"
2312 "directory in which you started the editor, or maybe in your home\n"
2313 "directory), and type\n"
2320 /* Now try to determine the actual path to the executable,
2321 to try to make the backtrace-determination process as foolproof
2323 if (GC_STRINGP (Vinvocation_name))
2324 name = (char *) XSTRING_DATA (Vinvocation_name);
2327 if (GC_STRINGP (Vinvocation_directory))
2328 dir = (char *) XSTRING_DATA (Vinvocation_directory);
2329 if (!dir || dir[0] != '/')
2330 stderr_out ("`which %s`", name);
2331 else if (dir[strlen (dir) - 1] != '/')
2332 stderr_out ("%s/%s", dir, name);
2334 stderr_out ("%s%s", dir, name);
2338 "then type `where' when the debugger prompt comes up.\n"
2339 "(If you don't have GDB on your system, you might have DBX,\n"
2340 "or XDB, or SDB. A similar procedure should work for all of\n"
2341 "these. Ask your system administrator if you need more help.)\n");
2344 stuff_buffered_input (stuff);
2346 kill_buffer_processes (Qnil);
2348 #ifdef CLASH_DETECTION
2349 unlock_all_files ();
2353 tt_session_quit (tt_default_session ());
2355 /* The following crashes when built on X11R5 and run on X11R6 */
2358 #endif /* TOOLTALK */
2364 /* Nothing like this can be implemented on an Apollo.
2367 extern char my_edata[];
2371 DEFUN ("dump-emacs-data", Fdump_emacs_data, 1, 1, 0, /*
2372 Dump current state of XEmacs into data file FILENAME.
2373 This function exists on systems that use HAVE_SHM.
2377 /* This function can GC */
2379 struct gcpro gcpro1;
2382 CHECK_STRING (intoname);
2383 intoname = Fexpand_file_name (intoname, Qnil);
2385 opurify = purify_flag;
2391 disksave_object_finalization ();
2392 release_breathing_space ();
2394 /* Tell malloc where start of impure now is */
2395 /* Also arrange for warnings when nearly out of space. */
2396 #ifndef SYSTEM_MALLOC
2397 memory_warnings (my_edata, malloc_warning);
2400 map_out_data (XSTRING_DATA (intoname));
2402 purify_flag = opurify;
2407 #else /* not HAVE_SHM */
2408 extern void disable_free_hook (void);
2410 DEFUN ("dump-emacs", Fdump_emacs, 2, 2, 0, /*
2411 Dump current state of XEmacs into executable file FILENAME.
2412 Take symbols from SYMFILE (presumably the file you executed to run XEmacs).
2413 This is used in the file `loadup.el' when building XEmacs.
2415 Remember to set `command-line-processed' to nil before dumping
2416 if you want the dumped XEmacs to process its command line
2417 and announce itself normally when it is run.
2419 (intoname, symname))
2421 /* This function can GC */
2422 struct gcpro gcpro1, gcpro2;
2425 GCPRO2 (intoname, symname);
2427 #ifdef FREE_CHECKING
2428 Freally_free (Qnil);
2430 /* When we're dumping, we can't use the debugging free() */
2431 disable_free_hook ();
2434 CHECK_STRING (intoname);
2435 intoname = Fexpand_file_name (intoname, Qnil);
2436 if (!NILP (symname))
2438 CHECK_STRING (symname);
2439 if (XSTRING_LENGTH (symname) > 0)
2440 symname = Fexpand_file_name (symname, Qnil);
2445 opurify = purify_flag;
2451 disksave_object_finalization ();
2452 release_breathing_space ();
2454 /* Tell malloc where start of impure now is */
2455 /* Also arrange for warnings when nearly out of space. */
2456 #ifndef SYSTEM_MALLOC
2457 memory_warnings (my_edata, malloc_warning);
2462 #if defined (MSDOS) && defined (EMX)
2464 int fd = open ((char *) XSTRING_DATA (intoname),
2465 O_WRONLY|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE);
2467 error ("Failure operating on %s", XSTRING_DATA (intoname));
2473 #else /* not MSDOS and EMX */
2478 GET_C_STRING_FILENAME_DATA_ALLOCA (intoname, intoname_ext);
2479 if (STRINGP (symname))
2480 GET_C_STRING_FILENAME_DATA_ALLOCA (symname, symname_ext);
2484 garbage_collect_1 ();
2485 #ifdef DOUG_LEA_MALLOC
2486 malloc_state_ptr = malloc_get_state ();
2488 /* here we break our rule that the filename conversion should
2489 be performed at the actual time that the system call is made.
2490 It's a whole lot easier to do the conversion here than to
2491 modify all the unexec routines to ensure that filename
2492 conversion is applied everywhere. Don't worry about memory
2493 leakage because this call only happens once. */
2494 unexec (intoname_ext, symname_ext, (uintptr_t) my_edata, 0, 0);
2495 #ifdef DOUG_LEA_MALLOC
2496 free (malloc_state_ptr);
2499 #endif /* not MSDOS and EMX */
2501 purify_flag = opurify;
2506 #endif /* not HAVE_SHM */
2508 #endif /* not CANNOT_DUMP */
2514 /* Split STRING into a list of substrings. The substrings are the
2515 parts of original STRING separated by SEPCHAR. */
2517 split_string_by_emchar_1 (CONST Bufbyte *string, Bytecount size,
2520 Lisp_Object result = Qnil;
2521 CONST Bufbyte *end = string + size;
2525 CONST Bufbyte *p = string;
2528 if (charptr_emchar (p) == sepchar)
2532 result = Fcons (make_string (string, p - string), result);
2536 INC_CHARPTR (string); /* skip sepchar */
2541 return Fnreverse (result);
2544 /* The same as the above, except PATH is an external C string (it is
2545 converted as FORMAT_FILENAME), and sepchar is hardcoded to SEPCHAR
2546 (':' or whatever). */
2548 decode_path (CONST char *path)
2555 GET_C_CHARPTR_INT_FILENAME_DATA_ALLOCA (path, newpath);
2557 len = strlen ((const char *) newpath);
2558 /* #### Does this make sense? It certainly does for
2559 decode_env_path(), but it looks dubious here. Does any code
2560 depend on decode_path("") returning nil instead of an empty
2565 return split_string_by_emchar_1 (newpath, (Bytecount)len, SEPCHAR);
2569 decode_env_path (CONST char *evarname, CONST char *default_)
2571 CONST char *path = 0;
2573 path = egetenv (evarname);
2576 return decode_path (path);
2579 /* Ben thinks this function should not exist or be exported to Lisp.
2580 We use it to define split-path-string in subr.el (not!). */
2582 DEFUN ("split-string-by-char", Fsplit_string_by_char, 1, 2, 0, /*
2583 Split STRING into a list of substrings originally separated by SEPCHAR.
2587 CHECK_STRING (string);
2588 CHECK_CHAR (sepchar);
2589 return split_string_by_emchar_1 (XSTRING_DATA (string),
2590 XSTRING_LENGTH (string),
2594 /* #### This was supposed to be in subr.el, but is used VERY early in
2595 the bootstrap process, so it goes here. Damn. */
2597 DEFUN ("split-path", Fsplit_path, 1, 1, 0, /*
2598 Explode a search path into a list of strings.
2599 The path components are separated with the characters specified
2600 with `path-separator'.
2604 CHECK_STRING (path);
2606 while (!STRINGP (Vpath_separator)
2607 || (XSTRING_CHAR_LENGTH (Vpath_separator) != 1))
2608 Vpath_separator = signal_simple_continuable_error
2609 ("`path-separator' should be set to a single-character string",
2612 return (split_string_by_emchar_1
2613 (XSTRING_DATA (path), XSTRING_LENGTH (path),
2614 charptr_emchar (XSTRING_DATA (Vpath_separator))));
2617 DEFUN ("noninteractive", Fnoninteractive, 0, 0, 0, /*
2618 Non-nil return value means XEmacs is running without interactive terminal.
2622 return noninteractive ? Qt : Qnil;
2625 /* This flag is useful to define if you're under a debugger; this way, you
2626 can put a breakpoint of assert_failed() and debug multiple problems
2627 in one session without having to recompile. */
2628 /* #define ASSERTIONS_DONT_ABORT */
2630 #ifdef USE_ASSERTIONS
2631 /* This highly dubious kludge ... shut up Jamie, I'm tired of your slagging. */
2634 assert_failed (CONST char *file, int line, CONST char *expr)
2636 stderr_out ("Fatal error: assertion failed, file %s, line %d, %s\n",
2638 #undef abort /* avoid infinite #define loop... */
2639 #if defined (WINDOWSNT) && defined (DEBUG_XEMACS)
2641 #elif !defined (ASSERTIONS_DONT_ABORT)
2645 #endif /* USE_ASSERTIONS */
2648 DEFUN ("quantify-start-recording-data", Fquantify_start_recording_data,
2650 Start recording Quantify data.
2654 quantify_start_recording_data ();
2658 DEFUN ("quantify-stop-recording-data", Fquantify_stop_recording_data,
2660 Stop recording Quantify data.
2664 quantify_stop_recording_data ();
2668 DEFUN ("quantify-clear-data", Fquantify_clear_data, 0, 0, "", /*
2669 Clear all Quantify data.
2673 quantify_clear_data ();
2676 #endif /* QUANTIFY */
2679 syms_of_emacs (void)
2683 DEFSUBR (Fdump_emacs_data);
2685 DEFSUBR (Fdump_emacs);
2687 #endif /* !CANNOT_DUMP */
2689 DEFSUBR (Frun_emacs_from_temacs);
2690 DEFSUBR (Frunning_temacs_p);
2691 DEFSUBR (Finvocation_name);
2692 DEFSUBR (Finvocation_directory);
2693 DEFSUBR (Fkill_emacs);
2694 DEFSUBR (Fnoninteractive);
2697 DEFSUBR (Fquantify_start_recording_data);
2698 DEFSUBR (Fquantify_stop_recording_data);
2699 DEFSUBR (Fquantify_clear_data);
2700 #endif /* QUANTIFY */
2702 DEFSUBR (Fsplit_string_by_char);
2703 DEFSUBR (Fsplit_path); /* #### */
2705 defsymbol (&Qkill_emacs_hook, "kill-emacs-hook");
2706 defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs");
2710 vars_of_emacs (void)
2712 DEFVAR_BOOL ("suppress-early-error-handler-backtrace",
2713 &suppress_early_error_handler_backtrace /*
2714 Non-nil means early error handler shouldn't print a backtrace.
2717 DEFVAR_LISP ("command-line-args", &Vcommand_line_args /*
2718 Args passed by shell to XEmacs, as a list of strings.
2721 DEFVAR_LISP ("invocation-name", &Vinvocation_name /*
2722 The program name that was used to run XEmacs.
2723 Any directory names are omitted.
2726 DEFVAR_LISP ("invocation-directory", &Vinvocation_directory /*
2727 The directory in which the XEmacs executable was found, to run it.
2728 The value is simply the program name if that directory's name is not known.
2731 DEFVAR_LISP ("invocation-path", &Vinvocation_path /*
2732 The path in which the XEmacs executable was found, to run it.
2733 The value is simply the value of environment variable PATH on startup
2734 if XEmacs was found there.
2738 xxDEFVAR_LISP ("installation-directory", &Vinstallation_directory,
2739 "A directory within which to look for the `lib-src' and `etc' directories.\n"
2740 "This is non-nil when we can't find those directories in their standard\n"
2741 "installed locations, but we can find them\n"
2742 "near where the XEmacs executable was found.");
2745 DEFVAR_LISP ("system-type", &Vsystem_type /*
2746 Symbol indicating type of operating system you are using.
2748 Vsystem_type = intern (SYSTEM_TYPE);
2749 Fprovide (intern(SYSTEM_TYPE));
2751 #ifndef EMACS_CONFIGURATION
2752 # define EMACS_CONFIGURATION "UNKNOWN"
2754 DEFVAR_LISP ("system-configuration", &Vsystem_configuration /*
2755 String naming the configuration XEmacs was built for.
2757 Vsystem_configuration = Fpurecopy (build_string (EMACS_CONFIGURATION));
2759 #ifndef EMACS_CONFIG_OPTIONS
2760 # define EMACS_CONFIG_OPTIONS "UNKNOWN"
2762 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options /*
2763 String containing the configuration options XEmacs was built with.
2765 Vsystem_configuration_options = Fpurecopy (build_string
2766 (EMACS_CONFIG_OPTIONS));
2768 DEFVAR_LISP ("emacs-major-version", &Vemacs_major_version /*
2769 Major version number of this version of Emacs, as an integer.
2770 Warning: this variable did not exist in Emacs versions earlier than:
2774 Vemacs_major_version = make_int (EMACS_MAJOR_VERSION);
2776 DEFVAR_LISP ("emacs-minor-version", &Vemacs_minor_version /*
2777 Minor version number of this version of Emacs, as an integer.
2778 Warning: this variable did not exist in Emacs versions earlier than:
2782 Vemacs_minor_version = make_int (EMACS_MINOR_VERSION);
2784 DEFVAR_LISP ("emacs-beta-version", &Vemacs_beta_version /*
2785 Beta number of this version of Emacs, as an integer.
2786 The value is nil if this is an officially released version of XEmacs.
2787 Warning: this variable does not exist in FSF Emacs or in XEmacs versions
2790 #ifdef EMACS_BETA_VERSION
2791 Vemacs_beta_version = make_int (EMACS_BETA_VERSION);
2793 Vemacs_beta_version = Qnil;
2797 DEFVAR_LISP ("infodock-major-version", &Vinfodock_major_version /*
2798 Major version number of this InfoDock release.
2800 Vinfodock_major_version = make_int (INFODOCK_MAJOR_VERSION);
2802 DEFVAR_LISP ("infodock-minor-version", &Vinfodock_minor_version /*
2803 Minor version number of this InfoDock release.
2805 Vinfodock_minor_version = make_int (INFODOCK_MINOR_VERSION);
2807 DEFVAR_LISP ("infodock-build-version", &Vinfodock_build_version /*
2808 Build version of this InfoDock release.
2810 Vinfodock_build_version = make_int (INFODOCK_BUILD_VERSION);
2813 DEFVAR_LISP ("xemacs-codename", &Vxemacs_codename /*
2814 Codename of this version of Emacs (a string).
2816 #ifndef XEMACS_CODENAME
2817 #define XEMACS_CODENAME "Noname"
2819 Vxemacs_codename = Fpurecopy (build_string (XEMACS_CODENAME));
2821 DEFVAR_BOOL ("noninteractive", &noninteractive1 /*
2822 Non-nil means XEmacs is running without interactive terminal.
2825 DEFVAR_BOOL ("inhibit-early-packages", &inhibit_early_packages /*
2826 Set to non-nil when the early packages should not be respected at startup.
2829 DEFVAR_BOOL ("inhibit-autoloads", &inhibit_autoloads /*
2830 Set to non-nil when autoloads should not be loaded at startup.
2833 DEFVAR_BOOL ("debug-paths", &debug_paths /*
2834 Set to non-nil when debug information about paths should be printed.
2837 DEFVAR_BOOL ("inhibit-site-lisp", &inhibit_site_lisp /*
2838 Set to non-nil when the site-lisp should not be searched at startup.
2840 #ifdef INHIBIT_SITE_LISP
2841 inhibit_site_lisp = 1;
2844 DEFVAR_BOOL ("inhibit-site-modules", &inhibit_site_modules /*
2845 Set to non-nil when site-modules should not be searched at startup.
2847 #ifdef INHIBIT_SITE_MODULES
2848 inhibit_site_modules = 1;
2851 DEFVAR_INT ("emacs-priority", &emacs_priority /*
2852 Priority for XEmacs to run at.
2853 This value is effective only if set before XEmacs is dumped,
2854 and only if the XEmacs executable is installed with setuid to permit
2855 it to change priority. (XEmacs sets its uid back to the real uid.)
2856 Currently, you need to define SET_EMACS_PRIORITY in `config.h'
2857 before you compile XEmacs, to enable the code for this feature.
2861 DEFVAR_CONST_LISP ("internal-error-checking", &Vinternal_error_checking /*
2862 Internal error checking built-in into this instance of XEmacs.
2863 This is a list of symbols, initialized at build-time. Legal symbols
2866 extents - check extents prior to each extent change;
2867 typecheck - check types strictly, aborting in case of error;
2868 malloc - check operation of malloc;
2869 gc - check garbage collection;
2870 bufpos - check buffer positions.
2872 Vinternal_error_checking = Qnil;
2873 #ifdef ERROR_CHECK_EXTENTS
2874 Vinternal_error_checking = Fcons (intern ("extents"),
2875 Vinternal_error_checking);
2877 #ifdef ERROR_CHECK_TYPECHECK
2878 Vinternal_error_checking = Fcons (intern ("typecheck"),
2879 Vinternal_error_checking);
2881 #ifdef ERROR_CHECK_MALLOC
2882 Vinternal_error_checking = Fcons (intern ("malloc"),
2883 Vinternal_error_checking);
2885 #ifdef ERROR_CHECK_GC
2886 Vinternal_error_checking = Fcons (intern ("gc"),
2887 Vinternal_error_checking);
2889 #ifdef ERROR_CHECK_BUFPOS
2890 Vinternal_error_checking = Fcons (intern ("bufpos"),
2891 Vinternal_error_checking);
2893 Vinternal_error_checking = Fpurecopy (Vinternal_error_checking);
2895 DEFVAR_LISP ("path-separator", &Vpath_separator /*
2896 The directory separator in search paths, as a string.
2900 Vpath_separator = make_string ((Bufbyte *)&c, 1);
2905 complex_vars_of_emacs (void)
2907 /* This is all related to path searching. */
2909 DEFVAR_LISP ("emacs-program-name", &Vemacs_program_name /*
2910 *Name of the Emacs variant.
2911 For example, this may be \"xemacs\" or \"infodock\".
2912 This is mainly meant for use in path searching.
2914 Vemacs_program_name = build_string ((char *) PATH_PROGNAME);
2916 DEFVAR_LISP ("emacs-program-version", &Vemacs_program_version /*
2917 *Version of the Emacs variant.
2918 This typically has the form XX.XX[-bXX].
2919 This is mainly meant for use in path searching.
2921 Vemacs_program_version = build_string ((char *) PATH_VERSION);
2923 DEFVAR_LISP ("exec-path", &Vexec_path /*
2924 *List of directories to search programs to run in subprocesses.
2925 Each element is a string (directory name) or nil (try default directory).
2929 DEFVAR_LISP ("exec-directory", &Vexec_directory /*
2930 *Directory of architecture-dependent files that come with XEmacs,
2931 especially executable programs intended for XEmacs to invoke.
2933 Vexec_directory = Qnil;
2935 DEFVAR_LISP ("configure-exec-directory", &Vconfigure_exec_directory /*
2936 For internal use by the build procedure only.
2937 configure's idea of what EXEC-DIRECTORY will be.
2940 Vconfigure_exec_directory = Ffile_name_as_directory
2941 (build_string ((char *) PATH_EXEC));
2943 Vconfigure_exec_directory = Qnil;
2946 DEFVAR_LISP ("lisp-directory", &Vlisp_directory /*
2947 *Directory of core Lisp files that come with XEmacs.
2949 Vlisp_directory = Qnil;
2951 DEFVAR_LISP ("configure-lisp-directory", &Vconfigure_lisp_directory /*
2952 For internal use by the build procedure only.
2953 configure's idea of what LISP-DIRECTORY will be.
2955 #ifdef PATH_LOADSEARCH
2956 Vconfigure_lisp_directory = Ffile_name_as_directory
2957 (build_string ((char *) PATH_LOADSEARCH));
2959 Vconfigure_lisp_directory = Qnil;
2962 DEFVAR_LISP ("module-directory", &Vmodule_directory /*
2963 *Directory of core dynamic modules that come with XEmacs.
2965 Vmodule_directory = Qnil;
2967 DEFVAR_LISP ("configure-module-directory", &Vconfigure_module_directory /*
2968 For internal use by the build procedure only.
2969 configure's idea of what MODULE-DIRECTORY will be.
2971 #ifdef PATH_MODULESEARCH
2972 Vconfigure_module_directory = Ffile_name_as_directory
2973 (build_string ((char *) PATH_MODULESEARCH));
2975 Vconfigure_module_directory = Qnil;
2978 DEFVAR_LISP ("configure-package-path", &Vconfigure_package_path /*
2979 For internal use by the build procedure only.
2980 configure's idea of what the package path will be.
2982 #ifdef PATH_PACKAGEPATH
2983 Vconfigure_package_path = decode_path (PATH_PACKAGEPATH);
2985 Vconfigure_package_path = Qnil;
2988 DEFVAR_LISP ("data-directory", &Vdata_directory /*
2989 *Directory of architecture-independent files that come with XEmacs,
2990 intended for XEmacs to use.
2991 Use of this variable in new code is almost never correct. See the
2992 function `locate-data-directory' and the variable `data-directory-list'.
2994 Vdata_directory = Qnil;
2996 DEFVAR_LISP ("configure-data-directory", &Vconfigure_data_directory /*
2997 For internal use by the build procedure only.
2998 configure's idea of what DATA-DIRECTORY will be.
3001 Vconfigure_data_directory = Ffile_name_as_directory
3002 (build_string ((char *) PATH_DATA));
3004 Vconfigure_data_directory = Qnil;
3007 DEFVAR_LISP ("data-directory-list", &Vdata_directory_list /*
3008 *List of directories of architecture-independent files that come with XEmacs
3009 or were installed as packages, and are intended for XEmacs to use.
3011 Vdata_directory_list = Qnil;
3013 #ifdef CLASH_DETECTION
3014 DEFVAR_LISP ("configure-lock-directory", &Vconfigure_lock_directory /*
3015 For internal use by the build procedure only.
3016 configure's idea of what LOCK-DIRECTORY will be.
3019 Vconfigure_lock_directory = Ffile_name_as_directory
3020 (build_string ((char *) PATH_LOCK));
3022 Vconfigure_lock_directory = Qnil;
3024 #endif /* CLASH_DETECTION */
3026 DEFVAR_LISP ("site-directory", &Vsite_directory /*
3027 *Directory of site-specific Lisp files that come with XEmacs.
3029 Vsite_directory = Qnil;
3031 DEFVAR_LISP ("configure-site-directory", &Vconfigure_site_directory /*
3032 For internal use by the build procedure only.
3033 configure's idea of what SITE-DIRECTORY will be.
3036 Vconfigure_site_directory = Ffile_name_as_directory
3037 (build_string ((char *) PATH_SITE));
3039 Vconfigure_site_directory = Qnil;
3042 DEFVAR_LISP ("site-module-directory", &Vsite_module_directory /*
3043 *Directory of site-specific loadable modules that come with XEmacs.
3045 Vsite_module_directory = Qnil;
3047 DEFVAR_LISP ("configure-site-module-directory", &Vconfigure_site_module_directory /*
3048 For internal use by the build procedure only.
3049 configure's idea of what SITE-DIRECTORY will be.
3051 #ifdef PATH_SITE_MODULES
3052 Vconfigure_site_module_directory = Ffile_name_as_directory
3053 (build_string ((char *) PATH_SITE_MODULES));
3055 Vconfigure_site_module_directory = Qnil;
3058 DEFVAR_LISP ("doc-directory", &Vdoc_directory /*
3059 *Directory containing the DOC file that comes with XEmacs.
3060 This is usually the same as exec-directory.
3062 Vdoc_directory = Qnil;
3064 DEFVAR_LISP ("configure-doc-directory", &Vconfigure_doc_directory /*
3065 For internal use by the build procedure only.
3066 configure's idea of what DOC-DIRECTORY will be.
3069 Vconfigure_doc_directory = Ffile_name_as_directory
3070 (build_string ((char *) PATH_DOC));
3072 Vconfigure_doc_directory = Qnil;
3075 DEFVAR_LISP ("configure-exec-prefix-directory", &Vconfigure_exec_prefix_directory /*
3076 For internal use by the build procedure only.
3077 configure's idea of what EXEC-PREFIX-DIRECTORY will be.
3079 #ifdef PATH_EXEC_PREFIX
3080 Vconfigure_exec_prefix_directory = Ffile_name_as_directory
3081 (build_string ((char *) PATH_EXEC_PREFIX));
3083 Vconfigure_exec_prefix_directory = Qnil;
3086 DEFVAR_LISP ("configure-prefix-directory", &Vconfigure_prefix_directory /*
3087 For internal use by the build procedure only.
3088 configure's idea of what PREFIX-DIRECTORY will be.
3091 Vconfigure_prefix_directory = Ffile_name_as_directory
3092 (build_string ((char *) PATH_PREFIX));
3094 Vconfigure_prefix_directory = Qnil;
3097 DEFVAR_LISP ("configure-info-directory", &Vconfigure_info_directory /*
3098 For internal use by the build procedure only.
3099 This is the name of the directory in which the build procedure installed
3100 Emacs's info files; the default value for Info-default-directory-list
3104 Vconfigure_info_directory =
3105 Ffile_name_as_directory (build_string (PATH_INFO));
3107 Vconfigure_info_directory = Qnil;
3110 DEFVAR_LISP ("configure-info-path", &Vconfigure_info_path /*
3111 The configured initial path for info documentation.
3113 #ifdef PATH_INFOPATH
3114 Vconfigure_info_path = decode_path (PATH_INFOPATH);
3116 Vconfigure_info_path = Qnil;
3121 /* This is so tremendously ugly I'd puke. But then, it works.
3122 * The target is to override the static constructor from the
3123 * libiflPNG.so library which is maskerading as libz, and
3124 * cores on us when re-started from the dumped executable.
3125 * This will have to go for 21.1 -- OG.
3127 void __sti__iflPNGFile_c___(void);
3128 void __sti__iflPNGFile_c___()