Mercurial > hg > xemacs-beta
diff src/emacs.c @ 5125:b5df3737028a ben-lisp-object
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 24 Feb 2010 01:58:04 -0600 |
parents | e0db3c197671 838630c0734f |
children | 2a462149bd6a |
line wrap: on
line diff
--- a/src/emacs.c Wed Jan 20 07:05:57 2010 -0600 +++ b/src/emacs.c Wed Feb 24 01:58:04 2010 -0600 @@ -2,7 +2,7 @@ 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 Ben Wing. + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2010 Ben Wing. This file is part of XEmacs. @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ +the Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, +Boston, MA 02111-1301, USA. */ /* Synched up with: Mule 2.0, FSF 19.28. */ @@ -391,7 +391,7 @@ sysdep.c (maybe; wait_for_termination) unexec.c unicode.c - xgccache.c (a bit) + 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. @@ -670,8 +670,11 @@ int preparing_for_armageddon; /* Nonzero means we're in an unstable situation and need to skip - i18n conversions and such. During printing we check for this, - and during conversion we abort if we see this. */ + 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; @@ -714,7 +717,7 @@ full_exe_path = mswindows_get_module_file_name (); assert (full_exe_path); fullpath = build_tstr_string (full_exe_path); - xfree (full_exe_path, Extbyte *); + xfree (full_exe_path); result = Fcons (fullpath, result); } else @@ -747,8 +750,9 @@ { CHECK_STRING (XCAR (next)); - LISP_STRING_TO_EXTERNAL_MALLOC (XCAR (next), (*argv) [i], - Qcommand_argument_encoding); + (*argv)[i] = + (Wexttext *) LISP_STRING_TO_EXTERNAL_MALLOC + (XCAR (next), Qcommand_argument_encoding); } (*argv) [n] = 0; *argc = i; @@ -761,10 +765,10 @@ while (argv[elt]) { - xfree (argv[elt], Wexttext *); + xfree (argv[elt]); elt++; } - xfree (argv, Wexttext **); + xfree (argv); } static void @@ -936,8 +940,8 @@ #define SHEBANG_PROGNAME_LENGTH \ (int)((sizeof (WEXTSTRING (SHEBANG_PROGNAME)) - sizeof (WEXTSTRING ("")))) -#define SHEBANG_EXE_PROGNAME_LENGTH \ - (int)(sizeof (WEXTSTRING (SHEBANG_PROGNAME) WEXTSTRING(".exe")) \ +#define SHEBANG_EXE_PROGNAME_LENGTH \ + (int)(sizeof (WEXTSTRING (SHEBANG_PROGNAME) WEXTSTRING (".exe")) \ - sizeof (WEXTSTRING (""))) { @@ -959,7 +963,7 @@ int j; newarr[0] = argv[0]; - newarr[1] = WEXTSTRING ("--script"); + newarr[1] = (Wexttext *) WEXTSTRING ("--script"); for (j = 1; j < argc; ++j) { newarr[j + 1] = argv[j]; @@ -1252,7 +1256,7 @@ for (j = 0; j < count_before + 1; j++) new_[j] = argv[j]; - new_[count_before + 1] = WEXTSTRING ("-d"); + 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]; @@ -1262,7 +1266,7 @@ /* 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] = WEXTSTRING ("-d"); + argv[count_before + 1] = (Wexttext *) WEXTSTRING ("-d"); /* Don't actually discard this arg. */ skip_args = count_before; @@ -1641,7 +1645,7 @@ #endif #endif /* HAVE_XIM */ -#ifdef USE_XFT +#ifdef HAVE_XFT syms_of_font_mgr(); #endif @@ -1895,6 +1899,9 @@ reinit_opaque_early (); #endif /* not NEW_GC */ reinit_eistring_early (); +#ifdef WITH_NUMBER_TYPES + reinit_vars_of_number (); +#endif reinit_console_type_create_stream (); #ifdef HAVE_TTY @@ -2007,8 +2014,9 @@ -- Fset() on a symbol that is unbound -- Any of the object-creating functions in alloc.c: e.g. - make_string() - - build_intstring() - - build_string() + - build_istring() + - build_cistring() + - build_ascstring() - make_vector() - make_int() - make_char() @@ -2221,7 +2229,7 @@ vars_of_gui_x (); #endif -#ifdef USE_XFT +#ifdef HAVE_XFT vars_of_font_mgr (); #endif @@ -2292,6 +2300,7 @@ /* Now do additional vars_of_*() initialization that happens both at dump time and after pdump load. */ reinit_vars_of_buffer (); + reinit_vars_of_bytecode (); reinit_vars_of_console (); #ifdef DEBUG_XEMACS reinit_vars_of_debug (); @@ -2351,7 +2360,7 @@ #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_X_DIALOGS) || defined (HAVE_TOOLBARS) reinit_vars_of_gui_x (); #endif -#ifdef USE_XFT +#ifdef HAVE_XFT reinit_vars_of_font_mgr (); #endif #endif /* HAVE_X_WINDOWS */ @@ -2411,8 +2420,11 @@ then we suddenly have dependence on the previous call. */ complex_vars_of_file_coding (); #ifdef WIN32_ANY + /* Define MS-Windows Unicode coding systems */ complex_vars_of_intl_win32 (); #endif + /* Define UTF-8 coding system */ + complex_vars_of_unicode (); /* At this point we should be able to do conversion operations. We have initialized things to the point that we can create Lisp @@ -2421,7 +2433,7 @@ quite soon, e.g. in complex_vars_of_glyphs_x(). */ inhibit_non_essential_conversion_operations = 0; -#ifdef USE_XFT +#ifdef HAVE_XFT /* This uses coding systems. Must be done before faces are init'ed. */ /* not in xft reloaded #3 */ complex_vars_of_font_mgr (); @@ -2626,7 +2638,7 @@ if (XSTRING_DATA (Vinvocation_name)[0] == '-') { /* XEmacs as a login shell, oh goody! */ - Vinvocation_name = build_intstring (egetenv ("SHELL")); + Vinvocation_name = build_istring (egetenv ("SHELL")); } Vinvocation_directory = Vinvocation_name; @@ -2912,9 +2924,9 @@ } memcpy (argv, new_argv, sizeof (Wexttext *) * argc); - xfree (new_argv, Wexttext **); - xfree (options, int *); - xfree (priority, int *); + xfree (new_argv); + xfree (options); + xfree (priority); } DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /* @@ -3002,15 +3014,16 @@ run_temacs_argc = nargs + 1; run_temacs_argv = xnew_array (Wexttext *, nargs + 2); - LISP_STRING_TO_EXTERNAL_MALLOC (Fcar (Vcommand_line_args), - run_temacs_argv[0], - Qcommand_argument_encoding); + run_temacs_argv[0] = + (Wexttext *) LISP_STRING_TO_EXTERNAL_MALLOC (Fcar (Vcommand_line_args), + Qcommand_argument_encoding); for (i = 0; i < nargs; i++) { CHECK_STRING (args[i]); - LISP_STRING_TO_EXTERNAL_MALLOC (args[i], run_temacs_argv[i + 1], - Qcommand_argument_encoding); + run_temacs_argv[i + 1] = + (Wexttext *) + LISP_STRING_TO_EXTERNAL_MALLOC (args[i], Qcommand_argument_encoding); } run_temacs_argv[nargs + 1] = 0; @@ -3287,10 +3300,10 @@ Extbyte *filename_ext; Extbyte *symfile_ext; - LISP_STRING_TO_EXTERNAL (filename, filename_ext, Qfile_name); + LISP_PATHNAME_CONVERT_OUT (filename, filename_ext); if (STRINGP (symfile)) - LISP_STRING_TO_EXTERNAL (symfile, symfile_ext, Qfile_name); + LISP_PATHNAME_CONVERT_OUT (symfile, symfile_ext); else symfile_ext = 0; @@ -3321,6 +3334,21 @@ /* exiting XEmacs (intended or not) */ /************************************************************************/ +/* Do we need to pause with a message box so that messages can be read + at shutdown? We do this is we have support for native Windows frames + and if we are native Windows. The first part is because only when compiled + for native Windows frames do we have Fmswindows_message_box(), and + the second part is because we don't want to do this under Cygwin, where + we have a Unix-like environment and a working stderr where the messages + go. The two conditions sound somewhat redundant (maybe we could just + use the second?) but they aren't completely: Theoretically (maybe with + MinGW?) we could imagine compiling under native Windows as the OS + but e.g. targetting only X Windows as the window system. --ben */ + +#if defined (HAVE_MS_WINDOWS) && defined (WIN32_NATIVE) +# define NEED_WINDOWS_MESSAGE_PAUSE +#endif + /* Info on intended/unintended exits: @@ -3348,7 +3376,7 @@ /* Return whether all bytes in the specified memory block can be read. */ int -debug_can_access_memory (void *ptr, Bytecount len) +debug_can_access_memory (const void *ptr, Bytecount len) { return !IsBadReadPtr (ptr, len); } @@ -3367,9 +3395,16 @@ LONGJMP (memory_error_jump, 1); } +/* Used in debug_can_access_memory(). Made into a global, externally + accessible variable to make absolutely sure that no compiler will + optimize away the memory-read function in debug_can_access_memory(); + see comments there. */ + +volatile int dcam_saveval; + /* Return whether all bytes in the specified memory block can be read. */ int -debug_can_access_memory (void *ptr, Bytecount len) +debug_can_access_memory (const void *ptr, Bytecount len) { /* Use volatile to protect variables from being clobbered by longjmp. */ SIGTYPE (*volatile old_sigbus) (int); @@ -3377,6 +3412,7 @@ volatile int old_errno = errno; volatile int retval = 1; + assert (len > 0); if (!SETJMP (memory_error_jump)) { old_sigbus = @@ -3384,13 +3420,24 @@ old_sigsegv = (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGSEGV, debug_memory_error); + /* We could just do memcmp (ptr, ptr, len), but we want to avoid any + possibility that a super-optimizing compiler might optimize away such + a call by concluding that its result is always 1. */ if (len > 1) - /* If we can, try to avoid problems with super-optimizing compilers - that might decide that memcmp (ptr, ptr, len) can be optimized - away since its result is always 1. */ - memcmp (ptr, (Rawbyte *) ptr + 1, len - 1); + /* Instead, if length is > 1, do off-by-one comparison. + We save the value somewhere that is externally accessible to + make absolutely sure that a compiler won't optimize away the + call by concluding that the return value isn't really used. + */ + dcam_saveval = memcmp (ptr, (Rawbyte *) ptr + 1, len - 1); else - memcmp (ptr, ptr, len); + { + /* We can't do the off-by-one trick with only one byte, so instead, + we compare to a fixed-sized buffer. */ + Rawbyte randval[1]; + randval[0] = 0; + dcam_saveval = memcmp (randval, ptr, len); + } } else retval = 0; @@ -3436,7 +3483,7 @@ Vquit_flag = Qnil; } -#ifdef HAVE_MS_WINDOWS +#ifdef NEED_WINDOWS_MESSAGE_PAUSE static void pause_so_user_can_read_messages (int allow_further) { @@ -3687,7 +3734,7 @@ UNGCPRO; -#ifdef HAVE_MS_WINDOWS +#ifdef NEED_WINDOWS_MESSAGE_PAUSE pause_so_user_can_read_messages (1); #endif @@ -3723,7 +3770,7 @@ loops will fight each other and the return key will never be passed to the "pause" handler so that XEmacs's GPF handler can return, resignal the GPF, and properly go into the debugger.) */ -#if defined (ERROR_CHECK_TYPES) || defined (ERROR_CHECK_TEXT) || defined (ERROR_CHECK_GC) || defined (ERROR_CHECK_STRUCTURES) +#ifdef ERROR_CHECK_ANY #define USER_IS_DEVELOPING_XEMACS #endif @@ -3779,7 +3826,7 @@ } } # endif -#if defined (HAVE_MS_WINDOWS) && !defined (USER_IS_DEVELOPING_XEMACS) +#if defined (NEED_WINDOWS_MESSAGE_PAUSE) && !defined (USER_IS_DEVELOPING_XEMACS) pause_so_user_can_read_messages (0); #endif } @@ -3938,7 +3985,7 @@ /* We are extremely paranoid so we sensibly deal with recursive assertion failures. */ in_assert_failed++; - inhibit_non_essential_conversion_operations = 1; + inhibit_non_essential_conversion_operations++; if (in_assert_failed >= 4) _exit (-1); @@ -4006,8 +4053,8 @@ really_abort (); #endif /* defined (_MSC_VER) || defined (CYGWIN) */ #endif /* !defined (ASSERTIONS_DONT_ABORT) */ - inhibit_non_essential_conversion_operations = 0; - in_assert_failed = 0; + inhibit_non_essential_conversion_operations--; + in_assert_failed--; } /* -------------------------------------- */ @@ -4183,7 +4230,7 @@ DEFVAR_LISP ("system-configuration", &Vsystem_configuration /* String naming the configuration XEmacs was built for. */ ); - Vsystem_configuration = build_string (EMACS_CONFIGURATION); + Vsystem_configuration = build_ascstring (EMACS_CONFIGURATION); #ifndef EMACS_CONFIG_OPTIONS # define EMACS_CONFIG_OPTIONS "UNKNOWN" @@ -4191,7 +4238,7 @@ DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options /* String containing the configuration options XEmacs was built with. */ ); - Vsystem_configuration_options = build_string (EMACS_CONFIG_OPTIONS); + Vsystem_configuration_options = build_ascstring (EMACS_CONFIG_OPTIONS); DEFVAR_LISP ("emacs-major-version", &Vemacs_major_version /* Major version number of this version of Emacs, as an integer. @@ -4257,7 +4304,7 @@ #ifndef XEMACS_CODENAME #define XEMACS_CODENAME "Noname" #endif - Vxemacs_codename = build_string (XEMACS_CODENAME); + Vxemacs_codename = build_ascstring (XEMACS_CODENAME); DEFVAR_LISP ("xemacs-extra-name", &Vxemacs_extra_name /* Arbitrary string to place in the version string after the codename. @@ -4270,7 +4317,7 @@ to indicate particular branches, etc. */ ); #ifdef XEMACS_EXTRA_NAME - Vxemacs_extra_name = build_string (XEMACS_EXTRA_NAME); + Vxemacs_extra_name = build_ascstring (XEMACS_EXTRA_NAME); #endif DEFVAR_LISP ("xemacs-release-date", &Vxemacs_release_date /* @@ -4282,7 +4329,7 @@ #ifndef XEMACS_RELEASE_DATE #define XEMACS_RELEASE_DATE "2005-02-18 (defaulted in emacs.c)" #endif - Vxemacs_release_date = build_string (XEMACS_RELEASE_DATE); + Vxemacs_release_date = build_ascstring (XEMACS_RELEASE_DATE); /* Lisp variables which contain command line flags. @@ -4451,14 +4498,14 @@ For example, this may be \"xemacs\" or \"infodock\". This is mainly meant for use in path searching. */ ); - Vemacs_program_name = build_ext_string (PATH_PROGNAME, Qfile_name); + Vemacs_program_name = build_extstring (PATH_PROGNAME, Qfile_name); DEFVAR_LISP ("emacs-program-version", &Vemacs_program_version /* *Version of the Emacs variant. This typically has the form NN.NN-bNN. This is mainly meant for use in path searching. */ ); - Vemacs_program_version = build_ext_string (PATH_VERSION, Qfile_name); + Vemacs_program_version = build_extstring (PATH_VERSION, Qfile_name); DEFVAR_LISP ("exec-path", &Vexec_path /* *List of directories to search programs to run in subprocesses. @@ -4478,7 +4525,7 @@ */ ); #ifdef PATH_EXEC Vconfigure_exec_directory = Ffile_name_as_directory - (build_ext_string (PATH_EXEC, Qfile_name)); + (build_extstring (PATH_EXEC, Qfile_name)); #else Vconfigure_exec_directory = Qnil; #endif @@ -4494,7 +4541,7 @@ */ ); #ifdef PATH_LOADSEARCH Vconfigure_lisp_directory = Ffile_name_as_directory - (build_ext_string (PATH_LOADSEARCH, Qfile_name)); + (build_extstring (PATH_LOADSEARCH, Qfile_name)); #else Vconfigure_lisp_directory = Qnil; #endif @@ -4510,7 +4557,7 @@ */ ); #ifdef PATH_MULELOADSEARCH Vconfigure_mule_lisp_directory = Ffile_name_as_directory - (build_ext_string (PATH_MULELOADSEARCH, Qfile_name); + (build_extstring (PATH_MULELOADSEARCH, Qfile_name); #else Vconfigure_mule_lisp_directory = Qnil; #endif @@ -4526,7 +4573,7 @@ */ ); #ifdef PATH_MODULESEARCH Vconfigure_module_directory = Ffile_name_as_directory - (build_ext_string (PATH_MODULESEARCH, Qfile_name)); + (build_extstring (PATH_MODULESEARCH, Qfile_name)); #else Vconfigure_module_directory = Qnil; #endif @@ -4586,7 +4633,7 @@ */ ); #ifdef PATH_DATA Vconfigure_data_directory = Ffile_name_as_directory - (build_ext_string (PATH_DATA, Qfile_name)); + (build_extstring (PATH_DATA, Qfile_name)); #else Vconfigure_data_directory = Qnil; #endif @@ -4608,7 +4655,7 @@ */ ); #ifdef PATH_SITE Vconfigure_site_directory = Ffile_name_as_directory - (build_ext_string (PATH_SITE, Qfile_name)); + (build_extstring (PATH_SITE, Qfile_name)); #else Vconfigure_site_directory = Qnil; #endif @@ -4624,7 +4671,7 @@ */ ); #ifdef PATH_SITE_MODULES Vconfigure_site_module_directory = Ffile_name_as_directory - (build_ext_string (PATH_SITE_MODULES, Qfile_name)); + (build_extstring (PATH_SITE_MODULES, Qfile_name)); #else Vconfigure_site_module_directory = Qnil; #endif @@ -4641,7 +4688,7 @@ */ ); #ifdef PATH_DOC Vconfigure_doc_directory = Ffile_name_as_directory - (build_ext_string (PATH_DOC, Qfile_name)); + (build_extstring (PATH_DOC, Qfile_name)); #else Vconfigure_doc_directory = Qnil; #endif @@ -4652,7 +4699,7 @@ */ ); #ifdef PATH_EXEC_PREFIX Vconfigure_exec_prefix_directory = Ffile_name_as_directory - (build_ext_string (PATH_EXEC_PREFIX, Qfile_name)); + (build_extstring (PATH_EXEC_PREFIX, Qfile_name)); #else Vconfigure_exec_prefix_directory = Qnil; #endif @@ -4663,7 +4710,7 @@ */ ); #ifdef PATH_PREFIX Vconfigure_prefix_directory = Ffile_name_as_directory - (build_ext_string (PATH_PREFIX, Qfile_name)); + (build_extstring (PATH_PREFIX, Qfile_name)); #else Vconfigure_prefix_directory = Qnil; #endif @@ -4676,7 +4723,7 @@ */ ); #ifdef PATH_INFO Vconfigure_info_directory = - Ffile_name_as_directory (build_ext_string (PATH_INFO, Qfile_name)); + Ffile_name_as_directory (build_extstring (PATH_INFO, Qfile_name)); #else Vconfigure_info_directory = Qnil; #endif