(main): Call syms_of_composite.
[bpt/emacs.git] / src / emacs.c
1 /* Fully extensible Emacs, running on Unix, intended for GNU.
2 Copyright (C) 1985,86,87,93,94,95,97,98,1999 Free Software Foundation, Inc.
3
4 This file is part of GNU Emacs.
5
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21
22 #include <config.h>
23 #include <signal.h>
24 #include <errno.h>
25 #include <stdio.h>
26
27 #include <sys/types.h>
28 #include <sys/file.h>
29
30 #ifdef VMS
31 #include <ssdef.h>
32 #endif
33
34 #ifdef HAVE_UNISTD_H
35 #include <unistd.h>
36 #endif
37
38 #ifdef BSD_SYSTEM
39 #include <sys/ioctl.h>
40 #endif
41
42 #include "lisp.h"
43 #include "commands.h"
44 #include "intervals.h"
45 #include "buffer.h"
46
47 #include "systty.h"
48 #include "blockinput.h"
49 #include "syssignal.h"
50 #include "process.h"
51 #include "termhooks.h"
52 #include "keyboard.h"
53
54 #ifdef HAVE_SETLOCALE
55 #include <locale.h>
56 #endif
57
58 #ifdef HAVE_SETRLIMIT
59 #include <sys/time.h>
60 #include <sys/resource.h>
61 #endif
62
63 #ifndef O_RDWR
64 #define O_RDWR 2
65 #endif
66
67 extern void malloc_warning ();
68 extern void set_time_zone_rule ();
69 extern char *index ();
70
71 /* Make these values available in GDB, which doesn't see macros. */
72
73 EMACS_INT gdb_valbits = VALBITS;
74 EMACS_INT gdb_gctypebits = GCTYPEBITS;
75 EMACS_INT gdb_emacs_intbits = sizeof (EMACS_INT) * BITS_PER_CHAR;
76 #ifdef DATA_SEG_BITS
77 EMACS_INT gdb_data_seg_bits = DATA_SEG_BITS;
78 #else
79 EMACS_INT gdb_data_seg_bits = 0;
80 #endif
81 EMACS_INT PVEC_FLAG = PSEUDOVECTOR_FLAG;
82
83 /* Command line args from shell, as list of strings */
84 Lisp_Object Vcommand_line_args;
85
86 /* The name under which Emacs was invoked, with any leading directory
87 names discarded. */
88 Lisp_Object Vinvocation_name;
89
90 /* The directory name from which Emacs was invoked. */
91 Lisp_Object Vinvocation_directory;
92
93 /* The directory name in which to find subdirs such as lisp and etc.
94 nil means get them only from PATH_LOADSEARCH. */
95 Lisp_Object Vinstallation_directory;
96
97 /* Hook run by `kill-emacs' before it does really anything. */
98 Lisp_Object Vkill_emacs_hook;
99
100 #ifdef SIGUSR1
101 /* Hooks for signal USR1 and USR2 handing */
102 Lisp_Object Vsignal_USR1_hook;
103 #ifdef SIGUSR2
104 Lisp_Object Vsignal_USR2_hook;
105 #endif
106 #endif
107
108 /* Search path separator. */
109 Lisp_Object Vpath_separator;
110
111 /* Set nonzero after Emacs has started up the first time.
112 Prevents reinitialization of the Lisp world and keymaps
113 on subsequent starts. */
114 int initialized;
115
116 #ifdef DOUG_LEA_MALLOC
117 /* Preserves a pointer to the memory allocated that copies that
118 static data inside glibc's malloc. */
119 void *malloc_state_ptr;
120 /* From glibc, a routine that returns a copy of the malloc internal state. */
121 extern void *malloc_get_state ();
122 /* From glibc, a routine that overwrites the malloc internal state. */
123 extern void malloc_set_state ();
124 /* Non-zero if the MALLOC_CHECK_ enviroment variable was set while
125 dumping. Used to work around a bug in glibc's malloc. */
126 int malloc_using_checking;
127 #endif
128
129 /* Variable whose value is symbol giving operating system type. */
130 Lisp_Object Vsystem_type;
131
132 /* Variable whose value is string giving configuration built for. */
133 Lisp_Object Vsystem_configuration;
134
135 /* Variable whose value is string giving configuration options,
136 for use when reporting bugs. */
137 Lisp_Object Vsystem_configuration_options;
138
139 Lisp_Object Qfile_name_handler_alist;
140
141 /* Current and previous system locales for messages and time. */
142 Lisp_Object Vsystem_messages_locale;
143 Lisp_Object Vprevious_system_messages_locale;
144 Lisp_Object Vsystem_time_locale;
145 Lisp_Object Vprevious_system_time_locale;
146
147 /* If non-zero, emacs should not attempt to use an window-specific code,
148 but instead should use the virtual terminal under which it was started */
149 int inhibit_window_system;
150
151 /* If nonzero, set Emacs to run at this priority. This is also used
152 in child_setup and sys_suspend to make sure subshells run at normal
153 priority; Those functions have their own extern declaration. */
154 int emacs_priority;
155
156 /* If non-zero a filter or a sentinel is running. Tested to save the match
157 data on the first attempt to change it inside asynchronous code. */
158 int running_asynch_code;
159
160 #ifdef BSD_PGRPS
161 /* See sysdep.c. */
162 extern int inherited_pgroup;
163 #endif
164
165 #ifdef HAVE_X_WINDOWS
166 /* If non-zero, -d was specified, meaning we're using some window system. */
167 int display_arg;
168 #endif
169
170 /* An address near the bottom of the stack.
171 Tells GC how to save a copy of the stack. */
172 char *stack_bottom;
173
174 #ifdef HAVE_WINDOW_SYSTEM
175 extern Lisp_Object Vwindow_system;
176 #endif /* HAVE_WINDOW_SYSTEM */
177
178 extern Lisp_Object Vauto_save_list_file_name;
179
180 #ifdef USG_SHARED_LIBRARIES
181 /* If nonzero, this is the place to put the end of the writable segment
182 at startup. */
183
184 unsigned int bss_end = 0;
185 #endif
186
187 /* Nonzero means running Emacs without interactive terminal. */
188
189 int noninteractive;
190
191 /* Value of Lisp variable `noninteractive'.
192 Normally same as C variable `noninteractive'
193 but nothing terrible happens if user sets this one. */
194
195 int noninteractive1;
196
197 /* Save argv and argc. */
198 char **initial_argv;
199 int initial_argc;
200
201 static void sort_args ();
202 void syms_of_emacs ();
203 \f
204 /* Signal code for the fatal signal that was received */
205 int fatal_error_code;
206
207 /* Nonzero if handling a fatal error already */
208 int fatal_error_in_progress;
209
210 #ifdef SIGUSR1
211 SIGTYPE
212 handle_USR1_signal (sig)
213 int sig;
214 {
215 struct input_event buf;
216
217 buf.kind = user_signal;
218 buf.code = 0;
219 buf.frame_or_window = selected_frame;
220 buf.modifiers = 0;
221 buf.timestamp = 0;
222
223 kbd_buffer_store_event (&buf);
224 }
225 #endif /* SIGUSR1 */
226
227 #ifdef SIGUSR2
228 SIGTYPE
229 handle_USR2_signal (sig)
230 int sig;
231 {
232 struct input_event buf;
233
234 buf.kind = user_signal;
235 buf.code = 1;
236 buf.frame_or_window = selected_frame;
237 buf.modifiers = 0;
238 buf.timestamp = 0;
239
240 kbd_buffer_store_event (&buf);
241 }
242 #endif /* SIGUSR2 */
243
244 /* Handle bus errors, illegal instruction, etc. */
245 SIGTYPE
246 fatal_error_signal (sig)
247 int sig;
248 {
249 fatal_error_code = sig;
250 signal (sig, SIG_DFL);
251
252 TOTALLY_UNBLOCK_INPUT;
253
254 /* If fatal error occurs in code below, avoid infinite recursion. */
255 if (! fatal_error_in_progress)
256 {
257 fatal_error_in_progress = 1;
258
259 shut_down_emacs (sig, 0, Qnil);
260 }
261
262 #ifdef VMS
263 LIB$STOP (SS$_ABORT);
264 #else
265 /* Signal the same code; this time it will really be fatal.
266 Remember that since we're in a signal handler, the signal we're
267 going to send is probably blocked, so we have to unblock it if we
268 want to really receive it. */
269 #ifndef MSDOS
270 sigunblock (sigmask (fatal_error_code));
271 #endif
272 kill (getpid (), fatal_error_code);
273 #endif /* not VMS */
274 }
275
276 #ifdef SIGDANGER
277
278 /* Handler for SIGDANGER. */
279 SIGTYPE
280 memory_warning_signal (sig)
281 int sig;
282 {
283 signal (sig, memory_warning_signal);
284
285 malloc_warning ("Operating system warns that virtual memory is running low.\n");
286
287 /* It might be unsafe to call do_auto_save now. */
288 force_auto_save_soon ();
289 }
290 #endif
291
292 /* We define abort, rather than using it from the library,
293 so that GDB can return from a breakpoint here.
294 MSDOS has its own definition on msdos.c */
295
296 #if ! defined (DOS_NT) && ! defined (NO_ABORT)
297
298 #ifndef ABORT_RETURN_TYPE
299 #define ABORT_RETURN_TYPE void
300 #endif
301
302 ABORT_RETURN_TYPE
303 abort ()
304 {
305 kill (getpid (), SIGABRT);
306 /* This shouldn't be executed, but it prevents a warning. */
307 exit (1);
308 }
309 #endif
310
311 \f
312 /* Code for dealing with Lisp access to the Unix command line */
313
314 static void
315 init_cmdargs (argc, argv, skip_args)
316 int argc;
317 char **argv;
318 int skip_args;
319 {
320 register int i;
321 Lisp_Object name, dir, tem;
322 int count = specpdl_ptr - specpdl;
323 Lisp_Object raw_name;
324
325 initial_argv = argv;
326 initial_argc = argc;
327
328 raw_name = build_string (argv[0]);
329
330 /* Add /: to the front of the name
331 if it would otherwise be treated as magic. */
332 tem = Ffind_file_name_handler (raw_name, Qt);
333 if (! NILP (tem))
334 raw_name = concat2 (build_string ("/:"), raw_name);
335
336 Vinvocation_name = Ffile_name_nondirectory (raw_name);
337 Vinvocation_directory = Ffile_name_directory (raw_name);
338
339 /* If we got no directory in argv[0], search PATH to find where
340 Emacs actually came from. */
341 if (NILP (Vinvocation_directory))
342 {
343 Lisp_Object found;
344 int yes = openp (Vexec_path, Vinvocation_name,
345 EXEC_SUFFIXES, &found, 1);
346 if (yes == 1)
347 {
348 /* Add /: to the front of the name
349 if it would otherwise be treated as magic. */
350 tem = Ffind_file_name_handler (found, Qt);
351 if (! NILP (tem))
352 found = concat2 (build_string ("/:"), found);
353 Vinvocation_directory = Ffile_name_directory (found);
354 }
355 }
356
357 if (!NILP (Vinvocation_directory)
358 && NILP (Ffile_name_absolute_p (Vinvocation_directory)))
359 /* Emacs was started with relative path, like ./emacs.
360 Make it absolute. */
361 Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, Qnil);
362
363 Vinstallation_directory = Qnil;
364
365 if (!NILP (Vinvocation_directory))
366 {
367 dir = Vinvocation_directory;
368 name = Fexpand_file_name (Vinvocation_name, dir);
369 while (1)
370 {
371 Lisp_Object tem, lib_src_exists;
372 Lisp_Object etc_exists, info_exists;
373
374 /* See if dir contains subdirs for use by Emacs.
375 Check for the ones that would exist in a build directory,
376 not including lisp and info. */
377 tem = Fexpand_file_name (build_string ("lib-src"), dir);
378 lib_src_exists = Ffile_exists_p (tem);
379
380 #ifdef MSDOS
381 /* MSDOS installations frequently remove lib-src, but we still
382 must set installation-directory, or else info won't find
383 its files (it uses the value of installation-directory). */
384 tem = Fexpand_file_name (build_string ("info"), dir);
385 info_exists = Ffile_exists_p (tem);
386 #else
387 info_exists = Qnil;
388 #endif
389
390 if (!NILP (lib_src_exists) || !NILP (info_exists))
391 {
392 tem = Fexpand_file_name (build_string ("etc"), dir);
393 etc_exists = Ffile_exists_p (tem);
394 if (!NILP (etc_exists))
395 {
396 Vinstallation_directory
397 = Ffile_name_as_directory (dir);
398 break;
399 }
400 }
401
402 /* See if dir's parent contains those subdirs. */
403 tem = Fexpand_file_name (build_string ("../lib-src"), dir);
404 lib_src_exists = Ffile_exists_p (tem);
405
406
407 #ifdef MSDOS
408 /* See the MSDOS commentary above. */
409 tem = Fexpand_file_name (build_string ("../info"), dir);
410 info_exists = Ffile_exists_p (tem);
411 #else
412 info_exists = Qnil;
413 #endif
414
415 if (!NILP (lib_src_exists) || !NILP (info_exists))
416 {
417 tem = Fexpand_file_name (build_string ("../etc"), dir);
418 etc_exists = Ffile_exists_p (tem);
419 if (!NILP (etc_exists))
420 {
421 tem = Fexpand_file_name (build_string (".."), dir);
422 Vinstallation_directory
423 = Ffile_name_as_directory (tem);
424 break;
425 }
426 }
427
428 /* If the Emacs executable is actually a link,
429 next try the dir that the link points into. */
430 tem = Ffile_symlink_p (name);
431 if (!NILP (tem))
432 {
433 name = Fexpand_file_name (tem, dir);
434 dir = Ffile_name_directory (name);
435 }
436 else
437 break;
438 }
439 }
440
441 Vcommand_line_args = Qnil;
442
443 for (i = argc - 1; i >= 0; i--)
444 {
445 if (i == 0 || i > skip_args)
446 Vcommand_line_args
447 = Fcons (build_string (argv[i]), Vcommand_line_args);
448 }
449
450 unbind_to (count, Qnil);
451 }
452
453 DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0,
454 "Return the program name that was used to run Emacs.\n\
455 Any directory names are omitted.")
456 ()
457 {
458 return Fcopy_sequence (Vinvocation_name);
459 }
460
461 DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory,
462 0, 0, 0,
463 "Return the directory name in which the Emacs executable was located")
464 ()
465 {
466 return Fcopy_sequence (Vinvocation_directory);
467 }
468
469 \f
470 #ifdef VMS
471 #ifdef LINK_CRTL_SHARE
472 #ifdef SHARABLE_LIB_BUG
473 extern noshare char **environ;
474 #endif /* SHARABLE_LIB_BUG */
475 #endif /* LINK_CRTL_SHARE */
476 #endif /* VMS */
477
478 #ifdef HAVE_TZSET
479 /* A valid but unlikely value for the TZ environment value.
480 It is OK (though a bit slower) if the user actually chooses this value. */
481 static char dump_tz[] = "UtC0";
482 #endif
483
484 #ifndef ORDINARY_LINK
485 /* We don't include crtbegin.o and crtend.o in the link,
486 so these functions and variables might be missed.
487 Provide dummy definitions to avoid error.
488 (We don't have any real constructors or destructors.) */
489 #ifdef __GNUC__
490 #ifndef GCC_CTORS_IN_LIBC
491 void __do_global_ctors ()
492 {}
493 void __do_global_ctors_aux ()
494 {}
495 void __do_global_dtors ()
496 {}
497 /* Linux has a bug in its library; avoid an error. */
498 #ifndef LINUX
499 char * __CTOR_LIST__[2] = { (char *) (-1), 0 };
500 #endif
501 char * __DTOR_LIST__[2] = { (char *) (-1), 0 };
502 #endif /* GCC_CTORS_IN_LIBC */
503 void __main ()
504 {}
505 #endif /* __GNUC__ */
506 #endif /* ORDINARY_LINK */
507
508 /* Test whether the next argument in ARGV matches SSTR or a prefix of
509 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
510 (the argument is supposed to have a value) store in *VALPTR either
511 the next argument or the portion of this one after the equal sign.
512 ARGV is read starting at position *SKIPPTR; this index is advanced
513 by the number of arguments used.
514
515 Too bad we can't just use getopt for all of this, but we don't have
516 enough information to do it right. */
517
518 static int
519 argmatch (argv, argc, sstr, lstr, minlen, valptr, skipptr)
520 char **argv;
521 int argc;
522 char *sstr;
523 char *lstr;
524 int minlen;
525 char **valptr;
526 int *skipptr;
527 {
528 char *p;
529 int arglen;
530 char *arg;
531
532 /* Don't access argv[argc]; give up in advance. */
533 if (argc <= *skipptr + 1)
534 return 0;
535
536 arg = argv[*skipptr+1];
537 if (arg == NULL)
538 return 0;
539 if (strcmp (arg, sstr) == 0)
540 {
541 if (valptr != NULL)
542 {
543 *valptr = argv[*skipptr+2];
544 *skipptr += 2;
545 }
546 else
547 *skipptr += 1;
548 return 1;
549 }
550 arglen = (valptr != NULL && (p = index (arg, '=')) != NULL
551 ? p - arg : strlen (arg));
552 if (lstr == 0 || arglen < minlen || strncmp (arg, lstr, arglen) != 0)
553 return 0;
554 else if (valptr == NULL)
555 {
556 *skipptr += 1;
557 return 1;
558 }
559 else if (p != NULL)
560 {
561 *valptr = p+1;
562 *skipptr += 1;
563 return 1;
564 }
565 else if (argv[*skipptr+2] != NULL)
566 {
567 *valptr = argv[*skipptr+2];
568 *skipptr += 2;
569 return 1;
570 }
571 else
572 {
573 return 0;
574 }
575 }
576
577 #ifdef DOUG_LEA_MALLOC
578
579 /* malloc can be invoked even before main (e.g. by the dynamic
580 linker), so the dumped malloc state must be restored as early as
581 possible using this special hook. */
582
583 static void
584 malloc_initialize_hook ()
585 {
586 extern char **environ;
587
588 if (initialized)
589 {
590 if (!malloc_using_checking)
591 /* Work around a bug in glibc's malloc. MALLOC_CHECK_ must be
592 ignored if the heap to be restored was constructed without
593 malloc checking. Can't use unsetenv, since that calls malloc. */
594 {
595 char **p;
596
597 for (p = environ; *p; p++)
598 if (strncmp (*p, "MALLOC_CHECK_=", 14) == 0)
599 {
600 do
601 *p = p[1];
602 while (*++p);
603 break;
604 }
605 }
606
607 malloc_set_state (malloc_state_ptr);
608 free (malloc_state_ptr);
609 }
610 else
611 malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL;
612 }
613
614 void (*__malloc_initialize_hook) () = malloc_initialize_hook;
615
616 #endif /* DOUG_LEA_MALLOC */
617
618 /* ARGSUSED */
619 int
620 main (argc, argv, envp)
621 int argc;
622 char **argv;
623 char **envp;
624 {
625 char stack_bottom_variable;
626 int do_initial_setlocale;
627 int skip_args = 0;
628 extern int errno;
629 extern int sys_nerr;
630 #ifdef HAVE_SETRLIMIT
631 struct rlimit rlim;
632 #endif
633 int no_loadup = 0;
634
635 #ifdef LINUX_SBRK_BUG
636 __sbrk (1);
637 #endif
638
639 #ifdef RUN_TIME_REMAP
640 if (initialized)
641 run_time_remap (argv[0]);
642 #endif
643
644 sort_args (argc, argv);
645 argc = 0;
646 while (argv[argc]) argc++;
647
648 if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args)
649 /* We don't know the version number unless this is a dumped Emacs.
650 So ignore --version otherwise. */
651 && initialized)
652 {
653 Lisp_Object tem;
654 tem = Fsymbol_value (intern ("emacs-version"));
655 if (!STRINGP (tem))
656 {
657 fprintf (stderr, "Invalid value of `emacs-version'\n");
658 exit (1);
659 }
660 else
661 {
662 printf ("GNU Emacs %s\n", XSTRING (tem)->data);
663 printf ("Copyright (C) 1999 Free Software Foundation, Inc.\n");
664 printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
665 printf ("You may redistribute copies of Emacs\n");
666 printf ("under the terms of the GNU General Public License.\n");
667 printf ("For more information about these matters, ");
668 printf ("see the file named COPYING.\n");
669 exit (0);
670 }
671 }
672
673 /* Map in shared memory, if we are using that. */
674 #ifdef HAVE_SHM
675 if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
676 {
677 map_in_data (0);
678 /* The shared memory was just restored, which clobbered this. */
679 skip_args = 1;
680 }
681 else
682 {
683 map_in_data (1);
684 /* The shared memory was just restored, which clobbered this. */
685 skip_args = 0;
686 }
687 #endif
688
689 #ifdef NeXT
690 {
691 extern int malloc_cookie;
692 /* This helps out unexnext.c. */
693 if (initialized)
694 if (malloc_jumpstart (malloc_cookie) != 0)
695 printf ("malloc jumpstart failed!\n");
696 }
697 #endif /* NeXT */
698
699 #ifdef VMS
700 /* If -map specified, map the data file in */
701 {
702 char *file;
703 if (argmatch (argv, argc, "-map", "--map-data", 3, &mapin_file, &skip_args))
704 mapin_data (file);
705 }
706
707 #ifdef LINK_CRTL_SHARE
708 #ifdef SHARABLE_LIB_BUG
709 /* Bletcherous shared libraries! */
710 if (!stdin)
711 stdin = fdopen (0, "r");
712 if (!stdout)
713 stdout = fdopen (1, "w");
714 if (!stderr)
715 stderr = fdopen (2, "w");
716 if (!environ)
717 environ = envp;
718 #endif /* SHARABLE_LIB_BUG */
719 #endif /* LINK_CRTL_SHARE */
720 #endif /* VMS */
721
722 #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK)
723 /* Extend the stack space available.
724 Don't do that if dumping, since some systems (e.g. DJGPP)
725 might define a smaller stack limit at that time. */
726 if (1
727 #ifndef CANNOT_DUMP
728 && (!noninteractive || initialized)
729 #endif
730 && !getrlimit (RLIMIT_STACK, &rlim))
731 {
732 long newlim;
733 extern int re_max_failures;
734 /* Approximate the amount regex.c needs per unit of re_max_failures. */
735 int ratio = 20 * sizeof (char *);
736 /* Then add 33% to cover the size of the smaller stacks that regex.c
737 successively allocates and discards, on its way to the maximum. */
738 ratio += ratio / 3;
739 /* Add in some extra to cover
740 what we're likely to use for other reasons. */
741 newlim = re_max_failures * ratio + 200000;
742 #ifdef __NetBSD__
743 /* NetBSD (at least NetBSD 1.2G and former) has a bug in its
744 stack allocation routine for new process that the allocation
745 fails if stack limit is not on page boundary. So, round up the
746 new limit to page boundary. */
747 newlim = (newlim + getpagesize () - 1) / getpagesize () * getpagesize();
748 #endif
749 if (newlim > rlim.rlim_max)
750 {
751 newlim = rlim.rlim_max;
752 /* Don't let regex.c overflow the stack we have. */
753 re_max_failures = (newlim - 200000) / ratio;
754 }
755 if (rlim.rlim_cur < newlim)
756 rlim.rlim_cur = newlim;
757
758 setrlimit (RLIMIT_STACK, &rlim);
759 }
760 #endif /* HAVE_SETRLIMIT and RLIMIT_STACK */
761
762 /* Record (approximately) where the stack begins. */
763 stack_bottom = &stack_bottom_variable;
764
765 #ifdef USG_SHARED_LIBRARIES
766 if (bss_end)
767 brk ((void *)bss_end);
768 #endif
769
770 clearerr (stdin);
771
772 #ifndef SYSTEM_MALLOC
773 /* Arrange to get warning messages as memory fills up. */
774 memory_warnings (0, malloc_warning);
775
776 /* Call malloc at least once, to run the initial __malloc_hook.
777 Also call realloc and free for consistency. */
778 free (realloc (malloc (4), 4));
779
780 /* Arrange to disable interrupt input inside malloc etc. */
781 uninterrupt_malloc ();
782 #endif /* not SYSTEM_MALLOC */
783
784 #ifdef MSDOS
785 /* We do all file input/output as binary files. When we need to translate
786 newlines, we do that manually. */
787 _fmode = O_BINARY;
788
789 #if __DJGPP__ >= 2
790 if (!isatty (fileno (stdin)))
791 setmode (fileno (stdin), O_BINARY);
792 if (!isatty (fileno (stdout)))
793 {
794 fflush (stdout);
795 setmode (fileno (stdout), O_BINARY);
796 }
797 #else /* not __DJGPP__ >= 2 */
798 (stdin)->_flag &= ~_IOTEXT;
799 (stdout)->_flag &= ~_IOTEXT;
800 (stderr)->_flag &= ~_IOTEXT;
801 #endif /* not __DJGPP__ >= 2 */
802 #endif /* MSDOS */
803
804 #ifdef SET_EMACS_PRIORITY
805 if (emacs_priority)
806 nice (emacs_priority);
807 setuid (getuid ());
808 #endif /* SET_EMACS_PRIORITY */
809
810 /* Skip initial setlocale if LC_ALL is "C", as it's not needed in that case.
811 The build procedure uses this while dumping, to ensure that the
812 dumped Emacs does not have its system locale tables initialized,
813 as that might cause screwups when the dumped Emacs starts up. */
814 {
815 char *lc_all = getenv ("LC_ALL");
816 do_initial_setlocale = ! lc_all || strcmp (lc_all, "C");
817 }
818
819 /* Set locale now, so that initial error messages are localized properly.
820 fixup_locale must wait until later, since it builds strings. */
821 if (do_initial_setlocale)
822 setlocale (LC_ALL, "");
823
824 #ifdef EXTRA_INITIALIZE
825 EXTRA_INITIALIZE;
826 #endif
827
828 inhibit_window_system = 0;
829
830 /* Handle the -t switch, which specifies filename to use as terminal */
831 while (1)
832 {
833 char *term;
834 if (argmatch (argv, argc, "-t", "--terminal", 4, &term, &skip_args))
835 {
836 int result;
837 emacs_close (0);
838 emacs_close (1);
839 result = emacs_open (term, O_RDWR, 0);
840 if (result < 0)
841 {
842 char *errstring = strerror (errno);
843 fprintf (stderr, "emacs: %s: %s\n", term, errstring);
844 exit (1);
845 }
846 dup (0);
847 if (! isatty (0))
848 {
849 fprintf (stderr, "emacs: %s: not a tty\n", term);
850 exit (1);
851 }
852 fprintf (stderr, "Using %s\n", term);
853 #ifdef HAVE_WINDOW_SYSTEM
854 inhibit_window_system = 1; /* -t => -nw */
855 #endif
856 }
857 else
858 break;
859 }
860
861 if (argmatch (argv, argc, "-nw", "--no-windows", 6, NULL, &skip_args))
862 inhibit_window_system = 1;
863
864 /* Handle the -batch switch, which means don't do interactive display. */
865 noninteractive = 0;
866 if (argmatch (argv, argc, "-batch", "--batch", 5, NULL, &skip_args))
867 noninteractive = 1;
868
869 /* Handle the --help option, which gives a usage message.. */
870 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
871 {
872 printf ("\
873 Usage: %s [--batch] [-t term] [--terminal term]\n\
874 [-d display] [--display display] [-nw] [--no-windows]\n\
875 [-q] [--no-init-file] [-u user] [--user user] [--debug-init]\n\
876 [--unibyte] [--multibyte] [--version] [--no-site-file]\n\
877 [-f func] [--funcall func] [-l file] [--load file] [--eval expr]\n\
878 [--execute expr] [--visit file] [--file file] [--insert file]\n\
879 [+linenum] file-to-visit [--kill]\n\
880 Report bugs to bug-gnu-emacs@gnu.org. First, please see\n\
881 the Bugs section of the Emacs manual or the file BUGS.\n", argv[0]);
882 exit (0);
883 }
884
885 if (! noninteractive)
886 {
887 #ifdef BSD_PGRPS
888 if (initialized)
889 {
890 inherited_pgroup = EMACS_GETPGRP (0);
891 setpgrp (0, getpid ());
892 }
893 #else
894 #if defined (USG5) && defined (INTERRUPT_INPUT)
895 setpgrp ();
896 #endif
897 #endif
898 }
899
900 init_signals ();
901
902 /* Don't catch SIGHUP if dumping. */
903 if (1
904 #ifndef CANNOT_DUMP
905 && initialized
906 #endif
907 )
908 {
909 sigblock (sigmask (SIGHUP));
910 /* In --batch mode, don't catch SIGHUP if already ignored.
911 That makes nohup work. */
912 if (! noninteractive
913 || signal (SIGHUP, SIG_IGN) != SIG_IGN)
914 signal (SIGHUP, fatal_error_signal);
915 sigunblock (sigmask (SIGHUP));
916 }
917
918 if (
919 #ifndef CANNOT_DUMP
920 ! noninteractive || initialized
921 #else
922 1
923 #endif
924 )
925 {
926 /* Don't catch these signals in batch mode if dumping.
927 On some machines, this sets static data that would make
928 signal fail to work right when the dumped Emacs is run. */
929 signal (SIGQUIT, fatal_error_signal);
930 signal (SIGILL, fatal_error_signal);
931 signal (SIGTRAP, fatal_error_signal);
932 #ifdef SIGUSR1
933 signal (SIGUSR1, handle_USR1_signal);
934 #ifdef SIGUSR2
935 signal (SIGUSR2, handle_USR2_signal);
936 #endif
937 #endif
938 #ifdef SIGABRT
939 signal (SIGABRT, fatal_error_signal);
940 #endif
941 #ifdef SIGHWE
942 signal (SIGHWE, fatal_error_signal);
943 #endif
944 #ifdef SIGPRE
945 signal (SIGPRE, fatal_error_signal);
946 #endif
947 #ifdef SIGORE
948 signal (SIGORE, fatal_error_signal);
949 #endif
950 #ifdef SIGUME
951 signal (SIGUME, fatal_error_signal);
952 #endif
953 #ifdef SIGDLK
954 signal (SIGDLK, fatal_error_signal);
955 #endif
956 #ifdef SIGCPULIM
957 signal (SIGCPULIM, fatal_error_signal);
958 #endif
959 #ifdef SIGIOT
960 /* This is missing on some systems - OS/2, for example. */
961 signal (SIGIOT, fatal_error_signal);
962 #endif
963 #ifdef SIGEMT
964 signal (SIGEMT, fatal_error_signal);
965 #endif
966 signal (SIGFPE, fatal_error_signal);
967 #ifdef SIGBUS
968 signal (SIGBUS, fatal_error_signal);
969 #endif
970 signal (SIGSEGV, fatal_error_signal);
971 #ifdef SIGSYS
972 signal (SIGSYS, fatal_error_signal);
973 #endif
974 signal (SIGTERM, fatal_error_signal);
975 #ifdef SIGXCPU
976 signal (SIGXCPU, fatal_error_signal);
977 #endif
978 #ifdef SIGXFSZ
979 signal (SIGXFSZ, fatal_error_signal);
980 #endif /* SIGXFSZ */
981
982 #ifdef SIGDANGER
983 /* This just means available memory is getting low. */
984 signal (SIGDANGER, memory_warning_signal);
985 #endif
986
987 #ifdef AIX
988 /* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */
989 signal (SIGXCPU, fatal_error_signal);
990 #ifndef _I386
991 signal (SIGIOINT, fatal_error_signal);
992 #endif
993 signal (SIGGRANT, fatal_error_signal);
994 signal (SIGRETRACT, fatal_error_signal);
995 signal (SIGSOUND, fatal_error_signal);
996 signal (SIGMSG, fatal_error_signal);
997 #endif /* AIX */
998 }
999
1000 noninteractive1 = noninteractive;
1001
1002 /* Perform basic initializations (not merely interning symbols) */
1003
1004 if (!initialized)
1005 {
1006 init_alloc_once ();
1007 init_obarray ();
1008 init_eval_once ();
1009 init_charset_once ();
1010 init_coding_once ();
1011 init_syntax_once (); /* Create standard syntax table. */
1012 init_category_once (); /* Create standard category table. */
1013 /* Must be done before init_buffer */
1014 init_casetab_once ();
1015 init_buffer_once (); /* Create buffer table and some buffers */
1016 init_minibuf_once (); /* Create list of minibuffers */
1017 /* Must precede init_window_once */
1018
1019 /* Call syms_of_xfaces before init_window_once because that
1020 function creates Vterminal_frame. Termcap frames now use
1021 faces, and the face implementation uses some symbols as
1022 face names. */
1023 #ifndef HAVE_NTGUI
1024 syms_of_xfaces ();
1025 #endif
1026
1027 init_window_once (); /* Init the window system */
1028 init_fileio_once (); /* Must precede any path manipulation. */
1029 }
1030
1031 init_alloc ();
1032
1033 if (do_initial_setlocale)
1034 {
1035 fixup_locale ();
1036 Vsystem_messages_locale = Vprevious_system_messages_locale;
1037 Vsystem_time_locale = Vprevious_system_time_locale;
1038 }
1039
1040 init_eval ();
1041 init_coding ();
1042 init_data ();
1043 #ifdef CLASH_DETECTION
1044 init_filelock ();;
1045 #endif
1046 running_asynch_code = 0;
1047
1048 /* Handle --unibyte and the EMACS_UNIBYTE envvar,
1049 but not while dumping. */
1050 if (
1051 #ifndef CANNOT_DUMP
1052 ! noninteractive || initialized
1053 #else
1054 1
1055 #endif
1056 )
1057 {
1058 int inhibit_unibyte = 0;
1059
1060 /* --multibyte overrides EMACS_UNIBYTE. */
1061 if (argmatch (argv, argc, "-no-unibyte", "--no-unibyte", 4, NULL, &skip_args)
1062 || argmatch (argv, argc, "-multibyte", "--multibyte", 4, NULL, &skip_args))
1063 inhibit_unibyte = 1;
1064
1065 /* --unibyte requests that we set up to do everything with single-byte
1066 buffers and strings. We need to handle this before calling
1067 init_lread, init_editfns and other places that generate Lisp strings
1068 from text in the environment. */
1069 /* Actually this shouldn't be needed as of 20.4 in a generally
1070 unibyte environment. As handa says, environment values
1071 aren't now decoded; also existing buffers are now made
1072 unibyte during startup if .emacs sets unibyte. Tested with
1073 8-bit data in environment variables and /etc/passwd, setting
1074 unibyte and Latin-1 in .emacs. -- Dave Love */
1075 if (argmatch (argv, argc, "-unibyte", "--unibyte", 4, NULL, &skip_args)
1076 || argmatch (argv, argc, "-no-multibyte", "--no-multibyte", 4, NULL, &skip_args)
1077 || (getenv ("EMACS_UNIBYTE") && !inhibit_unibyte))
1078 {
1079 Lisp_Object old_log_max;
1080 Lisp_Object symbol, tail;
1081
1082 symbol = intern ("default-enable-multibyte-characters");
1083 Fset (symbol, Qnil);
1084
1085 if (initialized)
1086 {
1087 /* Erase pre-dump messages in *Messages* now so no abort. */
1088 old_log_max = Vmessage_log_max;
1089 XSETFASTINT (Vmessage_log_max, 0);
1090 message_dolog ("", 0, 1, 0);
1091 Vmessage_log_max = old_log_max;
1092 }
1093
1094 for (tail = Vbuffer_alist; CONSP (tail);
1095 tail = XCDR (tail))
1096 {
1097 Lisp_Object buffer;
1098
1099 buffer = Fcdr (XCAR (tail));
1100 /* Verify that all buffers are empty now, as they
1101 ought to be. */
1102 if (BUF_Z (XBUFFER (buffer)) > BUF_BEG (XBUFFER (buffer)))
1103 abort ();
1104 /* It is safe to do this crudely in an empty buffer. */
1105 XBUFFER (buffer)->enable_multibyte_characters = Qnil;
1106 }
1107 }
1108 }
1109
1110 no_loadup
1111 = !argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args);
1112
1113
1114 #ifdef HAVE_X_WINDOWS
1115 /* Stupid kludge to catch command-line display spec. We can't
1116 handle this argument entirely in window system dependent code
1117 because we don't even know which window system dependent code
1118 to run until we've recognized this argument. */
1119 {
1120 char *displayname = 0;
1121 int count_before = skip_args;
1122
1123 /* Skip any number of -d options, but only use the last one. */
1124 while (1)
1125 {
1126 int count_before_this = skip_args;
1127
1128 if (argmatch (argv, argc, "-d", "--display", 3, &displayname, &skip_args))
1129 display_arg = 1;
1130 else if (argmatch (argv, argc, "-display", 0, 3, &displayname, &skip_args))
1131 display_arg = 1;
1132 else
1133 break;
1134
1135 count_before = count_before_this;
1136 }
1137
1138 /* If we have the form --display=NAME,
1139 convert it into -d name.
1140 This requires inserting a new element into argv. */
1141 if (displayname != 0 && skip_args - count_before == 1)
1142 {
1143 char **new = (char **) xmalloc (sizeof (char *) * (argc + 2));
1144 int j;
1145
1146 for (j = 0; j < count_before + 1; j++)
1147 new[j] = argv[j];
1148 new[count_before + 1] = "-d";
1149 new[count_before + 2] = displayname;
1150 for (j = count_before + 2; j <argc; j++)
1151 new[j + 1] = argv[j];
1152 argv = new;
1153 argc++;
1154 }
1155 /* Change --display to -d, when its arg is separate. */
1156 else if (displayname != 0 && skip_args > count_before
1157 && argv[count_before + 1][1] == '-')
1158 argv[count_before + 1] = "-d";
1159
1160 /* Don't actually discard this arg. */
1161 skip_args = count_before;
1162 }
1163 #endif
1164
1165 /* argmatch must not be used after here,
1166 except when bulding temacs
1167 because the -d argument has not been skipped in skip_args. */
1168
1169 #ifdef MSDOS
1170 /* Call early 'cause init_environment needs it. */
1171 init_dosfns ();
1172 /* Set defaults for several environment variables. */
1173 if (initialized)
1174 init_environment (argc, argv, skip_args);
1175 else
1176 tzset ();
1177 #endif /* MSDOS */
1178
1179 #ifdef WINDOWSNT
1180 /* Initialize environment from registry settings. */
1181 init_environment (argv);
1182 init_ntproc (); /* must precede init_editfns */
1183 #endif
1184
1185 /* egetenv is a pretty low-level facility, which may get called in
1186 many circumstances; it seems flimsy to put off initializing it
1187 until calling init_callproc. */
1188 set_process_environment ();
1189 /* AIX crashes are reported in system versions 3.2.3 and 3.2.4
1190 if this is not done. Do it after set_process_environment so that we
1191 don't pollute Vprocess_environment. */
1192 /* Setting LANG here will defeat the startup locale processing... */
1193 #ifdef AIX3_2
1194 putenv ("LANG=C");
1195 #endif
1196
1197 init_buffer (); /* Init default directory of main buffer */
1198
1199 init_callproc_1 (); /* Must precede init_cmdargs and init_sys_modes. */
1200 init_cmdargs (argc, argv, skip_args); /* Must precede init_lread. */
1201
1202 if (initialized)
1203 {
1204 /* Erase any pre-dump messages in the message log, to avoid confusion */
1205 Lisp_Object old_log_max;
1206 old_log_max = Vmessage_log_max;
1207 XSETFASTINT (Vmessage_log_max, 0);
1208 message_dolog ("", 0, 1, 0);
1209 Vmessage_log_max = old_log_max;
1210 }
1211
1212 init_callproc (); /* Must follow init_cmdargs but not init_sys_modes. */
1213 init_lread ();
1214
1215 /* Intern the names of all standard functions and variables;
1216 define standard keys. */
1217
1218 if (!initialized)
1219 {
1220 /* The basic levels of Lisp must come first */
1221 /* And data must come first of all
1222 for the sake of symbols like error-message */
1223 syms_of_data ();
1224 syms_of_alloc ();
1225 syms_of_lread ();
1226 syms_of_print ();
1227 syms_of_eval ();
1228 syms_of_fns ();
1229 syms_of_floatfns ();
1230
1231 syms_of_abbrev ();
1232 syms_of_buffer ();
1233 syms_of_bytecode ();
1234 syms_of_callint ();
1235 syms_of_casefiddle ();
1236 syms_of_casetab ();
1237 syms_of_callproc ();
1238 syms_of_category ();
1239 syms_of_ccl ();
1240 syms_of_charset ();
1241 syms_of_cmds ();
1242 #ifndef NO_DIR_LIBRARY
1243 syms_of_dired ();
1244 #endif /* not NO_DIR_LIBRARY */
1245 syms_of_display ();
1246 syms_of_doc ();
1247 syms_of_editfns ();
1248 syms_of_emacs ();
1249 syms_of_fileio ();
1250 syms_of_coding (); /* This should be after syms_of_fileio. */
1251 #ifdef CLASH_DETECTION
1252 syms_of_filelock ();
1253 #endif /* CLASH_DETECTION */
1254 syms_of_indent ();
1255 syms_of_insdel ();
1256 syms_of_keyboard ();
1257 syms_of_keymap ();
1258 syms_of_macros ();
1259 syms_of_marker ();
1260 syms_of_minibuf ();
1261 syms_of_mocklisp ();
1262 syms_of_process ();
1263 syms_of_search ();
1264 syms_of_frame ();
1265 syms_of_syntax ();
1266 syms_of_term ();
1267 syms_of_undo ();
1268 #ifdef HAVE_SOUND
1269 syms_of_sound ();
1270 #endif
1271
1272 syms_of_textprop ();
1273 syms_of_composite ();
1274 #ifdef VMS
1275 syms_of_vmsproc ();
1276 #endif /* VMS */
1277 #ifdef WINDOWSNT
1278 syms_of_ntproc ();
1279 #endif /* WINDOWSNT */
1280 syms_of_window ();
1281 syms_of_xdisp ();
1282 #ifdef HAVE_X_WINDOWS
1283 syms_of_xterm ();
1284 syms_of_xfns ();
1285 syms_of_fontset ();
1286 #ifdef HAVE_X11
1287 syms_of_xselect ();
1288 #endif
1289 #endif /* HAVE_X_WINDOWS */
1290
1291 #ifndef HAVE_NTGUI
1292 syms_of_xmenu ();
1293 #endif
1294
1295 #ifdef HAVE_NTGUI
1296 syms_of_w32term ();
1297 syms_of_w32fns ();
1298 syms_of_w32faces ();
1299 syms_of_w32select ();
1300 syms_of_w32menu ();
1301 syms_of_fontset ();
1302 #endif /* HAVE_NTGUI */
1303
1304 #ifdef SYMS_SYSTEM
1305 SYMS_SYSTEM;
1306 #endif
1307
1308 #ifdef SYMS_MACHINE
1309 SYMS_MACHINE;
1310 #endif
1311
1312 keys_of_casefiddle ();
1313 keys_of_cmds ();
1314 keys_of_buffer ();
1315 keys_of_keyboard ();
1316 keys_of_keymap ();
1317 keys_of_macros ();
1318 keys_of_minibuf ();
1319 keys_of_window ();
1320 keys_of_frame ();
1321 }
1322
1323 if (!noninteractive)
1324 {
1325 #ifdef VMS
1326 init_vms_input ();/* init_display calls get_frame_size, that needs this */
1327 #endif /* VMS */
1328 init_display (); /* Determine terminal type. init_sys_modes uses results */
1329 }
1330 init_keyboard (); /* This too must precede init_sys_modes */
1331 #ifdef VMS
1332 init_vmsproc (); /* And this too. */
1333 #endif /* VMS */
1334 init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.) */
1335 #ifdef HAVE_X_WINDOWS
1336 init_xfns ();
1337 #endif /* HAVE_X_WINDOWS */
1338 init_fns ();
1339 init_xdisp ();
1340 init_macros ();
1341 init_editfns ();
1342 #ifdef LISP_FLOAT_TYPE
1343 init_floatfns ();
1344 #endif
1345 #ifdef VMS
1346 init_vmsfns ();
1347 #endif /* VMS */
1348 init_process ();
1349 #ifdef HAVE_SOUND
1350 init_sound ();
1351 #endif
1352
1353 if (!initialized)
1354 {
1355 char *file;
1356 /* Handle -l loadup, args passed by Makefile. */
1357 if (argmatch (argv, argc, "-l", "--load", 3, &file, &skip_args))
1358 Vtop_level = Fcons (intern ("load"),
1359 Fcons (build_string (file), Qnil));
1360 #ifdef CANNOT_DUMP
1361 /* Unless next switch is -nl, load "loadup.el" first thing. */
1362 if (! no_loadup)
1363 Vtop_level = Fcons (intern ("load"),
1364 Fcons (build_string ("loadup.el"), Qnil));
1365 #endif /* CANNOT_DUMP */
1366 }
1367
1368 if (initialized)
1369 {
1370 #ifdef HAVE_TZSET
1371 {
1372 /* If the execution TZ happens to be the same as the dump TZ,
1373 change it to some other value and then change it back,
1374 to force the underlying implementation to reload the TZ info.
1375 This is needed on implementations that load TZ info from files,
1376 since the TZ file contents may differ between dump and execution. */
1377 char *tz = getenv ("TZ");
1378 if (tz && !strcmp (tz, dump_tz))
1379 {
1380 ++*tz;
1381 tzset ();
1382 --*tz;
1383 }
1384 }
1385 #endif
1386 }
1387
1388 /* Gerd Moellmann <gerd@acm.org> says this makes profiling work on
1389 FreeBSD. It might work on some other systems too.
1390 Give it a try and tell me if it works on your system. */
1391 #if defined (__FreeBSD__) || defined (__linux)
1392 #ifdef PROFILING
1393 if (initialized)
1394 {
1395 extern void _mcleanup ();
1396 extern char etext;
1397 extern void safe_bcopy ();
1398 extern void dump_opcode_frequencies ();
1399
1400 atexit (_mcleanup);
1401 // atexit (dump_opcode_frequencies);
1402 /* This uses safe_bcopy because that function comes first in the
1403 Emacs executable. It might be better to use something that
1404 gives the start of the text segment, but start_of_text is not
1405 defined on all systems now. */
1406 monstartup (safe_bcopy, &etext);
1407 }
1408 else
1409 moncontrol (0);
1410 #endif
1411 #endif
1412
1413 initialized = 1;
1414
1415 #ifdef LOCALTIME_CACHE
1416 /* Some versions of localtime have a bug. They cache the value of the time
1417 zone rather than looking it up every time. Since localtime() is
1418 called to bolt the undumping time into the undumped emacs, this
1419 results in localtime ignoring the TZ environment variable.
1420 This flushes the new TZ value into localtime. */
1421 tzset ();
1422 #endif /* defined (LOCALTIME_CACHE) */
1423
1424 /* Enter editor command loop. This never returns. */
1425 Frecursive_edit ();
1426 /* NOTREACHED */
1427 }
1428 \f
1429 /* Sort the args so we can find the most important ones
1430 at the beginning of argv. */
1431
1432 /* First, here's a table of all the standard options. */
1433
1434 struct standard_args
1435 {
1436 char *name;
1437 char *longname;
1438 int priority;
1439 int nargs;
1440 };
1441
1442 struct standard_args standard_args[] =
1443 {
1444 { "-version", "--version", 150, 0 },
1445 #ifdef HAVE_SHM
1446 { "-nl", "--no-shared-memory", 140, 0 },
1447 #endif
1448 #ifdef VMS
1449 { "-map", "--map-data", 130, 0 },
1450 #endif
1451 { "-t", "--terminal", 120, 1 },
1452 { "-nw", "--no-windows", 110, 0 },
1453 { "-batch", "--batch", 100, 0 },
1454 { "-help", "--help", 90, 0 },
1455 { "-no-unibyte", "--no-unibyte", 83, 0 },
1456 { "-multibyte", "--multibyte", 82, 0 },
1457 { "-unibyte", "--unibyte", 81, 0 },
1458 { "-no-multibyte", "--no-multibyte", 80, 0 },
1459 #ifdef CANNOT_DUMP
1460 { "-nl", "--no-loadup", 70, 0 },
1461 #endif
1462 /* -d must come last before the options handled in startup.el. */
1463 { "-d", "--display", 60, 1 },
1464 { "-display", 0, 60, 1 },
1465 /* Now for the options handled in startup.el. */
1466 { "-q", "--no-init-file", 50, 0 },
1467 { "-no-init-file", 0, 50, 0 },
1468 { "-no-site-file", "--no-site-file", 40, 0 },
1469 { "-u", "--user", 30, 1 },
1470 { "-user", 0, 30, 1 },
1471 { "-debug-init", "--debug-init", 20, 0 },
1472 { "-i", "--icon-type", 15, 0 },
1473 { "-itype", 0, 15, 0 },
1474 { "-iconic", "--iconic", 15, 0 },
1475 { "-bg", "--background-color", 10, 1 },
1476 { "-background", 0, 10, 1 },
1477 { "-fg", "--foreground-color", 10, 1 },
1478 { "-foreground", 0, 10, 1 },
1479 { "-bd", "--border-color", 10, 1 },
1480 { "-bw", "--border-width", 10, 1 },
1481 { "-ib", "--internal-border", 10, 1 },
1482 { "-ms", "--mouse-color", 10, 1 },
1483 { "-cr", "--cursor-color", 10, 1 },
1484 { "-fn", "--font", 10, 1 },
1485 { "-font", 0, 10, 1 },
1486 { "-g", "--geometry", 10, 1 },
1487 { "-geometry", 0, 10, 1 },
1488 { "-T", "--title", 10, 1 },
1489 { "-title", 0, 10, 1 },
1490 { "-name", "--name", 10, 1 },
1491 { "-xrm", "--xrm", 10, 1 },
1492 { "-r", "--reverse-video", 5, 0 },
1493 { "-rv", 0, 5, 0 },
1494 { "-reverse", 0, 5, 0 },
1495 { "-hb", "--horizontal-scroll-bars", 5, 0 },
1496 { "-vb", "--vertical-scroll-bars", 5, 0 },
1497 /* These have the same priority as ordinary file name args,
1498 so they are not reordered with respect to those. */
1499 { "-L", "--directory", 0, 1 },
1500 { "-directory", 0, 0, 1 },
1501 { "-l", "--load", 0, 1 },
1502 { "-load", 0, 0, 1 },
1503 { "-f", "--funcall", 0, 1 },
1504 { "-funcall", 0, 0, 1 },
1505 { "-eval", "--eval", 0, 1 },
1506 { "-execute", "--execute", 0, 1 },
1507 { "-find-file", "--find-file", 0, 1 },
1508 { "-visit", "--visit", 0, 1 },
1509 { "-file", "--file", 0, 1 },
1510 { "-insert", "--insert", 0, 1 },
1511 /* This should be processed after ordinary file name args and the like. */
1512 { "-kill", "--kill", -10, 0 },
1513 };
1514
1515 /* Reorder the elements of ARGV (assumed to have ARGC elements)
1516 so that the highest priority ones come first.
1517 Do not change the order of elements of equal priority.
1518 If an option takes an argument, keep it and its argument together.
1519
1520 If an option that takes no argument appears more
1521 than once, eliminate all but one copy of it. */
1522
1523 static void
1524 sort_args (argc, argv)
1525 int argc;
1526 char **argv;
1527 {
1528 char **new = (char **) xmalloc (sizeof (char *) * argc);
1529 /* For each element of argv,
1530 the corresponding element of options is:
1531 0 for an option that takes no arguments,
1532 1 for an option that takes one argument, etc.
1533 -1 for an ordinary non-option argument. */
1534 int *options = (int *) xmalloc (sizeof (int) * argc);
1535 int *priority = (int *) xmalloc (sizeof (int) * argc);
1536 int to = 1;
1537 int incoming_used = 1;
1538 int from;
1539 int i;
1540
1541 /* Categorize all the options,
1542 and figure out which argv elts are option arguments. */
1543 for (from = 1; from < argc; from++)
1544 {
1545 options[from] = -1;
1546 priority[from] = 0;
1547 if (argv[from][0] == '-')
1548 {
1549 int match, thislen;
1550 char *equals;
1551
1552 /* If we have found "--", don't consider
1553 any more arguments as options. */
1554 if (argv[from][1] == '-' && argv[from][2] == 0)
1555 {
1556 /* Leave the "--", and everything following it, at the end. */
1557 for (; from < argc; from++)
1558 {
1559 priority[from] = -100;
1560 options[from] = -1;
1561 }
1562 break;
1563 }
1564
1565 /* Look for a match with a known old-fashioned option. */
1566 for (i = 0; i < sizeof (standard_args) / sizeof (standard_args[0]); i++)
1567 if (!strcmp (argv[from], standard_args[i].name))
1568 {
1569 options[from] = standard_args[i].nargs;
1570 priority[from] = standard_args[i].priority;
1571 if (from + standard_args[i].nargs >= argc)
1572 fatal ("Option `%s' requires an argument\n", argv[from]);
1573 from += standard_args[i].nargs;
1574 goto done;
1575 }
1576
1577 /* Look for a match with a known long option.
1578 MATCH is -1 if no match so far, -2 if two or more matches so far,
1579 >= 0 (the table index of the match) if just one match so far. */
1580 if (argv[from][1] == '-')
1581 {
1582 match = -1;
1583 thislen = strlen (argv[from]);
1584 equals = index (argv[from], '=');
1585 if (equals != 0)
1586 thislen = equals - argv[from];
1587
1588 for (i = 0;
1589 i < sizeof (standard_args) / sizeof (standard_args[0]); i++)
1590 if (standard_args[i].longname
1591 && !strncmp (argv[from], standard_args[i].longname,
1592 thislen))
1593 {
1594 if (match == -1)
1595 match = i;
1596 else
1597 match = -2;
1598 }
1599
1600 /* If we found exactly one match, use that. */
1601 if (match >= 0)
1602 {
1603 options[from] = standard_args[match].nargs;
1604 priority[from] = standard_args[match].priority;
1605 /* If --OPTION=VALUE syntax is used,
1606 this option uses just one argv element. */
1607 if (equals != 0)
1608 options[from] = 0;
1609 if (from + options[from] >= argc)
1610 fatal ("Option `%s' requires an argument\n", argv[from]);
1611 from += options[from];
1612 }
1613 }
1614 done: ;
1615 }
1616 }
1617
1618 /* Copy the arguments, in order of decreasing priority, to NEW. */
1619 new[0] = argv[0];
1620 while (incoming_used < argc)
1621 {
1622 int best = -1;
1623 int best_priority = -9999;
1624
1625 /* Find the highest priority remaining option.
1626 If several have equal priority, take the first of them. */
1627 for (from = 1; from < argc; from++)
1628 {
1629 if (argv[from] != 0 && priority[from] > best_priority)
1630 {
1631 best_priority = priority[from];
1632 best = from;
1633 }
1634 /* Skip option arguments--they are tied to the options. */
1635 if (options[from] > 0)
1636 from += options[from];
1637 }
1638
1639 if (best < 0)
1640 abort ();
1641
1642 /* Copy the highest priority remaining option, with its args, to NEW.
1643 Unless it is a duplicate of the previous one. */
1644 if (! (options[best] == 0
1645 && ! strcmp (new[to - 1], argv[best])))
1646 {
1647 new[to++] = argv[best];
1648 for (i = 0; i < options[best]; i++)
1649 new[to++] = argv[best + i + 1];
1650 }
1651
1652 incoming_used += 1 + (options[best] > 0 ? options[best] : 0);
1653
1654 /* Clear out this option in ARGV. */
1655 argv[best] = 0;
1656 for (i = 0; i < options[best]; i++)
1657 argv[best + i + 1] = 0;
1658 }
1659
1660 /* If duplicate options were deleted, fill up extra space with null ptrs. */
1661 while (to < argc)
1662 new[to++] = 0;
1663
1664 bcopy (new, argv, sizeof (char *) * argc);
1665
1666 free (options);
1667 free (new);
1668 free (priority);
1669 }
1670 \f
1671 DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
1672 "Exit the Emacs job and kill it.\n\
1673 If ARG is an integer, return ARG as the exit program code.\n\
1674 If ARG is a string, stuff it as keyboard input.\n\n\
1675 The value of `kill-emacs-hook', if not void,\n\
1676 is a list of functions (of no args),\n\
1677 all of which are called before Emacs is actually killed.")
1678 (arg)
1679 Lisp_Object arg;
1680 {
1681 struct gcpro gcpro1;
1682
1683 GCPRO1 (arg);
1684
1685 if (feof (stdin))
1686 arg = Qt;
1687
1688 if (!NILP (Vrun_hooks) && !noninteractive)
1689 call1 (Vrun_hooks, intern ("kill-emacs-hook"));
1690
1691 UNGCPRO;
1692
1693 /* Is it really necessary to do this deassign
1694 when we are going to exit anyway? */
1695 /* #ifdef VMS
1696 stop_vms_input ();
1697 #endif */
1698
1699 shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil);
1700
1701 /* If we have an auto-save list file,
1702 kill it because we are exiting Emacs deliberately (not crashing).
1703 Do it after shut_down_emacs, which does an auto-save. */
1704 if (STRINGP (Vauto_save_list_file_name))
1705 unlink (XSTRING (Vauto_save_list_file_name)->data);
1706
1707 exit (INTEGERP (arg) ? XINT (arg)
1708 #ifdef VMS
1709 : 1
1710 #else
1711 : 0
1712 #endif
1713 );
1714 /* NOTREACHED */
1715 }
1716
1717
1718 /* Perform an orderly shutdown of Emacs. Autosave any modified
1719 buffers, kill any child processes, clean up the terminal modes (if
1720 we're in the foreground), and other stuff like that. Don't perform
1721 any redisplay; this may be called when Emacs is shutting down in
1722 the background, or after its X connection has died.
1723
1724 If SIG is a signal number, print a message for it.
1725
1726 This is called by fatal signal handlers, X protocol error handlers,
1727 and Fkill_emacs. */
1728
1729 void
1730 shut_down_emacs (sig, no_x, stuff)
1731 int sig, no_x;
1732 Lisp_Object stuff;
1733 {
1734 /* Prevent running of hooks from now on. */
1735 Vrun_hooks = Qnil;
1736
1737 /* If we are controlling the terminal, reset terminal modes */
1738 #ifdef EMACS_HAVE_TTY_PGRP
1739 {
1740 int pgrp = EMACS_GETPGRP (0);
1741
1742 int tpgrp;
1743 if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1
1744 && tpgrp == pgrp)
1745 {
1746 fflush (stdout);
1747 reset_sys_modes ();
1748 if (sig && sig != SIGTERM)
1749 fprintf (stderr, "Fatal error (%d).", sig);
1750 }
1751 }
1752 #else
1753 fflush (stdout);
1754 reset_sys_modes ();
1755 #endif
1756
1757 stuff_buffered_input (stuff);
1758
1759 kill_buffer_processes (Qnil);
1760 Fdo_auto_save (Qt, Qnil);
1761
1762 #ifdef CLASH_DETECTION
1763 unlock_all_files ();
1764 #endif
1765
1766 #ifdef VMS
1767 kill_vms_processes ();
1768 #endif
1769
1770 #if 0 /* This triggers a bug in XCloseDisplay and is not needed. */
1771 #ifdef HAVE_X_WINDOWS
1772 /* It's not safe to call intern here. Maybe we are crashing. */
1773 if (!noninteractive && SYMBOLP (Vwindow_system)
1774 && XSYMBOL (Vwindow_system)->name->size == 1
1775 && XSYMBOL (Vwindow_system)->name->data[0] == 'x'
1776 && ! no_x)
1777 Fx_close_current_connection ();
1778 #endif /* HAVE_X_WINDOWS */
1779 #endif
1780
1781 #ifdef SIGIO
1782 /* There is a tendency for a SIGIO signal to arrive within exit,
1783 and cause a SIGHUP because the input descriptor is already closed. */
1784 unrequest_sigio ();
1785 signal (SIGIO, SIG_IGN);
1786 #endif
1787
1788 #ifdef WINDOWSNT
1789 term_ntproc ();
1790 #endif
1791
1792 check_glyph_memory ();
1793 check_message_stack ();
1794
1795 #ifdef MSDOS
1796 dos_cleanup ();
1797 #endif
1798 }
1799
1800
1801 \f
1802 #ifndef CANNOT_DUMP
1803
1804 #ifdef HAVE_SHM
1805
1806 DEFUN ("dump-emacs-data", Fdump_emacs_data, Sdump_emacs_data, 1, 1, 0,
1807 "Dump current state of Emacs into data file FILENAME.\n\
1808 This function exists on systems that use HAVE_SHM.")
1809 (filename)
1810 Lisp_Object filename;
1811 {
1812 extern char my_edata[];
1813 Lisp_Object tem;
1814
1815 CHECK_STRING (filename, 0);
1816 filename = Fexpand_file_name (filename, Qnil);
1817
1818 tem = Vpurify_flag;
1819 Vpurify_flag = Qnil;
1820
1821 fflush (stdout);
1822 /* Tell malloc where start of impure now is */
1823 /* Also arrange for warnings when nearly out of space. */
1824 #ifndef SYSTEM_MALLOC
1825 memory_warnings (my_edata, malloc_warning);
1826 #endif
1827 map_out_data (XSTRING (filename)->data);
1828
1829 Vpurify_flag = tem;
1830
1831 return Qnil;
1832 }
1833
1834 #else /* not HAVE_SHM */
1835
1836 DEFUN ("dump-emacs", Fdump_emacs, Sdump_emacs, 2, 2, 0,
1837 "Dump current state of Emacs into executable file FILENAME.\n\
1838 Take symbols from SYMFILE (presumably the file you executed to run Emacs).\n\
1839 This is used in the file `loadup.el' when building Emacs.\n\
1840 \n\
1841 You must run Emacs in batch mode in order to dump it.")
1842 (filename, symfile)
1843 Lisp_Object filename, symfile;
1844 {
1845 extern char my_edata[];
1846 Lisp_Object tem;
1847 Lisp_Object symbol;
1848 int count = specpdl_ptr - specpdl;
1849
1850 if (! noninteractive)
1851 error ("Dumping Emacs works only in batch mode");
1852
1853 /* Bind `command-line-processed' to nil before dumping,
1854 so that the dumped Emacs will process its command line
1855 and set up to work with X windows if appropriate. */
1856 symbol = intern ("command-line-process");
1857 specbind (symbol, Qnil);
1858
1859 CHECK_STRING (filename, 0);
1860 filename = Fexpand_file_name (filename, Qnil);
1861 if (!NILP (symfile))
1862 {
1863 CHECK_STRING (symfile, 0);
1864 if (XSTRING (symfile)->size)
1865 symfile = Fexpand_file_name (symfile, Qnil);
1866 }
1867
1868 tem = Vpurify_flag;
1869 Vpurify_flag = Qnil;
1870
1871 #ifdef HAVE_TZSET
1872 set_time_zone_rule (dump_tz);
1873 #ifndef LOCALTIME_CACHE
1874 /* Force a tz reload, since set_time_zone_rule doesn't. */
1875 tzset ();
1876 #endif
1877 #endif
1878
1879 fflush (stdout);
1880 #ifdef VMS
1881 mapout_data (XSTRING (filename)->data);
1882 #else
1883 /* Tell malloc where start of impure now is */
1884 /* Also arrange for warnings when nearly out of space. */
1885 #ifndef SYSTEM_MALLOC
1886 #ifndef WINDOWSNT
1887 /* On Windows, this was done before dumping, and that once suffices.
1888 Meanwhile, my_edata is not valid on Windows. */
1889 memory_warnings (my_edata, malloc_warning);
1890 #endif /* not WINDOWSNT */
1891 #endif
1892 #ifdef DOUG_LEA_MALLOC
1893 malloc_state_ptr = malloc_get_state ();
1894 #endif
1895 unexec (XSTRING (filename)->data,
1896 !NILP (symfile) ? XSTRING (symfile)->data : 0, my_edata, 0, 0);
1897 #ifdef DOUG_LEA_MALLOC
1898 free (malloc_state_ptr);
1899 #endif
1900 #endif /* not VMS */
1901
1902 Vpurify_flag = tem;
1903
1904 return unbind_to (count, Qnil);
1905 }
1906
1907 #endif /* not HAVE_SHM */
1908
1909 #endif /* not CANNOT_DUMP */
1910 \f
1911 #if HAVE_SETLOCALE
1912 /* Recover from setlocale (LC_ALL, ""). */
1913 void
1914 fixup_locale ()
1915 {
1916 /* The Emacs Lisp reader needs LC_NUMERIC to be "C",
1917 so that numbers are read and printed properly for Emacs Lisp. */
1918 setlocale (LC_NUMERIC, "C");
1919 }
1920
1921 /* Set system locale CATEGORY, with previous locale *PLOCALE, to
1922 DESIRED_LOCALE. */
1923 static void
1924 synchronize_locale (category, plocale, desired_locale)
1925 int category;
1926 Lisp_Object *plocale;
1927 Lisp_Object desired_locale;
1928 {
1929 if (! EQ (*plocale, desired_locale))
1930 {
1931 *plocale = desired_locale;
1932 setlocale (category, (STRINGP (desired_locale)
1933 ? (char *)(XSTRING (desired_locale)->data)
1934 : ""));
1935 }
1936 }
1937
1938 /* Set system time locale to match Vsystem_time_locale, if possible. */
1939 void
1940 synchronize_system_time_locale ()
1941 {
1942 synchronize_locale (LC_TIME, &Vprevious_system_time_locale,
1943 Vsystem_time_locale);
1944 }
1945
1946 /* Set system messages locale to match Vsystem_messages_locale, if
1947 possible. */
1948 void
1949 synchronize_system_messages_locale ()
1950 {
1951 #ifdef LC_MESSAGES
1952 synchronize_locale (LC_MESSAGES, &Vprevious_system_messages_locale,
1953 Vsystem_messages_locale);
1954 #endif
1955 }
1956 #endif /* HAVE_SETLOCALE */
1957 \f
1958 #ifndef SEPCHAR
1959 #define SEPCHAR ':'
1960 #endif
1961
1962 Lisp_Object
1963 decode_env_path (evarname, defalt)
1964 char *evarname, *defalt;
1965 {
1966 register char *path, *p;
1967 Lisp_Object lpath, element, tem;
1968
1969 /* It's okay to use getenv here, because this function is only used
1970 to initialize variables when Emacs starts up, and isn't called
1971 after that. */
1972 if (evarname != 0)
1973 path = (char *) getenv (evarname);
1974 else
1975 path = 0;
1976 if (!path)
1977 path = defalt;
1978 #ifdef DOS_NT
1979 /* Ensure values from the environment use the proper directory separator. */
1980 if (path)
1981 {
1982 p = alloca (strlen (path) + 1);
1983 strcpy (p, path);
1984 path = p;
1985
1986 if ('/' == DIRECTORY_SEP)
1987 dostounix_filename (path);
1988 else
1989 unixtodos_filename (path);
1990 }
1991 #endif
1992 lpath = Qnil;
1993 while (1)
1994 {
1995 p = index (path, SEPCHAR);
1996 if (!p) p = path + strlen (path);
1997 element = (p - path ? make_string (path, p - path)
1998 : build_string ("."));
1999
2000 /* Add /: to the front of the name
2001 if it would otherwise be treated as magic. */
2002 tem = Ffind_file_name_handler (element, Qt);
2003 if (! NILP (tem))
2004 element = concat2 (build_string ("/:"), element);
2005
2006 lpath = Fcons (element, lpath);
2007 if (*p)
2008 path = p + 1;
2009 else
2010 break;
2011 }
2012 return Fnreverse (lpath);
2013 }
2014
2015 void
2016 syms_of_emacs ()
2017 {
2018 Qfile_name_handler_alist = intern ("file-name-handler-alist");
2019 staticpro (&Qfile_name_handler_alist);
2020
2021 #ifndef CANNOT_DUMP
2022 #ifdef HAVE_SHM
2023 defsubr (&Sdump_emacs_data);
2024 #else
2025 defsubr (&Sdump_emacs);
2026 #endif
2027 #endif
2028
2029 defsubr (&Skill_emacs);
2030
2031 defsubr (&Sinvocation_name);
2032 defsubr (&Sinvocation_directory);
2033
2034 DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
2035 "Args passed by shell to Emacs, as a list of strings.");
2036
2037 DEFVAR_LISP ("system-type", &Vsystem_type,
2038 "Value is symbol indicating type of operating system you are using.");
2039 Vsystem_type = intern (SYSTEM_TYPE);
2040
2041 DEFVAR_LISP ("system-configuration", &Vsystem_configuration,
2042 "Value is string indicating configuration Emacs was built for.");
2043 Vsystem_configuration = build_string (EMACS_CONFIGURATION);
2044
2045 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options,
2046 "String containing the configuration options Emacs was built with.");
2047 Vsystem_configuration_options = build_string (EMACS_CONFIG_OPTIONS);
2048
2049 DEFVAR_BOOL ("noninteractive", &noninteractive1,
2050 "Non-nil means Emacs is running without interactive terminal.");
2051
2052 DEFVAR_LISP ("kill-emacs-hook", &Vkill_emacs_hook,
2053 "Hook to be run whenever kill-emacs is called.\n\
2054 Since kill-emacs may be invoked when the terminal is disconnected (or\n\
2055 in other similar situations), functions placed on this hook should not\n\
2056 expect to be able to interact with the user. To ask for confirmation,\n\
2057 see `kill-emacs-query-functions' instead.");
2058 Vkill_emacs_hook = Qnil;
2059
2060 #ifdef SIGUSR1
2061 DEFVAR_LISP ("signal-USR1-hook", &Vsignal_USR1_hook,
2062 "Hook to be run whenever emacs receives a USR1 signal");
2063 Vsignal_USR1_hook = Qnil;
2064 #ifdef SIGUSR2
2065 DEFVAR_LISP ("signal-USR2-hook", &Vsignal_USR2_hook,
2066 "Hook to be run whenever emacs receives a USR2 signal");
2067 Vsignal_USR2_hook = Qnil;
2068 #endif
2069 #endif
2070
2071
2072 DEFVAR_INT ("emacs-priority", &emacs_priority,
2073 "Priority for Emacs to run at.\n\
2074 This value is effective only if set before Emacs is dumped,\n\
2075 and only if the Emacs executable is installed with setuid to permit\n\
2076 it to change priority. (Emacs sets its uid back to the real uid.)\n\
2077 Currently, you need to define SET_EMACS_PRIORITY in `config.h'\n\
2078 before you compile Emacs, to enable the code for this feature.");
2079 emacs_priority = 0;
2080
2081 DEFVAR_LISP ("path-separator", &Vpath_separator,
2082 "The directory separator in search paths, as a string.");
2083 {
2084 char c = SEPCHAR;
2085 Vpath_separator = make_string (&c, 1);
2086 }
2087
2088 DEFVAR_LISP ("invocation-name", &Vinvocation_name,
2089 "The program name that was used to run Emacs.\n\
2090 Any directory names are omitted.");
2091
2092 DEFVAR_LISP ("invocation-directory", &Vinvocation_directory,
2093 "The directory in which the Emacs executable was found, to run it.\n\
2094 The value is nil if that directory's name is not known.");
2095
2096 DEFVAR_LISP ("installation-directory", &Vinstallation_directory,
2097 "A directory within which to look for the `lib-src' and `etc' directories.\n\
2098 This is non-nil when we can't find those directories in their standard\n\
2099 installed locations, but we can find them\n\
2100 near where the Emacs executable was found.");
2101 Vinstallation_directory = Qnil;
2102
2103 DEFVAR_LISP ("system-messages-locale", &Vsystem_messages_locale,
2104 "System locale for messages.");
2105 Vsystem_messages_locale = Qnil;
2106
2107 DEFVAR_LISP ("previous-system-messages-locale",
2108 &Vprevious_system_messages_locale,
2109 "Most recently used system locale for messages.");
2110 Vprevious_system_messages_locale = Qnil;
2111
2112 DEFVAR_LISP ("system-time-locale", &Vsystem_time_locale,
2113 "System locale for time.");
2114 Vsystem_time_locale = Qnil;
2115
2116 DEFVAR_LISP ("previous-system-time-locale", &Vprevious_system_time_locale,
2117 "Most recently used system locale for time.");
2118 Vprevious_system_time_locale = Qnil;
2119 }