(shut_down_emacs): Set inhibit_sentinels.
[bpt/emacs.git] / src / emacs.c
index ae9eb4d..db9426d 100644 (file)
@@ -1,6 +1,6 @@
 /* Fully extensible Emacs, running on Unix, intended for GNU.
-   Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1998, 1999, 2001,
-     2002, 2003, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1998, 1999,
+                 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -112,6 +112,9 @@ EMACS_INT gdb_data_seg_bits = 0;
 #endif
 EMACS_INT PVEC_FLAG = PSEUDOVECTOR_FLAG;
 EMACS_INT gdb_array_mark_flag = ARRAY_MARK_FLAG;
+/* GDB might say "No enum type named pvec_type" if we don't have at
+   least one symbol with that type, and then xbacktrace could fail.  */
+enum pvec_type gdb_pvec_type = PVEC_TYPE_MASK;
 
 /* Command line args from shell, as list of strings.  */
 Lisp_Object Vcommand_line_args;
@@ -148,7 +151,7 @@ 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 ();
+extern int malloc_set_state ();
 /* Non-zero if the MALLOC_CHECK_ enviroment variable was set while
    dumping.  Used to work around a bug in glibc's malloc.  */
 int malloc_using_checking;
@@ -266,7 +269,7 @@ Initialization options:\n\
 --no-site-file              do not load site-start.el\n\
 --no-splash                 do not display a splash screen on startup\n\
 --no-window-system, -nw     do not communicate with X, ignoring $DISPLAY\n\
---quick, -Q                 equivalent to -q --no-site-file\n\
+--quick, -Q                 equivalent to -q --no-site-file --no-splash\n\
 --script FILE               run FILE as an Emacs Lisp script\n\
 --terminal, -t DEVICE       use DEVICE for terminal I/O\n\
 --unibyte, --no-multibyte   run Emacs in unibyte mode\n\
@@ -311,7 +314,7 @@ Display options:\n\
 --fullscreen, -fs               make first frame fullscreen\n\
 --fullwidth, -fw                make the first frame wide as the screen\n\
 --geometry, -g GEOMETRY         window geometry\n\
---icon-type, -i                 use picture of gnu for Emacs icon\n\
+--no-bitmap-icon, -nbi          do not use picture of gnu for Emacs icon\n\
 --iconic                        start Emacs in iconified state\n\
 --internal-border, -ib WIDTH    width between text and main border\n\
 --line-spacing, -lsp PIXELS     additional space to put between lines\n\
