comparison src/emacs.c @ 424:11054d720c21 r21-2-20

Import from CVS: tag r21-2-20
author cvs
date Mon, 13 Aug 2007 11:26:11 +0200
parents 95016f13131a
children
comparison
equal deleted inserted replaced
423:28d9c139be4c 424:11054d720c21
149 Lisp_Object Vconfigure_package_path; 149 Lisp_Object Vconfigure_package_path;
150 Lisp_Object Vdata_directory, Vconfigure_data_directory; 150 Lisp_Object Vdata_directory, Vconfigure_data_directory;
151 Lisp_Object Vdoc_directory, Vconfigure_doc_directory; 151 Lisp_Object Vdoc_directory, Vconfigure_doc_directory;
152 Lisp_Object Vconfigure_lock_directory; 152 Lisp_Object Vconfigure_lock_directory;
153 Lisp_Object Vdata_directory_list; 153 Lisp_Object Vdata_directory_list;
154 Lisp_Object Vinfo_directory, Vconfigure_info_directory; 154 Lisp_Object Vconfigure_info_directory;
155 Lisp_Object Vsite_directory, Vconfigure_site_directory; 155 Lisp_Object Vsite_directory, Vconfigure_site_directory;
156 Lisp_Object Vconfigure_info_path; 156 Lisp_Object Vconfigure_info_path;
157 Lisp_Object Vinternal_error_checking; 157 Lisp_Object Vinternal_error_checking;
158 Lisp_Object Vpath_separator; 158 Lisp_Object Vpath_separator;
159 159
219 219
220 /* Nonzero means print debug information about path searching */ 220 /* Nonzero means print debug information about path searching */
221 int debug_paths; 221 int debug_paths;
222 222
223 /* Save argv and argc. */ 223 /* Save argv and argc. */
224 char **initial_argv; 224 static char **initial_argv;
225 int initial_argc; 225 static int initial_argc;
226 226
227 static void sort_args (int argc, char **argv); 227 static void sort_args (int argc, char **argv);
228 228
229 Lisp_Object Qkill_emacs_hook; 229 Lisp_Object Qkill_emacs_hook;
230 Lisp_Object Qsave_buffers_kill_emacs; 230 Lisp_Object Qsave_buffers_kill_emacs;
545 int inhibit_window_system; 545 int inhibit_window_system;
546 #ifdef NeXT 546 #ifdef NeXT
547 extern int malloc_cookie; 547 extern int malloc_cookie;
548 #endif 548 #endif
549 549
550 #if !defined(SYSTEM_MALLOC) && !defined(HAVE_LIBMCHECK) 550 #if (!defined (SYSTEM_MALLOC) && !defined (HAVE_LIBMCHECK) \
551 && !defined (DOUG_LEA_MALLOC))
551 /* Make sure that any libraries we link against haven't installed a 552 /* Make sure that any libraries we link against haven't installed a
552 hook for a gmalloc of a potentially incompatible version. */ 553 hook for a gmalloc of a potentially incompatible version. */
553 /* If we're using libmcheck, the hooks have already been initialized, */ 554 /* If we're using libmcheck, the hooks have already been initialized, */
554 /* don't touch them. -slb */ 555 /* don't touch them. -slb */
555 __malloc_hook = NULL; 556 __malloc_hook = NULL;
556 __realloc_hook = NULL; 557 __realloc_hook = NULL;
557 __free_hook = NULL; 558 __free_hook = NULL;
558 #endif /* not SYSTEM_MALLOC */ 559 #endif /* not SYSTEM_MALLOC or HAVE_LIBMCHECK or DOUG_LEA_MALLOC */
559 560
560 noninteractive = 0; 561 noninteractive = 0;
561 562
562 #ifdef NeXT 563 #ifdef NeXT
563 /* 19-Jun-1995 -baw 564 /* 19-Jun-1995 -baw
853 environment when the dumped XEmacs is run. 854 environment when the dumped XEmacs is run.
854 855
855 We try to do things in an order that minimizes the non-obvious 856 We try to do things in an order that minimizes the non-obvious
856 dependencies between functions. */ 857 dependencies between functions. */
857 858
859 #ifdef PDUMP
860 initialized = restart || pdump_load ();
861 #endif
862
858 if (!initialized) 863 if (!initialized)
859 { 864 {
860 /* Initialize things so that new Lisp objects 865 /* Initialize things so that new Lisp objects
861 can be created and objects can be staticpro'd. 866 can be created and objects can be staticpro'd.
862 Must be basically the very first thing done 867 Must be basically the very first thing done
1251 Dynarr_*() 1256 Dynarr_*()
1252 Blocktype_*() 1257 Blocktype_*()
1253 staticpro() 1258 staticpro()
1254 Fprovide(symbol) 1259 Fprovide(symbol)
1255 intern() 1260 intern()
1256 pure_put() 1261 Fput()
1257 xmalloc() 1262 xmalloc()
1258 defsymbol(), if it's absolutely necessary and you're sure that 1263 defsymbol(), if it's absolutely necessary and you're sure that
1259 the symbol isn't referenced anywhere else in the initialization 1264 the symbol isn't referenced anywhere else in the initialization
1260 code 1265 code
1261 Fset() on a symbol that is unbound 1266 Fset() on a symbol that is unbound
1264 earlier on in the same function 1269 earlier on in the same function
1265 1270
1266 Any of the object-creating functions on alloc.c: e.g. 1271 Any of the object-creating functions on alloc.c: e.g.
1267 1272
1268 make_pure_*() 1273 make_pure_*()
1269 Fpurecopy()
1270 make_string() 1274 make_string()
1271 build_string() 1275 build_string()
1272 make_vector() 1276 make_vector()
1273 make_int() 1277 make_int()
1274 make_extent() 1278 make_extent()
1275 alloc_lcrecord() 1279 alloc_lcrecord()
1276 Fcons() 1280 Fcons()
1277 listN() 1281 listN()
1278 make_opaque_ptr() 1282 make_opaque_ptr()
1279 make_opaque_long()
1280 1283
1281 perhaps a few others. 1284 perhaps a few others.
1282 */ 1285 */
1283 1286
1284 /* Now allow Fprovide() statements to be made. */ 1287 /* Now allow Fprovide() statements to be made. */
1285 init_provide_once (); 1288 init_provide_once ();
1289
1290 /* Do that before any specifier creation (esp. vars_of_glyphs()) */
1291 vars_of_specifier ();
1286 1292
1287 vars_of_abbrev (); 1293 vars_of_abbrev ();
1288 vars_of_alloc (); 1294 vars_of_alloc ();
1289 #ifdef HAVE_X_WINDOWS 1295 #ifdef HAVE_X_WINDOWS
1290 vars_of_balloon_x (); 1296 vars_of_balloon_x ();
1391 vars_of_scrollbar (); 1397 vars_of_scrollbar ();
1392 #endif 1398 #endif
1393 vars_of_search (); 1399 vars_of_search ();
1394 vars_of_select (); 1400 vars_of_select ();
1395 vars_of_sound (); 1401 vars_of_sound ();
1396 vars_of_specifier ();
1397 vars_of_symbols (); 1402 vars_of_symbols ();
1398 vars_of_syntax (); 1403 vars_of_syntax ();
1399 #ifdef HAVE_TOOLBARS 1404 #ifdef HAVE_TOOLBARS
1400 vars_of_toolbar (); 1405 vars_of_toolbar ();
1401 #endif 1406 #endif
1607 extern int always_gc; 1612 extern int always_gc;
1608 if (always_gc) /* purification debugging hack */ 1613 if (always_gc) /* purification debugging hack */
1609 garbage_collect_1 (); 1614 garbage_collect_1 ();
1610 } 1615 }
1611 #endif 1616 #endif
1617 #ifdef PDUMP
1618 } else if (!restart) {
1619 reinit_alloc_once_early ();
1620 reinit_opaque_once_early ();
1621
1622 reinit_console_type_create_stream ();
1623 #ifdef HAVE_TTY
1624 reinit_console_type_create_tty ();
1625 #endif
1626 #ifdef HAVE_X_WINDOWS
1627 reinit_console_type_create_x ();
1628 reinit_console_type_create_device_x ();
1629 #endif
1630 #ifdef HAVE_MS_WINDOWS
1631 reinit_console_type_create_mswindows ();
1632 #endif
1633
1634 reinit_specifier_type_create ();
1635 reinit_specifier_type_create_image ();
1636 reinit_specifier_type_create_gutter ();
1637 reinit_specifier_type_create_objects ();
1638 #ifdef HAVE_TOOLBARS
1639 reinit_specifier_type_create_toolbar ();
1640 #endif
1641
1642 structure_type_create ();
1643
1644 structure_type_create_chartab ();
1645 structure_type_create_faces ();
1646 structure_type_create_rangetab ();
1647 structure_type_create_hash_table ();
1648
1649 lstream_type_create ();
1650 #ifdef FILE_CODING
1651 lstream_type_create_file_coding ();
1652 #endif
1653 #if defined (HAVE_MS_WINDOWS) && !defined(HAVE_MSG_SELECT)
1654 lstream_type_create_mswindows_selectable ();
1655 #endif
1656 #ifdef HAVE_UNIX_PROCESSES
1657 process_type_create_unix ();
1658 #endif
1659 #ifdef HAVE_WIN32_PROCESSES
1660 process_type_create_nt ();
1661 #endif
1662
1663 reinit_vars_of_buffer ();
1664 reinit_vars_of_console ();
1665 #ifdef DEBUG_XEMACS
1666 reinit_vars_of_debug ();
1667 #endif
1668 reinit_vars_of_device ();
1669 reinit_vars_of_eval ();
1670 #ifdef HAVE_X_WINDOWS
1671 reinit_vars_of_event_Xt ();
1672 #endif
1673 #if defined(HAVE_TTY) && (defined (DEBUG_TTY_EVENT_STREAM) || !defined (HAVE_X_WINDOWS))
1674 reinit_vars_of_event_tty ();
1675 #endif
1676 #ifdef HAVE_MS_WINDOWS
1677 reinit_vars_of_event_mswindows ();
1678 #endif
1679 reinit_vars_of_event_stream ();
1680 reinit_vars_of_events ();
1681 reinit_vars_of_extents ();
1682 reinit_vars_of_font_lock ();
1683 reinit_vars_of_glyphs ();
1684 reinit_vars_of_glyphs_widget ();
1685 reinit_vars_of_insdel ();
1686 reinit_vars_of_lread ();
1687 reinit_vars_of_lstream ();
1688 reinit_vars_of_minibuf ();
1689 reinit_vars_of_module ();
1690 reinit_vars_of_objects ();
1691 reinit_vars_of_print ();
1692 reinit_vars_of_redisplay ();
1693 reinit_vars_of_search ();
1694 reinit_vars_of_scrollbar_x ();
1695 reinit_vars_of_undo ();
1696 reinit_vars_of_window ();
1697
1698 #ifdef HAVE_MS_WINDOWS
1699 reinit_vars_of_frame_mswindows ();
1700 #endif
1701
1702 #ifdef HAVE_X_WINDOWS
1703 reinit_vars_of_device_x ();
1704 #ifdef HAVE_MENUBARS
1705 reinit_vars_of_menubar_x ();
1706 #endif
1707 reinit_vars_of_xselect ();
1708 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1709 reinit_vars_of_gui_x ();
1710 #endif
1711 #endif
1712
1713 #if defined(MULE) && defined(HAVE_WNN)
1714 reinit_vars_of_mule_wnn ();
1715 #endif
1716
1717 reinit_complex_vars_of_buffer ();
1718 reinit_complex_vars_of_console ();
1719 reinit_complex_vars_of_minibuf ();
1720 #endif
1612 } 1721 }
1722
1613 1723
1614 /* CONGRATULATIONS!!! We have successfully initialized the Lisp 1724 /* CONGRATULATIONS!!! We have successfully initialized the Lisp
1615 engine. */ 1725 engine. */
1616 1726
1617 if (initialized) 1727 if (initialized)
2198 static void 2308 static void
2199 voodoo_free_hook (void *mem) 2309 voodoo_free_hook (void *mem)
2200 { 2310 {
2201 /* Disable all calls to free() when XEmacs is exiting and it doesn't */ 2311 /* Disable all calls to free() when XEmacs is exiting and it doesn't */
2202 /* matter. */ 2312 /* matter. */
2203 __free_hook = voodoo_free_hook; 2313 __free_hook =
2204 } 2314 #ifdef __GNUC__ /* prototype of __free_hook varies with glibc version */
2205 #endif 2315 (__typeof__ (__free_hook))
2316 #endif
2317 voodoo_free_hook;
2318 }
2319 #endif /* GNU_MALLOC */
2206 2320
2207 DEFUN ("kill-emacs", Fkill_emacs, 0, 1, "P", /* 2321 DEFUN ("kill-emacs", Fkill_emacs, 0, 1, "P", /*
2208 Exit the XEmacs job and kill it. Ask for confirmation, without argument. 2322 Exit the XEmacs job and kill it. Ask for confirmation, without argument.
2209 If ARG is an integer, return ARG as the exit program code. 2323 If ARG is an integer, return ARG as the exit program code.
2210 If ARG is a string, stuff it as keyboard input. 2324 If ARG is a string, stuff it as keyboard input.
2254 } 2368 }
2255 } 2369 }
2256 2370
2257 UNGCPRO; 2371 UNGCPRO;
2258 2372
2259 shut_down_emacs (0, ((STRINGP (arg)) ? arg : Qnil)); 2373 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil);
2260 2374
2261 #if defined(GNU_MALLOC) 2375 #if defined(GNU_MALLOC)
2262 __free_hook = voodoo_free_hook; 2376 __free_hook =
2263 #endif 2377 #ifdef __GNUC__ /* prototype of __free_hook varies with glibc version */
2264 2378 (__typeof__ (__free_hook))
2265 exit ((INTP (arg)) ? XINT (arg) : 0); 2379 #endif
2380 voodoo_free_hook;
2381 #endif
2382
2383 exit (INTP (arg) ? XINT (arg) : 0);
2266 /* NOTREACHED */ 2384 /* NOTREACHED */
2267 return Qnil; /* I'm sick of the compiler warning */ 2385 return Qnil; /* I'm sick of the compiler warning */
2268 } 2386 }
2269 2387
2270 /* Perform an orderly shutdown of XEmacs. Autosave any modified 2388 /* Perform an orderly shutdown of XEmacs. Autosave any modified
2342 char *dir = 0; 2460 char *dir = 0;
2343 2461
2344 /* Now try to determine the actual path to the executable, 2462 /* Now try to determine the actual path to the executable,
2345 to try to make the backtrace-determination process as foolproof 2463 to try to make the backtrace-determination process as foolproof
2346 as possible. */ 2464 as possible. */
2347 if (GC_STRINGP (Vinvocation_name)) 2465 if (STRINGP (Vinvocation_name))
2348 name = (char *) XSTRING_DATA (Vinvocation_name); 2466 name = (char *) XSTRING_DATA (Vinvocation_name);
2349 else 2467 else
2350 name = "xemacs"; 2468 name = "xemacs";
2351 if (GC_STRINGP (Vinvocation_directory)) 2469 if (STRINGP (Vinvocation_directory))
2352 dir = (char *) XSTRING_DATA (Vinvocation_directory); 2470 dir = (char *) XSTRING_DATA (Vinvocation_directory);
2353 if (!dir || dir[0] != '/') 2471 if (!dir || dir[0] != '/')
2354 stderr_out ("`which %s`", name); 2472 stderr_out ("`which %s`", name);
2355 else if (dir[strlen (dir) - 1] != '/') 2473 else if (dir[strlen (dir) - 1] != '/')
2356 stderr_out ("%s/%s", dir, name); 2474 stderr_out ("%s/%s", dir, name);
2510 GET_C_STRING_FILENAME_DATA_ALLOCA (symname, symname_ext); 2628 GET_C_STRING_FILENAME_DATA_ALLOCA (symname, symname_ext);
2511 else 2629 else
2512 symname_ext = 0; 2630 symname_ext = 0;
2513 2631
2514 garbage_collect_1 (); 2632 garbage_collect_1 ();
2633
2634 #ifdef PDUMP
2635 pdump ();
2636 #else
2637
2515 #ifdef DOUG_LEA_MALLOC 2638 #ifdef DOUG_LEA_MALLOC
2516 malloc_state_ptr = malloc_get_state (); 2639 malloc_state_ptr = malloc_get_state ();
2517 #endif 2640 #endif
2518 /* here we break our rule that the filename conversion should 2641 /* here we break our rule that the filename conversion should
2519 be performed at the actual time that the system call is made. 2642 be performed at the actual time that the system call is made.
2523 leakage because this call only happens once. */ 2646 leakage because this call only happens once. */
2524 unexec (intoname_ext, symname_ext, (uintptr_t) my_edata, 0, 0); 2647 unexec (intoname_ext, symname_ext, (uintptr_t) my_edata, 0, 0);
2525 #ifdef DOUG_LEA_MALLOC 2648 #ifdef DOUG_LEA_MALLOC
2526 free (malloc_state_ptr); 2649 free (malloc_state_ptr);
2527 #endif 2650 #endif
2651 #endif /* not PDUMP */
2528 } 2652 }
2529 #endif /* not MSDOS and EMX */ 2653 #endif /* not MSDOS and EMX */
2530 2654
2531 purify_flag = opurify; 2655 purify_flag = opurify;
2532 2656
2782 # define EMACS_CONFIGURATION "UNKNOWN" 2906 # define EMACS_CONFIGURATION "UNKNOWN"
2783 #endif 2907 #endif
2784 DEFVAR_LISP ("system-configuration", &Vsystem_configuration /* 2908 DEFVAR_LISP ("system-configuration", &Vsystem_configuration /*
2785 String naming the configuration XEmacs was built for. 2909 String naming the configuration XEmacs was built for.
2786 */ ); 2910 */ );
2787 Vsystem_configuration = Fpurecopy (build_string (EMACS_CONFIGURATION)); 2911 Vsystem_configuration = build_string (EMACS_CONFIGURATION);
2788 2912
2789 #ifndef EMACS_CONFIG_OPTIONS 2913 #ifndef EMACS_CONFIG_OPTIONS
2790 # define EMACS_CONFIG_OPTIONS "UNKNOWN" 2914 # define EMACS_CONFIG_OPTIONS "UNKNOWN"
2791 #endif 2915 #endif
2792 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options /* 2916 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options /*
2793 String containing the configuration options XEmacs was built with. 2917 String containing the configuration options XEmacs was built with.
2794 */ ); 2918 */ );
2795 Vsystem_configuration_options = Fpurecopy (build_string 2919 Vsystem_configuration_options = build_string (EMACS_CONFIG_OPTIONS);
2796 (EMACS_CONFIG_OPTIONS));
2797 2920
2798 DEFVAR_LISP ("emacs-major-version", &Vemacs_major_version /* 2921 DEFVAR_LISP ("emacs-major-version", &Vemacs_major_version /*
2799 Major version number of this version of Emacs, as an integer. 2922 Major version number of this version of Emacs, as an integer.
2800 Warning: this variable did not exist in Emacs versions earlier than: 2923 Warning: this variable did not exist in Emacs versions earlier than:
2801 FSF Emacs: 19.23 2924 FSF Emacs: 19.23
2857 Codename of this version of Emacs (a string). 2980 Codename of this version of Emacs (a string).
2858 */ ); 2981 */ );
2859 #ifndef XEMACS_CODENAME 2982 #ifndef XEMACS_CODENAME
2860 #define XEMACS_CODENAME "Noname" 2983 #define XEMACS_CODENAME "Noname"
2861 #endif 2984 #endif
2862 Vxemacs_codename = Fpurecopy (build_string (XEMACS_CODENAME)); 2985 Vxemacs_codename = build_string (XEMACS_CODENAME);
2863 2986
2864 DEFVAR_BOOL ("noninteractive", &noninteractive1 /* 2987 DEFVAR_BOOL ("noninteractive", &noninteractive1 /*
2865 Non-nil means XEmacs is running without interactive terminal. 2988 Non-nil means XEmacs is running without interactive terminal.
2866 */ ); 2989 */ );
2867 2990
2931 #endif 3054 #endif
2932 #ifdef ERROR_CHECK_BUFPOS 3055 #ifdef ERROR_CHECK_BUFPOS
2933 Vinternal_error_checking = Fcons (intern ("bufpos"), 3056 Vinternal_error_checking = Fcons (intern ("bufpos"),
2934 Vinternal_error_checking); 3057 Vinternal_error_checking);
2935 #endif 3058 #endif
2936 Vinternal_error_checking = Fpurecopy (Vinternal_error_checking);
2937 3059
2938 DEFVAR_LISP ("path-separator", &Vpath_separator /* 3060 DEFVAR_LISP ("path-separator", &Vpath_separator /*
2939 The directory separator in search paths, as a string. 3061 The directory separator in search paths, as a string.
2940 */ ); 3062 */ );
2941 { 3063 {
3158 #else 3280 #else
3159 Vconfigure_info_path = Qnil; 3281 Vconfigure_info_path = Qnil;
3160 #endif 3282 #endif
3161 } 3283 }
3162 3284
3163 #ifdef __sgi 3285 #if defined(__sgi) && !defined(PDUMP)
3164 /* This is so tremendously ugly I'd puke. But then, it works. 3286 /* This is so tremendously ugly I'd puke. But then, it works.
3165 * The target is to override the static constructor from the 3287 * The target is to override the static constructor from the
3166 * libiflPNG.so library which is maskerading as libz, and 3288 * libiflPNG.so library which is maskerading as libz, and
3167 * cores on us when re-started from the dumped executable. 3289 * cores on us when re-started from the dumped executable.
3168 * This will have to go for 21.1 -- OG. 3290 * This will have to go for 21.1 -- OG.