Mercurial > hg > xemacs-beta
comparison src/emacs.c @ 404:2f8bb876ab1d r21-2-32
Import from CVS: tag r21-2-32
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:16:07 +0200 |
parents | a86b2b5e0111 |
children | b8cc9ab3f761 |
comparison
equal
deleted
inserted
replaced
403:9f011ab08d48 | 404:2f8bb876ab1d |
---|---|
42 #include "syssignal.h" /* Always include before systty.h */ | 42 #include "syssignal.h" /* Always include before systty.h */ |
43 #include "systty.h" | 43 #include "systty.h" |
44 #include "sysfile.h" | 44 #include "sysfile.h" |
45 #include "systime.h" | 45 #include "systime.h" |
46 | 46 |
47 #ifdef PDUMP | |
48 #include "dump-id.h" | |
49 #include "dumper.h" | |
50 #endif | |
51 | |
52 #ifndef SEPCHAR | |
53 #define SEPCHAR ':' | |
54 #endif | |
55 | |
47 #ifdef QUANTIFY | 56 #ifdef QUANTIFY |
48 #include <quantify.h> | 57 #include <quantify.h> |
49 #endif | 58 #endif |
50 | 59 |
51 #ifdef HAVE_SHLIB | 60 #ifdef HAVE_SHLIB |
66 #endif | 75 #endif |
67 | 76 |
68 /* For PATH_EXEC */ | 77 /* For PATH_EXEC */ |
69 #include <paths.h> | 78 #include <paths.h> |
70 | 79 |
71 #ifdef HEAP_IN_DATA | 80 #if defined (HEAP_IN_DATA) && !defined(PDUMP) |
72 void report_sheap_usage (int die_if_pure_storage_exceeded); | 81 void report_sheap_usage (int die_if_pure_storage_exceeded); |
73 #endif | 82 #endif |
74 | 83 |
75 #if !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC) | 84 #if !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC) |
76 extern void *(*__malloc_hook)(size_t); | 85 extern void *(*__malloc_hook)(size_t); |
211 int inhibit_early_packages; | 220 int inhibit_early_packages; |
212 | 221 |
213 /* Nonzero means don't load package autoloads at startup */ | 222 /* Nonzero means don't load package autoloads at startup */ |
214 int inhibit_autoloads; | 223 int inhibit_autoloads; |
215 | 224 |
225 /* Nonzero means don't load the dump file (ignored if not PDUMP) */ | |
226 | |
227 int nodumpfile; | |
228 | |
216 /* Nonzero means print debug information about path searching */ | 229 /* Nonzero means print debug information about path searching */ |
217 int debug_paths; | 230 int debug_paths; |
218 | 231 |
219 /* Save argv and argc. */ | 232 /* Save argv and argc. */ |
220 static char **initial_argv; | 233 static char **initial_argv; |
231 /* Signal code for the fatal signal that was received */ | 244 /* Signal code for the fatal signal that was received */ |
232 static int fatal_error_code; | 245 static int fatal_error_code; |
233 | 246 |
234 /* Nonzero if handling a fatal error already */ | 247 /* Nonzero if handling a fatal error already */ |
235 static int fatal_error_in_progress; | 248 static int fatal_error_in_progress; |
249 | |
250 static JMP_BUF run_temacs_catch; | |
251 | |
252 static int run_temacs_argc; | |
253 static char **run_temacs_argv; | |
254 static char *run_temacs_args; | |
255 static size_t run_temacs_argv_size; | |
256 static size_t run_temacs_args_size; | |
236 | 257 |
237 static void shut_down_emacs (int sig, Lisp_Object stuff); | 258 static void shut_down_emacs (int sig, Lisp_Object stuff); |
238 | 259 |
239 /* Handle bus errors, illegal instruction, etc. */ | 260 /* Handle bus errors, illegal instruction, etc. */ |
240 SIGTYPE | 261 SIGTYPE |
271 /* Signal the same code; this time it will really be fatal. */ | 292 /* Signal the same code; this time it will really be fatal. */ |
272 kill (getpid (), fatal_error_code); | 293 kill (getpid (), fatal_error_code); |
273 SIGRETURN; | 294 SIGRETURN; |
274 } | 295 } |
275 | 296 |
276 | |
277 DOESNT_RETURN | |
278 fatal (const char *fmt, ...) | |
279 { | |
280 va_list args; | |
281 va_start (args, fmt); | |
282 | |
283 fprintf (stderr, "\nXEmacs: "); | |
284 vfprintf (stderr, GETTEXT (fmt), args); | |
285 fprintf (stderr, "\n"); | |
286 | |
287 va_end (args); | |
288 fflush (stderr); | |
289 exit (1); | |
290 } | |
291 | |
292 /* #### The following two functions should be replaced with | |
293 calls to emacs_doprnt_*() functions, with STREAM set to send out | |
294 to stdout or stderr. This is the only way to ensure that | |
295 I18N3 works properly (many implementations of the *printf() | |
296 functions, including the ones included in glibc, do not implement | |
297 the %###$ argument-positioning syntax). */ | |
298 | |
299 /* exactly equivalent to fprintf (stderr, fmt, ...) except that it calls | |
300 GETTEXT on the format string. */ | |
301 | |
302 int | |
303 stderr_out (const char *fmt, ...) | |
304 { | |
305 int retval; | |
306 va_list args; | |
307 va_start (args, fmt); | |
308 | |
309 retval = vfprintf (stderr, GETTEXT (fmt), args); | |
310 | |
311 va_end (args); | |
312 /* fflush (stderr); */ | |
313 return retval; | |
314 } | |
315 | |
316 /* exactly equivalent to fprintf (stdout, fmt, ...) except that it calls | |
317 GETTEXT on the format string. */ | |
318 | |
319 int | |
320 stdout_out (const char *fmt, ...) | |
321 { | |
322 int retval; | |
323 va_list args; | |
324 va_start (args, fmt); | |
325 | |
326 retval = vfprintf (stdout, GETTEXT (fmt), args); | |
327 | |
328 va_end (args); | |
329 return retval; | |
330 } | |
331 | 297 |
332 #ifdef SIGDANGER | 298 #ifdef SIGDANGER |
333 | 299 |
334 /* Handler for SIGDANGER. */ | 300 /* Handler for SIGDANGER. */ |
335 SIGTYPE | 301 SIGTYPE |
567 * work with dumping. But malloc_jumpstart() and malloc_freezedry() in | 533 * work with dumping. But malloc_jumpstart() and malloc_freezedry() in |
568 * unexnext.c are both completely undocumented, even in NS header files! | 534 * unexnext.c are both completely undocumented, even in NS header files! |
569 * But hey, it solves all NS related memory problems, so who's | 535 * But hey, it solves all NS related memory problems, so who's |
570 * complaining? */ | 536 * complaining? */ |
571 if (initialized && malloc_jumpstart (malloc_cookie) != 0) | 537 if (initialized && malloc_jumpstart (malloc_cookie) != 0) |
572 fprintf (stderr, "malloc jumpstart failed!\n"); | 538 stderr_out ("malloc jumpstart failed!\n"); |
573 #endif /* NeXT */ | 539 #endif /* NeXT */ |
574 | 540 |
575 /* | 541 /* |
576 #if defined (GNU_MALLOC) && \ | 542 #if defined (GNU_MALLOC) && \ |
577 defined (ERROR_CHECK_MALLOC) && \ | 543 defined (ERROR_CHECK_MALLOC) && \ |
642 #ifdef HAVE_WINDOW_SYSTEM | 608 #ifdef HAVE_WINDOW_SYSTEM |
643 inhibit_window_system = 0; | 609 inhibit_window_system = 0; |
644 #else | 610 #else |
645 inhibit_window_system = 1; | 611 inhibit_window_system = 1; |
646 #endif | 612 #endif |
613 | |
614 /* Handle the -sd/--show-dump-id switch, which means show the hex dump_id and quit */ | |
615 if (argmatch (argv, argc, "-sd", "--show-dump-id", 9, NULL, &skip_args)) | |
616 { | |
617 #ifdef PDUMP | |
618 printf ("%08x\n", dump_id); | |
619 #else | |
620 printf ("*ERROR**\n"); | |
621 #endif | |
622 exit (0); | |
623 } | |
647 | 624 |
648 /* Handle the -t switch, which specifies filename to use as terminal */ | 625 /* Handle the -t switch, which specifies filename to use as terminal */ |
649 { | 626 { |
650 char *term; | 627 char *term; |
651 if (argmatch (argv, argc, "-t", "--terminal", 4, &term, &skip_args)) | 628 if (argmatch (argv, argc, "-t", "--terminal", 4, &term, &skip_args)) |
663 #endif | 640 #endif |
664 stderr_out ("Using %s", term); | 641 stderr_out ("Using %s", term); |
665 inhibit_window_system = 1; /* -t => -nw */ | 642 inhibit_window_system = 1; /* -t => -nw */ |
666 } | 643 } |
667 } | 644 } |
645 | |
646 /* Handle the --no-dump-file/-nd switch, which means don't load the dump file (ignored when not using pdump) */ | |
647 if (argmatch (argv, argc, "-nd", "--no-dump-file", 7, NULL, &skip_args)) | |
648 { | |
649 nodumpfile = 1; | |
650 } | |
668 | 651 |
669 /* Handle -nw switch */ | 652 /* Handle -nw switch */ |
670 if (argmatch (argv, argc, "-nw", "--no-windows", 6, NULL, &skip_args)) | 653 if (argmatch (argv, argc, "-nw", "--no-windows", 6, NULL, &skip_args)) |
671 inhibit_window_system = 1; | 654 inhibit_window_system = 1; |
672 | 655 |
835 | 818 |
836 purify_flag = 0; | 819 purify_flag = 0; |
837 #ifdef PDUMP | 820 #ifdef PDUMP |
838 if (restart) | 821 if (restart) |
839 initialized = 1; | 822 initialized = 1; |
840 else { | 823 else if (nodumpfile) { |
841 initialized = pdump_load (); | 824 initialized = 0; |
842 purify_flag = !initialized; | 825 purify_flag = 1; |
826 } else { | |
827 initialized = pdump_load (argv[0]); | |
828 if (initialized) | |
829 run_temacs_argc = -1; | |
830 else | |
831 purify_flag = 1; | |
843 } | 832 } |
844 #else | 833 #else |
845 if (!initialized) | 834 if (!initialized) |
846 purify_flag = 1; | 835 purify_flag = 1; |
847 #endif | 836 #endif |
928 syms_of_frame (); | 917 syms_of_frame (); |
929 syms_of_general (); | 918 syms_of_general (); |
930 syms_of_glyphs (); | 919 syms_of_glyphs (); |
931 syms_of_glyphs_eimage (); | 920 syms_of_glyphs_eimage (); |
932 syms_of_glyphs_widget (); | 921 syms_of_glyphs_widget (); |
933 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS) | |
934 syms_of_gui (); | 922 syms_of_gui (); |
935 #endif | |
936 syms_of_gutter (); | 923 syms_of_gutter (); |
937 syms_of_indent (); | 924 syms_of_indent (); |
938 syms_of_intl (); | 925 syms_of_intl (); |
939 syms_of_keymap (); | 926 syms_of_keymap (); |
940 syms_of_lread (); | 927 syms_of_lread (); |
1080 syms_of_eldap (); | 1067 syms_of_eldap (); |
1081 #endif | 1068 #endif |
1082 | 1069 |
1083 #ifdef HAVE_GPM | 1070 #ifdef HAVE_GPM |
1084 syms_of_gpmevent (); | 1071 syms_of_gpmevent (); |
1072 #endif | |
1073 | |
1074 #ifdef HAVE_POSTGRESQL | |
1075 syms_of_postgresql (); | |
1085 #endif | 1076 #endif |
1086 | 1077 |
1087 /* Now create the subtypes for the types that have them. | 1078 /* Now create the subtypes for the types that have them. |
1088 We do this before the vars_*() because more symbols | 1079 We do this before the vars_*() because more symbols |
1089 may get initialized here. */ | 1080 may get initialized here. */ |
1262 Fset() on a symbol that is unbound | 1253 Fset() on a symbol that is unbound |
1263 assigning a symbol or constant value to a variable | 1254 assigning a symbol or constant value to a variable |
1264 using a global variable that has been initialized | 1255 using a global variable that has been initialized |
1265 earlier on in the same function | 1256 earlier on in the same function |
1266 | 1257 |
1267 Any of the object-creating functions on alloc.c: e.g. | 1258 Any of the object-creating functions in alloc.c: e.g. |
1268 | 1259 |
1269 make_pure_*() | 1260 make_pure_*() |
1270 make_string() | 1261 make_string() |
1271 build_string() | 1262 build_string() |
1272 make_vector() | 1263 make_vector() |
1335 vars_of_font_lock (); | 1326 vars_of_font_lock (); |
1336 vars_of_frame (); | 1327 vars_of_frame (); |
1337 vars_of_glyphs (); | 1328 vars_of_glyphs (); |
1338 vars_of_glyphs_eimage (); | 1329 vars_of_glyphs_eimage (); |
1339 vars_of_glyphs_widget (); | 1330 vars_of_glyphs_widget (); |
1340 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS) | |
1341 vars_of_gui (); | 1331 vars_of_gui (); |
1342 #endif | |
1343 vars_of_gutter (); | 1332 vars_of_gutter (); |
1344 vars_of_indent (); | 1333 vars_of_indent (); |
1345 vars_of_insdel (); | 1334 vars_of_insdel (); |
1346 vars_of_intl (); | 1335 vars_of_intl (); |
1347 #ifdef HAVE_XIM | 1336 #ifdef HAVE_XIM |
1477 | 1466 |
1478 #ifdef HAVE_LDAP | 1467 #ifdef HAVE_LDAP |
1479 vars_of_eldap (); | 1468 vars_of_eldap (); |
1480 #endif | 1469 #endif |
1481 | 1470 |
1471 #ifdef HAVE_POSTGRESQL | |
1472 vars_of_postgresql(); | |
1473 #endif | |
1474 | |
1482 #ifdef HAVE_GPM | 1475 #ifdef HAVE_GPM |
1483 vars_of_gpmevent (); | 1476 vars_of_gpmevent (); |
1484 #endif | 1477 #endif |
1485 | 1478 |
1486 /* Now initialize any specifier variables. We do this later | 1479 /* Now initialize any specifier variables. We do this later |
1678 reinit_vars_of_event_mswindows (); | 1671 reinit_vars_of_event_mswindows (); |
1679 #endif | 1672 #endif |
1680 reinit_vars_of_event_stream (); | 1673 reinit_vars_of_event_stream (); |
1681 reinit_vars_of_events (); | 1674 reinit_vars_of_events (); |
1682 reinit_vars_of_extents (); | 1675 reinit_vars_of_extents (); |
1676 reinit_vars_of_fileio (); | |
1683 reinit_vars_of_font_lock (); | 1677 reinit_vars_of_font_lock (); |
1684 reinit_vars_of_glyphs (); | 1678 reinit_vars_of_glyphs (); |
1685 reinit_vars_of_glyphs_widget (); | 1679 reinit_vars_of_glyphs_widget (); |
1686 reinit_vars_of_insdel (); | 1680 reinit_vars_of_insdel (); |
1687 reinit_vars_of_lread (); | 1681 reinit_vars_of_lread (); |
1792 init_hpplay (); | 1786 init_hpplay (); |
1793 #endif | 1787 #endif |
1794 #ifdef HAVE_TTY | 1788 #ifdef HAVE_TTY |
1795 init_device_tty (); | 1789 init_device_tty (); |
1796 #endif | 1790 #endif |
1797 init_console_stream (); /* Create the first console */ | 1791 init_console_stream (restart); /* Create the first console */ |
1798 | 1792 |
1799 /* try to get the actual pathname of the exec file we are running */ | 1793 /* try to get the actual pathname of the exec file we are running */ |
1800 if (!restart) | 1794 if (!restart) |
1801 { | 1795 { |
1802 Vinvocation_name = Fcar (Vcommand_line_args); | 1796 Vinvocation_name = Fcar (Vcommand_line_args); |
1895 }; | 1889 }; |
1896 | 1890 |
1897 static const struct standard_args standard_args[] = | 1891 static const struct standard_args standard_args[] = |
1898 { | 1892 { |
1899 /* Handled by main_1 above: */ | 1893 /* Handled by main_1 above: */ |
1900 { "-nl", "--no-shared-memory", 100, 0 }, | 1894 { "-sd", "--show-dump-id", 105, 0 }, |
1901 { "-t", "--terminal", 95, 1 }, | 1895 { "-t", "--terminal", 100, 1 }, |
1896 { "-nd", "--no-dump-file", 95, 0 }, | |
1902 { "-nw", "--no-windows", 90, 0 }, | 1897 { "-nw", "--no-windows", 90, 0 }, |
1903 { "-batch", "--batch", 85, 0 }, | 1898 { "-batch", "--batch", 85, 0 }, |
1904 { "-debug-paths", "--debug-paths", 82, 0 }, | 1899 { "-debug-paths", "--debug-paths", 82, 0 }, |
1905 { "-help", "--help", 80, 0 }, | 1900 { "-help", "--help", 80, 0 }, |
1906 { "-version", "--version", 75, 0 }, | 1901 { "-version", "--version", 75, 0 }, |
2091 xfree (new_argv); | 2086 xfree (new_argv); |
2092 xfree (options); | 2087 xfree (options); |
2093 xfree (priority); | 2088 xfree (priority); |
2094 } | 2089 } |
2095 | 2090 |
2096 static JMP_BUF run_temacs_catch; | |
2097 | |
2098 static int run_temacs_argc; | |
2099 static char **run_temacs_argv; | |
2100 static char *run_temacs_args; | |
2101 static size_t run_temacs_argv_size; | |
2102 static size_t run_temacs_args_size; | |
2103 | |
2104 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /* | 2091 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /* |
2105 True if running temacs. This means we are in the dumping stage. | 2092 True if running temacs. This means we are in the dumping stage. |
2106 This is false during normal execution of the `xemacs' program, and | 2093 This is false during normal execution of the `xemacs' program, and |
2107 becomes false once `run-emacs-from-temacs' is run. | 2094 becomes false once `run-emacs-from-temacs' is run. |
2108 */ | 2095 */ |
2173 catchlist = NULL; /* Important! Otherwise free_cons() calls in | 2160 catchlist = NULL; /* Important! Otherwise free_cons() calls in |
2174 condition_case_unwind() may lead to GC death. */ | 2161 condition_case_unwind() may lead to GC death. */ |
2175 unbind_to (0, Qnil); /* this closes loadup.el */ | 2162 unbind_to (0, Qnil); /* this closes loadup.el */ |
2176 purify_flag = 0; | 2163 purify_flag = 0; |
2177 run_temacs_argc = nargs + 1; | 2164 run_temacs_argc = nargs + 1; |
2178 #ifdef HEAP_IN_DATA | 2165 #if defined (HEAP_IN_DATA) && !defined(PDUMP) |
2179 report_sheap_usage (0); | 2166 report_sheap_usage (0); |
2180 #endif | 2167 #endif |
2181 LONGJMP (run_temacs_catch, 1); | 2168 LONGJMP (run_temacs_catch, 1); |
2182 return Qnil; /* not reached; warning suppression */ | 2169 return Qnil; /* not reached; warning suppression */ |
2183 } | 2170 } |
2279 if (initialized && (malloc_state_ptr != NULL)) | 2266 if (initialized && (malloc_state_ptr != NULL)) |
2280 { | 2267 { |
2281 int rc = malloc_set_state (malloc_state_ptr); | 2268 int rc = malloc_set_state (malloc_state_ptr); |
2282 if (rc != 0) | 2269 if (rc != 0) |
2283 { | 2270 { |
2284 fprintf (stderr, "malloc_set_state failed, rc = %d\n", rc); | 2271 stderr_out ("malloc_set_state failed, rc = %d\n", rc); |
2285 abort (); | 2272 abort (); |
2286 } | 2273 } |
2287 #if 0 | 2274 #if 0 |
2288 free (malloc_state_ptr); | 2275 free (malloc_state_ptr); |
2289 #endif | 2276 #endif |
2557 } | 2544 } |
2558 | 2545 |
2559 opurify = purify_flag; | 2546 opurify = purify_flag; |
2560 purify_flag = 0; | 2547 purify_flag = 0; |
2561 | 2548 |
2562 #ifdef HEAP_IN_DATA | 2549 #if defined (HEAP_IN_DATA) && !defined(PDUMP) |
2563 report_sheap_usage (1); | 2550 report_sheap_usage (1); |
2564 #endif | 2551 #endif |
2565 | 2552 |
2566 clear_message (); | 2553 clear_message (); |
2567 | 2554 |
2634 return Qnil; | 2621 return Qnil; |
2635 } | 2622 } |
2636 | 2623 |
2637 #endif /* not CANNOT_DUMP */ | 2624 #endif /* not CANNOT_DUMP */ |
2638 | 2625 |
2639 #ifndef SEPCHAR | |
2640 #define SEPCHAR ':' | |
2641 #endif | |
2642 | 2626 |
2643 /* Split STRING into a list of substrings. The substrings are the | 2627 /* Split STRING into a list of substrings. The substrings are the |
2644 parts of original STRING separated by SEPCHAR. */ | 2628 parts of original STRING separated by SEPCHAR. */ |
2645 static Lisp_Object | 2629 static Lisp_Object |
2646 split_string_by_emchar_1 (const Bufbyte *string, Bytecount size, | 2630 split_string_by_emchar_1 (const Bufbyte *string, Bytecount size, |
3162 | 3146 |
3163 DEFVAR_LISP ("data-directory", &Vdata_directory /* | 3147 DEFVAR_LISP ("data-directory", &Vdata_directory /* |
3164 *Directory of architecture-independent files that come with XEmacs, | 3148 *Directory of architecture-independent files that come with XEmacs, |
3165 intended for XEmacs to use. | 3149 intended for XEmacs to use. |
3166 Use of this variable in new code is almost never correct. See the | 3150 Use of this variable in new code is almost never correct. See the |
3167 function `locate-data-directory' and the variable `data-directory-list'. | 3151 functions `locate-data-file' and `locate-data-directory' and the variable |
3152 `data-directory-list'. | |
3168 */ ); | 3153 */ ); |
3169 Vdata_directory = Qnil; | 3154 Vdata_directory = Qnil; |
3170 | 3155 |
3171 DEFVAR_LISP ("configure-data-directory", &Vconfigure_data_directory /* | 3156 DEFVAR_LISP ("configure-data-directory", &Vconfigure_data_directory /* |
3172 For internal use by the build procedure only. | 3157 For internal use by the build procedure only. |