on subsequent starts. */
int initialized;
+#ifdef DOUG_LEA_MALLOC
+/* Preserves a pointer to the memory allocated that copies that
+ static data inside glibc's malloc. */
+void *malloc_state_ptr;
+/* From glibc, a routine that returns a copy of the malloc internal state. */
+extern void *malloc_get_state ();
+/* From glibc, a routine that overwrites the malloc internal state. */
+extern void malloc_set_state ();
+#endif
+
/* Variable whose value is symbol giving operating system type. */
Lisp_Object Vsystem_type;
tem = Fexpand_file_name (build_string ("lib-src"), dir);
lib_src_exists = Ffile_exists_p (tem);
+#ifdef MSDOS
/* MSDOS installations frequently remove lib-src, but we still
must set installation-directory, or else info won't find
its files (it uses the value of installation-directory). */
tem = Fexpand_file_name (build_string ("info"), dir);
info_exists = Ffile_exists_p (tem);
+#else
+ info_exists = Qnil;
+#endif
if (!NILP (lib_src_exists) || !NILP (info_exists))
{
tem = Fexpand_file_name (build_string ("../lib-src"), dir);
lib_src_exists = Ffile_exists_p (tem);
+
+#ifdef MSDOS
+ /* See the MSDOS commentary above. */
tem = Fexpand_file_name (build_string ("../info"), dir);
info_exists = Ffile_exists_p (tem);
+#else
+ info_exists = Qnil;
+#endif
if (!NILP (lib_src_exists) || !NILP (info_exists))
{
__sbrk (1);
#endif
+#ifdef DOUG_LEA_MALLOC
+ if (initialized)
+ {
+ malloc_set_state (malloc_state_ptr);
+ free (malloc_state_ptr);
+ r_alloc_reinit ();
+ }
+#endif
+
+#ifdef RUN_TIME_REMAP
+ if (initialized)
+ run_time_remap (argv[0]);
+#endif
+
sort_args (argc, argv);
if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args))
else
{
printf ("GNU Emacs %s\n", XSTRING (tem)->data);
- printf ("Copyright (C) 1996 Free Software Foundation, Inc.\n");
+ printf ("Copyright (C) 1997 Free Software Foundation, Inc.\n");
printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
printf ("You may redistribute copies of Emacs\n");
printf ("under the terms of the GNU General Public License.\n");
#endif /* LINK_CRTL_SHARE */
#endif /* VMS */
-#ifdef HAVE_SETRLIMIT
- /* Extend the stack space available. */
- if (!getrlimit (RLIMIT_STACK, &rlim))
+#if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK)
+ /* Extend the stack space available.
+ Don't do that if dumping, since some systems (e.g. DJGPP)
+ might define a smaller stack limit at that time. */
+ if (1
+#ifndef CANNOT_DUMP
+ && (!noninteractive || initialized)
+#endif
+ && !getrlimit (RLIMIT_STACK, &rlim))
{
- rlim.rlim_cur = rlim.rlim_max;
+ long newlim;
+ extern int re_max_failures;
+ /* Approximate the amount regex.c needs, plus some more. */
+ newlim = re_max_failures * 2 * 20 * sizeof (char *);
+#ifdef __NetBSD__
+ /* NetBSD (at least NetBSD 1.2G and former) has a bug in its
+ stack allocation routine for new process that the allocation
+ fails if stack limit is not on page boundary. So, round up the
+ new limit to page boundary. */
+ newlim = (newlim + getpagesize () - 1) / getpagesize () * getpagesize();
+#endif
+ if (newlim > rlim.rlim_max)
+ {
+ newlim = rlim.rlim_max;
+ /* Don't let regex.c overflow the stack. */
+ re_max_failures = newlim / (2 * 20 * sizeof (char *));
+ }
+ if (rlim.rlim_cur < newlim)
+ rlim.rlim_cur = newlim;
+
setrlimit (RLIMIT_STACK, &rlim);
}
-#endif
+#endif /* HAVE_SETRLIMIT and RLIMIT_STACK */
/* Record (approximately) where the stack begins. */
stack_bottom = &stack_bottom_variable;
-#ifdef RUN_TIME_REMAP
- if (initialized)
- run_time_remap (argv[0]);
-#endif
-
#ifdef USG_SHARED_LIBRARIES
if (bss_end)
brk ((void *)bss_end);
[-f func] [--funcall func] [-l file] [--load file] [--insert file]\n\
[+linenum] file-to-visit [--kill]\n\
Report bugs to bug-gnu-emacs@prep.ai.mit.edu. First, please see\n\
-the Bugs section of the Emacs manual or the file BUGS.", argv[0]);
+the Bugs section of the Emacs manual or the file BUGS.\n", argv[0]);
exit (0);
}
init_alloc_once ();
init_obarray ();
init_eval_once ();
+ init_charset_once ();
+ init_coding_once ();
init_syntax_once (); /* Create standard syntax table. */
+ init_category_once (); /* Create standard category table. */
/* Must be done before init_buffer */
init_casetab_once ();
init_buffer_once (); /* Create buffer table and some buffers */
init_vmsfns ();
#endif /* VMS */
init_process ();
-#ifdef CLASH_DETECTION
- init_filelock ();
-#endif /* CLASH_DETECTION */
/* Intern the names of all standard functions and variables; define standard keys */
syms_of_casefiddle ();
syms_of_casetab ();
syms_of_callproc ();
+ syms_of_category ();
+ syms_of_ccl ();
+ syms_of_charset ();
syms_of_cmds ();
#ifndef NO_DIR_LIBRARY
syms_of_dired ();
syms_of_editfns ();
syms_of_emacs ();
syms_of_fileio ();
+ syms_of_coding (); /* This should be after syms_of_fileio. */
#ifdef CLASH_DETECTION
syms_of_filelock ();
#endif /* CLASH_DETECTION */
#ifdef HAVE_X_WINDOWS
syms_of_xterm ();
syms_of_xfns ();
- syms_of_xfaces ();
+ syms_of_fontset ();
#ifdef HAVE_X11
syms_of_xselect ();
#endif
#endif /* HAVE_X_WINDOWS */
-#if defined (MSDOS) && !defined (HAVE_X_WINDOWS)
- syms_of_xfaces ();
-#endif
-
#ifndef HAVE_NTGUI
+ syms_of_xfaces ();
syms_of_xmenu ();
#endif
#endif
}
+ /* Gerd Moellmann <gerd@acm.org> says this makes profiling work on
+ FreeBSD. It might work on some other systems too.
+ Give it a try and tell me if it works on your system. */
+#ifdef __FreeBSD__
+#ifdef PROFILING
+ if (initialized)
+ {
+ extern void _mcleanup ();
+ extern char etext;
+ extern Lisp_Object Fredraw_frame ();
+ atexit (_mcleanup);
+ /* This uses Fredraw_frame because that function
+ comes first in the Emacs executable.
+ It might be better to use something that gives
+ the start of the text segment, but start_of_text
+ is not defined on all systems now. */
+ monstartup (Fredraw_frame, &etext);
+ }
+ else
+ moncontrol (0);
+#endif
+#endif
+
initialized = 1;
#ifdef LOCALTIME_CACHE
/* If we have found "--", don't consider
any more arguments as options. */
- if (argv[from][1] == '-')
+ if (argv[from][1] == '-' && argv[from][2] == 0)
{
/* Leave the "--", and everything following it, at the end. */
for (; from < argc; from++)
}
bcopy (new, argv, sizeof (char *) * argc);
+
+ free (options);
+ free (new);
+ free (priority);
}
\f
DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
Take symbols from SYMFILE (presumably the file you executed to run Emacs).\n\
This is used in the file `loadup.el' when building Emacs.\n\
\n\
-Bind `command-line-processed' to nil before dumping,\n\
-if you want the dumped Emacs to process its command line\n\
-and announce itself normally when it is run.")
+You must run Emacs in batch mode in order to dump it.")
(filename, symfile)
Lisp_Object filename, symfile;
{
extern char my_edata[];
Lisp_Object tem;
+ Lisp_Object symbol;
+ int count = specpdl_ptr - specpdl;
+
+ if (! noninteractive)
+ error ("Dumping Emacs works only in batch mode");
+
+ /* Bind `command-line-processed' to nil before dumping,
+ so that the dumped Emacs will process its command line
+ and set up to work with X windows if appropriate. */
+ symbol = intern ("command-line-process");
+ specbind (symbol, Qnil);
CHECK_STRING (filename, 0);
filename = Fexpand_file_name (filename, Qnil);
Meanwhile, my_edata is not valid on Windows. */
memory_warnings (my_edata, malloc_warning);
#endif /* not WINDOWSNT */
+#endif
+#ifdef DOUG_LEA_MALLOC
+ malloc_state_ptr = malloc_get_state ();
#endif
unexec (XSTRING (filename)->data,
!NILP (symfile) ? XSTRING (symfile)->data : 0, my_edata, 0, 0);
+#ifdef DOUG_LEA_MALLOC
+ free (malloc_state_ptr);
+#endif
#endif /* not VMS */
Vpurify_flag = tem;
- return Qnil;
+ return unbind_to (count, Qnil);
}
#endif /* not HAVE_SHM */
path = 0;
if (!path)
path = defalt;
+#ifdef DOS_NT
+ /* Ensure values from the environment use the proper directory separator. */
+ if (path)
+ {
+ p = alloca (strlen (path) + 1);
+ strcpy (p, path);
+ path = p;
+
+ if ('/' == DIRECTORY_SEP)
+ dostounix_filename (path);
+ else
+ unixtodos_filename (path);
+ }
+#endif
lpath = Qnil;
while (1)
{