X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/8247c60d3b72d15a668b43ab4dfbf714ab0c4751..b12f6e85a068462962d1bf012260e2b55aabd4e7:/src/emacs.c diff --git a/src/emacs.c b/src/emacs.c index 6f3301b4c8..55475e5779 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1,12 +1,12 @@ /* 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, 2006 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Emacs. GNU Emacs 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 2, or (at your option) +the Free Software Foundation; either version 3, or (at your option) any later version. GNU Emacs is distributed in the hope that it will be useful, @@ -57,6 +57,7 @@ Boston, MA 02110-1301, USA. */ #include "blockinput.h" #include "syssignal.h" #include "process.h" +#include "frame.h" #include "termhooks.h" #include "keyboard.h" #include "keymap.h" @@ -133,8 +134,8 @@ Lisp_Object Vinstallation_directory; /* Hook run by `kill-emacs' before it does really anything. */ Lisp_Object Vkill_emacs_hook; -/* An empty lisp string. To avoid having to build any other. */ -Lisp_Object empty_string; +/* Empty lisp strings. To avoid having to build any others. */ +Lisp_Object empty_unibyte_string, empty_multibyte_string; /* Search path separator. */ Lisp_Object Vpath_separator; @@ -214,7 +215,7 @@ static unsigned long heap_bss_diff; #ifdef HAVE_WINDOW_SYSTEM -extern Lisp_Object Vwindow_system; +extern Lisp_Object Vinitial_window_system; #endif /* HAVE_WINDOW_SYSTEM */ extern Lisp_Object Vauto_save_list_file_name; @@ -280,9 +281,8 @@ Initialization options:\n\ Action options:\n\ \n\ FILE visit FILE using find-file\n\ -+LINE FILE visit FILE using find-file, then go to line LINE\n\ -+LINE:COLUMN FILE visit FILE using find-file, then go to line LINE,\n\ - column COLUMN\n\ ++LINE go to line LINE in next FILE\n\ ++LINE:COLUMN go to line LINE, column COLUMN, in next FILE\n\ --directory, -L DIR add DIR to variable load-path\n\ --eval EXPR evaluate Emacs Lisp expression EXPR\n\ --execute EXPR evaluate Emacs Lisp expression EXPR\n\ @@ -303,7 +303,7 @@ Display options:\n\ used for debugging Emacs\n\ --border-color, -bd COLOR main border color\n\ --border-width, -bw WIDTH width of main border\n\ ---color, --color=MODE color mode for character terminals;\n\ +--color, --color=MODE override color mode for character terminals;\n\ MODE defaults to `auto', and can also\n\ be `never', `auto', `always',\n\ or a mode name like `ansi8'\n\ @@ -361,24 +361,6 @@ pthread_t main_thread; #endif -#if defined (SIGUSR1) || defined (SIGUSR2) -SIGTYPE -handle_user_signal (sig) - int sig; -{ - struct input_event buf; - - SIGNAL_THREAD_CHECK (sig); - bzero (&buf, sizeof buf); - buf.kind = USER_SIGNAL_EVENT; - buf.frame_or_window = selected_frame; - - kbd_buffer_store_event (&buf); - buf.code = sig; - kbd_buffer_store_event (&buf); -} -#endif - /* Handle bus errors, invalid instruction, etc. */ SIGTYPE fatal_error_signal (sig) @@ -874,17 +856,23 @@ main (argc, argv So ignore --version otherwise. */ && initialized) { - Lisp_Object tem; + Lisp_Object tem, tem2; tem = Fsymbol_value (intern ("emacs-version")); + tem2 = Fsymbol_value (intern ("emacs-copyright")); if (!STRINGP (tem)) { fprintf (stderr, "Invalid value of `emacs-version'\n"); exit (1); } + if (!STRINGP (tem2)) + { + fprintf (stderr, "Invalid value of `emacs-copyright'\n"); + exit (1); + } else { printf ("GNU Emacs %s\n", SDATA (tem)); - printf ("Copyright (C) 2006 Free Software Foundation, Inc.\n"); + printf ("%s\n", SDATA(tem2)); 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"); @@ -1175,6 +1163,13 @@ main (argc, argv #if defined (USG5) && defined (INTERRUPT_INPUT) setpgrp (); #endif +#endif +#if defined (HAVE_GTK_AND_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC) + { + extern void malloc_enable_thread P_ ((void)); + + malloc_enable_thread (); + } #endif } @@ -1211,10 +1206,10 @@ main (argc, argv signal (SIGILL, fatal_error_signal); signal (SIGTRAP, fatal_error_signal); #ifdef SIGUSR1 - signal (SIGUSR1, handle_user_signal); + add_user_signal (SIGUSR1, "sigusr1"); #endif #ifdef SIGUSR2 - signal (SIGUSR2, handle_user_signal); + add_user_signal (SIGUSR2, "sigusr2"); #endif #ifdef SIGABRT signal (SIGABRT, fatal_error_signal); @@ -1302,6 +1297,9 @@ main (argc, argv faces, and the face implementation uses some symbols as face names. */ syms_of_xfaces (); + /* XXX syms_of_keyboard uses some symbols in keymap.c. It would + be better to arrange things not to have this dependency. */ + syms_of_keymap (); /* Call syms_of_keyboard before init_window_once because keyboard sets up symbols that include some face names that the X support will want to use. This can happen when @@ -1499,10 +1497,10 @@ main (argc, argv /* egetenv is a pretty low-level facility, which may get called in many circumstances; it seems flimsy to put off initializing it until calling init_callproc. */ - set_process_environment (); + set_initial_environment (); /* AIX crashes are reported in system versions 3.2.3 and 3.2.4 - if this is not done. Do it after set_process_environment so that we - don't pollute Vprocess_environment. */ + if this is not done. Do it after set_global_environment so that we + don't pollute Vglobal_environment. */ /* Setting LANG here will defeat the startup locale processing... */ #ifdef AIX3_2 putenv ("LANG=C"); @@ -1573,7 +1571,7 @@ main (argc, argv #endif /* CLASH_DETECTION */ syms_of_indent (); syms_of_insdel (); - syms_of_keymap (); + /* syms_of_keymap (); */ syms_of_macros (); syms_of_marker (); syms_of_minibuf (); @@ -1584,6 +1582,7 @@ main (argc, argv syms_of_frame (); #endif syms_of_syntax (); + syms_of_terminal (); syms_of_term (); syms_of_undo (); #ifdef HAVE_SOUND @@ -1668,13 +1667,7 @@ main (argc, argv #endif /* HAVE_NTGUI */ } - if (!noninteractive) - { -#ifdef VMS - init_vms_input ();/* init_display calls get_frame_size, that needs this. */ -#endif /* VMS */ - init_display (); /* Determine terminal type. init_sys_modes uses results. */ - } + init_process (); /* init_display uses add_keyboard_wait_descriptor. */ #ifndef MAC_OS8 /* Called before init_window_once for Mac OS Classic. */ init_keyboard (); /* This too must precede init_sys_modes. */ @@ -1682,7 +1675,13 @@ main (argc, argv #ifdef VMS init_vmsproc (); /* And this too. */ #endif /* VMS */ - init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.). */ + if (!noninteractive) + { +#ifdef VMS + init_vms_input ();/* init_display calls get_tty_size, that needs this. */ +#endif /* VMS */ + init_display (); /* Determine terminal type. Calls init_sys_modes. */ + } init_fns (); init_xdisp (); #ifdef HAVE_WINDOW_SYSTEM @@ -1695,7 +1694,6 @@ main (argc, argv #ifdef VMS init_vmsfns (); #endif /* VMS */ - init_process (); #ifdef HAVE_SOUND init_sound (); #endif @@ -1737,8 +1735,9 @@ main (argc, argv /* 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'. */ + for profiling, add -pg to the switches your platform uses in + CFLAGS and LDFLAGS. For example: + `make CFLAGS="-pg -g -O -DPROFILING=1" LDFLAGS="-pg -g"'. */ #if defined (__FreeBSD__) || defined (GNU_LINUX) || defined(__MINGW32__) #ifdef PROFILING if (initialized) @@ -2107,15 +2106,14 @@ shut_down_emacs (sig, no_x, stuff) if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1 && tpgrp == pgrp) { - fflush (stdout); - reset_sys_modes (); + reset_all_sys_modes (); if (sig && sig != SIGTERM) fprintf (stderr, "Fatal error (%d)", sig); } } #else fflush (stdout); - reset_sys_modes (); + reset_all_sys_modes (); #endif stuff_buffered_input (stuff); @@ -2137,9 +2135,9 @@ shut_down_emacs (sig, no_x, stuff) #if 0 /* This triggers a bug in XCloseDisplay and is not needed. */ #ifdef HAVE_X_WINDOWS /* It's not safe to call intern here. Maybe we are crashing. */ - if (!noninteractive && SYMBOLP (Vwindow_system) - && SCHARS (SYMBOL_NAME (Vwindow_system)) == 1 - && SREF (SYMBOL_NAME (Vwindow_system), 0) == 'x' + if (!noninteractive && SYMBOLP (Vinitial_window_system) + && SCHARS (SYMBOL_NAME (Vinitial_window_system)) == 1 + && SREF (SYMBOL_NAME (Vinitial_window_system), 0) == 'x' && ! no_x) Fx_close_current_connection (); #endif /* HAVE_X_WINDOWS */ @@ -2457,7 +2455,8 @@ Special values: `ms-dos' compiled as an MS-DOS application. `windows-nt' compiled as a native W32 application. `cygwin' compiled using the Cygwin library. - `vax-vms' or `axp-vms': compiled for a (Open)VMS system. + `vax-vms' or + `axp-vms' compiled for a (Open)VMS system. Anything else indicates some sort of Unix system. */); Vsystem_type = intern (SYSTEM_TYPE); @@ -2484,9 +2483,6 @@ see `kill-emacs-query-functions' instead. The hook is not run in batch mode, i.e., if `noninteractive' is non-nil. */); Vkill_emacs_hook = Qnil; - empty_string = build_string (""); - staticpro (&empty_string); - DEFVAR_INT ("emacs-priority", &emacs_priority, doc: /* Priority for Emacs to run at. This value is effective only if set before Emacs is dumped, @@ -2497,7 +2493,8 @@ before you compile Emacs, to enable the code for this feature. */); emacs_priority = 0; DEFVAR_LISP ("path-separator", &Vpath_separator, - doc: /* The directory separator in search paths, as a string. */); + doc: /* String containing the character that separates directories in +search paths, such as PATH and other similar environment variables. */); { char c = SEPCHAR; Vpath_separator = make_string (&c, 1);