(displaying-byte-compile-warnings): Show
[bpt/emacs.git] / src / emacs.c
index 7e6ac14..bf3e46c 100644 (file)
@@ -505,6 +505,11 @@ main (argc, argv, envp)
     }
 #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))
@@ -519,7 +524,7 @@ main (argc, argv, envp)
       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");
@@ -579,12 +584,19 @@ main (argc, argv, envp)
 #endif /* VMS */
 
 #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK)
-  /* Extend the stack space available.  */
-  if (!getrlimit (RLIMIT_STACK, &rlim))
+  /* 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))
     {
       long newlim;
+      extern int re_max_failures;
       /* Approximate the amount regex.c needs, plus some more.  */
-      newlim = 800000 * sizeof (char *);
+      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
@@ -593,7 +605,11 @@ main (argc, argv, envp)
       newlim = (newlim + getpagesize () - 1) / getpagesize () * getpagesize();
 #endif
       if (newlim > rlim.rlim_max)
-       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;
 
@@ -604,11 +620,6 @@ main (argc, argv, envp)
   /* 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);
@@ -1095,6 +1106,29 @@ the Bugs section of the Emacs manual or the file BUGS.\n", argv[0]);
 #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