home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / editors / mntemacs.zoo / src / emacs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-02  |  16.9 KB  |  722 lines

  1. /* Fully extensible Emacs, running on Unix, intended for GNU.
  2.    Copyright (C) 1985, 1986, 1987, 1990 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. #include <signal.h>
  22. #include <errno.h>
  23.  
  24. #include "config.h"
  25. #include <stdio.h>
  26. #undef NULL
  27. #include "lisp.h"
  28. #include "commands.h"
  29.  
  30. #include <sys/types.h>
  31. #include <sys/file.h>
  32.  
  33. #ifdef VMS
  34. #include <ssdef.h>
  35. #endif
  36.  
  37. #ifdef USG5
  38. #include <fcntl.h>
  39. #endif
  40.  
  41. #ifdef BSD
  42. #include <sys/ioctl.h>
  43. #endif
  44.  
  45. #ifdef APOLLO
  46. #ifndef APOLLO_SR10
  47. #include <default_acl.h>
  48. #endif
  49. #endif
  50.  
  51. #ifndef O_RDWR
  52. #define O_RDWR 2
  53. #endif
  54.  
  55. #define PRIO_PROCESS 0
  56.  
  57. /* Command line args from shell, as list of strings */
  58. Lisp_Object Vcommand_line_args;
  59.  
  60. /* Hook run by `kill-emacs' before it does really anything.  */
  61. Lisp_Object Vkill_emacs_hook;
  62.  
  63. /* Set nonzero after Emacs has started up the first time.
  64.   Prevents reinitialization of the Lisp world and keymaps
  65.   on subsequent starts.  */
  66. int initialized;
  67.  
  68. /* Variable whose value is symbol giving operating system type */
  69. Lisp_Object Vsystem_type;
  70.   
  71. /* If non-zero, emacs should not attempt to use an window-specific code,
  72.    but instead should use the virtual terminal under which it was started */
  73. int inhibit_window_system;
  74.  
  75. #ifdef HAVE_X_WINDOWS
  76. /* If -d option is used, this variable points to the name of
  77.    the display to use.  */
  78. char *alternate_display;
  79. char **xargv;
  80. int xargc;
  81. #endif /* HAVE_X_WINDOWS */
  82.  
  83. #ifdef USG_SHARED_LIBRARIES
  84. /* If nonzero, this is the place to put the end of the writable segment
  85.    at startup.  */
  86.  
  87. unsigned int bss_end = 0;
  88. #endif
  89.  
  90. /* Nonzero means running Emacs without interactive terminal.  */
  91.  
  92. int noninteractive;
  93.  
  94. /* Value of Lisp variable `noninteractive'.
  95.    Normally same as C variable `noninteractive'
  96.    but nothing terrible happens if user sets this one.  */
  97.  
  98. int noninteractive1;
  99.  
  100. /* Signal code for the fatal signal that was received */
  101. int fatal_error_code;
  102.  
  103. /* Nonzero if handling a fatal error already */
  104. int fatal_error_in_progress;
  105.  
  106. /* Handle bus errors, illegal instruction, etc. */
  107. fatal_error_signal (sig)
  108.      int sig;
  109. {
  110. #ifdef BSD
  111.   int tpgrp;
  112. #endif /* BSD */
  113.  
  114.   fatal_error_code = sig;
  115.   signal (sig, SIG_DFL);
  116.  
  117.   /* If fatal error occurs in code below, avoid infinite recursion.  */
  118.   if (fatal_error_in_progress)
  119.     kill (getpid (), fatal_error_code);
  120.  
  121.   fatal_error_in_progress = 1;
  122.  
  123.   /* If we are controlling the terminal, reset terminal modes */
  124. #ifdef BSD
  125.   if (ioctl(0, TIOCGPGRP, &tpgrp) == 0
  126.       && tpgrp == getpgrp (0))
  127. #endif /* BSD */
  128.     {
  129.       reset_sys_modes ();
  130.       if (sig != SIGTERM)
  131.     fprintf (stderr, "Fatal error (%d).", sig);
  132.     }
  133.  
  134.   /* Clean up */
  135. #ifdef subprocesses
  136.   kill_buffer_processes (Qnil);
  137. #endif
  138.   Fdo_auto_save (Qt);
  139.  
  140. #ifdef CLASH_DETECTION
  141.   unlock_all_files ();
  142. #endif /* CLASH_DETECTION */
  143.  
  144. #ifdef VMS
  145.   kill_vms_processes ();
  146.   LIB$STOP (SS$_ABORT);
  147. #else
  148.   /* Signal the same code; this time it will really be fatal.  */
  149.   kill (getpid (), fatal_error_code);
  150. #endif /* not VMS */
  151. }
  152.  
  153. /* Code for dealing with Lisp access to the Unix command line */
  154.  
  155. static
  156. init_cmdargs (argc, argv, skip_args)
  157.      int argc;
  158.      char **argv;
  159.      int skip_args;
  160. {
  161.   register int i;
  162.  
  163.   Vcommand_line_args = Qnil;
  164.  
  165.   for (i = argc - 1; i >= 0; i--)
  166.     {
  167.       if (i == 0 || i > skip_args)
  168.     Vcommand_line_args
  169.       = Fcons (build_string (argv[i]), Vcommand_line_args);
  170.     }
  171. }
  172.  
  173.  
  174. #ifdef VMS
  175. #ifdef LINK_CRTL_SHARE
  176. #ifdef SHAREABLE_LIB_BUG
  177. extern noshare char **environ;
  178. #endif /* SHAREABLE_LIB_BUG */
  179. #endif /* LINK_CRTL_SHARE */
  180. #endif /* VMS */
  181.  
  182. /* ARGSUSED */
  183. main (argc, argv, envp)
  184.      int argc;
  185.      char **argv;
  186.      char **envp;
  187. {
  188.   int skip_args = 0;
  189.   extern int errno;
  190.   extern void malloc_warning ();
  191.  
  192. /* Map in shared memory, if we are using that.  */
  193. #ifdef HAVE_SHM
  194.   if (argc > 1 && !strcmp (argv[1], "-nl"))
  195.     {
  196.       map_in_data (0);
  197.       /* The shared momory was just restored, which clobbered this.  */
  198.       skip_args = 1;
  199.     }
  200.   else
  201.     {
  202.       map_in_data (1);
  203.       /* The shared momory was just restored, which clobbered this.  */
  204.       skip_args = 0;
  205.     }
  206. #endif
  207.  
  208. #ifdef VMS
  209.   /* If -map specified, map the data file in */
  210.   if (argc > 2 && ! strcmp (argv[1], "-map"))
  211.     {
  212.       skip_args = 2;
  213.       mapin_data (argv[2]);
  214.     }
  215.  
  216. #ifdef LINK_CRTL_SHARE
  217. #ifdef SHAREABLE_LIB_BUG
  218.   /* Bletcherous shared libraries! */
  219.   if (!stdin)
  220.     stdin = fdopen (0, "r");
  221.   if (!stdout)
  222.     stdout = fdopen (1, "w");
  223.   if (!stderr)
  224.     stderr = fdopen (2, "w");
  225.   if (!environ)
  226.     environ = envp;
  227. #endif /* SHAREABLE_LIB_BUG */
  228. #endif /* LINK_CRTL_SHARE */
  229. #endif /* VMS */
  230.  
  231. #ifdef USG_SHARED_LIBRARIES
  232.   if (bss_end)
  233.     brk (bss_end);
  234. #endif
  235.  
  236.   clearerr (stdin);
  237.  
  238. #ifdef APOLLO
  239. #ifndef APOLLO_SR10
  240.   /* If USE_DOMAIN_ACLS environment variable exists,
  241.      use ACLs rather than UNIX modes. */
  242.   if (egetenv ("USE_DOMAIN_ACLS"))
  243.     default_acl (USE_DEFACL);
  244. #endif
  245. #endif /* APOLLO */
  246.  
  247. #ifndef SYSTEM_MALLOC
  248.   /* Arrange for warnings when nearly out of space.  */
  249.   malloc_init (0, malloc_warning);
  250. #endif
  251.  
  252. #ifdef HIGHPRI
  253.   setpriority (PRIO_PROCESS, getpid (), HIGHPRI);
  254.   setuid (getuid ());
  255. #endif HIGHPRI
  256.  
  257.   inhibit_window_system = 0;
  258.  
  259. #ifdef HAVE_X_WINDOWS
  260.   xargv = argv;
  261.   xargc = argc;
  262. #endif
  263.  
  264. /* Handle the -t switch, which specifies filename to use as terminal */
  265.   if (skip_args + 2 < argc && !strcmp (argv[skip_args + 1], "-t"))
  266.     {
  267.       skip_args += 2;
  268.       close (0);
  269.       close (1);
  270.       open (argv[skip_args], O_RDWR, 2 );
  271.       dup (0);
  272.       fprintf (stderr, "Using %s\n", argv[skip_args]);
  273. #ifdef HAVE_X_WINDOWS
  274.       inhibit_window_system = 1;    /* -t => -nw */
  275. #endif
  276.     }
  277. #ifdef HAVE_X_WINDOWS
  278. /* Handle the -d switch, which means use a different display for X */
  279.   if (skip_args + 2 < argc && (!strcmp (argv[skip_args + 1], "-d") ||
  280.                    !strcmp (argv[skip_args + 1], "-display")))
  281.     {
  282.       skip_args += 2;
  283.       alternate_display = argv[skip_args];
  284.     } 
  285.   else
  286.     alternate_display = 0;
  287. #endif    /* HAVE_X_WINDOWS */
  288.  
  289.   if (skip_args + 1 < argc
  290.       && (!strcmp (argv[skip_args + 1], "-nw")))
  291.     {
  292.       skip_args += 1;
  293.       inhibit_window_system = 1;
  294.     }
  295.  
  296. /* Handle the -batch switch, which means don't do interactive display.  */
  297.   noninteractive = 0;
  298.   if (skip_args + 1 < argc && !strcmp (argv[skip_args + 1], "-batch"))
  299.     {
  300.       skip_args += 1;
  301.       noninteractive = 1;
  302.     }
  303.  
  304.   if (
  305. #ifndef CANNOT_DUMP
  306.       ! noninteractive || initialized
  307. #else
  308.       1
  309. #endif
  310.       )
  311.     {
  312.       /* Don't catch these signals in batch mode if not initialized.
  313.      On some machines, this sets static data that would make
  314.      signal fail to work right when the dumped Emacs is run.  */
  315. /**
  316.  **  (sjk++) cast to keep gcc quite.
  317.  **/
  318. #ifdef atarist
  319.       signal (SIGHUP, (__Sigfunc)fatal_error_signal);
  320.       signal (SIGQUIT, (__Sigfunc)fatal_error_signal);
  321.       signal (SIGILL, (__Sigfunc)fatal_error_signal);
  322.       signal (SIGTRAP, (__Sigfunc)fatal_error_signal);
  323.       signal (SIGIOT, (__Sigfunc)fatal_error_signal);
  324. #ifdef SIGEMT
  325.       signal (SIGEMT, (__Sigfunc)fatal_error_signal);
  326. #endif
  327.       signal (SIGFPE, (__Sigfunc)fatal_error_signal);
  328.       signal (SIGBUS, (__Sigfunc)fatal_error_signal);
  329.       signal (SIGSEGV, (__Sigfunc)fatal_error_signal);
  330.       signal (SIGSYS, (__Sigfunc)fatal_error_signal);
  331.       signal (SIGTERM, (__Sigfunc)fatal_error_signal);
  332. #ifdef SIGXCPU
  333.       signal (SIGXCPU, (__Sigfunc)fatal_error_signal);
  334. #endif
  335. #ifdef SIGXFSZ
  336.       signal (SIGXFSZ, (__Sigfunc)fatal_error_signal);
  337. #endif SIGXFSZ
  338. #endif /* atarist */
  339.  
  340. #ifdef AIX
  341.       signal (SIGDANGER, fatal_error_signal);
  342.       signal (20, fatal_error_signal);
  343.       signal (21, fatal_error_signal);
  344.       signal (22, fatal_error_signal);
  345.       signal (23, fatal_error_signal);
  346.       signal (24, fatal_error_signal);
  347.       signal (SIGAIO, fatal_error_signal);
  348.       signal (SIGPTY, fatal_error_signal);
  349.       signal (SIGIOINT, fatal_error_signal);
  350.       signal (SIGGRANT, fatal_error_signal);
  351.       signal (SIGRETRACT, fatal_error_signal);
  352.       signal (SIGSOUND, fatal_error_signal);
  353.       signal (SIGMSG, fatal_error_signal);
  354. #endif /* AIX */
  355.     }
  356.  
  357.   noninteractive1 = noninteractive;
  358.  
  359. /* Perform basic initializations (not merely interning symbols) */
  360.  
  361.   if (!initialized)
  362.     {
  363.       init_alloc_once ();
  364.       init_obarray ();
  365.       init_eval_once ();
  366.       init_syntax_once ();    /* Create standard syntax table.  */
  367.               /* Must be done before init_buffer */
  368.       init_buffer_once ();    /* Create buffer table and some buffers */
  369.       init_minibuf_once ();    /* Create list of minibuffers */
  370.                   /* Must precede init_window_once */
  371.       init_window_once ();    /* Init the window system */
  372.     }
  373.  
  374.   init_alloc ();
  375. #ifdef MAINTAIN_ENVIRONMENT
  376.   init_environ ();
  377. #endif
  378.   init_eval ();
  379.   init_data ();
  380.   init_read ();
  381.  
  382.   init_cmdargs (argc, argv, skip_args);    /* Create list Vcommand_line_args */
  383.   init_buffer ();    /* Init default directory of main buffer */
  384.   if (!noninteractive)
  385.     {
  386. #ifdef VMS
  387.       init_vms_input ();/* init_display calls get_screen_size, that needs this */
  388. #endif /* VMS */
  389.       init_display ();    /* Determine terminal type.  init_sys_modes uses results */
  390.     }
  391.   init_keyboard ();    /* This too must precede init_sys_modes */
  392.   init_callproc ();    /* And this too. */
  393.   init_sys_modes ();    /* Init system terminal modes (RAW or CBREAK, etc.) */
  394.   init_xdisp ();
  395.   init_macros ();
  396.   init_editfns ();
  397. #ifdef VMS
  398.   init_vmsfns ();
  399. #endif /* VMS */
  400. #ifdef subprocesses
  401.   init_process ();
  402. #endif /* subprocesses */
  403.  
  404. /**
  405.  **  (sjk++) Do the nasties at the start (atari st specific inits)
  406.  **/
  407. #if defined(atarist) 
  408.   INIT_SYSTEM;
  409. #endif
  410.  
  411. /* Intern the names of all standard functions and variables; define standard keys */
  412.  
  413.   if (!initialized)
  414.     {
  415.       /* The basic levels of Lisp must come first */
  416.       /* And data must come first of all
  417.      for the sake of symbols like error-message */
  418.       syms_of_data ();
  419.       syms_of_alloc ();
  420. #ifdef MAINTAIN_ENVIRONMENT
  421.       syms_of_environ ();
  422. #endif MAINTAIN_ENVIRONMENT
  423.       syms_of_read ();
  424.       syms_of_print ();
  425.       syms_of_eval ();
  426.       syms_of_fns ();
  427.  
  428.       syms_of_abbrev ();
  429.       syms_of_buffer ();
  430.       syms_of_bytecode ();
  431.       syms_of_callint ();
  432.       syms_of_casefiddle ();
  433.       syms_of_callproc ();
  434.       syms_of_cmds ();
  435. #ifndef NO_DIR_LIBRARY
  436.       syms_of_dired ();
  437. #endif /* not NO_DIR_LIBRARY */
  438.       syms_of_display ();
  439.       syms_of_doc ();
  440.       syms_of_editfns ();
  441.       syms_of_emacs ();
  442.       syms_of_fileio ();
  443. #ifdef CLASH_DETECTION
  444.       syms_of_filelock ();
  445. #endif /* CLASH_DETECTION */
  446.       syms_of_indent ();
  447.       syms_of_keyboard ();
  448.       syms_of_keymap ();
  449.       syms_of_macros ();
  450.       syms_of_marker ();
  451.       syms_of_minibuf ();
  452.       syms_of_mocklisp ();
  453. #ifdef subprocesses
  454.       syms_of_process ();
  455. #endif /* subprocesses */
  456.       syms_of_search ();
  457.       syms_of_syntax ();
  458.       syms_of_undo ();
  459.       syms_of_window ();
  460.       syms_of_xdisp ();
  461. #ifdef HAVE_X_WINDOWS
  462.       syms_of_xfns ();
  463. #ifdef HAVE_X_MENU
  464.       syms_of_xmenu ();
  465. #endif /* HAVE_X_MENU */
  466. #endif /* HAVE_X_WINDOWS */
  467.  
  468. #ifdef SYMS_SYSTEM
  469.       SYMS_SYSTEM;
  470. #endif
  471.  
  472. #ifdef SYMS_MACHINE
  473.       SYMS_MACHINE;
  474. #endif
  475.  
  476.       keys_of_casefiddle ();
  477.       keys_of_cmds ();
  478.       keys_of_buffer ();
  479.       keys_of_keyboard ();
  480.       keys_of_keymap ();
  481.       keys_of_macros ();
  482.       keys_of_minibuf ();
  483.       keys_of_window ();
  484.     }
  485.  
  486.   if (!initialized)
  487.     {
  488.       /* Handle -l loadup-and-dump, args passed by Makefile. */
  489.       if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l"))
  490.     Vtop_level = Fcons (intern ("load"),
  491.                 Fcons (build_string (argv[2 + skip_args]), Qnil));
  492. #ifdef CANNOT_DUMP
  493.       /* Unless next switch is -nl, load "loadup.el" first thing.  */
  494.       if (!(argc > 1 + skip_args && !strcmp (argv[1 + skip_args], "-nl")))
  495.     Vtop_level = Fcons (intern ("load"),
  496.                 Fcons (build_string ("loadup.el"), Qnil));
  497. #endif /* CANNOT_DUMP */
  498.     }
  499.  
  500.   initialized = 1;
  501.  
  502.   /* Enter editor command loop.  This never returns.  */
  503.   Frecursive_edit ();
  504.   /* NOTREACHED */
  505. }
  506.  
  507. DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
  508.   "Exit the Emacs job and kill it.  ARG means no query.\n\
  509. If emacs is running noninteractively and ARG is an integer,\n\
  510. return ARG as the exit program code.")
  511.   (arg)
  512.      Lisp_Object arg;
  513. {
  514.   Lisp_Object answer;
  515.   int i;
  516.   struct gcpro gcpro1;
  517.  
  518.   GCPRO1 (arg);
  519.  
  520.   if (!NULL (Vkill_emacs_hook))
  521.     call0 (Vkill_emacs_hook);
  522.  
  523.   if (feof (stdin))
  524.     arg = Qt;
  525.  
  526. #ifdef subprocesses
  527.   kill_buffer_processes (Qnil);
  528. #endif /* subprocesses */
  529.  
  530. #ifdef VMS
  531.   kill_vms_processes ();
  532. #endif /* VMS */
  533.  
  534.   Fdo_auto_save (Qt);
  535.  
  536. #ifdef CLASH_DETECTION
  537.   unlock_all_files ();
  538. #endif /* CLASH_DETECTION */
  539.  
  540.   fflush (stdout);
  541.   reset_sys_modes ();
  542.   UNGCPRO;
  543.  
  544. /* Is it really necessary to do this deassign
  545.    when we are going to exit anyway?  */
  546. /* #ifdef VMS
  547.   stop_vms_input ();
  548.  #endif  */
  549.   stuff_buffered_input (arg);
  550.  
  551. /**
  552.  **  (sjk++) why fake out a signal that we never see?
  553.  **/
  554. #if defined(atarist)
  555. #undef SIGIO
  556. #endif 
  557.  
  558. #ifdef SIGIO
  559.   /* There is a tendency for a SIGIO signal to arrive within exit,
  560.      and cause a SIGHUP because the input descriptor is already closed.  */
  561.   unrequest_sigio ();
  562.   signal (SIGIO, SIG_IGN);
  563. #endif
  564.   exit ((XTYPE (arg) == Lisp_Int) ? XINT (arg)
  565. #ifdef VMS
  566.     : 1
  567. #else
  568.     : 0
  569. #endif
  570.     );
  571.   /* NOTREACHED */
  572. }
  573.  
  574. #ifndef CANNOT_DUMP
  575. /* Nothing like this can be implemented on an Apollo.
  576.    What a loss!  */
  577.  
  578. #ifdef HAVE_SHM
  579.  
  580. DEFUN ("dump-emacs-data", Fdump_emacs_data, Sdump_emacs_data, 1, 1, 0,
  581.   "Dump current state of Emacs into data file FILENAME.\n\
  582. This function exists on systems that use HAVE_SHM.")
  583.   (intoname)
  584.      Lisp_Object intoname;
  585. {
  586.   extern int my_edata;
  587.   Lisp_Object tem;
  588.   extern void malloc_warning ();
  589.  
  590.   CHECK_STRING (intoname, 0);
  591.   intoname = Fexpand_file_name (intoname, Qnil);
  592.  
  593.   tem = Vpurify_flag;
  594.   Vpurify_flag = Qnil;
  595.  
  596.   fflush (stdout);
  597.   /* Tell malloc where start of impure now is */
  598.   /* Also arrange for warnings when nearly out of space.  */
  599. #ifndef SYSTEM_MALLOC
  600.   malloc_init (&my_edata, malloc_warning);
  601. #endif
  602.   map_out_data (XSTRING (intoname)->data);
  603.  
  604.   Vpurify_flag = tem;
  605.  
  606.   return Qnil;
  607. }
  608.  
  609. #else /* not HAVE_SHM */
  610.  
  611. DEFUN ("dump-emacs", Fdump_emacs, Sdump_emacs, 2, 2, 0,
  612.   "Dump current state of Emacs into executable file FILENAME.\n\
  613. Take symbols from SYMFILE (presumably the file you executed to run Emacs).")
  614.   (intoname, symname)
  615.      Lisp_Object intoname, symname;
  616. {
  617.   extern int my_edata;
  618.   Lisp_Object tem;
  619.   extern void malloc_warning ();
  620.  
  621.   CHECK_STRING (intoname, 0);
  622.   intoname = Fexpand_file_name (intoname, Qnil);
  623.   if (!NULL (symname))
  624.     {
  625.       CHECK_STRING (symname, 0);
  626.       if (XSTRING (symname)->size)
  627.     symname = Fexpand_file_name (symname, Qnil);
  628.     }
  629.  
  630.   tem = Vpurify_flag;
  631.   Vpurify_flag = Qnil;
  632.  
  633.   fflush (stdout);
  634. #ifdef VMS
  635.   mapout_data (XSTRING (intoname)->data);
  636. #else
  637.   /* Tell malloc where start of impure now is */
  638.   /* Also arrange for warnings when nearly out of space.  */
  639. #ifndef SYSTEM_MALLOC
  640.   malloc_init (&my_edata, malloc_warning);
  641. #endif
  642.   unexec (XSTRING (intoname)->data,
  643.       !NULL (symname) ? XSTRING (symname)->data : 0, &my_edata, 0, 0);
  644. #endif /* not VMS */
  645.  
  646.   Vpurify_flag = tem;
  647.  
  648.   return Qnil;
  649. }
  650.  
  651. #endif /* not HAVE_SHM */
  652.  
  653. #endif /* not CANNOT_DUMP */
  654.  
  655. #ifdef VMS
  656. #define SEPCHAR ','
  657. #else
  658. /**
  659.  **  (sjk)++ a reasonable guess.
  660.  **/
  661. #if defined(atarist)
  662. #define SEPCHAR ','
  663. #else
  664. #define SEPCHAR ':'
  665. #endif
  666. #endif
  667.  
  668. Lisp_Object
  669. decode_env_path (evarname, defalt)
  670.      char *evarname, *defalt;
  671. {
  672.   register char *path, *p;
  673.   extern char *index ();
  674.  
  675.   Lisp_Object lpath;
  676.  
  677.   path = (char *) egetenv (evarname);
  678.   if (!path)
  679.     path = defalt;
  680.   lpath = Qnil;
  681.   while (1)
  682.     {
  683.       p = index (path, SEPCHAR);
  684.       if (!p) p = path + strlen (path);
  685.       lpath = Fcons (p - path ? make_string (path, p - path) : Qnil,
  686.              lpath);
  687.       if (*p)
  688.     path = p + 1;
  689.       else
  690.     break;
  691.     }
  692.   return Fnreverse (lpath);
  693. }
  694.  
  695. syms_of_emacs ()
  696. {
  697. #ifndef CANNOT_DUMP
  698. #ifdef HAVE_SHM
  699.   defsubr (&Sdump_emacs_data);
  700. #else
  701.   defsubr (&Sdump_emacs);
  702. #endif
  703. #endif /* not CANNOT_DUMP */
  704.  
  705.   defsubr (&Skill_emacs);
  706.  
  707.   DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
  708.     "Args passed by shell to Emacs, as a list of strings.");
  709.  
  710.   DEFVAR_LISP ("system-type", &Vsystem_type,
  711.     "Symbol indicating type of operating system you are using.");
  712.   Vsystem_type = intern (SYSTEM_TYPE);
  713.  
  714.   DEFVAR_BOOL ("noninteractive", &noninteractive1,
  715.     "Non-nil means Emacs is running without interactive terminal.");
  716.  
  717.   Vkill_emacs_hook = Qnil;
  718.  
  719.   DEFVAR_LISP ("kill-emacs-hook", &Vkill_emacs_hook,
  720.     "Function called, if non-nil, whenever kill-emacs is called.");
  721. }
  722.