/src/emacs.c
C | 4802 lines | 2771 code | 517 blank | 1514 comment | 292 complexity | 7b4f9ec6ca1b41c6835967e1d35d1582 MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- /* XEmacs -- Fully extensible Emacs, running on Unix and other platforms.
- Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994
- Free Software Foundation, Inc.
- Copyright (C) 1995 Sun Microsystems, Inc.
- Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2010 Ben Wing.
- This file is part of XEmacs.
- XEmacs is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation, either version 3 of the License, or (at your
- option) any later version.
- XEmacs is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
- You should have received a copy of the GNU General Public License
- along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
- /* Synched up with: Mule 2.0, FSF 19.28. */
- /* This file has been Mule-ized, Ben Wing, 10-7-04. */
- /* Capsule summary of the various releases of Lucid Emacs/XEmacs and
- FSF/GNU Emacs. (Copied from the Internals Manual, where the
- canonical version lives.) Provided here for use in cross-referencing
- version releases and dates in comments, esp. in the authorship
- comments at the beginning of each file. More information about
- history can be found in the beginning of the Internals Manual and
- in the About page.
- -- A time line for Lucid Emacs/XEmacs is
- Version 19.0 shipped with Energize 1.0, April 1992.
- Version 19.1 released June 4, 1992.
- Version 19.2 released June 19, 1992.
- Version 19.3 released September 9, 1992.
- Version 19.4 released January 21, 1993.
- Version 19.5 released February 5, 1993. This was a repackaging of 19.4 with a
- few bug fixes and shipped with Energize 2.0. It was a trade-show giveaway
- and never released to the net.
- Version 19.6 released April 9, 1993.
- Version 19.7 was a repackaging of 19.6 with a few bug fixes and
- shipped with Energize 2.1. Never released to the net.
- Version 19.8 released September 6, 1993. (Epoch merger, preliminary I18N
- support)
- Version 19.9 released January 12, 1994. (Scrollbars, Athena.)
- Version 19.10 released May 27, 1994. Known as "Lucid Emacs" when
- shipped by Lucid, and as "XEmacs" when shipped by Sun; but Lucid
- went out of business a few days later and it's unclear very many
- copies of 19.10 were released by Lucid. (Last release by Jamie Zawinski.)
- Version 19.11 (first XEmacs) released September 13, 1994.
- Version 19.12 released June 23, 1995.
- Version 19.13 released September 1, 1995.
- Version 19.14 released June 23, 1996.
- Version 20.0 released February 9, 1997.
- Version 19.15 released March 28, 1997.
- Version 20.1 (not released to the net) April 15, 1997.
- Version 20.2 released May 16, 1997.
- Version 19.16 released October 31, 1997; retiring of v19 series.
- Version 20.3 (the first stable version of XEmacs 20.x) released November 30,
- 1997.
- Version 20.4 released February 28, 1998. (Jamie claims this version is the
- "first reasonably stable release with MULE support" and says that "XEmacs
- 'core' and 'packages' now packaged separately.")
- Version 21.0-pre5 released July 18, 1998. (Jamie says "Numbering scheme goes
- wonky due to switch to stable + unstable branches.")
- Version 21.0.60 released December 10, 1998. (The version naming scheme was
- changed at this point: [a] the second version number is odd for stable
- versions, even for beta versions; [b] a third version number is added,
- replacing the "beta xxx" ending for beta versions and allowing for
- periodic maintenance releases for stable versions. Therefore, 21.0 was
- never "officially" released; similarly for 21.2, etc.)
- Version 21.0.61 released January 4, 1999.
- Version 21.0.63 released February 3, 1999.
- Version 21.0.64 released March 1, 1999.
- Version 21.0.65 released March 5, 1999.
- Version 21.0.66 released March 12, 1999.
- Version 21.0.67 released March 25, 1999.
- Version 21.1.2 released May 14, 1999; on comp.emacs, May 28. (This is
- the followup to 21.0.67. The second version number was bumped to indicate
- the beginning of the "stable" series.)
- Version 21.1.3 released June 26, 1999.
- Version 21.1.4 released July 8, 1999.
- Version 21.1.6 released August 14, 1999. (There was no 21.1.5.)
- Version 21.1.7 released September 26, 1999.
- Version 21.1.8 released November 2, 1999.
- Version 21.1.9 released February 13, 2000.
- Version 21.1.10 released May 7, 2000.
- Version 21.1.10a released June 24, 2000.
- Version 21.1.11 released July 18, 2000.
- Version 21.1.12 released August 5, 2000.
- Version 21.1.13 released January 7, 2001.
- Version 21.1.14 released January 27, 2001.
- Version 21.2.9 released February 3, 1999.
- Version 21.2.10 released February 5, 1999.
- Version 21.2.11 released March 1, 1999.
- Version 21.2.12 released March 5, 1999.
- Version 21.2.13 released March 12, 1999.
- Version 21.2.14 released May 14, 1999.
- Version 21.2.15 released June 4, 1999.
- Version 21.2.16 released June 11, 1999.
- Version 21.2.17 released June 22, 1999.
- Version 21.2.18 released July 14, 1999.
- Version 21.2.19 released July 30, 1999.
- Version 21.2.20 released November 10, 1999.
- Version 21.2.21 released November 28, 1999.
- Version 21.2.22 released November 29, 1999.
- Version 21.2.23 released December 7, 1999.
- Version 21.2.24 released December 14, 1999.
- Version 21.2.25 released December 24, 1999.
- Version 21.2.26 released December 31, 1999.
- Version 21.2.27 released January 18, 2000.
- Version 21.2.28 released February 7, 2000.
- Version 21.2.29 released February 16, 2000.
- Version 21.2.30 released February 21, 2000.
- Version 21.2.31 released February 23, 2000.
- Version 21.2.32 released March 20, 2000.
- Version 21.2.33 released May 1, 2000.
- Version 21.2.34 released May 28, 2000.
- Version 21.2.35 released July 19, 2000.
- Version 21.2.36 released October 4, 2000.
- Version 21.2.37 released November 14, 2000.
- Version 21.2.38 released December 5, 2000.
- Version 21.2.39 released December 31, 2000.
- Version 21.2.40 released January 8, 2001.
- Version 21.2.41 "Polyhymnia" released January 17, 2001.
- Version 21.2.42 "Poseidon" released January 20, 2001.
- Version 21.2.43 "Terspichore" released January 26, 2001.
- Version 21.2.44 "Thalia" released February 8, 2001.
- Version 21.2.45 "Thelxepeia" released February 23, 2001.
- Version 21.2.46 "Urania" released March 21, 2001.
- Version 21.2.47 "Zephir" released April 14, 2001.
- Version 21.4.0 "Solid Vapor" released April 16, 2001.
- Version 21.4.1 "Copyleft" released April 19, 2001.
- Version 21.4.2 "Developer-Friendly Unix APIs" released May 10, 2001.
- Version 21.4.3 "Academic Rigor" released May 17, 2001.
- Version 21.4.4 "Artificial Intelligence" released July 28, 2001.
- Version 21.4.5 "Civil Service" released October 23, 2001.
- Version 21.4.6 "Common Lisp" released December 17, 2001.
- Version 21.4.7 "Economic Science" released May 4, 2002.
- Version 21.4.8 "Honest Recruiter" released May 9, 2002.
- Version 21.4.9 "Informed Management" released August 23, 2002.
- Version 21.4.10 "Military Intelligence" released November 2, 2002.
- Version 21.4.11 "Native Windows TTY Support" released January 3, 2003.
- Version 21.4.12 "Portable Code" released January 15, 2003.
- Version 21.4.13 "Rational FORTRAN" released May 25, 2003.
- Version 21.4.14 "Reasonable Discussion" released September 3, 2003.
- Version 21.4.15 "Security Through Obscurity" released February 2, 2004.
- Version 21.5.0 "alfalfa" released April 18, 2001.
- Version 21.5.1 "anise" released May 9, 2001.
- Version 21.5.2 "artichoke" released July 28, 2001.
- Version 21.5.3 "asparagus" released September 7, 2001.
- Version 21.5.4 "bamboo" released January 8, 2002.
- Version 21.5.5 "beets" released March 5, 2002.
- Version 21.5.6 "bok choi" released April 5, 2002.
- Version 21.5.7 "broccoflower" released July 2, 2002.
- Version 21.5.8 "broccoli" released July 27, 2002.
- Version 21.5.9 "brussels sprouts" released August 30, 2002.
- Version 21.5.10 "burdock" released January 4, 2003.
- Version 21.5.11 "cabbage" released February 16, 2003.
- Version 21.5.12 "carrot" released April 24, 2003.
- Version 21.5.13 "cauliflower" released May 10, 2003.
- Version 21.5.14 "cassava" released June 1, 2003.
- Version 21.5.15 "celery" released September 3, 2003.
- Version 21.5.16 "celeriac" released September 26, 2003.
- Version 21.5.17 "chayote" released March 22, 2004.
- Version 21.5.18 "chestnut" released October 22, 2004.
- -- A time line for GNU Emacs version 19 is
- version 19.7 (beta) (first beta release) released ??????; prob. late May 1993.
- version 19.8 (beta) released May 27, 1993.
- version 19.9 (beta) released May 27, 1993.
- version 19.10 (beta) released May 30, 1993.
- version 19.11 (beta) released June 1, 1993.
- version 19.12 (beta) released June 2, 1993.
- version 19.13 (beta) released June 8, 1993.
- version 19.14 (beta) released June 17, 1993.
- version 19.15 (beta) released June 19, 1993.
- version 19.16 (beta) released July 6, 1993.
- version 19.17 (beta) released late July, 1993.
- version 19.18 (beta) released August 9, 1993.
- version 19.19 (beta) released August 15, 1993.
- version 19.20 (beta) released November 17, 1993.
- version 19.21 (beta) released November 17, 1993.
- version 19.22 (beta) released November 28, 1993.
- version 19.23 (beta) released on comp.emacs, May 17, 1994.
- version 19.24 (beta) released May 16, 1994.
- version 19.25 (beta) released June 3, 1994.
- version 19.26 (beta) released September 11, 1994.
- version 19.27 (beta) released September 14, 1994.
- version 19.28 (first ``official'' release) released November 1, 1994.
- version 19.29 released June 21, 1995.
- version 19.30 released November 24, 1995.
- version 19.31 released May 25, 1996.
- version 19.32 released July 31, 1996.
- version 19.33 released August 11, 1996.
- version 19.34 released August 21, 1996; on comp.emacs, August 22.
- version 19.34b released September 6, 1996.
- -- A time line for GNU Emacs versions 20 and 21 is
- version 20.1 released September 17, 1997.
- version 20.2 released September 20, 1997.
- version 20.3 released August 19, 1998.
- version 20.4 released July 12, 1999; on comp.emacs, July 27.
- version 21.1 released October 20, 2001.
- Version 21.2 released March 16, 2002.
- Version 21.3 released March 19, 2003.
- -- A time line for GNU Emacs version 18 and older is
- GNU Emacs version 15 (15.34) was released sometime in 1984 or 1985 and
- shared some code with a version of Emacs written by James Gosling (the
- same James Gosling who later created the Java language).
- GNU Emacs version 16 (first released version was 16.56) was released on
- July 15, 1985. All Gosling code was removed due to potential copyright
- problems with the code.
- version 16.57: released on September 16, 1985.
- versions 16.58, 16.59: released on September 17, 1985.
- version 16.60: released on September 19, 1985. These later version 16's
- incorporated patches from the net, esp. for getting Emacs to work under
- System V.
- version 17.36 (first official v17 release) released on December 20, 1985.
- Included a TeX-able user manual. First official unpatched version that
- worked on vanilla System V machines.
- version 17.43 (second official v17 release) released on January 25, 1986.
- version 17.45 released on January 30, 1986.
- version 17.46 released on February 4, 1986.
- version 17.48 released on February 10, 1986.
- version 17.49 released on February 12, 1986.
- version 17.55 released on March 18, 1986.
- version 17.57 released on March 27, 1986.
- version 17.58 released on April 4, 1986.
- version 17.61 released on April 12, 1986.
- version 17.63 released on May 7, 1986.
- version 17.64 released on May 12, 1986.
- version 18.24 (a beta version) released on October 2, 1986.
- version 18.30 (a beta version) released on November 15, 1986.
- version 18.31 (a beta version) released on November 23, 1986.
- version 18.32 (a beta version) released on December 7, 1986.
- version 18.33 (a beta version) released on December 12, 1986.
- version 18.35 (a beta version) released on January 5, 1987.
- version 18.36 (a beta version) released on January 21, 1987.
- January 27, 1987: The Great Usenet Renaming. net.emacs is now comp.emacs.
- version 18.37 (a beta version) released on February 12, 1987.
- version 18.38 (a beta version) released on March 3, 1987.
- version 18.39 (a beta version) released on March 14, 1987.
- version 18.40 (a beta version) released on March 18, 1987.
- version 18.41 (the first ``official'' release) released on March 22, 1987.
- version 18.45 released on June 2, 1987.
- version 18.46 released on June 9, 1987.
- version 18.47 released on June 18, 1987.
- version 18.48 released on September 3, 1987.
- version 18.49 released on September 18, 1987.
- version 18.50 released on February 13, 1988.
- version 18.51 released on May 7, 1988.
- version 18.52 released on September 1, 1988.
- version 18.53 released on February 24, 1989.
- version 18.54 released on April 26, 1989.
- version 18.55 released on August 23, 1989. This is the earliest version
- that is still available by FTP.
- version 18.56 released on January 17, 1991.
- version 18.57 released late January, 1991.
- version 18.58 released ?????.
- version 18.59 released October 31, 1992.
- -- A time line for Epoch is
- Epoch 1.0 released December 14, 1989. (by Simon Kaplan, Chris Love, et al.)
- Epoch 2.0 released December 23, 1989.
- Epoch 3.1 released February 6, 1990.
- Epoch 3.2 released December[????] 11, 1990.
- Epoch 4.0 released August 27, 1990.
- */
- /* Sources for further information:
- -----------------------------------
- 1. Using XEmacs, Programming Elisp:
- -----------------------------------
- ;;; -- the XEmacs User's Manual (Access using the online Info browser:
- ;;; Use `Help->Info (Online Docs)->XEmacs User's Manual' (if
- ;;; there is such an entry); or get to the Info contents page
- ;;; using `Help->Info Contents' or `C-h i', and then
- ;;; *middle-click* the XEmacs link or move the cursor into the
- ;;; link and hit ENTER. This manual contains a great deal of
- ;;; documentation on customization: Scroll down to the
- ;;; Customization link and select it in the same fashion as for
- ;;; the XEmacs link just mentioned.)
- ;;; -- the XEmacs FAQ (`C-h F' for the local version; get either the
- ;;; local version or the very latest version off the net using
- ;;; the Help menu)
- ;;; -- the XEmacs Lisp Reference Manual, containing detailed
- ;;; documentation on Elisp. (Access using Info, just like for the
- ;;; XEmacs User's Manual.)
- ;;; -- the documentation strings for specific commands, functions,
- ;;; key sequences, and variables. NOTE: This is *not* the same
- ;;; information as in the XEmacs User's Manual or XEmacs Lisp
- ;;; Reference Manual! In general, the doc strings are more
- ;;; terse and more up-to-date than what is found in the manuals.
- ;;; Once you understand the general concepts, these doc strings
- ;;; should be your first point of reference for further
- ;;; info. (Access using menu entries under `Help->Commands,
- ;;; Variables, Keys' or using the keyboard: `C-h k' for a key
- ;;; sequence, `C-h f' for a named command or Elisp function,
- ;;; `C-h v' for a variable. There is various other useful
- ;;; information accessible similarly, such as `C-h a'
- ;;; ["Apropos", i.e. search for a command, function, or variable
- ;;; by name]; `C-h C-a' ["Apropos Docs", i.e. search through the
- ;;; text of the doc strings]; `C-h b' to list all key bindings;
- ;;; `C-h m' to describe the current major and minor modes; etc.
- ;;; Type `C-h ? ?' for a complete list.)
- ;;; -- Getting Started with XEmacs [aka the "New User's Guide"], a
- ;;; more introductory manual than the XEmacs User's Manual.
- ;;; (Access using Info, just like for the XEmacs User's Manual.
- ;;; There are some sections on customization here.)
- ;;; -- the XEmacs tutorial, a very simple introduction to XEmacs for
- ;;; total beginners. (`C-h t' for English; get the version in
- ;;; various languages from the Help menu)
- ;;; -- the XEmacs web site, www.xemacs.org.
- ;;; -- the XEmacs mailing lists (xemacs-FOO@xemacs.org;
- ;;; see http://www.xemacs.org/Lists/ for more info. Before
- ;;; posting, consider looking through the archives -- they go back
- ;;; years and there is a powerful searching interface. Currently
- ;;; the archives are at http://list-archive.xemacs.org/, but if
- ;;; this doesn't work, you can always access them through
- ;;; www.xemacs.org.)
- ;;; -- the XEmacs newsgroup, comp.emacs.xemacs. This is
- ;;; bi-directionally gatewayed with xemacs@xemacs.org. WARNING:
- ;;; The developers do not normally hang out on this newsgroup. If
- ;;; you need to contact them, use xemacs-beta@xemacs.org.
- ;;; -- the XEmacs internals manual, for those interested in working on
- ;;; the XEmacs C code. (Available through Info.)
- ;;; -- `Help->About XEmacs' to find out who the maintainers are.
- ---------------------
- 2. Developing XEmacs:
- ---------------------
- -- the internals manual, man/internals/internals.texi
- -- long comments at the head of certain files:
- emacs.c
- extents.c
- text.c
- text.h
- lisp.h
- redisplay.h
- dynarr.c
- blocktype.c
- eval.c
- event-Xt.c (sort of)
- event-stream.c (command event queue)
- frame.c
- intl-encap-win32.c
- keymap.c
- line-number.c (a little bit)
- menubar-msw.c (sort of)
- menubar-x.c (sort of)
- mule-canna.c (sort of)
- mule-ccl.c
- mule-coding.c (scattered in the file)
- mule-wnn.c (in japanese)
- ntheap.c (near the top)
- redisplay.c (various scattered)
- regex.c (various scattered)
- sysdep.c (maybe; wait_for_termination)
- unexec.c
- unicode.c
- gccache-x.c (a bit)
- #### review .h files; write a perl program to look for long comments
- throughout the files, ignoring stuff inside of DEFUN's.
- #### elsewhere?
- -- comments scattered throughout the sources (#### should be grouped
- together if feasible). For example, lrecord.h (pdump and object-
- creation), alloc.c (fixed-type allocation), etc. #### fill in.
- -- Ben's Architecting XEmacs web site.
- (http://www.xemacs.org/Architecting-XEmacs/index.html; #### should be
- integrated into the sources)
- -- Back discussions on xemacs-beta (#### The juiciest tidbits, esp.
- those with specific proposals, should be extracted and stuck in
- the source)
- -- README.* in the src/ directory (and maybe other directories)
- -- The ChangeLog files, sometimes.
- */
- /* Note: It is necessary to specify <config.h> and not "config.h" in
- order for the --srcdir type of compilation to work properly.
- Otherwise the config.h from the srcdir, rather than the one from
- the build dir, will be used. */
- #include <config.h>
- #include "lisp.h"
- #include "backtrace.h" /* run-emacs-from-temacs needs this */
- #include "buffer.h"
- #include "commands.h"
- #include "console.h"
- #include "process.h"
- #include "redisplay.h"
- #include "frame.h"
- #include "sysdep.h"
- #include "systty.h"
- #include "sysfile.h"
- #include "systime.h"
- #include "sysproc.h" /* for qxe_getpid() */
- #ifdef QUANTIFY
- #include <quantify.h>
- #endif
- #ifdef HAVE_SHLIB
- #include "sysdll.h"
- #endif
- #ifdef TOOLTALK
- #include TT_C_H_FILE
- #endif
- #ifdef WIN32_ANY
- #include "console-msw.h"
- #endif
- #ifdef DUMP_IN_EXEC
- #ifndef WIN32_NATIVE
- #include "dump-data.h"
- #endif
- #endif
- /* For PATH_EXEC */
- #include <paths.h>
- #if defined (HEAP_IN_DATA) && !defined (PDUMP)
- void report_sheap_usage (int die_if_pure_storage_exceeded);
- #endif
- #if !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC)
- extern void *(*__malloc_hook)(size_t);
- extern void *(*__realloc_hook)(void *, size_t);
- extern void (*__free_hook)(void *);
- #endif /* not SYSTEM_MALLOC && not DOUG_LEA_MALLOC */
- /* Command line args from shell, as list of strings */
- Lisp_Object Vcommand_line_args;
- /* Set nonzero after XEmacs has started up the first time.
- Prevents reinitialization of the Lisp world and keymaps
- on subsequent starts. */
- int initialized;
- #ifdef DOUG_LEA_MALLOC
- # include <malloc.h>
- /* Preserves a pointer to the memory allocated that copies that
- static data inside glibc's malloc. */
- static void *malloc_state_ptr;
- #endif /* DOUG_LEA_MALLOC */
- # ifdef REL_ALLOC
- void r_alloc_reinit (void);
- # endif
- /* Variable whose value is symbol giving operating system type. */
- Lisp_Object Vsystem_type;
- /* Variable whose value is string giving configuration built for. */
- Lisp_Object Vsystem_configuration;
- /* Variable whose value is string containing the configuration options
- XEmacs was built with. */
- Lisp_Object Vsystem_configuration_options;
- /* Version numbers and strings */
- Lisp_Object Vemacs_major_version;
- Lisp_Object Vemacs_minor_version;
- Lisp_Object Vemacs_patch_level;
- Lisp_Object Vemacs_beta_version;
- Lisp_Object Vxemacs_codename;
- Lisp_Object Vxemacs_extra_name;
- Lisp_Object Vxemacs_release_date;
- /* The path under which XEmacs was invoked. */
- Lisp_Object Vinvocation_path;
- /* The name under which XEmacs was invoked, with any leading directory
- names discarded. */
- Lisp_Object Vinvocation_name;
- /* The directory name from which XEmacs was invoked. */
- Lisp_Object Vinvocation_directory;
- #if 0 /* FSFmacs */
- /* The directory name in which to find subdirs such as lisp and etc.
- nil means get them only from PATH_LOADSEARCH. */
- Lisp_Object Vinstallation_directory;
- #endif
- Lisp_Object Vemacs_program_name, Vemacs_program_version;
- Lisp_Object Vexec_path;
- Lisp_Object Vexec_directory, Vconfigure_exec_directory;
- Lisp_Object Vlisp_directory, Vconfigure_lisp_directory;
- Lisp_Object Vmule_lisp_directory, Vconfigure_mule_lisp_directory;
- Lisp_Object Vmodule_directory, Vconfigure_module_directory;
- Lisp_Object Vsite_module_directory, Vconfigure_site_module_directory;
- Lisp_Object Vconfigure_package_path;
- Lisp_Object Vconfigure_early_package_directories;
- Lisp_Object Vconfigure_late_package_directories;
- Lisp_Object Vconfigure_last_package_directories;
- Lisp_Object Vdata_directory, Vconfigure_data_directory;
- Lisp_Object Vdoc_directory, Vconfigure_doc_directory;
- Lisp_Object Vconfigure_lock_directory;
- Lisp_Object Vdata_directory_list;
- Lisp_Object Vconfigure_info_directory;
- Lisp_Object Vsite_directory, Vconfigure_site_directory;
- Lisp_Object Vconfigure_info_path;
- Lisp_Object Vinternal_error_checking;
- Lisp_Object Vmail_lock_methods, Vconfigure_mail_lock_method;
- /* The default base directory XEmacs is installed under. */
- Lisp_Object Vconfigure_exec_prefix_directory, Vconfigure_prefix_directory;
- /* If nonzero, set XEmacs to run at this priority. This is also used
- in child_setup and sys_suspend to make sure subshells run at normal
- priority. */
- Fixnum emacs_priority;
- /* Some FSF junk with running_asynch_code, to preserve the match
- data. Not necessary because we don't call process filters
- asynchronously (i.e. from within QUIT). */
- /* If non-zero, a window-system was specified on the command line. */
- int display_arg;
- /* Type of display specified. We cannot use a Lisp symbol here because
- Lisp symbols may not initialized at the time that we set this
- variable. */
- const Ascbyte *display_use;
- /* If non-zero, then the early error handler will only print the error
- message and exit. */
- int suppress_early_error_handler_backtrace;
- /* An address near the bottom of the stack.
- Tells GC how to save a copy of the stack. */
- Rawbyte *stack_bottom;
- #ifdef USG_SHARED_LIBRARIES
- /* If nonzero, this is the place to put the end of the writable segment
- at startup. */
- uintptr_t bss_end = 0;
- #endif
- /* Number of bytes of writable memory we can expect to be able to get:
- Leave this as an unsigned int because it could potentially be 4G */
- unsigned long lim_data;
- /* WARNING!
- Some LISP-visible command-line options are set by XEmacs _before_ the
- data is dumped in building a --pdump XEmacs, but used _after_ it is
- restored in normal operation. Thus the dump-time values overwrite the
- values XEmacs is getting at runtime. Such variables must be saved
- before loading the dumpfile, and restored afterward.
- Therefore these variables may not be initialized in vars_of_emacs().
- The save/restore is done immediately before and after pdump_load() in
- main_1(). See that function for the current list of protected variables.
- Note that saving/restoring is only necessary for a few variables that are
- o command line arguments effective at runtime (as opposed to dump-time),
- o parsed before pdump_load, and
- o exported to Lisp via a DEFVAR.
- */
- /* Nonzero means running XEmacs without interactive terminal. */
- int noninteractive;
- /* Value of Lisp variable `noninteractive'.
- Normally same as C variable `noninteractive'
- but nothing terrible happens if user sets this one.
- Shadowed from the pdumper by `noninteractive'. */
- int noninteractive1;
- /* Nonzero means don't perform site-lisp searches at startup */
- int inhibit_site_lisp;
- /* Nonzero means don't perform site-modules searches at startup */
- int inhibit_site_modules;
- /* Nonzero means don't load user-init or site-start file */
- int vanilla_inhibiting;
- /* Nonzero means don't respect early packages at startup */
- int inhibit_early_packages;
- /* Nonzero means don't respect any packages at startup -- act as if they
- don't exist. */
- int inhibit_all_packages;
- /* Nonzero means don't load package autoloads at startup */
- int inhibit_autoloads;
- /* Nonzero means don't load the dump file (ignored if not PDUMP) */
- int nodumpfile;
- /* Nonzero means print debug information about path searching */
- int debug_paths;
- /* Save argv and argc. */
- static Wexttext **initial_argv; /* #### currently unused */
- static int initial_argc; /* #### currently unused */
- static void sort_args (int argc, Wexttext **argv);
- Lisp_Object Qkill_emacs_hook;
- Lisp_Object Qsave_buffers_kill_emacs;
- Lisp_Object Qtemacs, Qdumping, Qrestarted, Qpdump, Qbatch;
- /* Nonzero if handling a fatal error already. */
- int fatal_error_in_progress;
- /* Nonzero means we're going down, so we better not run any hooks
- or do other non-essential stuff. */
- int preparing_for_armageddon;
- /* Nonzero means we're in an unstable situation and need to skip
- internal->external conversions, QUIT checking and such. This gets set
- during early startup, during shutdown, and when debug printing
- (i.e. called from a debugger such as gdb to print Lisp objects or
- backtraces). During printing we check for this, and during conversion
- we abort if we see this. */
- int inhibit_non_essential_conversion_operations;
- static JMP_BUF run_temacs_catch;
- static int run_temacs_argc;
- static Wexttext **run_temacs_argv;
- #ifdef _MSC_VER
- static DWORD mswindows_handle_hardware_exceptions (DWORD code);
- #endif
- #ifdef WIN32_NATIVE
- static DWORD CALLBACK wait_for_termination_signal (LPVOID handle);
- #endif
- /************************************************************************/
- /* Functions to handle arguments */
- /************************************************************************/
- /* Code for dealing with Lisp access to the Unix command line */
- static Lisp_Object
- make_arg_list_1 (int argc, Wexttext **argv, int skip_args)
- {
- Lisp_Object result = Qnil;
- REGISTER int i;
- for (i = argc - 1; i >= 0; i--)
- {
- if (i == 0 || i > skip_args)
- {
- #ifdef WIN32_NATIVE
- if (i == 0)
- {
- /* Do not trust to what crt0 has stuffed into argv[0] */
- Extbyte *full_exe_path;
- Lisp_Object fullpath;
- full_exe_path = mswindows_get_module_file_name ();
- assert (full_exe_path);
- fullpath = build_tstr_string (full_exe_path);
- xfree (full_exe_path);
- result = Fcons (fullpath, result);
- }
- else
- #endif
- result = Fcons (build_wext_string (argv[i],
- Qcommand_argument_encoding),
- result);
- }
- }
- return result;
- }
- Lisp_Object
- make_arg_list (int argc, Wexttext **argv)
- {
- return make_arg_list_1 (argc, argv, 0);
- }
- /* Calling functions are also responsible for calling free_argc_argv
- when they are done with the generated list. */
- void
- make_argc_argv (Lisp_Object argv_list, int *argc, Wexttext ***argv)
- {
- Lisp_Object next;
- int n = XFIXNUM (Flength (argv_list));
- REGISTER int i;
- *argv = xnew_array (Wexttext *, n + 1);
- for (i = 0, next = argv_list; i < n; i++, next = XCDR (next))
- {
- CHECK_STRING (XCAR (next));
- (*argv)[i] =
- (Wexttext *) LISP_STRING_TO_EXTERNAL_MALLOC
- (XCAR (next), Qcommand_argument_encoding);
- }
- (*argv) [n] = 0;
- *argc = i;
- }
- void
- free_argc_argv (Wexttext **argv)
- {
- int elt = 0;
- while (argv[elt])
- {
- xfree (argv[elt]);
- argv[elt] = 0;
- elt++;
- }
- xfree (argv);
- }
- static void
- init_cmdargs (int argc, Wexttext **argv, int skip_args)
- {
- initial_argv = argv;
- initial_argc = argc;
- Vcommand_line_args = make_arg_list_1 (argc, argv, skip_args);
- }
- DEFUN ("invocation-name", Finvocation_name, 0, 0, 0, /*
- Return the program name that was used to run XEmacs.
- Any directory names are omitted.
- */
- ())
- {
- return Fcopy_sequence (Vinvocation_name);
- }
- DEFUN ("invocation-directory", Finvocation_directory, 0, 0, 0, /*
- Return the directory name in which the Emacs executable was located.
- */
- ())
- {
- return Fcopy_sequence (Vinvocation_directory);
- }
- /* Test whether the next argument in ARGV matches SSTR or a prefix of LSTR
- (at least MINLEN characters; if MINLEN is 0, set to size of LSTR). If
- so, then if VALPTR is non-null (the argument is supposed to have a
- value) store in *VALPTR either the next argument or the portion of this
- one after the equal sign. ARGV is read starting at position *SKIPPTR;
- this index is advanced by the number of arguments used.
- Too bad we can't just use getopt for all of this, but we don't have
- enough information to do it right. */
- static int
- argmatch (Wexttext **argv, int argc, const Ascbyte *sstr, const Ascbyte *lstr,
- int minlen, Wexttext **valptr, int *skipptr)
- {
- Wexttext *p = NULL;
- Charcount arglen;
- Wexttext *arg;
- /* Don't access argv[argc]; give up in advance. */
- if (argc <= *skipptr + 1)
- return 0;
- arg = argv[*skipptr+1];
- if (arg == NULL)
- return 0;
- if (wext_strcmp_ascii (arg, sstr) == 0)
- {
- if (valptr != NULL)
- {
- *valptr = argv[*skipptr+2];
- *skipptr += 2;
- }
- else
- *skipptr += 1;
- return 1;
- }
- arglen = (valptr != NULL && (p = wext_strchr (arg, '=')) != NULL
- ? p - arg : (Charcount) wext_strlen (arg));
- if (lstr && !minlen)
- minlen = strlen (lstr);
- if (lstr == 0 || arglen < minlen ||
- wext_strncmp_ascii (arg, lstr, arglen) != 0)
- return 0;
- else if (valptr == NULL)
- {
- *skipptr += 1;
- return 1;
- }
- else if (p != NULL)
- {
- *valptr = p + 1;
- *skipptr += 1;
- return 1;
- }
- else if (argv[*skipptr + 2] != NULL)
- {
- *valptr = argv[*skipptr + 2];
- *skipptr += 2;
- return 1;
- }
- else
- {
- return 0;
- }
- }
- static void
- check_compatible_window_system (const Ascbyte *must)
- {
- if (display_use && strcmp (display_use, must))
- fatal ("Incompatible window system type `%s': `%s' already specified",
- must, display_use);
- display_use = must;
- }
- /************************************************************************/
- /* main and friends: XEmacs startup */
- /************************************************************************/
- /* Make stack traces always identify version + configuration */
- #define main_1 STACK_TRACE_EYE_CATCHER
- /* This function is not static, so that the compiler is less likely to
- inline it, which would make it not show up in stack traces.
- The restart argument is a flag that indicates that main_1 is now
- being called for the second time in this invocation of xemacs; this
- happens as a result of using `run-temacs' in the command line, when
- invoking a bare (without dumped data) XEmacs (i.e. `temacs' with
- the conventional dumper or `xemacs -nd' with the pdumper). See
- Frun_emacs_from_temacs().
- */
- DECLARE_DOESNT_RETURN (main_1 (int, Wexttext **, Wexttext **, int));
- DOESNT_RETURN
- main_1 (int argc, Wexttext **argv, Wexttext **UNUSED (envp), int restart)
- {
- Rawbyte stack_bottom_variable;
- int skip_args = 0;
- Lisp_Object load_me;
- #if (!defined (SYSTEM_MALLOC) && !defined (HAVE_LIBMCHECK) \
- && !defined (DOUG_LEA_MALLOC))
- /* Make sure that any libraries we link against haven't installed a
- hook for a gmalloc of a potentially incompatible version. */
- /* If we're using libmcheck, the hooks have already been initialized, */
- /* don't touch them. -slb */
- __malloc_hook = NULL;
- __realloc_hook = NULL;
- __free_hook = NULL;
- #endif /* not SYSTEM_MALLOC or HAVE_LIBMCHECK or DOUG_LEA_MALLOC */
- noninteractive = 0;
- display_use = NULL;
- inhibit_non_essential_conversion_operations = 1;
- #ifdef NEW_GC
- #ifndef PDUMP
- if (!initialized)
- #endif
- {
- if (!restart)
- {
- init_mc_allocator ();
- #ifdef ALLOC_TYPE_STATS
- init_lrecord_stats ();
- #endif /* ALLOC_TYPE_STATS */
- }
- }
- #endif /* NEW_GC */
- #if defined (LOSING_GCC_DESTRUCTOR_FREE_BUG)
- /* Prior to XEmacs 21, this was `#if 0'ed out. */
- /* I'm enabling this because it is the only reliable way I've found to */
- /* prevent a very annoying problem where GCC will attempt to free (3) */
- /* memory at exit() and cause a coredump. */
- init_free_hook ();
- #endif
- #define SHEBANG_PROGNAME_LENGTH \
- (int)((sizeof (WEXTSTRING (SHEBANG_PROGNAME)) - sizeof (WEXTSTRING (""))))
- #define SHEBANG_EXE_PROGNAME_LENGTH \
- (int)(sizeof (WEXTSTRING (SHEBANG_PROGNAME) WEXTSTRING (".exe")) \
- - sizeof (WEXTSTRING ("")))
- {
- int progname_len = wext_strlen (argv[0]);
- if (progname_len >= SHEBANG_PROGNAME_LENGTH)
- {
- if (!wext_strcmp_ascii (argv[0] +
- (progname_len - SHEBANG_PROGNAME_LENGTH),
- SHEBANG_PROGNAME)
- /* Allow trailing .exe. Don't check it, it could also be
- .com. */
- || (progname_len >= SHEBANG_EXE_PROGNAME_LENGTH &&
- !wext_strncmp_ascii
- (argv[0] + (progname_len - SHEBANG_EXE_PROGNAME_LENGTH),
- SHEBANG_PROGNAME,
- SHEBANG_PROGNAME_LENGTH)))
- {
- Wexttext **newarr = alloca_array (Wexttext *, argc + 2);
- int j;
- newarr[0] = argv[0];
- newarr[1] = (Wexttext *) WEXTSTRING ("--script");
- for (j = 1; j < argc; ++j)
- {
- newarr[j + 1] = argv[j];
- }
- argv = newarr;
- argc++;
- }
- }
- }
- sort_args (argc, argv);
- #if 0 /* defined (_SCO_DS)
- #### Turn this off, we already have another SCO_DS hack in main().
- */
- environ = envp;
- #endif
- /* Record (approximately) where the stack begins. */
- stack_bottom = &stack_bottom_variable;
- #ifdef USG_SHARED_LIBRARIES
- if (bss_end)
- brk ((void *) bss_end);
- #endif
- clearerr (stdin);
- #if defined (HAVE_MMAP) && defined (REL_ALLOC)
- /* ralloc can only be used if using the GNU memory allocator. */
- init_ralloc ();
- #elif defined (REL_ALLOC) && !defined (DOUG_LEA_MALLOC)
- if (initialized)
- init_ralloc ();
- #endif
- #ifdef HAVE_SOCKS
- if (initialized)
- SOCKSinit (argv[0]);
- #endif /* HAVE_SOCKS */
- #ifndef SYSTEM_MALLOC
- if (!initialized)
- /* Arrange to get warning messages as memory fills up. */
- memory_warnings (0, malloc_warning);
- #endif /* not SYSTEM_MALLOC */
- #ifdef SET_EMACS_PRIORITY
- if (emacs_priority != 0)
- nice (-emacs_priority);
- setuid (getuid ());
- #endif /* SET_EMACS_PRIORITY */
- /* NOTE NOTE NOTE: Keep the following args in sync with the big list of
- arguments below in standard_args[], with the help text in startup.el,
- and with the list of non-clobbered variables near where pdump_load()
- is called! */
- /* Handle the -sd/--show-dump-id switch, which means show the hex dump_id
- and quit */
- if (argmatch (argv, argc, "-sd", "--show-dump-id", 0, NULL, &skip_args))
- {
- #ifdef PDUMP
- printf ("%08x\n", dump_id);
- #else
- printf ("Portable dumper not configured; -sd just forces exit.\n");
- #endif
- exit (0);
- }
- /* Handle the -si/--show-inline-info switch, which means show the
- alignment and max size of the inline data and quit */
- if (argmatch (argv, argc, "-si", "--show-inline-info", 0, NULL, &skip_args))
- {
- #if defined (PDUMP) && defined (DUMP_IN_EXEC) && !defined (WIN32_NATIVE)
- /* #### We really should check for sizeof (size_t) > sizeof (long) */
- printf ("%lu %lu\n", (unsigned long) dumped_data_max_size (),
- (unsigned long) dumped_data_align_offset ());
- #else
- printf ("Portable dumper not configured for dumping into executable or windows native; -si just forces exit.\n");
- #endif
- exit (0);
- }
- /* Handle the --no-dump-file/-nd switch, which means don't load the dump
- file (ignored when not using pdump) */
- if (argmatch (argv, argc, "-nd", "--no-dump-file", 0, NULL, &skip_args))
- nodumpfile = 1;
- /* Handle the -batch switch, which means don't do interactive display. */
- if (argmatch (argv, argc, "-batch", "--batch", 0, NULL, &skip_args))
- {
- #if 0 /* I don't think this is correct. */
- inhibit_autoloads = 1;
- #endif
- noninteractive = 1;
- }
- {
- int count_before = skip_args;
- /* Handle the -script switch, which implies batch and vanilla. The -l
- part of its functionality is implemented in Lisp. */
- if (argmatch (argv, argc, "-script", "--script", 0, NULL,
- &skip_args))
- {
- noninteractive = 1;
- vanilla_inhibiting = 1;
- }
- /* Don't actually discard this argument. */
- skip_args = count_before;
- }
- #ifdef WIN32_NATIVE
- {
- /* Since we aren't a console application, we can't easily be terminated
- using ^C. (We aren't a console application to avoid Windows from
- automatically and unwantedly creating a console window for us. If
- only the Windows designers had some sense in them and didn't create
- this artificial console/non-console distinction!) Therefore, we set
- up a communication path with i.exe so that when a ^C is sent to it
- (using GenerateConsoleCtrlEvent), it in turn signals us to commit
- suicide. (This is cleaner than using TerminateProcess()). This
- makes (e.g.) the "Stop Build" command from VC++ correctly terminate
- XEmacs. */
- Wexttext *heventstr;
- if (argmatch (argv, argc, "-mswindows-termination-handle", 0, 0,
- &heventstr, &skip_args))
- {
- HANDLE hevent = (HANDLE) wext_atol (heventstr);
- DWORD unused;
- HANDLE h_thread = CreateThread (NULL, 0, wait_for_termination_signal,
- (void *) hevent, 0, &unused);
- CloseHandle (h_thread);
- }
- }
- /* Handle the -nuni switch, which forces XEmacs to use the ANSI
- versions of Unicode-split API's even on Windows NT, which has
- full Unicode support. This helps flush out problems in the code
- we've written to convert between ANSI and Unicode. */
- if (argmatch (argv, argc, "-nuni", "--no-unicode-lib-calls", 0, NULL,
- &skip_args))
- no_mswin_unicode_lib_calls = 1;
- #endif /* WIN32_NATIVE */
- if (argmatch (argv, argc, "-debug-paths", "--debug-paths",
- 0, NULL, &skip_args))
- debug_paths = 1;
- /* Handle (maybe partially) some inhibiting flags. Packages are searched
- prior to the rest of the command line being parsed in startup.el. */
- if (argmatch (argv, argc, "-no-packages", "--no-packages",
- 0, NULL, &skip_args))
- {
- inhibit_all_packages = 1;
- inhibit_early_packages = 1;
- vanilla_inhibiting = 1;
- }
- if (argmatch (argv, argc, "-no-early-packages", "--no-early-packages",
- 0, NULL, &skip_args))
- inhibit_early_packages = 1;
- #ifdef HAVE_SHLIB
- if (argmatch (argv, argc, "-no-site-modules", "--no-site-modules",
- 0, NULL, &skip_args))
- #endif
- inhibit_site_modules = 1;
- if (argmatch (argv, argc, "-vanilla", "--vanilla",
- 0, NULL, &skip_args))
- {
- inhibit_early_packages = 1;
- vanilla_inhibiting = 1;
- }
- if (argmatch (argv, argc, "-no-autoloads", "--no-autoloads",
- 0, NULL, &skip_args))
- {
- inhibit_autoloads = 1;
- inhibit_early_packages = 1;
- vanilla_inhibiting = 1;
- }
- /* Partially handle the -version and -help switches: they imply -batch,
- but are not removed from the list. */
- if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
- noninteractive = 1, skip_args--;
- if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args) ||
- argmatch (argv, argc, "-V", 0, 2, NULL, &skip_args))
- noninteractive = 1, skip_args--;
- /* Now, figure out which type of console is our first console. */
- if (noninteractive)
- display_use = "stream";
- if (argmatch (argv, argc, "-nw", "--no-windows", 0, NULL, &skip_args) ||
- argmatch (argv, argc, "-tty", "--use-tty", 0, NULL, &skip_args))
- {
- check_compatible_window_system ("tty");
- #ifndef HAVE_TTY
- fatal ("Sorry, this XEmacs was not compiled with TTY support");
- #endif
- }
- if (argmatch (argv, argc, "-x", "--use-x", 0, NULL, &skip_args))
- {
- check_compatible_window_system ("x");
- #ifndef HAVE_X_WINDOWS
- fatal ("Sorry, this XEmacs was not compiled with X support");
- #endif
- }
- if (argmatch (argv, argc, "-gtk", "--use-gtk", 0, NULL, &skip_args) ||
- argmatch (argv, argc, "-gnome", "--use-gnome", 0, NULL, &skip_args))
- {
- check_compatible_window_system ("gtk");
- #ifndef HAVE_GTK
- fatal ("Sorry, this XEmacs was not compiled with GTK support");
- #endif
- }
- if (argmatch (argv, argc, "-msw", "--use-ms-windows", 0, NULL, &skip_args))
- {
- check_compatible_window_system ("mswindows");
- #ifndef HAVE_MS_WINDOWS
- fatal ("Sorry, this XEmacs was not compiled with MS Windows support");
- #endif
- }
- /* Handle other switches implying particular window systems: */
- /* Handle the -t switch, which specifies filename to use as terminal */
- {
- Wexttext *term;
- if (argmatch (argv, argc, "-t", "--terminal", 0, &term, &skip_args))
- {
- int fd;
- check_compatible_window_system ("tty");
- #ifndef HAVE_TTY
- fatal ("Sorry, this XEmacs was not compiled with TTY support");
- #endif
- retry_close (0);
- retry_close (1);
- fd = wext_retry_open (term, O_RDWR | OPEN_BINARY, 2);
- /* Conversions are not possible yet, and printing will be in
- external format, so strerror() and ttyname() are OK. */
- if (fd < 0 || dup (0) < 0)
- fatal ("%s: %s", WEXTTEXT_TO_8_BIT (term), strerror (errno));
- if (! isatty (0))
- fatal ("%s: not a tty", WEXTTEXT_TO_8_BIT (term));
- #if 0
- stderr_out ("Using %s", ttyname (0));
- #endif
- stderr_out ("Using %s", WEXTTEXT_TO_8_BIT (term));
- }
- }
- /* Stupid kludge to catch command-line display spec. We can't
- handle this argument entirely in window-system-dependent code
- because we don't even know which window-system-dependent code
- to run until we've recognized this argument. */
- {
- #ifdef HAVE_X_WINDOWS
- Wexttext *dpy = 0;
- int count_before = skip_args;
- if (argmatch (argv, argc, "-d", "--display", 3, &dpy, &skip_args) ||
- argmatch (argv, argc, "-display", 0, 3, &dpy, &skip_args))
- {
- check_compatible_window_system ("x");
- display_arg = 1;
- }
- /* If we have the form --display=NAME,
- convert it into -d name.
- This requires inserting a new element into argv. */
- if (dpy != 0 && skip_args - count_before == 1)
- {
- Wexttext **new_ = xnew_array (Wexttext *, argc + 2);
- int j;
- for (j = 0; j < count_before + 1; j++)
- new_[j] = argv[j];
- new_[count_before + 1] = (Wexttext *) WEXTSTRING ("-d");
- new_[count_before + 2] = dpy;
- for (j = count_before + 2; j <argc; j++)
- new_[j + 1] = argv[j];
- argv = new_;
- argc++;
- }
- /* Change --display to -d, when its arg is separate. */
- else if (dpy != 0 && skip_args > count_before
- && argv[count_before + 1][1] == '-')
- argv[count_before + 1] = (Wexttext *) WEXTSTRING ("-d");
- /* Don't actually discard this arg. */
- skip_args = count_before;
- #endif /* HAVE_X_WINDOWS */
- }
- /* If no switch telling us which window system to use, try other
- possibilities: */
- #if defined (HAVE_X_WINDOWS) || defined (HAVE_GTK)
- if (!display_use)
- {
- Wexttext *dpy;
- /* If there is a non-empty environment var DISPLAY, assume X or GTK,
- but don't set `display_arg', which is only to be set if the
- display was specified on the command line. */
- if ((dpy = wext_getenv (WEXTSTRING ("DISPLAY"))) && dpy[0])
- #ifdef HAVE_X_WINDOWS
- /* #### Who gets precedence? X or GTK? For the moment, GTK support is
- unstable so use X. Maybe eventually we will switch this. */
- display_use = "x";
- #else
- display_use = "gtk";
- #endif
- }
- #endif /* defined (HAVE_X_WINDOWS) || defined (HAVE_GTK) */
- #ifdef HAVE_MS_WINDOWS
- if (!display_use)
- display_use = "mswindows";
- #endif /* HAVE_MS_WINDOWS */
- #ifdef HAVE_TTY
- if (!display_use)
- display_use = "tty";
- #endif /* HAVE_MS_WINDOWS */
- if (!display_use)
- fatal ("No window systems and no TTY's in this XEmacs: Must specify "
- "-batch");
- noninteractive1 = noninteractive;
- /****** Now initialize everything *******/
- /* NOTE NOTE NOTE:
- In the code below, there are three different states we are concerned
- about:
- "raw-temacs" == No dumped Lisp data present. `temacs', or (with pdump)
- `xemacs -nd'.
- "run-temacs" == We are restarting. run-emacs-from-temacs is called,
- aka `run-temacs' on the command line.
- "post-dump" == We are running an unexec()ed XEmacs, or we have loaded
- dump data using pdump_load().
- initialized==0 => raw-temacs
- initialized!=0 && restart!=0 => run-temacs
- initialized!=0 && restart==0 => post-dump
- When post-pdump_load(), we need to reinitialize various structures.
- This case is noted in the code below by
- initialized +
- !restart +
- ifdef PDUMP.
- In the comments below, "dump time" or "dumping" == raw-temacs.
- "run time" == run-temacs or post-dump.
- */
- /* First, do really basic environment initialization -- catching signals
- and the like. These functions have no dependence on any part of
- the Lisp engine and need to be done both at dump time and at run time. */
- init_signals_very_early ();
- #ifdef NEW_GC
- vdb_install_signal_handler ();
- #endif /* NEW_GC */
- init_data_very_early (); /* Catch math errors. */
- init_floatfns_very_early (); /* Catch floating-point math errors. */
- init_process_times_very_early (); /* Initialize our process timers.
- As early as possible, of course,
- so we can be fairly accurate. */
- #ifdef HAVE_MS_WINDOWS
- /* Depends on XEUNICODE_P */
- init_mswindows_dde_very_early (); /* DDE needs to be initialized early so
- that the client doesn't give up
- waiting. */
- #endif
- /* Now initialize the Lisp engine and the like. Done only during
- dumping. No dependence on anything that may be in the user's
- environment when the dumped XEmacs is run.
- We try to do things in an order that minimizes the non-obvious
- dependencies between functions. */
- /* purify_flag is set to indicate we are dumping (its name refers to
- purespace, which no longer exists and was a way of marking some
- areas read-only so they could be shared among many processes).
- loadup.el will set to nil at end. */
- purify_flag = 0;
- #ifdef PDUMP
- in_pdump = 0;
- if (restart)
- initialized = 1;
- else if (nodumpfile)
- {
- initialized = 0;
- purify_flag = 1;
- }
- else
- {
- /* Keep command options from getting stomped.
- Some LISP-visible options are changed by XEmacs _after_ the data is
- dumped in building a --pdump XEmacs, but _before_ it is restored in
- normal operation. Thus the restored values overwrite the values
- XEmacs is getting at run-time. Such variables must be saved here,
- and restored after loading the dumped data.
- (Remember: Only LISP-visible options that are set up to this point
- need to be listed here.)
- */
- /* noninteractive1 is saved in noninteractive, which isn't
- LISP-visible */
- int inhibit_early_packages_save = inhibit_early_packages;
- int inhibit_autoloads_save = inhibit_autoloads;
- int inhibit_all_packages_save = inhibit_all_packages;
- int vanilla_inhibiting_save = vanilla_inhibiting;
- int debug_paths_save = debug_paths;
- int inhibit_site_lisp_save = inhibit_site_lisp;
- int inhibit_site_modules_save = inhibit_site_modules;
- initialized = pdump_load (argv[0]);
- /* Now unstomp everything */
- noninteractive1 = noninteractive;
- inhibit_early_packages = inhibit_early_packages_save;
- inhibit_autoloads = inhibit_autoloads_save;
- inhibit_all_packages = inhibit_all_packages_save;
- vanilla_inhibiting = vanilla_inhibiting_save;
- debug_paths = debug_paths_save;
- inhibit_site_lisp = inhibit_site_lisp_save;
- inhibit_site_modules = inhibit_site_modules_save;
- if (initialized)
- run_temacs_argc = -1;
- else
- purify_flag = 1;
- }
- #else /* not PDUMP */
- if (!initialized)
- purify_flag = 1;
- #endif
- init_alloc_early ();
- init_gc_early ();
- if (!initialized)
- {
- /* Initialize things so that new Lisp objects
- can be created and objects can be staticpro'd.
- Must be basically the very first thing done
- because pretty much all of the initialization
- routines below create new objects. */
- init_alloc_once_early ();
- init_gc_once_early ();
- /* Initialize Qnil, Qt, Qunbound, and the
- obarray. After this, symbols can be
- interned. This depends on init_alloc_once_early(). */
- init_symbols_once_early ();
- /* Declare the basic symbols pertaining to errors,
- So that DEFERROR*() can be called. */
- init_errors_once_early ();
- /* Make sure that opaque pointers can be created. */
- init_opaque_once_early ();
- /* Make sure that hash tables can be created. */
- init_elhash_once_early ();
- /* Make sure that eistrings can be crea…
Large files files are truncated, but you can click here to view the full file