home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / gnu / emacs-19.28-src.lha / emacs-19.28 / src / lread.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-17  |  50.8 KB  |  2,041 lines

  1. /* Lisp parsing and input streams.
  2.    Copyright (C) 1985, 1986, 1987, 1988, 1989, 
  3.    1993, 1994 Free Software Foundation, Inc.
  4.  
  5. This file is part of GNU Emacs.
  6.  
  7. GNU Emacs is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU Emacs is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU Emacs; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. #include <config.h>
  23. #include <stdio.h>
  24. #include <sys/types.h>
  25. #include <sys/stat.h>
  26. #include <sys/file.h>
  27. #include <ctype.h>
  28. #include <errno.h>
  29. #include "lisp.h"
  30.  
  31. #ifndef standalone
  32. #include "buffer.h"
  33. #include <paths.h>
  34. #include "commands.h"
  35. #include "keyboard.h"
  36. #include "termhooks.h"
  37. #endif
  38.  
  39. #ifdef lint
  40. #include <sys/inode.h>
  41. #endif /* lint */
  42.  
  43. #ifndef X_OK
  44. #define X_OK 01
  45. #endif
  46.  
  47. #ifdef LISP_FLOAT_TYPE
  48. #ifdef STDC_HEADERS
  49. #ifdef AMIGA /* CHFIXME */
  50. #undef abort
  51. #endif
  52. #include <stdlib.h>
  53. #endif
  54.  
  55. #ifdef MSDOS
  56. #include "msdos.h"
  57. /* These are redefined (correctly, but differently) in values.h.  */
  58. #undef INTBITS
  59. #undef LONGBITS
  60. #undef SHORTBITS
  61. #endif
  62.  
  63. #include <math.h>
  64. #endif /* LISP_FLOAT_TYPE */
  65.  
  66. #ifndef O_RDONLY
  67. #define O_RDONLY 0
  68. #endif
  69.  
  70. extern int errno;
  71.  
  72. #ifdef USE_PROTOS
  73. #include "protos.h"
  74. #endif
  75.  
  76. Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list;
  77. Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
  78. Lisp_Object Qascii_character, Qload;
  79.  
  80. extern Lisp_Object Qevent_symbol_element_mask;
  81.  
  82. /* non-zero if inside `load' */
  83. int load_in_progress;
  84.  
  85. /* Search path for files to be loaded. */
  86. Lisp_Object Vload_path;
  87.  
  88. /* This is the user-visible association list that maps features to
  89.    lists of defs in their load files. */
  90. Lisp_Object Vload_history;
  91.  
  92. /* This is useud to build the load history. */
  93. Lisp_Object Vcurrent_load_list;
  94.  
  95. /* List of descriptors now open for Fload.  */
  96. static Lisp_Object load_descriptor_list;
  97.  
  98. /* File for get_file_char to read from.  Use by load */
  99. static FILE *instream;
  100.  
  101. /* When nonzero, read conses in pure space */
  102. static int read_pure;
  103.  
  104. /* For use within read-from-string (this reader is non-reentrant!!) */
  105. static int read_from_string_index;
  106. static int read_from_string_limit;
  107.  
  108. /* Handle unreading and rereading of characters.
  109.    Write READCHAR to read a character,
  110.    UNREAD(c) to unread c to be read again. */
  111.  
  112. #define READCHAR readchar (readcharfun)
  113. #define UNREAD(c) unreadchar (readcharfun, c)
  114.  
  115. static int
  116. readchar (readcharfun)
  117.      Lisp_Object readcharfun;
  118. {
  119.   Lisp_Object tem;
  120.   register struct buffer *inbuffer;
  121.   register int c, mpos;
  122.  
  123.   if (XTYPE (readcharfun) == Lisp_Buffer)
  124.     {
  125.       inbuffer = XBUFFER (readcharfun);
  126.  
  127.       if (BUF_PT (inbuffer) >= BUF_ZV (inbuffer))
  128.     return -1;
  129.       c = *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer, BUF_PT (inbuffer));
  130.       SET_BUF_PT (inbuffer, BUF_PT (inbuffer) + 1);
  131.  
  132.       return c;
  133.     }
  134.   if (XTYPE (readcharfun) == Lisp_Marker)
  135.     {
  136.       inbuffer = XMARKER (readcharfun)->buffer;
  137.  
  138.       mpos = marker_position (readcharfun);
  139.  
  140.       if (mpos > BUF_ZV (inbuffer) - 1)
  141.     return -1;
  142.       c = *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer, mpos);
  143.       if (mpos != BUF_GPT (inbuffer))
  144.     XMARKER (readcharfun)->bufpos++;
  145.       else
  146.     Fset_marker (readcharfun, make_number (mpos + 1),
  147.              Fmarker_buffer (readcharfun));
  148.       return c;
  149.     }
  150.   if (EQ (readcharfun, Qget_file_char))
  151.     {
  152.       c = getc (instream);
  153. #ifdef EINTR
  154.       /* Interrupted reads have been observed while reading over the network */
  155.       while (c == EOF && ferror (instream) && errno == EINTR)
  156.     {
  157.       clearerr (instream);
  158.       c = getc (instream);
  159.     }
  160. #endif
  161.       return c;
  162.     }
  163.  
  164.   if (XTYPE (readcharfun) == Lisp_String)
  165.     {
  166.       register int c;
  167.       /* This used to be return of a conditional expression,
  168.      but that truncated -1 to a char on VMS.  */
  169.       if (read_from_string_index < read_from_string_limit)
  170.     c = XSTRING (readcharfun)->data[read_from_string_index++];
  171.       else
  172.     c = -1;
  173.       return c;
  174.     }
  175.  
  176.   tem = call0 (readcharfun);
  177.  
  178.   if (NILP (tem))
  179.     return -1;
  180.   return XINT (tem);
  181. }
  182.  
  183. /* Unread the character C in the way appropriate for the stream READCHARFUN.
  184.    If the stream is a user function, call it with the char as argument.  */
  185.  
  186. static void
  187. unreadchar (readcharfun, c)
  188.      Lisp_Object readcharfun;
  189.      int c;
  190. {
  191.   if (c == -1)
  192.     /* Don't back up the pointer if we're unreading the end-of-input mark,
  193.        since readchar didn't advance it when we read it.  */
  194.     ;
  195.   else if (XTYPE (readcharfun) == Lisp_Buffer)
  196.     {
  197.       if (XBUFFER (readcharfun) == current_buffer)
  198.     SET_PT (point - 1);
  199.       else
  200.     SET_BUF_PT (XBUFFER (readcharfun), BUF_PT (XBUFFER (readcharfun)) - 1);
  201.     }
  202.   else if (XTYPE (readcharfun) == Lisp_Marker)
  203.     XMARKER (readcharfun)->bufpos--;
  204.   else if (XTYPE (readcharfun) == Lisp_String)
  205.     read_from_string_index--;
  206.   else if (EQ (readcharfun, Qget_file_char))
  207.     ungetc (c, instream);
  208.   else
  209.     call1 (readcharfun, make_number (c));
  210. }
  211.  
  212. static Lisp_Object read0 (), read1 (), read_list (), read_vector ();
  213.  
  214. /* get a character from the tty */
  215.  
  216. extern Lisp_Object read_char ();
  217.  
  218. /* Read input events until we get one that's acceptable for our purposes.
  219.  
  220.    If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed
  221.    until we get a character we like, and then stuffed into
  222.    unread_switch_frame.
  223.  
  224.    If ASCII_REQUIRED is non-zero, we check function key events to see
  225.    if the unmodified version of the symbol has a Qascii_character
  226.    property, and use that character, if present.
  227.  
  228.    If ERROR_NONASCII is non-zero, we signal an error if the input we
  229.    get isn't an ASCII character with modifiers.  If it's zero but
  230.    ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII
  231.    character.  */
  232. Lisp_Object
  233. read_filtered_event (no_switch_frame, ascii_required, error_nonascii)
  234.      int no_switch_frame, ascii_required, error_nonascii;
  235. {
  236. #ifdef standalone
  237.   return make_number (getchar ());
  238. #else
  239.   register Lisp_Object val, delayed_switch_frame;
  240.  
  241.   delayed_switch_frame = Qnil;
  242.  
  243.   /* Read until we get an acceptable event.  */
  244.  retry:
  245.   val = read_char (0, 0, 0, Qnil, 0);
  246.  
  247.   if (XTYPE (val) == Lisp_Buffer)
  248.     goto retry;
  249.  
  250.   /* switch-frame events are put off until after the next ASCII
  251.      character.  This is better than signalling an error just because
  252.      the last characters were typed to a separate minibuffer frame,
  253.      for example.  Eventually, some code which can deal with
  254.      switch-frame events will read it and process it.  */
  255.   if (no_switch_frame
  256.       && EVENT_HAS_PARAMETERS (val)
  257.       && EQ (EVENT_HEAD (val), Qswitch_frame))
  258.     {
  259.       delayed_switch_frame = val;
  260.       goto retry;
  261.     }
  262.  
  263.   if (ascii_required)
  264.     {
  265.       /* Convert certain symbols to their ASCII equivalents.  */
  266.       if (XTYPE (val) == Lisp_Symbol)
  267.     {
  268.       Lisp_Object tem, tem1, tem2;
  269.       tem = Fget (val, Qevent_symbol_element_mask);
  270.       if (!NILP (tem))
  271.         {
  272.           tem1 = Fget (Fcar (tem), Qascii_character);
  273.           /* Merge this symbol's modifier bits
  274.          with the ASCII equivalent of its basic code.  */
  275.           if (!NILP (tem1))
  276.         XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem)));
  277.         }
  278.     }
  279.       
  280.       /* If we don't have a character now, deal with it appropriately.  */
  281.       if (XTYPE (val) != Lisp_Int)
  282.     {
  283.       if (error_nonascii)
  284.         {
  285.           Vunread_command_events = Fcons (val, Qnil);
  286.           error ("Non-character input-event");
  287.         }
  288.       else
  289.         goto retry;
  290.     }
  291.     }
  292.  
  293.   if (! NILP (delayed_switch_frame))
  294.     unread_switch_frame = delayed_switch_frame;
  295.  
  296.   return val;
  297. #endif
  298. }
  299.  
  300. DEFUN ("read-char", Fread_char, Sread_char, 0, 0, 0,
  301.   "Read a character from the command input (keyboard or macro).\n\
  302. It is returned as a number.\n\
  303. If the user generates an event which is not a character (i.e. a mouse\n\
  304. click or function key event), `read-char' signals an error.  As an\n\
  305. exception, switch-frame events are put off until non-ASCII events can\n\
  306. be read.\n\
  307. If you want to read non-character events, or ignore them, call\n\
  308. `read-event' or `read-char-exclusive' instead.")
  309.   ()
  310. {
  311.   return read_filtered_event (1, 1, 1);
  312. }
  313.  
  314. DEFUN ("read-event", Fread_event, Sread_event, 0, 0, 0,
  315.   "Read an event object from the input stream.")
  316.   ()
  317. {
  318.   return read_filtered_event (0, 0, 0);
  319. }
  320.  
  321. DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 0, 0,
  322.   "Read a character from the command input (keyboard or macro).\n\
  323. It is returned as a number.  Non character events are ignored.")
  324.   ()
  325. {
  326.   return read_filtered_event (1, 1, 0);
  327. }
  328.  
  329. DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
  330.   "Don't use this yourself.")
  331.   ()
  332. {
  333.   register Lisp_Object val;
  334.   XSET (val, Lisp_Int, getc (instream));
  335.   return val;
  336. }
  337.  
  338. static void readevalloop ();
  339. static Lisp_Object load_unwind ();
  340. static Lisp_Object load_descriptor_unwind ();
  341.  
  342. DEFUN ("load", Fload, Sload, 1, 4, 0,
  343.   "Execute a file of Lisp code named FILE.\n\
  344. First try FILE with `.elc' appended, then try with `.el',\n\
  345.  then try FILE unmodified.\n\
  346. This function searches the directories in `load-path'.\n\
  347. If optional second arg NOERROR is non-nil,\n\
  348.  report no error if FILE doesn't exist.\n\
  349. Print messages at start and end of loading unless\n\
  350.  optional third arg NOMESSAGE is non-nil.\n\
  351. If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
  352.  suffixes `.elc' or `.el' to the specified name FILE.\n\
  353. Return t if file exists.")
  354.   (str, noerror, nomessage, nosuffix)
  355.      Lisp_Object str, noerror, nomessage, nosuffix;
  356. {
  357.   register FILE *stream;
  358.   register int fd = -1;
  359.   register Lisp_Object lispstream;
  360.   register FILE **ptr;
  361.   int count = specpdl_ptr - specpdl;
  362.   Lisp_Object temp;
  363.   struct gcpro gcpro1;
  364.   Lisp_Object found;
  365.   /* 1 means inhibit the message at the beginning.  */
  366.   int nomessage1 = 0;
  367.   Lisp_Object handler;
  368. #ifdef MSDOS
  369.   char *dosmode = "rt";
  370. #endif
  371.  
  372.   CHECK_STRING (str, 0);
  373.   str = Fsubstitute_in_file_name (str);
  374.  
  375.   /* If file name is magic, call the handler.  */
  376.   handler = Ffind_file_name_handler (str, Qload);
  377.   if (!NILP (handler))
  378.     return call5 (handler, Qload, str, noerror, nomessage, nosuffix);
  379.  
  380.   /* Avoid weird lossage with null string as arg,
  381.      since it would try to load a directory as a Lisp file */
  382.   if (XSTRING (str)->size > 0)
  383.     {
  384.       GCPRO1 (str);
  385.       fd = openp (Vload_path, str, !NILP (nosuffix) ? "" : ".elc:.el:",
  386.           &found, 0);
  387.       UNGCPRO;
  388.     }
  389.  
  390.   if (fd < 0)
  391.     {
  392.       if (NILP (noerror))
  393.     while (1)
  394.       Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"),
  395.                        Fcons (str, Qnil)));
  396.       else
  397.     return Qnil;
  398.     }
  399.  
  400.   if (!bcmp (&(XSTRING (found)->data[XSTRING (found)->size - 4]),
  401.          ".elc", 4))
  402.     {
  403.       struct stat s1, s2;
  404.       int result;
  405.  
  406. #ifdef MSDOS
  407.       dosmode = "rb";
  408. #endif
  409.       stat ((char *)XSTRING (found)->data, &s1);
  410.       XSTRING (found)->data[XSTRING (found)->size - 1] = 0;
  411.       result = stat ((char *)XSTRING (found)->data, &s2);
  412.       if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
  413.     {
  414.       message ("Source file `%s' newer than byte-compiled file",
  415.            XSTRING (found)->data);
  416.       /* Don't immediately overwrite this message.  */
  417.       if (!noninteractive)
  418.         nomessage1 = 1;
  419.     }
  420.       XSTRING (found)->data[XSTRING (found)->size - 1] = 'c';
  421.     }
  422.  
  423. #ifdef MSDOS
  424.   close (fd);
  425.   stream = fopen ((char *) XSTRING (found)->data, dosmode);
  426. #else
  427.   stream = fdopen (fd, "r");
  428. #endif
  429.   if (stream == 0)
  430.     {
  431.       close (fd);
  432.       error ("Failure to create stdio stream for %s", XSTRING (str)->data);
  433.     }
  434.  
  435.   if (NILP (nomessage) && !nomessage1)
  436.     message ("Loading %s...", XSTRING (str)->data);
  437.  
  438.   GCPRO1 (str);
  439.   /* We may not be able to store STREAM itself as a Lisp_Object pointer
  440.      since that is guaranteed to work only for data that has been malloc'd.
  441.      So malloc a full-size pointer, and record the address of that pointer.  */
  442.   ptr = (FILE **) xmalloc (sizeof (FILE *));
  443.   *ptr = stream;
  444.   XSET (lispstream, Lisp_Internal_Stream, (int) ptr);
  445.   record_unwind_protect (load_unwind, lispstream);
  446.   record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
  447.   load_descriptor_list
  448.     = Fcons (make_number (fileno (stream)), load_descriptor_list);
  449.   load_in_progress++;
  450.   readevalloop (Qget_file_char, stream, str, Feval, 0);
  451.   unbind_to (count, Qnil);
  452.  
  453.   /* Run any load-hooks for this file.  */
  454.   temp = Fassoc (str, Vafter_load_alist);
  455.   if (!NILP (temp))
  456.     Fprogn (Fcdr (temp));
  457.   UNGCPRO;
  458.  
  459.   if (!noninteractive && NILP (nomessage))
  460.     message ("Loading %s...done", XSTRING (str)->data);
  461.   return Qt;
  462. }
  463.  
  464. static Lisp_Object
  465. load_unwind (stream)  /* used as unwind-protect function in load */
  466.      Lisp_Object stream;
  467. {
  468.   fclose (*(FILE **) XSTRING (stream));
  469.   xfree (XPNTR (stream));
  470.   if (--load_in_progress < 0) load_in_progress = 0;
  471.   return Qnil;
  472. }
  473.  
  474. static Lisp_Object
  475. load_descriptor_unwind (oldlist)
  476.      Lisp_Object oldlist;
  477. {
  478.   load_descriptor_list = oldlist;
  479. }
  480.  
  481. /* Close all descriptors in use for Floads.
  482.    This is used when starting a subprocess.  */
  483.  
  484. void
  485. close_load_descs ()
  486. {
  487.   Lisp_Object tail;
  488.   for (tail = load_descriptor_list; !NILP (tail); tail = XCONS (tail)->cdr)
  489.     close (XFASTINT (XCONS (tail)->car));
  490. }
  491.  
  492. static int
  493. complete_filename_p (pathname)
  494.      Lisp_Object pathname;
  495. {
  496.   register unsigned char *s = XSTRING (pathname)->data;
  497. #ifdef AMIGA
  498.   return (*s && index(s + 1, ':')); /* Non-leading : */
  499. #else
  500.   return (*s == '/'
  501. #ifdef ALTOS
  502.       || *s == '@'
  503. #endif
  504. #ifdef VMS
  505.       || index (s, ':')
  506. #endif /* VMS */
  507. #ifdef MSDOS    /* MW, May 1993 */
  508.       || (s[0] != '\0' && s[1] == ':' && s[2] == '/')
  509. #endif
  510.       );
  511. #endif /* not AMIGA */
  512. }
  513.  
  514. /* Search for a file whose name is STR, looking in directories
  515.    in the Lisp list PATH, and trying suffixes from SUFFIX.
  516.    SUFFIX is a string containing possible suffixes separated by colons.
  517.    On success, returns a file descriptor.  On failure, returns -1.
  518.  
  519.    EXEC_ONLY nonzero means don't open the files,
  520.    just look for one that is executable.  In this case,
  521.    returns 1 on success.
  522.  
  523.    If STOREPTR is nonzero, it points to a slot where the name of
  524.    the file actually found should be stored as a Lisp string.
  525.    Nil is stored there on failure.  */
  526.  
  527. int
  528. openp (path, str, suffix, storeptr, exec_only)
  529.      Lisp_Object path, str;
  530.      char *suffix;
  531.      Lisp_Object *storeptr;
  532.      int exec_only;
  533. {
  534.   register int fd;
  535.   int fn_size = 100;
  536.   char buf[100];
  537.   register char *fn = buf;
  538.   int absolute = 0;
  539.   int want_size;
  540.   register Lisp_Object filename;
  541.   struct stat st;
  542.   struct gcpro gcpro1;
  543.  
  544.   GCPRO1 (str);
  545.   if (storeptr)
  546.     *storeptr = Qnil;
  547.  
  548.   if (complete_filename_p (str))
  549.     absolute = 1;
  550.  
  551.   for (; !NILP (path); path = Fcdr (path))
  552.     {
  553.       char *nsuffix;
  554.  
  555.       filename = Fexpand_file_name (str, Fcar (path));
  556.       if (!complete_filename_p (filename))
  557.     /* If there are non-absolute elts in PATH (eg ".") */
  558.     /* Of course, this could conceivably lose if luser sets
  559.        default-directory to be something non-absolute... */
  560.     {
  561.       filename = Fexpand_file_name (filename, current_buffer->directory);
  562.       if (!complete_filename_p (filename))
  563.         /* Give up on this path element! */
  564.         continue;
  565.     }
  566.  
  567.       /* Calculate maximum size of any filename made from
  568.      this path element/specified file name and any possible suffix.  */
  569.       want_size = strlen (suffix) + XSTRING (filename)->size + 1;
  570.       if (fn_size < want_size)
  571.     fn = (char *) alloca (fn_size = 100 + want_size);
  572.  
  573.       nsuffix = suffix;
  574.  
  575.       /* Loop over suffixes.  */
  576.       while (1)
  577.     {
  578.       char *esuffix = (char *) index (nsuffix, ':');
  579.       int lsuffix = esuffix ? esuffix - nsuffix : strlen (nsuffix);
  580.  
  581.       /* Concatenate path element/specified name with the suffix.  */
  582.       strncpy (fn, XSTRING (filename)->data, XSTRING (filename)->size);
  583.       fn[XSTRING (filename)->size] = 0;
  584.       if (lsuffix != 0)  /* Bug happens on CCI if lsuffix is 0.  */
  585.         strncat (fn, nsuffix, lsuffix);
  586.  
  587.       /* Ignore file if it's a directory.  */
  588.       if (stat (fn, &st) >= 0
  589.           && (st.st_mode & S_IFMT) != S_IFDIR)
  590.         {
  591.           /* Check that we can access or open it.  */
  592.           if (exec_only)
  593.         fd = (access (fn, X_OK) == 0) ? 1 : -1;
  594.           else
  595.         fd = open (fn, O_RDONLY, 0);
  596.  
  597.           if (fd >= 0)
  598.         {
  599.           /* We succeeded; return this descriptor and filename.  */
  600.           if (storeptr)
  601.             *storeptr = build_string (fn);
  602.           RETURN_UNGCPRO (fd);
  603.         }
  604.         }
  605.  
  606.       /* Advance to next suffix.  */
  607.       if (esuffix == 0)
  608.         break;
  609.       nsuffix += lsuffix + 1;
  610.     }
  611.       if (absolute)
  612.     RETURN_UNGCPRO (-1);
  613.     }
  614.  
  615.   RETURN_UNGCPRO (-1);
  616. }
  617.  
  618.  
  619. /* Merge the list we've accumulated of globals from the current input source
  620.    into the load_history variable.  The details depend on whether
  621.    the source has an associated file name or not. */
  622.  
  623. static void
  624. build_load_history (stream, source)
  625.      FILE *stream;
  626.      Lisp_Object source;
  627. {
  628.   register Lisp_Object tail, prev, newelt;
  629.   register Lisp_Object tem, tem2;
  630.   register int foundit, loading;
  631.  
  632.   /* Don't bother recording anything for preloaded files.  */
  633.   if (!NILP (Vpurify_flag))
  634.     return;
  635.  
  636.   loading = stream || !NARROWED;
  637.  
  638.   tail = Vload_history;
  639.   prev = Qnil;
  640.   foundit = 0;
  641.   while (!NILP (tail))
  642.     {
  643.       tem = Fcar (tail);
  644.  
  645.       /* Find the feature's previous assoc list... */
  646.       if (!NILP (Fequal (source, Fcar (tem))))
  647.     {
  648.       foundit = 1;
  649.  
  650.       /*  If we're loading, remove it. */
  651.       if (loading)
  652.         {      
  653.           if (NILP (prev))
  654.         Vload_history = Fcdr (tail);
  655.           else
  656.         Fsetcdr (prev, Fcdr (tail));
  657.         }
  658.  
  659.       /*  Otherwise, cons on new symbols that are not already members.  */
  660.       else
  661.         {
  662.           tem2 = Vcurrent_load_list;
  663.  
  664.           while (CONSP (tem2))
  665.         {
  666.           newelt = Fcar (tem2);
  667.  
  668.           if (NILP (Fmemq (newelt, tem)))
  669.             Fsetcar (tail, Fcons (Fcar (tem),
  670.                       Fcons (newelt, Fcdr (tem))));
  671.  
  672.           tem2 = Fcdr (tem2);
  673.           QUIT;
  674.         }
  675.         }
  676.     }
  677.       else
  678.     prev = tail;
  679.       tail = Fcdr (tail);
  680.       QUIT;
  681.     }
  682.  
  683.   /* If we're loading, cons the new assoc onto the front of load-history,
  684.      the most-recently-loaded position.  Also do this if we didn't find
  685.      an existing member for the current source.  */
  686.   if (loading || !foundit)
  687.     Vload_history = Fcons (Fnreverse (Vcurrent_load_list),
  688.                Vload_history);
  689. }
  690.  
  691. Lisp_Object
  692. unreadpure ()    /* Used as unwind-protect function in readevalloop */
  693. {
  694.   read_pure = 0;
  695.   return Qnil;
  696. }
  697.  
  698. static void
  699. readevalloop (readcharfun, stream, sourcename, evalfun, printflag)
  700.      Lisp_Object readcharfun;
  701.      FILE *stream;
  702.      Lisp_Object sourcename;
  703.      Lisp_Object (*evalfun) ();
  704.      int printflag;
  705. {
  706.   register int c;
  707.   register Lisp_Object val;
  708.   int count = specpdl_ptr - specpdl;
  709.   struct gcpro gcpro1;
  710.   struct buffer *b = 0;
  711.  
  712.   if (BUFFERP (readcharfun))
  713.     b = XBUFFER (readcharfun);
  714.   else if (MARKERP (readcharfun))
  715.     b = XMARKER (readcharfun)->buffer;
  716.  
  717.   specbind (Qstandard_input, readcharfun);
  718.   specbind (Qcurrent_load_list, Qnil);
  719.  
  720.   GCPRO1 (sourcename);
  721.  
  722.   LOADHIST_ATTACH (sourcename);
  723.  
  724.   while (1)
  725.     {
  726.       if (b != 0 && NILP (b->name))
  727.     error ("Reading from killed buffer");
  728.  
  729.       instream = stream;
  730.       c = READCHAR;
  731.       if (c == ';')
  732.     {
  733.       while ((c = READCHAR) != '\n' && c != -1);
  734.       continue;
  735.     }
  736.       if (c < 0) break;
  737.       if (c == ' ' || c == '\t' || c == '\n' || c == '\f') continue;
  738.  
  739.       if (!NILP (Vpurify_flag) && c == '(')
  740.     {
  741.       int count1 = specpdl_ptr - specpdl;
  742.       record_unwind_protect (unreadpure, Qnil);
  743.       val = read_list (-1, readcharfun);
  744.       unbind_to (count1, Qnil);
  745.     }
  746.       else
  747.     {
  748.       UNREAD (c);
  749.       val = read0 (readcharfun);
  750.     }
  751.  
  752.       val = (*evalfun) (val);
  753.       if (printflag)
  754.     {
  755.       Vvalues = Fcons (val, Vvalues);
  756.       if (EQ (Vstandard_output, Qt))
  757.         Fprin1 (val, Qnil);
  758.       else
  759.         Fprint (val, Qnil);
  760.     }
  761.     }
  762.  
  763.   build_load_history (stream, sourcename);
  764.   UNGCPRO;
  765.  
  766.   unbind_to (count, Qnil);
  767. }
  768.  
  769. #ifndef standalone
  770.  
  771. DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 2, "",
  772.   "Execute the current buffer as Lisp code.\n\
  773. Programs can pass two arguments, BUFFER and PRINTFLAG.\n\
  774. BUFFER is the buffer to evaluate (nil means use current buffer).\n\
  775. PRINTFLAG controls printing of output:\n\
  776. nil means discard it; anything else is stream for print.\n\
  777. \n\
  778. If there is no error, point does not move.  If there is an error,\n\
  779. point remains at the end of the last character read from the buffer.")
  780.   (bufname, printflag)
  781.      Lisp_Object bufname, printflag;
  782. {
  783.   int count = specpdl_ptr - specpdl;
  784.   Lisp_Object tem, buf;
  785.  
  786.   if (NILP (bufname))
  787.     buf = Fcurrent_buffer ();
  788.   else
  789.     buf = Fget_buffer (bufname);
  790.   if (NILP (buf))
  791.     error ("No such buffer.");
  792.  
  793.   if (NILP (printflag))
  794.     tem = Qsymbolp;
  795.   else
  796.     tem = printflag;
  797.   specbind (Qstandard_output, tem);
  798.   record_unwind_protect (save_excursion_restore, save_excursion_save ());
  799.   BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
  800.   readevalloop (buf, 0, XBUFFER (buf)->filename, Feval, !NILP (printflag));
  801.   unbind_to (count, Qnil);
  802.  
  803.   return Qnil;
  804. }
  805.  
  806. #if 0
  807. DEFUN ("eval-current-buffer", Feval_current_buffer, Seval_current_buffer, 0, 1, "",
  808.   "Execute the current buffer as Lisp code.\n\
  809. Programs can pass argument PRINTFLAG which controls printing of output:\n\
  810. nil means discard it; anything else is stream for print.\n\
  811. \n\
  812. If there is no error, point does not move.  If there is an error,\n\
  813. point remains at the end of the last character read from the buffer.")
  814.   (printflag)
  815.      Lisp_Object printflag;
  816. {
  817.   int count = specpdl_ptr - specpdl;
  818.   Lisp_Object tem, cbuf;
  819.  
  820.   cbuf = Fcurrent_buffer ()
  821.  
  822.   if (NILP (printflag))
  823.     tem = Qsymbolp;
  824.   else
  825.     tem = printflag;
  826.   specbind (Qstandard_output, tem);
  827.   record_unwind_protect (save_excursion_restore, save_excursion_save ());
  828.   SET_PT (BEGV);
  829.   readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag));
  830.   return unbind_to (count, Qnil);
  831. }
  832. #endif
  833.  
  834. DEFUN ("eval-region", Feval_region, Seval_region, 2, 3, "r",
  835.   "Execute the region as Lisp code.\n\
  836. When called from programs, expects two arguments,\n\
  837. giving starting and ending indices in the current buffer\n\
  838. of the text to be executed.\n\
  839. Programs can pass third argument PRINTFLAG which controls output:\n\
  840. nil means discard it; anything else is stream for printing it.\n\
  841. \n\
  842. If there is no error, point does not move.  If there is an error,\n\
  843. point remains at the end of the last character read from the buffer.")
  844.   (b, e, printflag)
  845.      Lisp_Object b, e, printflag;
  846. {
  847.   int count = specpdl_ptr - specpdl;
  848.   Lisp_Object tem, cbuf;
  849.  
  850.   cbuf = Fcurrent_buffer ();
  851.  
  852.   if (NILP (printflag))
  853.     tem = Qsymbolp;
  854.   else
  855.     tem = printflag;
  856.   specbind (Qstandard_output, tem);
  857.  
  858.   if (NILP (printflag))
  859.     record_unwind_protect (save_excursion_restore, save_excursion_save ());
  860.   record_unwind_protect (save_restriction_restore, save_restriction_save ());
  861.  
  862.   /* This both uses b and checks its type.  */
  863.   Fgoto_char (b);
  864.   Fnarrow_to_region (make_number (BEGV), e);
  865.   readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag));
  866.  
  867.   return unbind_to (count, Qnil);
  868. }
  869.  
  870. #endif /* standalone */
  871.  
  872. DEFUN ("read", Fread, Sread, 0, 1, 0,
  873.   "Read one Lisp expression as text from STREAM, return as Lisp object.\n\
  874. If STREAM is nil, use the value of `standard-input' (which see).\n\
  875. STREAM or the value of `standard-input' may be:\n\
  876.  a buffer (read from point and advance it)\n\
  877.  a marker (read from where it points and advance it)\n\
  878.  a function (call it with no arguments for each character,\n\
  879.      call it with a char as argument to push a char back)\n\
  880.  a string (takes text from string, starting at the beginning)\n\
  881.  t (read text line using minibuffer and use it).")
  882.   (readcharfun)
  883.      Lisp_Object readcharfun;
  884. {
  885.   extern Lisp_Object Fread_minibuffer ();
  886.  
  887.   if (NILP (readcharfun))
  888.     readcharfun = Vstandard_input;
  889.   if (EQ (readcharfun, Qt))
  890.     readcharfun = Qread_char;
  891.  
  892. #ifndef standalone
  893.   if (EQ (readcharfun, Qread_char))
  894.     return Fread_minibuffer (build_string ("Lisp expression: "), Qnil);
  895. #endif
  896.  
  897.   if (XTYPE (readcharfun) == Lisp_String)
  898.     return Fcar (Fread_from_string (readcharfun, Qnil, Qnil));
  899.  
  900.   return read0 (readcharfun);
  901. }
  902.  
  903. DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0,
  904.   "Read one Lisp expression which is represented as text by STRING.\n\
  905. Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\
  906. START and END optionally delimit a substring of STRING from which to read;\n\
  907.  they default to 0 and (length STRING) respectively.")
  908.   (string, start, end)
  909.      Lisp_Object string, start, end;
  910. {
  911.   int startval, endval;
  912.   Lisp_Object tem;
  913.  
  914.   CHECK_STRING (string,0);
  915.  
  916.   if (NILP (end))
  917.     endval = XSTRING (string)->size;
  918.   else
  919.     { CHECK_NUMBER (end,2);
  920.       endval = XINT (end);
  921.       if (endval < 0 || endval > XSTRING (string)->size)
  922.     args_out_of_range (string, end);
  923.     }
  924.  
  925.   if (NILP (start))
  926.     startval = 0;
  927.   else
  928.     { CHECK_NUMBER (start,1);
  929.       startval = XINT (start);
  930.       if (startval < 0 || startval > endval)
  931.     args_out_of_range (string, start);
  932.     }
  933.  
  934.   read_from_string_index = startval;
  935.   read_from_string_limit = endval;
  936.  
  937.   tem = read0 (string);
  938.   return Fcons (tem, make_number (read_from_string_index));
  939. }
  940.  
  941. /* Use this for recursive reads, in contexts where internal tokens are not allowed. */
  942.  
  943. static Lisp_Object
  944. read0 (readcharfun)
  945.      Lisp_Object readcharfun;
  946. {
  947.   register Lisp_Object val;
  948.   char c;
  949.  
  950.   val = read1 (readcharfun);
  951.   if (XTYPE (val) == Lisp_Internal)
  952.     {
  953.       c = XINT (val);
  954.       return Fsignal (Qinvalid_read_syntax, Fcons (make_string (&c, 1), Qnil));
  955.     }
  956.  
  957.   return val;
  958. }
  959.  
  960. static int read_buffer_size;
  961. char *read_buffer; /* CHFIXME */
  962.  
  963. static int
  964. read_escape (readcharfun)
  965.      Lisp_Object readcharfun;
  966. {
  967.   register int c = READCHAR;
  968.   switch (c)
  969.     {
  970.     case 'a':
  971.       return '\007';
  972.     case 'b':
  973.       return '\b';
  974.     case 'd':
  975.       return 0177;
  976.     case 'e':
  977.       return 033;
  978.     case 'f':
  979.       return '\f';
  980.     case 'n':
  981.       return '\n';
  982.     case 'r':
  983.       return '\r';
  984.     case 't':
  985.       return '\t';
  986.     case 'v':
  987.       return '\v';
  988.     case '\n':
  989.       return -1;
  990.  
  991.     case 'M':
  992.       c = READCHAR;
  993.       if (c != '-')
  994.     error ("Invalid escape character syntax");
  995.       c = READCHAR;
  996.       if (c == '\\')
  997.     c = read_escape (readcharfun);
  998.       return c | meta_modifier;
  999.  
  1000.     case 'S':
  1001.       c = READCHAR;
  1002.       if (c != '-')
  1003.     error ("Invalid escape character syntax");
  1004.       c = READCHAR;
  1005.       if (c == '\\')
  1006.     c = read_escape (readcharfun);
  1007.       return c | shift_modifier;
  1008.  
  1009.     case 'H':
  1010.       c = READCHAR;
  1011.       if (c != '-')
  1012.     error ("Invalid escape character syntax");
  1013.       c = READCHAR;
  1014.       if (c == '\\')
  1015.     c = read_escape (readcharfun);
  1016.       return c | hyper_modifier;
  1017.  
  1018.     case 'A':
  1019.       c = READCHAR;
  1020.       if (c != '-')
  1021.     error ("Invalid escape character syntax");
  1022.       c = READCHAR;
  1023.       if (c == '\\')
  1024.     c = read_escape (readcharfun);
  1025.       return c | alt_modifier;
  1026.  
  1027.     case 's':
  1028.       c = READCHAR;
  1029.       if (c != '-')
  1030.     error ("Invalid escape character syntax");
  1031.       c = READCHAR;
  1032.       if (c == '\\')
  1033.     c = read_escape (readcharfun);
  1034.       return c | super_modifier;
  1035.  
  1036.     case 'C':
  1037.       c = READCHAR;
  1038.       if (c != '-')
  1039.     error ("Invalid escape character syntax");
  1040.     case '^':
  1041.       c = READCHAR;
  1042.       if (c == '\\')
  1043.     c = read_escape (readcharfun);
  1044.       if ((c & 0177) == '?')
  1045.     return 0177 | c;
  1046.       /* ASCII control chars are made from letters (both cases),
  1047.      as well as the non-letters within 0100...0137.  */
  1048.       else if ((c & 0137) >= 0101 && (c & 0137) <= 0132)
  1049.     return (c & (037 | ~0177));
  1050.       else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
  1051.     return (c & (037 | ~0177));
  1052.       else
  1053.     return c | ctrl_modifier;
  1054.  
  1055.     case '0':
  1056.     case '1':
  1057.     case '2':
  1058.     case '3':
  1059.     case '4':
  1060.     case '5':
  1061.     case '6':
  1062.     case '7':
  1063.       /* An octal escape, as in ANSI C.  */
  1064.       {
  1065.     register int i = c - '0';
  1066.     register int count = 0;
  1067.     while (++count < 3)
  1068.       {
  1069.         if ((c = READCHAR) >= '0' && c <= '7')
  1070.           {
  1071.         i *= 8;
  1072.         i += c - '0';
  1073.           }
  1074.         else
  1075.           {
  1076.         UNREAD (c);
  1077.         break;
  1078.           }
  1079.       }
  1080.     return i;
  1081.       }
  1082.  
  1083.     case 'x':
  1084.       /* A hex escape, as in ANSI C.  */
  1085.       {
  1086.     int i = 0;
  1087.     while (1)
  1088.       {
  1089.         c = READCHAR;
  1090.         if (c >= '0' && c <= '9')
  1091.           {
  1092.         i *= 16;
  1093.         i += c - '0';
  1094.           }
  1095.         else if ((c >= 'a' && c <= 'f')
  1096.              || (c >= 'A' && c <= 'F'))
  1097.           {
  1098.         i *= 16;
  1099.         if (c >= 'a' && c <= 'f')
  1100.           i += c - 'a' + 10;
  1101.         else
  1102.           i += c - 'A' + 10;
  1103.           }
  1104.         else
  1105.           {
  1106.         UNREAD (c);
  1107.         break;
  1108.           }
  1109.       }
  1110.     return i;
  1111.       }
  1112.  
  1113.     default:
  1114.       return c;
  1115.     }
  1116. }
  1117.  
  1118. static Lisp_Object
  1119. read1 (readcharfun)
  1120.      register Lisp_Object readcharfun;
  1121. {
  1122.   register int c;
  1123.  
  1124.  retry:
  1125.  
  1126.   c = READCHAR;
  1127.   if (c < 0) return Fsignal (Qend_of_file, Qnil);
  1128.  
  1129.   switch (c)
  1130.     {
  1131.     case '(':
  1132.       return read_list (0, readcharfun);
  1133.  
  1134.     case '[':
  1135.       return read_vector (readcharfun);
  1136.  
  1137.     case ')':
  1138.     case ']':
  1139.       {
  1140.     register Lisp_Object val;
  1141.     XSET (val, Lisp_Internal, c);
  1142.     return val;
  1143.       }
  1144.  
  1145.     case '#':
  1146.       c = READCHAR;
  1147.       if (c == '[')
  1148.     {
  1149.       /* Accept compiled functions at read-time so that we don't have to
  1150.          build them using function calls.  */
  1151.       Lisp_Object tmp;
  1152.       tmp = read_vector (readcharfun);
  1153.       return Fmake_byte_code (XVECTOR (tmp)->size,
  1154.                   XVECTOR (tmp)->contents);
  1155.     }
  1156. #ifdef USE_TEXT_PROPERTIES
  1157.       if (c == '(')
  1158.     {
  1159.       Lisp_Object tmp;
  1160.       struct gcpro gcpro1;
  1161.  
  1162.       /* Read the string itself.  */
  1163.       tmp = read1 (readcharfun);
  1164.       if (XTYPE (tmp) != Lisp_String)
  1165.         Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
  1166.       GCPRO1 (tmp);
  1167.       /* Read the intervals and their properties.  */
  1168.       while (1)
  1169.         {
  1170.           Lisp_Object beg, end, plist;
  1171.  
  1172.           beg = read1 (readcharfun);
  1173.           if (XTYPE (beg) == Lisp_Internal)
  1174.         {
  1175.           if (XINT (beg) == ')')
  1176.             break;
  1177.           Fsignal (Qinvalid_read_syntax, Fcons (make_string ("invalid string property list", 28), Qnil));
  1178.         }
  1179.           end = read1 (readcharfun);
  1180.           if (XTYPE (end) == Lisp_Internal)
  1181.         Fsignal (Qinvalid_read_syntax,
  1182.              Fcons (make_string ("invalid string property list", 28), Qnil));
  1183.         
  1184.           plist = read1 (readcharfun);
  1185.           if (XTYPE (plist) == Lisp_Internal)
  1186.         Fsignal (Qinvalid_read_syntax,
  1187.              Fcons (make_string ("invalid string property list", 28), Qnil));
  1188.           Fset_text_properties (beg, end, plist, tmp);
  1189.         }
  1190.       UNGCPRO;
  1191.       return tmp;
  1192.     }
  1193. #endif
  1194.       UNREAD (c);
  1195.       Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
  1196.  
  1197.     case ';':
  1198.       while ((c = READCHAR) >= 0 && c != '\n');
  1199.       goto retry;
  1200.  
  1201.     case '\'':
  1202.       {
  1203.     return Fcons (Qquote, Fcons (read0 (readcharfun), Qnil));
  1204.       }
  1205.  
  1206.     case '?':
  1207.       {
  1208.     register Lisp_Object val;
  1209.  
  1210.     c = READCHAR;
  1211.     if (c < 0) return Fsignal (Qend_of_file, Qnil);
  1212.  
  1213.     if (c == '\\')
  1214.       XSET (val, Lisp_Int, read_escape (readcharfun));
  1215.     else
  1216.       XSET (val, Lisp_Int, c);
  1217.  
  1218.     return val;
  1219.       }
  1220.  
  1221.     case '\"':
  1222.       {
  1223.     register char *p = read_buffer;
  1224.     register char *end = read_buffer + read_buffer_size;
  1225.     register int c;
  1226.     int cancel = 0;
  1227.  
  1228.     while ((c = READCHAR) >= 0
  1229.            && c != '\"')
  1230.       {
  1231.         if (p == end)
  1232.           {
  1233.         char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  1234.         p += new - read_buffer;
  1235.         read_buffer += new - read_buffer;
  1236.         end = read_buffer + read_buffer_size;
  1237.           }
  1238.         if (c == '\\')
  1239.           c = read_escape (readcharfun);
  1240.         /* c is -1 if \ newline has just been seen */
  1241.         if (c == -1)
  1242.           {
  1243.         if (p == read_buffer)
  1244.           cancel = 1;
  1245.           }
  1246.         else
  1247.           {
  1248.         /* Allow `\C- ' and `\C-?'.  */
  1249.         if (c == (CHAR_CTL | ' '))
  1250.           c = 0;
  1251.         else if (c == (CHAR_CTL | '?'))
  1252.           c = 127;
  1253.  
  1254.         if (c & CHAR_META)
  1255.           /* Move the meta bit to the right place for a string.  */
  1256.           c = (c & ~CHAR_META) | 0x80;
  1257.         if (c & ~0xff)
  1258.           error ("Invalid modifier in string");
  1259.         *p++ = c;
  1260.           }
  1261.       }
  1262.     if (c < 0) return Fsignal (Qend_of_file, Qnil);
  1263.  
  1264.     /* If purifying, and string starts with \ newline,
  1265.        return zero instead.  This is for doc strings
  1266.        that we are really going to find in etc/DOC.nn.nn  */
  1267.     if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel)
  1268.       return make_number (0);
  1269.  
  1270.     if (read_pure)
  1271.       return make_pure_string (read_buffer, p - read_buffer);
  1272.     else
  1273.       return make_string (read_buffer, p - read_buffer);
  1274.       }
  1275.  
  1276.     case '.':
  1277.       {
  1278. #ifdef LISP_FLOAT_TYPE
  1279.     /* If a period is followed by a number, then we should read it
  1280.        as a floating point number.  Otherwise, it denotes a dotted
  1281.        pair.  */
  1282.     int next_char = READCHAR;
  1283.     UNREAD (next_char);
  1284.  
  1285.     if (! isdigit (next_char))
  1286. #endif
  1287.       {
  1288.         register Lisp_Object val;
  1289.         XSET (val, Lisp_Internal, c);
  1290.         return val;
  1291.       }
  1292.  
  1293.     /* Otherwise, we fall through!  Note that the atom-reading loop
  1294.        below will now loop at least once, assuring that we will not
  1295.        try to UNREAD two characters in a row.  */
  1296.       }
  1297.     default:
  1298.       if (c <= 040) goto retry;
  1299.       {
  1300.     register char *p = read_buffer;
  1301.     int quoted = 0;
  1302.  
  1303.     {
  1304.       register char *end = read_buffer + read_buffer_size;
  1305.  
  1306.       while (c > 040 && 
  1307.          !(c == '\"' || c == '\'' || c == ';' || c == '?'
  1308.            || c == '(' || c == ')'
  1309. #ifndef LISP_FLOAT_TYPE
  1310.            /* If we have floating-point support, then we need
  1311.               to allow <digits><dot><digits>.  */
  1312.            || c =='.'
  1313. #endif /* not LISP_FLOAT_TYPE */
  1314.            || c == '[' || c == ']' || c == '#'
  1315.            ))
  1316.         {
  1317.           if (p == end)
  1318.         {
  1319.           register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  1320.           p += new - read_buffer;
  1321.           read_buffer += new - read_buffer;
  1322.           end = read_buffer + read_buffer_size;
  1323.         }
  1324.           if (c == '\\')
  1325.         {
  1326.           c = READCHAR;
  1327.           quoted = 1;
  1328.         }
  1329.           *p++ = c;
  1330.           c = READCHAR;
  1331.         }
  1332.  
  1333.       if (p == end)
  1334.         {
  1335.           char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  1336.           p += new - read_buffer;
  1337.           read_buffer += new - read_buffer;
  1338. /*          end = read_buffer + read_buffer_size;  */
  1339.         }
  1340.       *p = 0;
  1341.       if (c >= 0)
  1342.         UNREAD (c);
  1343.     }
  1344.  
  1345.     if (!quoted)
  1346.       {
  1347.         register char *p1;
  1348.         register Lisp_Object val;
  1349.         p1 = read_buffer;
  1350.         if (*p1 == '+' || *p1 == '-') p1++;
  1351.         /* Is it an integer? */
  1352.         if (p1 != p)
  1353.           {
  1354.         while (p1 != p && (c = *p1) >= '0' && c <= '9') p1++;
  1355. #ifdef LISP_FLOAT_TYPE
  1356.         /* Integers can have trailing decimal points.  */
  1357.         if (p1 > read_buffer && p1 < p && *p1 == '.') p1++;
  1358. #endif
  1359.         if (p1 == p)
  1360.           /* It is an integer. */
  1361.           {
  1362. #ifdef LISP_FLOAT_TYPE
  1363.             if (p1[-1] == '.')
  1364.               p1[-1] = '\0';
  1365. #endif
  1366.             XSET (val, Lisp_Int, atoi (read_buffer));
  1367.             return val;
  1368.           }
  1369.           }
  1370. #ifdef LISP_FLOAT_TYPE
  1371.         if (isfloat_string (read_buffer))
  1372.           return make_float (atof (read_buffer));
  1373. #endif
  1374.       }
  1375.  
  1376.     return intern (read_buffer);
  1377.       }
  1378.     }
  1379. }
  1380.  
  1381. #ifdef LISP_FLOAT_TYPE
  1382.  
  1383. #define LEAD_INT 1
  1384. #define DOT_CHAR 2
  1385. #define TRAIL_INT 4
  1386. #define E_CHAR 8
  1387. #define EXP_INT 16
  1388.  
  1389. int
  1390. isfloat_string (cp)
  1391.      register char *cp;
  1392. {
  1393.   register state;
  1394.   
  1395.   state = 0;
  1396.   if (*cp == '+' || *cp == '-')
  1397.     cp++;
  1398.  
  1399.   if (isdigit(*cp))
  1400.     {
  1401.       state |= LEAD_INT;
  1402.       while (isdigit (*cp))
  1403.     cp ++;
  1404.     }
  1405.   if (*cp == '.')
  1406.     {
  1407.       state |= DOT_CHAR;
  1408.       cp++;
  1409.     }
  1410.   if (isdigit(*cp))
  1411.     {
  1412.       state |= TRAIL_INT;
  1413.       while (isdigit (*cp))
  1414.     cp++;
  1415.     }
  1416.   if (*cp == 'e')
  1417.     {
  1418.       state |= E_CHAR;
  1419.       cp++;
  1420.     }
  1421.   if ((*cp == '+') || (*cp == '-'))
  1422.     cp++;
  1423.  
  1424.   if (isdigit (*cp))
  1425.     {
  1426.       state |= EXP_INT;
  1427.       while (isdigit (*cp))
  1428.     cp++;
  1429.     }
  1430.   return (*cp == 0
  1431.       && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT)
  1432.           || state == (DOT_CHAR|TRAIL_INT)
  1433.           || state == (LEAD_INT|E_CHAR|EXP_INT)
  1434.           || state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)
  1435.           || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)));
  1436. }
  1437. #endif /* LISP_FLOAT_TYPE */
  1438.  
  1439. static Lisp_Object
  1440. read_vector (readcharfun)
  1441.      Lisp_Object readcharfun;
  1442. {
  1443.   register int i;
  1444.   register int size;
  1445.   register Lisp_Object *ptr;
  1446.   register Lisp_Object tem, vector;
  1447.   register struct Lisp_Cons *otem;
  1448.   Lisp_Object len;
  1449.  
  1450.   tem = read_list (1, readcharfun);
  1451.   len = Flength (tem);
  1452.   vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil));
  1453.  
  1454.  
  1455.   size = XVECTOR (vector)->size;
  1456.   ptr = XVECTOR (vector)->contents;
  1457.   for (i = 0; i < size; i++)
  1458.     {
  1459.       ptr[i] = read_pure ? Fpurecopy (Fcar (tem)) : Fcar (tem);
  1460.       otem = XCONS (tem);
  1461.       tem = Fcdr (tem);
  1462.       free_cons (otem);
  1463.     }
  1464.   return vector;
  1465. }
  1466.   
  1467. /* flag = 1 means check for ] to terminate rather than ) and .
  1468.    flag = -1 means check for starting with defun
  1469.     and make structure pure.  */
  1470.  
  1471. static Lisp_Object
  1472. read_list (flag, readcharfun)
  1473.      int flag;
  1474.      register Lisp_Object readcharfun;
  1475. {
  1476.   /* -1 means check next element for defun,
  1477.      0 means don't check,
  1478.      1 means already checked and found defun. */
  1479.   int defunflag = flag < 0 ? -1 : 0;
  1480.   Lisp_Object val, tail;
  1481.   register Lisp_Object elt, tem;
  1482.   struct gcpro gcpro1, gcpro2;
  1483.  
  1484.   val = Qnil;
  1485.   tail = Qnil;
  1486.  
  1487.   while (1)
  1488.     {
  1489.       GCPRO2 (val, tail);
  1490.       elt = read1 (readcharfun);
  1491.       UNGCPRO;
  1492.       if (XTYPE (elt) == Lisp_Internal)
  1493.     {
  1494.       if (flag > 0)
  1495.         {
  1496.           if (XINT (elt) == ']')
  1497.         return val;
  1498.           return Fsignal (Qinvalid_read_syntax, Fcons (make_string (") or . in a vector", 18), Qnil));
  1499.         }
  1500.       if (XINT (elt) == ')')
  1501.         return val;
  1502.       if (XINT (elt) == '.')
  1503.         {
  1504.           GCPRO2 (val, tail);
  1505.           if (!NILP (tail))
  1506.         XCONS (tail)->cdr = read0 (readcharfun);
  1507.           else
  1508.         val = read0 (readcharfun);
  1509.           elt = read1 (readcharfun);
  1510.           UNGCPRO;
  1511.           if (XTYPE (elt) == Lisp_Internal && XINT (elt) == ')')
  1512.         return val;
  1513.           return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil));
  1514.         }
  1515.       return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil));
  1516.     }
  1517.       tem = (read_pure && flag <= 0
  1518.          ? pure_cons (elt, Qnil)
  1519.          : Fcons (elt, Qnil));
  1520.       if (!NILP (tail))
  1521.     XCONS (tail)->cdr = tem;
  1522.       else
  1523.     val = tem;
  1524.       tail = tem;
  1525.       if (defunflag < 0)
  1526.     defunflag = EQ (elt, Qdefun);
  1527.       else if (defunflag > 0)
  1528.     read_pure = 1;
  1529.     }
  1530. }
  1531.  
  1532. Lisp_Object Vobarray;
  1533. Lisp_Object initial_obarray;
  1534.  
  1535. Lisp_Object
  1536. check_obarray (obarray)
  1537.      Lisp_Object obarray;
  1538. {
  1539.   while (XTYPE (obarray) != Lisp_Vector || XVECTOR (obarray)->size == 0)
  1540.     {
  1541.       /* If Vobarray is now invalid, force it to be valid.  */
  1542.       if (EQ (Vobarray, obarray)) Vobarray = initial_obarray;
  1543.  
  1544.       obarray = wrong_type_argument (Qvectorp, obarray);
  1545.     }
  1546.   return obarray;
  1547. }
  1548.  
  1549. static int hash_string ();
  1550. Lisp_Object oblookup ();
  1551.  
  1552. Lisp_Object
  1553. intern (str)
  1554.      char *str;
  1555. {
  1556.   Lisp_Object tem;
  1557.   int len = strlen (str);
  1558.   Lisp_Object obarray;
  1559.  
  1560.   obarray = Vobarray;
  1561.   if (XTYPE (obarray) != Lisp_Vector || XVECTOR (obarray)->size == 0)
  1562.     obarray = check_obarray (obarray);
  1563.   tem = oblookup (obarray, str, len);
  1564.   if (XTYPE (tem) == Lisp_Symbol)
  1565.     return tem;
  1566.   return Fintern ((!NILP (Vpurify_flag)
  1567.            ? make_pure_string (str, len)
  1568.            : make_string (str, len)),
  1569.           obarray);
  1570. }
  1571.  
  1572. DEFUN ("intern", Fintern, Sintern, 1, 2, 0,
  1573.   "Return the canonical symbol whose name is STRING.\n\
  1574. If there is none, one is created by this function and returned.\n\
  1575. A second optional argument specifies the obarray to use;\n\
  1576. it defaults to the value of `obarray'.")
  1577.   (str, obarray)
  1578.      Lisp_Object str, obarray;
  1579. {
  1580.   register Lisp_Object tem, sym, *ptr;
  1581.  
  1582.   if (NILP (obarray)) obarray = Vobarray;
  1583.   obarray = check_obarray (obarray);
  1584.  
  1585.   CHECK_STRING (str, 0);
  1586.  
  1587.   tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size);
  1588.   if (XTYPE (tem) != Lisp_Int)
  1589.     return tem;
  1590.  
  1591.   if (!NILP (Vpurify_flag))
  1592.     str = Fpurecopy (str);
  1593.   sym = Fmake_symbol (str);
  1594.  
  1595.   ptr = &XVECTOR (obarray)->contents[XINT (tem)];
  1596.   if (XTYPE (*ptr) == Lisp_Symbol)
  1597.     XSYMBOL (sym)->next = XSYMBOL (*ptr);
  1598.   else
  1599.     XSYMBOL (sym)->next = 0;
  1600.   *ptr = sym;
  1601.   return sym;
  1602. }
  1603.  
  1604. DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0,
  1605.   "Return the canonical symbol whose name is STRING, or nil if none exists.\n\
  1606. A second optional argument specifies the obarray to use;\n\
  1607. it defaults to the value of `obarray'.")
  1608.   (str, obarray)
  1609.      Lisp_Object str, obarray;
  1610. {
  1611.   register Lisp_Object tem;
  1612.  
  1613.   if (NILP (obarray)) obarray = Vobarray;
  1614.   obarray = check_obarray (obarray);
  1615.  
  1616.   CHECK_STRING (str, 0);
  1617.  
  1618.   tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size);
  1619.   if (XTYPE (tem) != Lisp_Int)
  1620.     return tem;
  1621.   return Qnil;
  1622. }
  1623.  
  1624. Lisp_Object
  1625. oblookup (obarray, ptr, size)
  1626.      Lisp_Object obarray;
  1627.      register char *ptr;
  1628.      register int size;
  1629. {
  1630.   int hash, obsize;
  1631.   register Lisp_Object tail;
  1632.   Lisp_Object bucket, tem;
  1633.  
  1634.   if (XTYPE (obarray) != Lisp_Vector
  1635.       || (obsize = XVECTOR (obarray)->size) == 0)
  1636.     {
  1637.       obarray = check_obarray (obarray);
  1638.       obsize = XVECTOR (obarray)->size;
  1639.     }
  1640.   /* Combining next two lines breaks VMS C 2.3.  */
  1641.   hash = hash_string (ptr, size);
  1642.   hash %= obsize;
  1643.   bucket = XVECTOR (obarray)->contents[hash];
  1644.   if (XFASTINT (bucket) == 0)
  1645.     ;
  1646.   else if (XTYPE (bucket) != Lisp_Symbol)
  1647.     error ("Bad data in guts of obarray"); /* Like CADR error message */
  1648.   else for (tail = bucket; ; XSET (tail, Lisp_Symbol, XSYMBOL (tail)->next))
  1649.       {
  1650.     if (XSYMBOL (tail)->name->size == size &&
  1651.         !bcmp (XSYMBOL (tail)->name->data, ptr, size))
  1652.       return tail;
  1653.     else if (XSYMBOL (tail)->next == 0)
  1654.       break;
  1655.       }
  1656.   XSET (tem, Lisp_Int, hash);
  1657.   return tem;
  1658. }
  1659.  
  1660. static int
  1661. hash_string (ptr, len)
  1662.      unsigned char *ptr;
  1663.      int len;
  1664. {
  1665.   register unsigned char *p = ptr;
  1666.   register unsigned char *end = p + len;
  1667.   register unsigned char c;
  1668.   register int hash = 0;
  1669.  
  1670.   while (p != end)
  1671.     {
  1672.       c = *p++;
  1673.       if (c >= 0140) c -= 40;
  1674.       hash = ((hash<<3) + (hash>>28) + c);
  1675.     }
  1676.   return hash & 07777777777;
  1677. }
  1678.  
  1679. void
  1680. map_obarray (obarray, fn, arg)
  1681.      Lisp_Object obarray;
  1682.      int (*fn) ();
  1683.      Lisp_Object arg;
  1684. {
  1685.   register int i;
  1686.   register Lisp_Object tail;
  1687.   CHECK_VECTOR (obarray, 1);
  1688.   for (i = XVECTOR (obarray)->size - 1; i >= 0; i--)
  1689.     {
  1690.       tail = XVECTOR (obarray)->contents[i];
  1691.       if (XFASTINT (tail) != 0)
  1692.     while (1)
  1693.       {
  1694.         (*fn) (tail, arg);
  1695.         if (XSYMBOL (tail)->next == 0)
  1696.           break;
  1697.         XSET (tail, Lisp_Symbol, XSYMBOL (tail)->next);
  1698.       }
  1699.     }
  1700. }
  1701.  
  1702. mapatoms_1 (sym, function)
  1703.      Lisp_Object sym, function;
  1704. {
  1705.   call1 (function, sym);
  1706. }
  1707.  
  1708. DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0,
  1709.   "Call FUNCTION on every symbol in OBARRAY.\n\
  1710. OBARRAY defaults to the value of `obarray'.")
  1711.   (function, obarray)
  1712.      Lisp_Object function, obarray;
  1713. {
  1714.   Lisp_Object tem;
  1715.  
  1716.   if (NILP (obarray)) obarray = Vobarray;
  1717.   obarray = check_obarray (obarray);
  1718.  
  1719.   map_obarray (obarray, mapatoms_1, function);
  1720.   return Qnil;
  1721. }
  1722.  
  1723. #define OBARRAY_SIZE 1511
  1724.  
  1725. void
  1726. init_obarray ()
  1727. {
  1728.   Lisp_Object oblength;
  1729.   int hash;
  1730.   Lisp_Object *tem;
  1731.  
  1732.   XFASTINT (oblength) = OBARRAY_SIZE;
  1733.  
  1734.   Qnil = Fmake_symbol (make_pure_string ("nil", 3));
  1735.   Vobarray = Fmake_vector (oblength, make_number (0));
  1736.   initial_obarray = Vobarray;
  1737.   staticpro (&initial_obarray);
  1738.   /* Intern nil in the obarray */
  1739.   /* These locals are to kludge around a pyramid compiler bug. */
  1740.   hash = hash_string ("nil", 3);
  1741.   /* Separate statement here to avoid VAXC bug. */
  1742.   hash %= OBARRAY_SIZE;
  1743.   tem = &XVECTOR (Vobarray)->contents[hash];
  1744.   *tem = Qnil;
  1745.  
  1746.   Qunbound = Fmake_symbol (make_pure_string ("unbound", 7));
  1747.   XSYMBOL (Qnil)->function = Qunbound;
  1748.   XSYMBOL (Qunbound)->value = Qunbound;
  1749.   XSYMBOL (Qunbound)->function = Qunbound;
  1750.  
  1751.   Qt = intern ("t");
  1752.   XSYMBOL (Qnil)->value = Qnil;
  1753.   XSYMBOL (Qnil)->plist = Qnil;
  1754.   XSYMBOL (Qt)->value = Qt;
  1755.  
  1756.   /* Qt is correct even if CANNOT_DUMP.  loadup.el will set to nil at end.  */
  1757.   Vpurify_flag = Qt;
  1758.  
  1759.   Qvariable_documentation = intern ("variable-documentation");
  1760.  
  1761.   read_buffer_size = 100;
  1762.   read_buffer = (char *) malloc (read_buffer_size);
  1763. }
  1764.  
  1765. void
  1766. defsubr (sname)
  1767.      struct Lisp_Subr *sname;
  1768. {
  1769.   Lisp_Object sym;
  1770.   sym = intern (sname->symbol_name);
  1771.   XSET (XSYMBOL (sym)->function, Lisp_Subr, sname);
  1772. }
  1773.  
  1774. #ifdef NOTDEF /* use fset in subr.el now */
  1775. void
  1776. defalias (sname, string)
  1777.      struct Lisp_Subr *sname;
  1778.      char *string;
  1779. {
  1780.   Lisp_Object sym;
  1781.   sym = intern (string);
  1782.   XSET (XSYMBOL (sym)->function, Lisp_Subr, sname);
  1783. }
  1784. #endif /* NOTDEF */
  1785.  
  1786. /* Define an "integer variable"; a symbol whose value is forwarded
  1787.  to a C variable of type int.  Sample call: */
  1788.   /* DEFVARINT ("indent-tabs-mode", &indent_tabs_mode, "Documentation");  */
  1789.  
  1790. void
  1791. defvar_int (namestring, address)
  1792.      char *namestring;
  1793.      int *address;
  1794. {
  1795.   Lisp_Object sym;
  1796.   sym = intern (namestring);
  1797.   XSET (XSYMBOL (sym)->value, Lisp_Intfwd, address);
  1798. }
  1799.  
  1800. /* Similar but define a variable whose value is T if address contains 1,
  1801.  NIL if address contains 0 */
  1802.  
  1803. void
  1804. defvar_bool (namestring, address)
  1805.      char *namestring;
  1806.      int *address;
  1807. {
  1808.   Lisp_Object sym;
  1809.   sym = intern (namestring);
  1810.   XSET (XSYMBOL (sym)->value, Lisp_Boolfwd, address);
  1811. }
  1812.  
  1813. /* Similar but define a variable whose value is the Lisp Object stored at address. */
  1814.  
  1815. void
  1816. defvar_lisp (namestring, address)
  1817.      char *namestring;
  1818.      Lisp_Object *address;
  1819. {
  1820.   Lisp_Object sym;
  1821.   sym = intern (namestring);
  1822.   XSET (XSYMBOL (sym)->value, Lisp_Objfwd, address);
  1823.   staticpro (address);
  1824. }
  1825.  
  1826. /* Similar but don't request gc-marking of the C variable.
  1827.    Used when that variable will be gc-marked for some other reason,
  1828.    since marking the same slot twice can cause trouble with strings.  */
  1829.  
  1830. void
  1831. defvar_lisp_nopro (namestring, address)
  1832.      char *namestring;
  1833.      Lisp_Object *address;
  1834. {
  1835.   Lisp_Object sym;
  1836.   sym = intern (namestring);
  1837.   XSET (XSYMBOL (sym)->value, Lisp_Objfwd, address);
  1838. }
  1839.  
  1840. #ifndef standalone
  1841.  
  1842. /* Similar but define a variable whose value is the Lisp Object stored in
  1843.  the current buffer.  address is the address of the slot in the buffer that is current now. */
  1844.  
  1845. void
  1846. defvar_per_buffer (namestring, address, type, doc)
  1847.      char *namestring;
  1848.      Lisp_Object *address;
  1849.      Lisp_Object type;
  1850.      char *doc;
  1851. {
  1852.   Lisp_Object sym;
  1853.   int offset;
  1854.   extern struct buffer buffer_local_symbols;
  1855.  
  1856.   sym = intern (namestring);
  1857.   offset = (char *)address - (char *)current_buffer;
  1858.  
  1859.   XSET (XSYMBOL (sym)->value, Lisp_Buffer_Objfwd,
  1860.     (Lisp_Object *) offset);
  1861.   *(Lisp_Object *)(offset + (char *)&buffer_local_symbols) = sym;
  1862.   *(Lisp_Object *)(offset + (char *)&buffer_local_types) = type;
  1863.   if (*(int *)(offset + (char *)&buffer_local_flags) == 0)
  1864.     /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
  1865.        slot of buffer_local_flags */
  1866.     abort ();
  1867. }
  1868.  
  1869. #endif /* standalone */
  1870.  
  1871. init_lread ()
  1872. {
  1873.   char *normal;
  1874.  
  1875.   /* Compute the default load-path.  */
  1876. #ifdef CANNOT_DUMP
  1877.   normal = PATH_LOADSEARCH;
  1878.   Vload_path = decode_env_path (0, normal);
  1879. #else
  1880.   if (NILP (Vpurify_flag))
  1881.     normal = PATH_LOADSEARCH;
  1882.   else
  1883.     normal = PATH_DUMPLOADSEARCH;
  1884.  
  1885.   /* In a dumped Emacs, we normally have to reset the value of
  1886.      Vload_path from PATH_LOADSEARCH, since the value that was dumped
  1887.      uses ../lisp, instead of the path of the installed elisp
  1888.      libraries.  However, if it appears that Vload_path was changed
  1889.      from the default before dumping, don't override that value.  */
  1890.   if (initialized)
  1891.     {
  1892.       Lisp_Object dump_path;
  1893.  
  1894.       dump_path = decode_env_path (0, PATH_DUMPLOADSEARCH);
  1895.       if (! NILP (Fequal (dump_path, Vload_path)))
  1896.     {
  1897.       Vload_path = decode_env_path (0, normal);
  1898.       if (!NILP (Vinstallation_directory))
  1899.         {
  1900.           /* Add to the path the lisp subdir of the
  1901.          installation dir, if it exists.  */
  1902.           Lisp_Object tem, tem1;
  1903.           tem = Fexpand_file_name (build_string ("lisp"),
  1904.                        Vinstallation_directory);
  1905.           tem1 = Ffile_exists_p (tem);
  1906.           if (!NILP (tem1))
  1907.         {
  1908.           if (NILP (Fmember (tem, Vload_path)))
  1909.             Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
  1910.         }
  1911.           else
  1912.         /* That dir doesn't exist, so add the build-time
  1913.            Lisp dirs instead.  */
  1914.         Vload_path = nconc2 (Vload_path, dump_path);
  1915.         }
  1916.     }
  1917.     }
  1918.   else
  1919.     Vload_path = decode_env_path (0, normal);
  1920. #endif
  1921.  
  1922.   /* Warn if dirs in the *standard* path don't exist.  */
  1923.   {
  1924.     Lisp_Object path_tail;
  1925.  
  1926.     for (path_tail = Vload_path;
  1927.      !NILP (path_tail);
  1928.      path_tail = XCONS (path_tail)->cdr)
  1929.       {
  1930.     Lisp_Object dirfile;
  1931.     dirfile = Fcar (path_tail);
  1932.     if (XTYPE (dirfile) == Lisp_String)
  1933.       {
  1934.         dirfile = Fdirectory_file_name (dirfile);
  1935.         if (access (XSTRING (dirfile)->data, 0) < 0)
  1936.           fprintf (stderr,
  1937.                "Warning: Lisp directory `%s' does not exist.\n",
  1938.                XSTRING (Fcar (path_tail))->data);
  1939.       }
  1940.       }
  1941.   }
  1942.  
  1943.   /* If the EMACSLOADPATH environment variable is set, use its value.
  1944.      This doesn't apply if we're dumping.  */
  1945.   if (NILP (Vpurify_flag)
  1946.       && egetenv ("EMACSLOADPATH"))
  1947.     Vload_path = decode_env_path ("EMACSLOADPATH", normal);
  1948.  
  1949.   Vvalues = Qnil;
  1950.  
  1951.   load_in_progress = 0;
  1952.  
  1953.   load_descriptor_list = Qnil;
  1954. }
  1955.  
  1956. void
  1957. syms_of_lread ()
  1958. {
  1959.   defsubr (&Sread);
  1960.   defsubr (&Sread_from_string);
  1961.   defsubr (&Sintern);
  1962.   defsubr (&Sintern_soft);
  1963.   defsubr (&Sload);
  1964.   defsubr (&Seval_buffer);
  1965.   defsubr (&Seval_region);
  1966.   defsubr (&Sread_char);
  1967.   defsubr (&Sread_char_exclusive);
  1968.   defsubr (&Sread_event);
  1969.   defsubr (&Sget_file_char);
  1970.   defsubr (&Smapatoms);
  1971.  
  1972.   DEFVAR_LISP ("obarray", &Vobarray,
  1973.     "Symbol table for use by `intern' and `read'.\n\
  1974. It is a vector whose length ought to be prime for best results.\n\
  1975. The vector's contents don't make sense if examined from Lisp programs;\n\
  1976. to find all the symbols in an obarray, use `mapatoms'.");
  1977.  
  1978.   DEFVAR_LISP ("values", &Vvalues,
  1979.     "List of values of all expressions which were read, evaluated and printed.\n\
  1980. Order is reverse chronological.");
  1981.  
  1982.   DEFVAR_LISP ("standard-input", &Vstandard_input,
  1983.     "Stream for read to get input from.\n\
  1984. See documentation of `read' for possible values.");
  1985.   Vstandard_input = Qt;
  1986.  
  1987.   DEFVAR_LISP ("load-path", &Vload_path,
  1988.     "*List of directories to search for files to load.\n\
  1989. Each element is a string (directory name) or nil (try default directory).\n\
  1990. Initialized based on EMACSLOADPATH environment variable, if any,\n\
  1991. otherwise to default specified by file `paths.h' when Emacs was built.");
  1992.  
  1993.   DEFVAR_BOOL ("load-in-progress", &load_in_progress,
  1994.     "Non-nil iff inside of `load'.");
  1995.  
  1996.   DEFVAR_LISP ("after-load-alist", &Vafter_load_alist,
  1997.     "An alist of expressions to be evalled when particular files are loaded.\n\
  1998. Each element looks like (FILENAME FORMS...).\n\
  1999. When `load' is run and the file-name argument is FILENAME,\n\
  2000. the FORMS in the corresponding element are executed at the end of loading.\n\n\
  2001. FILENAME must match exactly!  Normally FILENAME is the name of a library,\n\
  2002. with no directory specified, since that is how `load' is normally called.\n\
  2003. An error in FORMS does not undo the load,\n\
  2004. but does prevent execution of the rest of the FORMS.");
  2005.   Vafter_load_alist = Qnil;
  2006.  
  2007.   DEFVAR_LISP ("load-history", &Vload_history,
  2008.     "Alist mapping source file names to symbols and features.\n\
  2009. Each alist element is a list that starts with a file name,\n\
  2010. except for one element (optional) that starts with nil and describes\n\
  2011. definitions evaluated from buffers not visiting files.\n\
  2012. The remaining elements of each list are symbols defined as functions\n\
  2013. or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
  2014.   Vload_history = Qnil;
  2015.  
  2016.   DEFVAR_LISP ("current-load-list", &Vcurrent_load_list,
  2017.     "Used for internal purposes by `load'.");
  2018.   Vcurrent_load_list = Qnil;
  2019.  
  2020.   load_descriptor_list = Qnil;
  2021.   staticpro (&load_descriptor_list);
  2022.  
  2023.   Qcurrent_load_list = intern ("current-load-list");
  2024.   staticpro (&Qcurrent_load_list);
  2025.  
  2026.   Qstandard_input = intern ("standard-input");
  2027.   staticpro (&Qstandard_input);
  2028.  
  2029.   Qread_char = intern ("read-char");
  2030.   staticpro (&Qread_char);
  2031.  
  2032.   Qget_file_char = intern ("get-file-char");
  2033.   staticpro (&Qget_file_char);
  2034.  
  2035.   Qascii_character = intern ("ascii-character");
  2036.   staticpro (&Qascii_character);
  2037.  
  2038.   Qload = intern ("load");
  2039.   staticpro (&Qload);
  2040. }
  2041.