@@ -896,7 +899,7 @@ main (argc, argv
       else
        {
          printf ("GNU Emacs %s\n", SDATA (tem));
-         printf ("Copyright (C) 2004 Free Software Foundation, Inc.\n");
+         printf ("Copyright (C) 2006 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");
@@ -962,9 +965,15 @@ main (argc, argv
 
 #ifdef MAC_OSX
   /* Skip process serial number passed in the form -psn_x_y as
-     command-line argument.  */
+     command-line argument.  The WindowServer adds this option when
+     Emacs is invoked from the Finder or by the `open' command.  In
+     these cases, the working directory becomes `/', so we change it
+     to the user's home directory.  */
   if (argc > skip_args + 1 && strncmp (argv[skip_args+1], "-psn_", 5) == 0)
-    skip_args++;
+    {
+      chdir (getenv ("HOME"));
+      skip_args++;
+    }
 #endif /* MAC_OSX */
 
 #ifdef VMS
@@ -1001,7 +1010,7 @@ main (argc, argv
       && !getrlimit (RLIMIT_STACK, &rlim))
     {
       long newlim;
-      extern int re_max_failures;
+      extern size_t re_max_failures;
       /* Approximate the amount regex.c needs per unit of re_max_failures.  */
       int ratio = 20 * sizeof (char *);
       /* Then add 33% to cover the size of the smaller stacks that regex.c
@@ -1153,9 +1162,9 @@ main (argc, argv
   if (argmatch (argv, argc, "-script", "--script", 3, &junk, &skip_args))
     {
       noninteractive = 1;      /* Set batch mode.  */
-      /* Convert --script to -l, un-skip it, and sort again so that -l will be
-        handled in proper sequence.  */
-      argv[skip_args - 1] = "-l";
+      /* Convert --script to --scriptload, un-skip it, and sort again
+        so that it will be handled in proper sequence.  */
+      argv[skip_args - 1] = "-scriptload";
       skip_args -= 2;
       sort_args (argc, argv);
     }
@@ -1624,14 +1633,12 @@ main (argc, argv
 #endif
 #endif /* HAVE_X_WINDOWS */
 
-#ifdef HAVE_MENUS
 #ifndef HAVE_NTGUI
 #ifndef MAC_OS
       /* Called before init_window_once for Mac OS Classic.  */
       syms_of_xmenu ();
 #endif
 #endif
-#endif
 
 #ifdef HAVE_NTGUI
       syms_of_w32term ();
@@ -1742,16 +1749,21 @@ main (argc, argv
 #endif
     }
 
-  /* Set up for profiling.  This is known to work on FreeBSD and
-     GNU/Linux.  It might work on some other systems too.  Give it a
-     try and tell us if it works on your system.  To compile for
-     profiling use something like `make CFLAGS="-pg -g -O -DPROFILING=1'.  */
-#if defined (__FreeBSD__) || defined (__linux)
+  /* Set up for profiling.  This is known to work on FreeBSD,
+     GNU/Linux and MinGW.  It might work on some other systems too.
+     Give it a try and tell us if it works on your system.  To compile
+     for profiling use something like:
+       `make CFLAGS="-pg -g -O -DPROFILING=1'.  */
+#if defined (__FreeBSD__) || defined (GNU_LINUX) || defined(__MINGW32__)
 #ifdef PROFILING
   if (initialized)
     {
       extern void _mcleanup ();
+#ifdef __MINGW32__
+      extern unsigned char etext asm ("etext");
+#else
       extern char etext;
+#endif
       extern void safe_bcopy ();
       extern void dump_opcode_frequencies ();
 
@@ -1830,11 +1842,10 @@ struct standard_args standard_args[] =
   { "-u", "--user", 30, 1 },
   { "-user", 0, 30, 1 },
   { "-debug-init", "--debug-init", 20, 0 },
-  { "-i", "--icon-type", 15, 0 },
-  { "-itype", 0, 15, 0 },
+  { "-nbi", "--no-bitmap-icon", 15, 0 },
   { "-iconic", "--iconic", 15, 0 },
   { "-D", "--basic-display", 12, 0},
-  { "--basic-display", 0, 12, 0},
+  { "-basic-display", 0, 12, 0},
   { "-bg", "--background-color", 10, 1 },
   { "-background", 0, 10, 1 },
   { "-fg", "--foreground-color", 10, 1 },
@@ -1868,6 +1879,7 @@ struct standard_args standard_args[] =
   { "-directory", 0, 0, 1 },
   { "-l", "--load", 0, 1 },
   { "-load", 0, 0, 1 },
+  { "-scriptload", "--scriptload", 0, 1 },
   { "-f", "--funcall", 0, 1 },
   { "-funcall", 0, 0, 1 },
   { "-eval", "--eval", 0, 1 },
@@ -2123,6 +2135,7 @@ shut_down_emacs (sig, no_x, stuff)
 
   stuff_buffered_input (stuff);
 
+  inhibit_sentinels = 1;
   kill_buffer_processes (Qnil);
   Fdo_auto_save (Qt, Qnil);
 
@@ -2225,7 +2238,7 @@ You must run Emacs in batch mode in order to dump it.  */)
   if (! noninteractive)
     error ("Dumping Emacs works only in batch mode");
 
-#ifdef __linux__
+#ifdef GNU_LINUX
   if (heap_bss_diff > MAX_HEAP_BSS_DIFF)
     {
       fprintf (stderr, "**************************************************\n");
@@ -2237,7 +2250,7 @@ You must run Emacs in batch mode in order to dump it.  */)
       fprintf (stderr, "exec-shield in etc/PROBLEMS for more information.\n");
       fprintf (stderr, "**************************************************\n");
     }
-#endif /* __linux__ */
+#endif /* GNU_LINUX */
 
   /* Bind `command-line-processed' to nil before dumping,
      so that the dumped Emacs will process its command line