(Ftranspose_regions): Use xfree instead of free.
[bpt/emacs.git] / src / lread.c
1 /* Lisp parsing and input streams.
2 Copyright (C) 1985, 86, 87, 88, 89, 93, 94, 95, 97, 98, 1999
3 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, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22
23 #include <config.h>
24 #include <stdio.h>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <sys/file.h>
28 #include <errno.h>
29 #include "lisp.h"
30 #include "intervals.h"
31 #include "buffer.h"
32 #include "charset.h"
33 #include <epaths.h>
34 #include "commands.h"
35 #include "keyboard.h"
36 #include "termhooks.h"
37
38 #ifdef lint
39 #include <sys/inode.h>
40 #endif /* lint */
41
42 #ifdef MSDOS
43 #if __DJGPP__ < 2
44 #include <unistd.h> /* to get X_OK */
45 #endif
46 #include "msdos.h"
47 #endif
48
49 #ifdef HAVE_UNISTD_H
50 #include <unistd.h>
51 #endif
52
53 #ifndef X_OK
54 #define X_OK 01
55 #endif
56
57 #include <math.h>
58
59 #ifdef HAVE_SETLOCALE
60 #include <locale.h>
61 #endif /* HAVE_SETLOCALE */
62
63 #ifndef O_RDONLY
64 #define O_RDONLY 0
65 #endif
66
67 #ifdef HAVE_FTELLO
68 #define file_offset off_t
69 #define file_tell ftello
70 #else
71 #define file_offset long
72 #define file_tell ftell
73 #endif
74
75 extern int errno;
76
77 Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list;
78 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
79 Lisp_Object Qascii_character, Qload, Qload_file_name;
80 Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
81 Lisp_Object Qinhibit_file_name_operation;
82
83 extern Lisp_Object Qevent_symbol_element_mask;
84 extern Lisp_Object Qfile_exists_p;
85
86 /* non-zero if inside `load' */
87 int load_in_progress;
88
89 /* Directory in which the sources were found. */
90 Lisp_Object Vsource_directory;
91
92 /* Search path for files to be loaded. */
93 Lisp_Object Vload_path;
94
95 /* File name of user's init file. */
96 Lisp_Object Vuser_init_file;
97
98 /* This is the user-visible association list that maps features to
99 lists of defs in their load files. */
100 Lisp_Object Vload_history;
101
102 /* This is used to build the load history. */
103 Lisp_Object Vcurrent_load_list;
104
105 /* List of files that were preloaded. */
106 Lisp_Object Vpreloaded_file_list;
107
108 /* Name of file actually being read by `load'. */
109 Lisp_Object Vload_file_name;
110
111 /* Function to use for reading, in `load' and friends. */
112 Lisp_Object Vload_read_function;
113
114 /* The association list of objects read with the #n=object form.
115 Each member of the list has the form (n . object), and is used to
116 look up the object for the corresponding #n# construct.
117 It must be set to nil before all top-level calls to read0. */
118 Lisp_Object read_objects;
119
120 /* Nonzero means load should forcibly load all dynamic doc strings. */
121 static int load_force_doc_strings;
122
123 /* Nonzero means read should convert strings to unibyte. */
124 static int load_convert_to_unibyte;
125
126 /* Function to use for loading an Emacs lisp source file (not
127 compiled) instead of readevalloop. */
128 Lisp_Object Vload_source_file_function;
129
130 /* List of all DEFVAR_BOOL variables. Used by the byte optimizer. */
131 Lisp_Object Vbyte_boolean_vars;
132
133 /* List of descriptors now open for Fload. */
134 static Lisp_Object load_descriptor_list;
135
136 /* File for get_file_char to read from. Use by load. */
137 static FILE *instream;
138
139 /* When nonzero, read conses in pure space */
140 static int read_pure;
141
142 /* For use within read-from-string (this reader is non-reentrant!!) */
143 static int read_from_string_index;
144 static int read_from_string_index_byte;
145 static int read_from_string_limit;
146
147 /* Number of bytes left to read in the buffer character
148 that `readchar' has already advanced over. */
149 static int readchar_backlog;
150
151 /* This contains the last string skipped with #@. */
152 static char *saved_doc_string;
153 /* Length of buffer allocated in saved_doc_string. */
154 static int saved_doc_string_size;
155 /* Length of actual data in saved_doc_string. */
156 static int saved_doc_string_length;
157 /* This is the file position that string came from. */
158 static file_offset saved_doc_string_position;
159
160 /* This contains the previous string skipped with #@.
161 We copy it from saved_doc_string when a new string
162 is put in saved_doc_string. */
163 static char *prev_saved_doc_string;
164 /* Length of buffer allocated in prev_saved_doc_string. */
165 static int prev_saved_doc_string_size;
166 /* Length of actual data in prev_saved_doc_string. */
167 static int prev_saved_doc_string_length;
168 /* This is the file position that string came from. */
169 static file_offset prev_saved_doc_string_position;
170
171 /* Nonzero means inside a new-style backquote
172 with no surrounding parentheses.
173 Fread initializes this to zero, so we need not specbind it
174 or worry about what happens to it when there is an error. */
175 static int new_backquote_flag;
176 \f
177 /* Handle unreading and rereading of characters.
178 Write READCHAR to read a character,
179 UNREAD(c) to unread c to be read again.
180
181 These macros actually read/unread a byte code, multibyte characters
182 are not handled here. The caller should manage them if necessary.
183 */
184
185 #define READCHAR readchar (readcharfun)
186 #define UNREAD(c) unreadchar (readcharfun, c)
187
188 static int
189 readchar (readcharfun)
190 Lisp_Object readcharfun;
191 {
192 Lisp_Object tem;
193 register int c;
194
195 if (BUFFERP (readcharfun))
196 {
197 register struct buffer *inbuffer = XBUFFER (readcharfun);
198
199 int pt_byte = BUF_PT_BYTE (inbuffer);
200 int orig_pt_byte = pt_byte;
201
202 if (readchar_backlog > 0)
203 /* We get the address of the byte just passed,
204 which is the last byte of the character.
205 The other bytes in this character are consecutive with it,
206 because the gap can't be in the middle of a character. */
207 return *(BUF_BYTE_ADDRESS (inbuffer, BUF_PT_BYTE (inbuffer) - 1)
208 - --readchar_backlog);
209
210 if (pt_byte >= BUF_ZV_BYTE (inbuffer))
211 return -1;
212
213 readchar_backlog = -1;
214
215 if (! NILP (inbuffer->enable_multibyte_characters))
216 {
217 /* Fetch the character code from the buffer. */
218 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, pt_byte);
219 BUF_INC_POS (inbuffer, pt_byte);
220 c = STRING_CHAR (p, pt_byte - orig_pt_byte);
221 }
222 else
223 {
224 c = BUF_FETCH_BYTE (inbuffer, pt_byte);
225 pt_byte++;
226 }
227 SET_BUF_PT_BOTH (inbuffer, BUF_PT (inbuffer) + 1, pt_byte);
228
229 return c;
230 }
231 if (MARKERP (readcharfun))
232 {
233 register struct buffer *inbuffer = XMARKER (readcharfun)->buffer;
234
235 int bytepos = marker_byte_position (readcharfun);
236 int orig_bytepos = bytepos;
237
238 if (readchar_backlog > 0)
239 /* We get the address of the byte just passed,
240 which is the last byte of the character.
241 The other bytes in this character are consecutive with it,
242 because the gap can't be in the middle of a character. */
243 return *(BUF_BYTE_ADDRESS (inbuffer, XMARKER (readcharfun)->bytepos - 1)
244 - --readchar_backlog);
245
246 if (bytepos >= BUF_ZV_BYTE (inbuffer))
247 return -1;
248
249 readchar_backlog = -1;
250
251 if (! NILP (inbuffer->enable_multibyte_characters))
252 {
253 /* Fetch the character code from the buffer. */
254 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, bytepos);
255 BUF_INC_POS (inbuffer, bytepos);
256 c = STRING_CHAR (p, bytepos - orig_bytepos);
257 }
258 else
259 {
260 c = BUF_FETCH_BYTE (inbuffer, bytepos);
261 bytepos++;
262 }
263
264 XMARKER (readcharfun)->bytepos = bytepos;
265 XMARKER (readcharfun)->charpos++;
266
267 return c;
268 }
269
270 if (EQ (readcharfun, Qlambda))
271 return read_bytecode_char (0);
272
273 if (EQ (readcharfun, Qget_file_char))
274 {
275 c = getc (instream);
276 #ifdef EINTR
277 /* Interrupted reads have been observed while reading over the network */
278 while (c == EOF && ferror (instream) && errno == EINTR)
279 {
280 clearerr (instream);
281 c = getc (instream);
282 }
283 #endif
284 return c;
285 }
286
287 if (STRINGP (readcharfun))
288 {
289 if (read_from_string_index >= read_from_string_limit)
290 c = -1;
291 else
292 FETCH_STRING_CHAR_ADVANCE (c, readcharfun,
293 read_from_string_index,
294 read_from_string_index_byte);
295
296 return c;
297 }
298
299 tem = call0 (readcharfun);
300
301 if (NILP (tem))
302 return -1;
303 return XINT (tem);
304 }
305
306 /* Unread the character C in the way appropriate for the stream READCHARFUN.
307 If the stream is a user function, call it with the char as argument. */
308
309 static void
310 unreadchar (readcharfun, c)
311 Lisp_Object readcharfun;
312 int c;
313 {
314 if (c == -1)
315 /* Don't back up the pointer if we're unreading the end-of-input mark,
316 since readchar didn't advance it when we read it. */
317 ;
318 else if (BUFFERP (readcharfun))
319 {
320 struct buffer *b = XBUFFER (readcharfun);
321 int bytepos = BUF_PT_BYTE (b);
322
323 if (readchar_backlog >= 0)
324 readchar_backlog++;
325 else
326 {
327 BUF_PT (b)--;
328 if (! NILP (b->enable_multibyte_characters))
329 BUF_DEC_POS (b, bytepos);
330 else
331 bytepos--;
332
333 BUF_PT_BYTE (b) = bytepos;
334 }
335 }
336 else if (MARKERP (readcharfun))
337 {
338 struct buffer *b = XMARKER (readcharfun)->buffer;
339 int bytepos = XMARKER (readcharfun)->bytepos;
340
341 if (readchar_backlog >= 0)
342 readchar_backlog++;
343 else
344 {
345 XMARKER (readcharfun)->charpos--;
346 if (! NILP (b->enable_multibyte_characters))
347 BUF_DEC_POS (b, bytepos);
348 else
349 bytepos--;
350
351 XMARKER (readcharfun)->bytepos = bytepos;
352 }
353 }
354 else if (STRINGP (readcharfun))
355 {
356 read_from_string_index--;
357 read_from_string_index_byte
358 = string_char_to_byte (readcharfun, read_from_string_index);
359 }
360 else if (EQ (readcharfun, Qlambda))
361 read_bytecode_char (1);
362 else if (EQ (readcharfun, Qget_file_char))
363 ungetc (c, instream);
364 else
365 call1 (readcharfun, make_number (c));
366 }
367
368 static Lisp_Object read0 (), read1 (), read_list (), read_vector ();
369 static int read_multibyte ();
370 static Lisp_Object substitute_object_recurse ();
371 static void substitute_object_in_subtree (), substitute_in_interval ();
372
373 \f
374 /* Get a character from the tty. */
375
376 extern Lisp_Object read_char ();
377
378 /* Read input events until we get one that's acceptable for our purposes.
379
380 If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed
381 until we get a character we like, and then stuffed into
382 unread_switch_frame.
383
384 If ASCII_REQUIRED is non-zero, we check function key events to see
385 if the unmodified version of the symbol has a Qascii_character
386 property, and use that character, if present.
387
388 If ERROR_NONASCII is non-zero, we signal an error if the input we
389 get isn't an ASCII character with modifiers. If it's zero but
390 ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII
391 character.
392
393 If INPUT_METHOD is nonzero, we invoke the current input method
394 if the character warrants that. */
395
396 Lisp_Object
397 read_filtered_event (no_switch_frame, ascii_required, error_nonascii,
398 input_method)
399 int no_switch_frame, ascii_required, error_nonascii, input_method;
400 {
401 register Lisp_Object val, delayed_switch_frame;
402
403 #ifdef HAVE_WINDOW_SYSTEM
404 if (display_busy_cursor_p)
405 cancel_busy_cursor ();
406 #endif
407
408 delayed_switch_frame = Qnil;
409
410 /* Read until we get an acceptable event. */
411 retry:
412 val = read_char (0, 0, 0,
413 (input_method ? Qnil : Qt),
414 0);
415
416 if (BUFFERP (val))
417 goto retry;
418
419 /* switch-frame events are put off until after the next ASCII
420 character. This is better than signaling an error just because
421 the last characters were typed to a separate minibuffer frame,
422 for example. Eventually, some code which can deal with
423 switch-frame events will read it and process it. */
424 if (no_switch_frame
425 && EVENT_HAS_PARAMETERS (val)
426 && EQ (EVENT_HEAD (val), Qswitch_frame))
427 {
428 delayed_switch_frame = val;
429 goto retry;
430 }
431
432 if (ascii_required)
433 {
434 /* Convert certain symbols to their ASCII equivalents. */
435 if (SYMBOLP (val))
436 {
437 Lisp_Object tem, tem1;
438 tem = Fget (val, Qevent_symbol_element_mask);
439 if (!NILP (tem))
440 {
441 tem1 = Fget (Fcar (tem), Qascii_character);
442 /* Merge this symbol's modifier bits
443 with the ASCII equivalent of its basic code. */
444 if (!NILP (tem1))
445 XSETFASTINT (val, XINT (tem1) | XINT (Fcar (Fcdr (tem))));
446 }
447 }
448
449 /* If we don't have a character now, deal with it appropriately. */
450 if (!INTEGERP (val))
451 {
452 if (error_nonascii)
453 {
454 Vunread_command_events = Fcons (val, Qnil);
455 error ("Non-character input-event");
456 }
457 else
458 goto retry;
459 }
460 }
461
462 if (! NILP (delayed_switch_frame))
463 unread_switch_frame = delayed_switch_frame;
464
465 #ifdef HAVE_WINDOW_SYSTEM
466 if (display_busy_cursor_p)
467 start_busy_cursor ();
468 #endif
469 return val;
470 }
471
472 DEFUN ("read-char", Fread_char, Sread_char, 0, 2, 0,
473 "Read a character from the command input (keyboard or macro).\n\
474 It is returned as a number.\n\
475 If the user generates an event which is not a character (i.e. a mouse\n\
476 click or function key event), `read-char' signals an error. As an\n\
477 exception, switch-frame events are put off until non-ASCII events can\n\
478 be read.\n\
479 If you want to read non-character events, or ignore them, call\n\
480 `read-event' or `read-char-exclusive' instead.\n\
481 \n\
482 If the optional argument PROMPT is non-nil, display that as a prompt.\n\
483 If the optional argument INHERIT-INPUT-METHOD is non-nil and some\n\
484 input method is turned on in the current buffer, that input method\n\
485 is used for reading a character.")
486 (prompt, inherit_input_method)
487 Lisp_Object prompt, inherit_input_method;
488 {
489 if (! NILP (prompt))
490 message_with_string ("%s", prompt, 0);
491 return read_filtered_event (1, 1, 1, ! NILP (inherit_input_method));
492 }
493
494 DEFUN ("read-event", Fread_event, Sread_event, 0, 2, 0,
495 "Read an event object from the input stream.\n\
496 If the optional argument PROMPT is non-nil, display that as a prompt.\n\
497 If the optional argument INHERIT-INPUT-METHOD is non-nil and some\n\
498 input method is turned on in the current buffer, that input method\n\
499 is used for reading a character.")
500 (prompt, inherit_input_method)
501 Lisp_Object prompt, inherit_input_method;
502 {
503 if (! NILP (prompt))
504 message_with_string ("%s", prompt, 0);
505 return read_filtered_event (0, 0, 0, ! NILP (inherit_input_method));
506 }
507
508 DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 2, 0,
509 "Read a character from the command input (keyboard or macro).\n\
510 It is returned as a number. Non-character events are ignored.\n\
511 \n\
512 If the optional argument PROMPT is non-nil, display that as a prompt.\n\
513 If the optional argument INHERIT-INPUT-METHOD is non-nil and some\n\
514 input method is turned on in the current buffer, that input method\n\
515 is used for reading a character.")
516 (prompt, inherit_input_method)
517 Lisp_Object prompt, inherit_input_method;
518 {
519 if (! NILP (prompt))
520 message_with_string ("%s", prompt, 0);
521 return read_filtered_event (1, 1, 0, ! NILP (inherit_input_method));
522 }
523
524 DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
525 "Don't use this yourself.")
526 ()
527 {
528 register Lisp_Object val;
529 XSETINT (val, getc (instream));
530 return val;
531 }
532 \f
533 static void readevalloop ();
534 static Lisp_Object load_unwind ();
535 static Lisp_Object load_descriptor_unwind ();
536
537 /* Non-zero means load dangerous compiled Lisp files. */
538
539 int load_dangerous_libraries;
540
541 /* A regular expression used to detect files compiled with Emacs. */
542
543 static Lisp_Object Vbytecomp_version_regexp;
544
545
546 /* Value is non-zero if the file asswociated with file descriptor FD
547 is a compiled Lisp file that's safe to load. Only files compiled
548 with Emacs are safe to load. Files compiled with XEmacs can lead
549 to a crash in Fbyte_code because of an incompatible change in the
550 byte compiler. */
551
552 static int
553 safe_to_load_p (fd)
554 int fd;
555 {
556 char buf[512];
557 int nbytes, i;
558 int safe_p = 1;
559
560 /* Read the first few bytes from the file, and look for a line
561 specifying the byte compiler version used. */
562 nbytes = emacs_read (fd, buf, sizeof buf - 1);
563 if (nbytes > 0)
564 {
565 buf[nbytes] = '\0';
566
567 /* Skip to the next newline, skipping over the initial `ELC'
568 with NUL bytes following it. */
569 for (i = 0; i < nbytes && buf[i] != '\n'; ++i)
570 ;
571
572 if (i < nbytes
573 && fast_c_string_match_ignore_case (Vbytecomp_version_regexp,
574 buf + i) < 0)
575 safe_p = 0;
576 }
577
578 lseek (fd, 0, SEEK_SET);
579 return safe_p;
580 }
581
582
583 DEFUN ("load", Fload, Sload, 1, 5, 0,
584 "Execute a file of Lisp code named FILE.\n\
585 First try FILE with `.elc' appended, then try with `.el',\n\
586 then try FILE unmodified.\n\
587 This function searches the directories in `load-path'.\n\
588 If optional second arg NOERROR is non-nil,\n\
589 report no error if FILE doesn't exist.\n\
590 Print messages at start and end of loading unless\n\
591 optional third arg NOMESSAGE is non-nil.\n\
592 If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
593 suffixes `.elc' or `.el' to the specified name FILE.\n\
594 If optional fifth arg MUST-SUFFIX is non-nil, insist on\n\
595 the suffix `.elc' or `.el'; don't accept just FILE unless\n\
596 it ends in one of those suffixes or includes a directory name.\n\
597 Return t if file exists.")
598 (file, noerror, nomessage, nosuffix, must_suffix)
599 Lisp_Object file, noerror, nomessage, nosuffix, must_suffix;
600 {
601 register FILE *stream;
602 register int fd = -1;
603 register Lisp_Object lispstream;
604 int count = specpdl_ptr - specpdl;
605 Lisp_Object temp;
606 struct gcpro gcpro1;
607 Lisp_Object found;
608 /* 1 means we printed the ".el is newer" message. */
609 int newer = 0;
610 /* 1 means we are loading a compiled file. */
611 int compiled = 0;
612 Lisp_Object handler;
613 int safe_p = 1;
614 char *fmode = "r";
615 #ifdef DOS_NT
616 fmode = "rt";
617 #endif /* DOS_NT */
618
619 CHECK_STRING (file, 0);
620
621 /* If file name is magic, call the handler. */
622 handler = Ffind_file_name_handler (file, Qload);
623 if (!NILP (handler))
624 return call5 (handler, Qload, file, noerror, nomessage, nosuffix);
625
626 /* Do this after the handler to avoid
627 the need to gcpro noerror, nomessage and nosuffix.
628 (Below here, we care only whether they are nil or not.) */
629 file = Fsubstitute_in_file_name (file);
630
631 /* Avoid weird lossage with null string as arg,
632 since it would try to load a directory as a Lisp file */
633 if (XSTRING (file)->size > 0)
634 {
635 int size = STRING_BYTES (XSTRING (file));
636
637 GCPRO1 (file);
638
639 if (! NILP (must_suffix))
640 {
641 /* Don't insist on adding a suffix if FILE already ends with one. */
642 if (size > 3
643 && !strcmp (XSTRING (file)->data + size - 3, ".el"))
644 must_suffix = Qnil;
645 else if (size > 4
646 && !strcmp (XSTRING (file)->data + size - 4, ".elc"))
647 must_suffix = Qnil;
648 /* Don't insist on adding a suffix
649 if the argument includes a directory name. */
650 else if (! NILP (Ffile_name_directory (file)))
651 must_suffix = Qnil;
652 }
653
654 fd = openp (Vload_path, file,
655 (!NILP (nosuffix) ? ""
656 : ! NILP (must_suffix) ? ".elc.gz:.elc:.el.gz:.el"
657 : ".elc:.elc.gz:.el.gz:.el:"),
658 &found, 0);
659 UNGCPRO;
660 }
661
662 if (fd < 0)
663 {
664 if (NILP (noerror))
665 while (1)
666 Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"),
667 Fcons (file, Qnil)));
668 else
669 return Qnil;
670 }
671
672 /* Tell startup.el whether or not we found the user's init file. */
673 if (EQ (Qt, Vuser_init_file))
674 Vuser_init_file = found;
675
676 /* If FD is 0, that means openp found a magic file. */
677 if (fd == 0)
678 {
679 if (NILP (Fequal (found, file)))
680 /* If FOUND is a different file name from FILE,
681 find its handler even if we have already inhibited
682 the `load' operation on FILE. */
683 handler = Ffind_file_name_handler (found, Qt);
684 else
685 handler = Ffind_file_name_handler (found, Qload);
686 if (! NILP (handler))
687 return call5 (handler, Qload, found, noerror, nomessage, Qt);
688 }
689
690 /* Load .elc files directly, but not when they are
691 remote and have no handler! */
692 if (!bcmp (&(XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 4]),
693 ".elc", 4)
694 && fd != 0)
695 {
696 struct stat s1, s2;
697 int result;
698
699 if (!safe_to_load_p (fd))
700 {
701 safe_p = 0;
702 if (!load_dangerous_libraries)
703 error ("File `%s' was not compiled in Emacs",
704 XSTRING (found)->data);
705 else if (!NILP (nomessage))
706 message_with_string ("File `%s' not compiled in Emacs", found, 1);
707 }
708
709 compiled = 1;
710
711 #ifdef DOS_NT
712 fmode = "rb";
713 #endif /* DOS_NT */
714 stat ((char *)XSTRING (found)->data, &s1);
715 XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 1] = 0;
716 result = stat ((char *)XSTRING (found)->data, &s2);
717 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
718 {
719 /* Make the progress messages mention that source is newer. */
720 newer = 1;
721
722 /* If we won't print another message, mention this anyway. */
723 if (! NILP (nomessage))
724 message_with_string ("Source file `%s' newer than byte-compiled file",
725 found, 1);
726 }
727 XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 1] = 'c';
728 }
729 else
730 {
731 load_source:
732
733 /* We are loading a source file (*.el). */
734 if (!NILP (Vload_source_file_function))
735 {
736 if (fd != 0)
737 emacs_close (fd);
738 return call4 (Vload_source_file_function, found, file,
739 NILP (noerror) ? Qnil : Qt,
740 NILP (nomessage) ? Qnil : Qt);
741 }
742 }
743
744 #ifdef WINDOWSNT
745 emacs_close (fd);
746 stream = fopen ((char *) XSTRING (found)->data, fmode);
747 #else /* not WINDOWSNT */
748 stream = fdopen (fd, fmode);
749 #endif /* not WINDOWSNT */
750 if (stream == 0)
751 {
752 emacs_close (fd);
753 error ("Failure to create stdio stream for %s", XSTRING (file)->data);
754 }
755
756 if (! NILP (Vpurify_flag))
757 Vpreloaded_file_list = Fcons (file, Vpreloaded_file_list);
758
759 if (NILP (nomessage))
760 {
761 if (!safe_p)
762 message_with_string ("Loading %s (compiled; note unsafe, not compiled in Emacs)...",
763 file, 1);
764 else if (!compiled)
765 message_with_string ("Loading %s (source)...", file, 1);
766 else if (newer)
767 message_with_string ("Loading %s (compiled; note, source file is newer)...",
768 file, 1);
769 else /* The typical case; compiled file newer than source file. */
770 message_with_string ("Loading %s...", file, 1);
771 }
772
773 GCPRO1 (file);
774 lispstream = Fcons (Qnil, Qnil);
775 XSETFASTINT (XCAR (lispstream), (EMACS_UINT)stream >> 16);
776 XSETFASTINT (XCDR (lispstream), (EMACS_UINT)stream & 0xffff);
777 record_unwind_protect (load_unwind, lispstream);
778 record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
779 specbind (Qload_file_name, found);
780 specbind (Qinhibit_file_name_operation, Qnil);
781 load_descriptor_list
782 = Fcons (make_number (fileno (stream)), load_descriptor_list);
783 load_in_progress++;
784 readevalloop (Qget_file_char, stream, file, Feval, 0, Qnil, Qnil);
785 unbind_to (count, Qnil);
786
787 /* Run any load-hooks for this file. */
788 temp = Fassoc (file, Vafter_load_alist);
789 if (!NILP (temp))
790 Fprogn (Fcdr (temp));
791 UNGCPRO;
792
793 if (saved_doc_string)
794 free (saved_doc_string);
795 saved_doc_string = 0;
796 saved_doc_string_size = 0;
797
798 if (prev_saved_doc_string)
799 xfree (prev_saved_doc_string);
800 prev_saved_doc_string = 0;
801 prev_saved_doc_string_size = 0;
802
803 if (!noninteractive && NILP (nomessage))
804 {
805 if (!safe_p)
806 message_with_string ("Loading %s (compiled; note unsafe, not compiled in Emacs)...done",
807 file, 1);
808 else if (!compiled)
809 message_with_string ("Loading %s (source)...done", file, 1);
810 else if (newer)
811 message_with_string ("Loading %s (compiled; note, source file is newer)...done",
812 file, 1);
813 else /* The typical case; compiled file newer than source file. */
814 message_with_string ("Loading %s...done", file, 1);
815 }
816 return Qt;
817 }
818
819 static Lisp_Object
820 load_unwind (stream) /* used as unwind-protect function in load */
821 Lisp_Object stream;
822 {
823 fclose ((FILE *) (XFASTINT (XCAR (stream)) << 16
824 | XFASTINT (XCDR (stream))));
825 if (--load_in_progress < 0) load_in_progress = 0;
826 return Qnil;
827 }
828
829 static Lisp_Object
830 load_descriptor_unwind (oldlist)
831 Lisp_Object oldlist;
832 {
833 load_descriptor_list = oldlist;
834 return Qnil;
835 }
836
837 /* Close all descriptors in use for Floads.
838 This is used when starting a subprocess. */
839
840 void
841 close_load_descs ()
842 {
843 #ifndef WINDOWSNT
844 Lisp_Object tail;
845 for (tail = load_descriptor_list; !NILP (tail); tail = XCDR (tail))
846 emacs_close (XFASTINT (XCAR (tail)));
847 #endif
848 }
849 \f
850 static int
851 complete_filename_p (pathname)
852 Lisp_Object pathname;
853 {
854 register unsigned char *s = XSTRING (pathname)->data;
855 return (IS_DIRECTORY_SEP (s[0])
856 || (XSTRING (pathname)->size > 2
857 && IS_DEVICE_SEP (s[1]) && IS_DIRECTORY_SEP (s[2]))
858 #ifdef ALTOS
859 || *s == '@'
860 #endif
861 #ifdef VMS
862 || index (s, ':')
863 #endif /* VMS */
864 );
865 }
866
867 /* Search for a file whose name is STR, looking in directories
868 in the Lisp list PATH, and trying suffixes from SUFFIX.
869 SUFFIX is a string containing possible suffixes separated by colons.
870 On success, returns a file descriptor. On failure, returns -1.
871
872 EXEC_ONLY nonzero means don't open the files,
873 just look for one that is executable. In this case,
874 returns 1 on success.
875
876 If STOREPTR is nonzero, it points to a slot where the name of
877 the file actually found should be stored as a Lisp string.
878 nil is stored there on failure.
879
880 If the file we find is remote, return 0
881 but store the found remote file name in *STOREPTR.
882 We do not check for remote files if EXEC_ONLY is nonzero. */
883
884 int
885 openp (path, str, suffix, storeptr, exec_only)
886 Lisp_Object path, str;
887 char *suffix;
888 Lisp_Object *storeptr;
889 int exec_only;
890 {
891 register int fd;
892 int fn_size = 100;
893 char buf[100];
894 register char *fn = buf;
895 int absolute = 0;
896 int want_size;
897 Lisp_Object filename;
898 struct stat st;
899 struct gcpro gcpro1;
900
901 GCPRO1 (str);
902 if (storeptr)
903 *storeptr = Qnil;
904
905 if (complete_filename_p (str))
906 absolute = 1;
907
908 for (; !NILP (path); path = Fcdr (path))
909 {
910 char *nsuffix;
911
912 filename = Fexpand_file_name (str, Fcar (path));
913 if (!complete_filename_p (filename))
914 /* If there are non-absolute elts in PATH (eg ".") */
915 /* Of course, this could conceivably lose if luser sets
916 default-directory to be something non-absolute... */
917 {
918 filename = Fexpand_file_name (filename, current_buffer->directory);
919 if (!complete_filename_p (filename))
920 /* Give up on this path element! */
921 continue;
922 }
923
924 /* Calculate maximum size of any filename made from
925 this path element/specified file name and any possible suffix. */
926 want_size = strlen (suffix) + STRING_BYTES (XSTRING (filename)) + 1;
927 if (fn_size < want_size)
928 fn = (char *) alloca (fn_size = 100 + want_size);
929
930 nsuffix = suffix;
931
932 /* Loop over suffixes. */
933 while (1)
934 {
935 char *esuffix = (char *) index (nsuffix, ':');
936 int lsuffix = esuffix ? esuffix - nsuffix : strlen (nsuffix);
937 Lisp_Object handler;
938
939 /* Concatenate path element/specified name with the suffix.
940 If the directory starts with /:, remove that. */
941 if (XSTRING (filename)->size > 2
942 && XSTRING (filename)->data[0] == '/'
943 && XSTRING (filename)->data[1] == ':')
944 {
945 strncpy (fn, XSTRING (filename)->data + 2,
946 STRING_BYTES (XSTRING (filename)) - 2);
947 fn[STRING_BYTES (XSTRING (filename)) - 2] = 0;
948 }
949 else
950 {
951 strncpy (fn, XSTRING (filename)->data,
952 STRING_BYTES (XSTRING (filename)));
953 fn[STRING_BYTES (XSTRING (filename))] = 0;
954 }
955
956 if (lsuffix != 0) /* Bug happens on CCI if lsuffix is 0. */
957 strncat (fn, nsuffix, lsuffix);
958
959 /* Check that the file exists and is not a directory. */
960 if (absolute)
961 handler = Qnil;
962 else
963 handler = Ffind_file_name_handler (filename, Qfile_exists_p);
964 if (! NILP (handler) && ! exec_only)
965 {
966 Lisp_Object string;
967 int exists;
968
969 string = build_string (fn);
970 exists = ! NILP (exec_only ? Ffile_executable_p (string)
971 : Ffile_readable_p (string));
972 if (exists
973 && ! NILP (Ffile_directory_p (build_string (fn))))
974 exists = 0;
975
976 if (exists)
977 {
978 /* We succeeded; return this descriptor and filename. */
979 if (storeptr)
980 *storeptr = build_string (fn);
981 UNGCPRO;
982 return 0;
983 }
984 }
985 else
986 {
987 int exists = (stat (fn, &st) >= 0
988 && (st.st_mode & S_IFMT) != S_IFDIR);
989 if (exists)
990 {
991 /* Check that we can access or open it. */
992 if (exec_only)
993 fd = (access (fn, X_OK) == 0) ? 1 : -1;
994 else
995 fd = emacs_open (fn, O_RDONLY, 0);
996
997 if (fd >= 0)
998 {
999 /* We succeeded; return this descriptor and filename. */
1000 if (storeptr)
1001 *storeptr = build_string (fn);
1002 UNGCPRO;
1003 return fd;
1004 }
1005 }
1006 }
1007
1008 /* Advance to next suffix. */
1009 if (esuffix == 0)
1010 break;
1011 nsuffix += lsuffix + 1;
1012 }
1013 if (absolute)
1014 break;
1015 }
1016
1017 UNGCPRO;
1018 return -1;
1019 }
1020
1021 \f
1022 /* Merge the list we've accumulated of globals from the current input source
1023 into the load_history variable. The details depend on whether
1024 the source has an associated file name or not. */
1025
1026 static void
1027 build_load_history (stream, source)
1028 FILE *stream;
1029 Lisp_Object source;
1030 {
1031 register Lisp_Object tail, prev, newelt;
1032 register Lisp_Object tem, tem2;
1033 register int foundit, loading;
1034
1035 loading = stream || !NARROWED;
1036
1037 tail = Vload_history;
1038 prev = Qnil;
1039 foundit = 0;
1040 while (!NILP (tail))
1041 {
1042 tem = Fcar (tail);
1043
1044 /* Find the feature's previous assoc list... */
1045 if (!NILP (Fequal (source, Fcar (tem))))
1046 {
1047 foundit = 1;
1048
1049 /* If we're loading, remove it. */
1050 if (loading)
1051 {
1052 if (NILP (prev))
1053 Vload_history = Fcdr (tail);
1054 else
1055 Fsetcdr (prev, Fcdr (tail));
1056 }
1057
1058 /* Otherwise, cons on new symbols that are not already members. */
1059 else
1060 {
1061 tem2 = Vcurrent_load_list;
1062
1063 while (CONSP (tem2))
1064 {
1065 newelt = Fcar (tem2);
1066
1067 if (NILP (Fmemq (newelt, tem)))
1068 Fsetcar (tail, Fcons (Fcar (tem),
1069 Fcons (newelt, Fcdr (tem))));
1070
1071 tem2 = Fcdr (tem2);
1072 QUIT;
1073 }
1074 }
1075 }
1076 else
1077 prev = tail;
1078 tail = Fcdr (tail);
1079 QUIT;
1080 }
1081
1082 /* If we're loading, cons the new assoc onto the front of load-history,
1083 the most-recently-loaded position. Also do this if we didn't find
1084 an existing member for the current source. */
1085 if (loading || !foundit)
1086 Vload_history = Fcons (Fnreverse (Vcurrent_load_list),
1087 Vload_history);
1088 }
1089
1090 Lisp_Object
1091 unreadpure () /* Used as unwind-protect function in readevalloop */
1092 {
1093 read_pure = 0;
1094 return Qnil;
1095 }
1096
1097 static Lisp_Object
1098 readevalloop_1 (old)
1099 Lisp_Object old;
1100 {
1101 load_convert_to_unibyte = ! NILP (old);
1102 return Qnil;
1103 }
1104
1105 /* Signal an `end-of-file' error, if possible with file name
1106 information. */
1107
1108 static void
1109 end_of_file_error ()
1110 {
1111 Lisp_Object data;
1112
1113 if (STRINGP (Vload_file_name))
1114 data = Fcons (Vload_file_name, Qnil);
1115 else
1116 data = Qnil;
1117
1118 Fsignal (Qend_of_file, data);
1119 }
1120
1121 /* UNIBYTE specifies how to set load_convert_to_unibyte
1122 for this invocation.
1123 READFUN, if non-nil, is used instead of `read'. */
1124
1125 static void
1126 readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte, readfun)
1127 Lisp_Object readcharfun;
1128 FILE *stream;
1129 Lisp_Object sourcename;
1130 Lisp_Object (*evalfun) ();
1131 int printflag;
1132 Lisp_Object unibyte, readfun;
1133 {
1134 register int c;
1135 register Lisp_Object val;
1136 int count = specpdl_ptr - specpdl;
1137 struct gcpro gcpro1;
1138 struct buffer *b = 0;
1139 int continue_reading_p;
1140
1141 if (BUFFERP (readcharfun))
1142 b = XBUFFER (readcharfun);
1143 else if (MARKERP (readcharfun))
1144 b = XMARKER (readcharfun)->buffer;
1145
1146 specbind (Qstandard_input, readcharfun);
1147 specbind (Qcurrent_load_list, Qnil);
1148 record_unwind_protect (readevalloop_1, load_convert_to_unibyte ? Qt : Qnil);
1149 load_convert_to_unibyte = !NILP (unibyte);
1150
1151 readchar_backlog = -1;
1152
1153 GCPRO1 (sourcename);
1154
1155 LOADHIST_ATTACH (sourcename);
1156
1157 continue_reading_p = 1;
1158 while (continue_reading_p)
1159 {
1160 if (b != 0 && NILP (b->name))
1161 error ("Reading from killed buffer");
1162
1163 instream = stream;
1164 c = READCHAR;
1165 if (c == ';')
1166 {
1167 while ((c = READCHAR) != '\n' && c != -1);
1168 continue;
1169 }
1170 if (c < 0) break;
1171
1172 /* Ignore whitespace here, so we can detect eof. */
1173 if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r')
1174 continue;
1175
1176 if (!NILP (Vpurify_flag) && c == '(')
1177 {
1178 int count1 = specpdl_ptr - specpdl;
1179 record_unwind_protect (unreadpure, Qnil);
1180 val = read_list (-1, readcharfun);
1181 unbind_to (count1, Qnil);
1182 }
1183 else
1184 {
1185 UNREAD (c);
1186 read_objects = Qnil;
1187 if (!NILP (readfun))
1188 {
1189 val = call1 (readfun, readcharfun);
1190
1191 /* If READCHARFUN has set point to ZV, we should
1192 stop reading, even if the form read sets point
1193 to a different value when evaluated. */
1194 if (BUFFERP (readcharfun))
1195 {
1196 struct buffer *b = XBUFFER (readcharfun);
1197 if (BUF_PT (b) == BUF_ZV (b))
1198 continue_reading_p = 0;
1199 }
1200 }
1201 else if (! NILP (Vload_read_function))
1202 val = call1 (Vload_read_function, readcharfun);
1203 else
1204 val = read0 (readcharfun);
1205 }
1206
1207 val = (*evalfun) (val);
1208
1209 if (printflag)
1210 {
1211 Vvalues = Fcons (val, Vvalues);
1212 if (EQ (Vstandard_output, Qt))
1213 Fprin1 (val, Qnil);
1214 else
1215 Fprint (val, Qnil);
1216 }
1217 }
1218
1219 build_load_history (stream, sourcename);
1220 UNGCPRO;
1221
1222 unbind_to (count, Qnil);
1223 }
1224
1225 DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 5, "",
1226 "Execute the current buffer as Lisp code.\n\
1227 Programs can pass two arguments, BUFFER and PRINTFLAG.\n\
1228 BUFFER is the buffer to evaluate (nil means use current buffer).\n\
1229 PRINTFLAG controls printing of output:\n\
1230 nil means discard it; anything else is stream for print.\n\
1231 \n\
1232 If the optional third argument FILENAME is non-nil,\n\
1233 it specifies the file name to use for `load-history'.\n\
1234 The optional fourth argument UNIBYTE specifies `load-convert-to-unibyte'\n\
1235 for this invocation.\n\
1236 \n\
1237 The optional fifth argument DO-ALLOW-PRINT, if not-nil, specifies that\n\
1238 `print' and related functions should work normally even if PRINTFLAG is nil.\n\
1239 \n\
1240 This function preserves the position of point.")
1241 (buffer, printflag, filename, unibyte, do_allow_print)
1242 Lisp_Object buffer, printflag, filename, unibyte, do_allow_print;
1243 {
1244 int count = specpdl_ptr - specpdl;
1245 Lisp_Object tem, buf;
1246
1247 if (NILP (buffer))
1248 buf = Fcurrent_buffer ();
1249 else
1250 buf = Fget_buffer (buffer);
1251 if (NILP (buf))
1252 error ("No such buffer");
1253
1254 if (NILP (printflag) && NILP (do_allow_print))
1255 tem = Qsymbolp;
1256 else
1257 tem = printflag;
1258
1259 if (NILP (filename))
1260 filename = XBUFFER (buf)->filename;
1261
1262 specbind (Qstandard_output, tem);
1263 record_unwind_protect (save_excursion_restore, save_excursion_save ());
1264 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
1265 readevalloop (buf, 0, filename, Feval, !NILP (printflag), unibyte, Qnil);
1266 unbind_to (count, Qnil);
1267
1268 return Qnil;
1269 }
1270
1271 #if 0
1272 XDEFUN ("eval-current-buffer", Feval_current_buffer, Seval_current_buffer, 0, 1, "",
1273 "Execute the current buffer as Lisp code.\n\
1274 Programs can pass argument PRINTFLAG which controls printing of output:\n\
1275 nil means discard it; anything else is stream for print.\n\
1276 \n\
1277 If there is no error, point does not move. If there is an error,\n\
1278 point remains at the end of the last character read from the buffer.")
1279 (printflag)
1280 Lisp_Object printflag;
1281 {
1282 int count = specpdl_ptr - specpdl;
1283 Lisp_Object tem, cbuf;
1284
1285 cbuf = Fcurrent_buffer ()
1286
1287 if (NILP (printflag))
1288 tem = Qsymbolp;
1289 else
1290 tem = printflag;
1291 specbind (Qstandard_output, tem);
1292 record_unwind_protect (save_excursion_restore, save_excursion_save ());
1293 SET_PT (BEGV);
1294 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval,
1295 !NILP (printflag), Qnil, Qnil);
1296 return unbind_to (count, Qnil);
1297 }
1298 #endif
1299
1300 DEFUN ("eval-region", Feval_region, Seval_region, 2, 4, "r",
1301 "Execute the region as Lisp code.\n\
1302 When called from programs, expects two arguments,\n\
1303 giving starting and ending indices in the current buffer\n\
1304 of the text to be executed.\n\
1305 Programs can pass third argument PRINTFLAG which controls output:\n\
1306 nil means discard it; anything else is stream for printing it.\n\
1307 Also the fourth argument READ-FUNCTION, if non-nil, is used\n\
1308 instead of `read' to read each expression. It gets one argument\n\
1309 which is the input stream for reading characters.\n\
1310 \n\
1311 This function does not move point.")
1312 (start, end, printflag, read_function)
1313 Lisp_Object start, end, printflag, read_function;
1314 {
1315 int count = specpdl_ptr - specpdl;
1316 Lisp_Object tem, cbuf;
1317
1318 cbuf = Fcurrent_buffer ();
1319
1320 if (NILP (printflag))
1321 tem = Qsymbolp;
1322 else
1323 tem = printflag;
1324 specbind (Qstandard_output, tem);
1325
1326 if (NILP (printflag))
1327 record_unwind_protect (save_excursion_restore, save_excursion_save ());
1328 record_unwind_protect (save_restriction_restore, save_restriction_save ());
1329
1330 /* This both uses start and checks its type. */
1331 Fgoto_char (start);
1332 Fnarrow_to_region (make_number (BEGV), end);
1333 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval,
1334 !NILP (printflag), Qnil, read_function);
1335
1336 return unbind_to (count, Qnil);
1337 }
1338
1339 \f
1340 DEFUN ("read", Fread, Sread, 0, 1, 0,
1341 "Read one Lisp expression as text from STREAM, return as Lisp object.\n\
1342 If STREAM is nil, use the value of `standard-input' (which see).\n\
1343 STREAM or the value of `standard-input' may be:\n\
1344 a buffer (read from point and advance it)\n\
1345 a marker (read from where it points and advance it)\n\
1346 a function (call it with no arguments for each character,\n\
1347 call it with a char as argument to push a char back)\n\
1348 a string (takes text from string, starting at the beginning)\n\
1349 t (read text line using minibuffer and use it).")
1350 (stream)
1351 Lisp_Object stream;
1352 {
1353 extern Lisp_Object Fread_minibuffer ();
1354
1355 if (NILP (stream))
1356 stream = Vstandard_input;
1357 if (EQ (stream, Qt))
1358 stream = Qread_char;
1359
1360 readchar_backlog = -1;
1361 new_backquote_flag = 0;
1362 read_objects = Qnil;
1363
1364 if (EQ (stream, Qread_char))
1365 return Fread_minibuffer (build_string ("Lisp expression: "), Qnil);
1366
1367 if (STRINGP (stream))
1368 return Fcar (Fread_from_string (stream, Qnil, Qnil));
1369
1370 return read0 (stream);
1371 }
1372
1373 DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0,
1374 "Read one Lisp expression which is represented as text by STRING.\n\
1375 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\
1376 START and END optionally delimit a substring of STRING from which to read;\n\
1377 they default to 0 and (length STRING) respectively.")
1378 (string, start, end)
1379 Lisp_Object string, start, end;
1380 {
1381 int startval, endval;
1382 Lisp_Object tem;
1383
1384 CHECK_STRING (string,0);
1385
1386 if (NILP (end))
1387 endval = XSTRING (string)->size;
1388 else
1389 {
1390 CHECK_NUMBER (end, 2);
1391 endval = XINT (end);
1392 if (endval < 0 || endval > XSTRING (string)->size)
1393 args_out_of_range (string, end);
1394 }
1395
1396 if (NILP (start))
1397 startval = 0;
1398 else
1399 {
1400 CHECK_NUMBER (start, 1);
1401 startval = XINT (start);
1402 if (startval < 0 || startval > endval)
1403 args_out_of_range (string, start);
1404 }
1405
1406 read_from_string_index = startval;
1407 read_from_string_index_byte = string_char_to_byte (string, startval);
1408 read_from_string_limit = endval;
1409
1410 new_backquote_flag = 0;
1411 read_objects = Qnil;
1412
1413 tem = read0 (string);
1414 return Fcons (tem, make_number (read_from_string_index));
1415 }
1416 \f
1417 /* Use this for recursive reads, in contexts where internal tokens
1418 are not allowed. */
1419
1420 static Lisp_Object
1421 read0 (readcharfun)
1422 Lisp_Object readcharfun;
1423 {
1424 register Lisp_Object val;
1425 int c;
1426
1427 val = read1 (readcharfun, &c, 0);
1428 if (c)
1429 Fsignal (Qinvalid_read_syntax, Fcons (Fmake_string (make_number (1),
1430 make_number (c)),
1431 Qnil));
1432
1433 return val;
1434 }
1435 \f
1436 static int read_buffer_size;
1437 static char *read_buffer;
1438
1439 /* Read multibyte form and return it as a character. C is a first
1440 byte of multibyte form, and rest of them are read from
1441 READCHARFUN. */
1442
1443 static int
1444 read_multibyte (c, readcharfun)
1445 register int c;
1446 Lisp_Object readcharfun;
1447 {
1448 /* We need the actual character code of this multibyte
1449 characters. */
1450 unsigned char str[MAX_MULTIBYTE_LENGTH];
1451 int len = 0;
1452
1453 str[len++] = c;
1454 while ((c = READCHAR) >= 0xA0
1455 && len < MAX_MULTIBYTE_LENGTH)
1456 str[len++] = c;
1457 UNREAD (c);
1458 return STRING_CHAR (str, len);
1459 }
1460
1461 /* Read a \-escape sequence, assuming we already read the `\'. */
1462
1463 static int
1464 read_escape (readcharfun, stringp)
1465 Lisp_Object readcharfun;
1466 int stringp;
1467 {
1468 register int c = READCHAR;
1469 switch (c)
1470 {
1471 case -1:
1472 error ("End of file");
1473
1474 case 'a':
1475 return '\007';
1476 case 'b':
1477 return '\b';
1478 case 'd':
1479 return 0177;
1480 case 'e':
1481 return 033;
1482 case 'f':
1483 return '\f';
1484 case 'n':
1485 return '\n';
1486 case 'r':
1487 return '\r';
1488 case 't':
1489 return '\t';
1490 case 'v':
1491 return '\v';
1492 case '\n':
1493 return -1;
1494 case ' ':
1495 if (stringp)
1496 return -1;
1497 return ' ';
1498
1499 case 'M':
1500 c = READCHAR;
1501 if (c != '-')
1502 error ("Invalid escape character syntax");
1503 c = READCHAR;
1504 if (c == '\\')
1505 c = read_escape (readcharfun, 0);
1506 return c | meta_modifier;
1507
1508 case 'S':
1509 c = READCHAR;
1510 if (c != '-')
1511 error ("Invalid escape character syntax");
1512 c = READCHAR;
1513 if (c == '\\')
1514 c = read_escape (readcharfun, 0);
1515 return c | shift_modifier;
1516
1517 case 'H':
1518 c = READCHAR;
1519 if (c != '-')
1520 error ("Invalid escape character syntax");
1521 c = READCHAR;
1522 if (c == '\\')
1523 c = read_escape (readcharfun, 0);
1524 return c | hyper_modifier;
1525
1526 case 'A':
1527 c = READCHAR;
1528 if (c != '-')
1529 error ("Invalid escape character syntax");
1530 c = READCHAR;
1531 if (c == '\\')
1532 c = read_escape (readcharfun, 0);
1533 return c | alt_modifier;
1534
1535 case 's':
1536 c = READCHAR;
1537 if (c != '-')
1538 error ("Invalid escape character syntax");
1539 c = READCHAR;
1540 if (c == '\\')
1541 c = read_escape (readcharfun, 0);
1542 return c | super_modifier;
1543
1544 case 'C':
1545 c = READCHAR;
1546 if (c != '-')
1547 error ("Invalid escape character syntax");
1548 case '^':
1549 c = READCHAR;
1550 if (c == '\\')
1551 c = read_escape (readcharfun, 0);
1552 if ((c & ~CHAR_MODIFIER_MASK) == '?')
1553 return 0177 | (c & CHAR_MODIFIER_MASK);
1554 else if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)))
1555 return c | ctrl_modifier;
1556 /* ASCII control chars are made from letters (both cases),
1557 as well as the non-letters within 0100...0137. */
1558 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132)
1559 return (c & (037 | ~0177));
1560 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
1561 return (c & (037 | ~0177));
1562 else
1563 return c | ctrl_modifier;
1564
1565 case '0':
1566 case '1':
1567 case '2':
1568 case '3':
1569 case '4':
1570 case '5':
1571 case '6':
1572 case '7':
1573 /* An octal escape, as in ANSI C. */
1574 {
1575 register int i = c - '0';
1576 register int count = 0;
1577 while (++count < 3)
1578 {
1579 if ((c = READCHAR) >= '0' && c <= '7')
1580 {
1581 i *= 8;
1582 i += c - '0';
1583 }
1584 else
1585 {
1586 UNREAD (c);
1587 break;
1588 }
1589 }
1590 return i;
1591 }
1592
1593 case 'x':
1594 /* A hex escape, as in ANSI C. */
1595 {
1596 int i = 0;
1597 while (1)
1598 {
1599 c = READCHAR;
1600 if (c >= '0' && c <= '9')
1601 {
1602 i *= 16;
1603 i += c - '0';
1604 }
1605 else if ((c >= 'a' && c <= 'f')
1606 || (c >= 'A' && c <= 'F'))
1607 {
1608 i *= 16;
1609 if (c >= 'a' && c <= 'f')
1610 i += c - 'a' + 10;
1611 else
1612 i += c - 'A' + 10;
1613 }
1614 else
1615 {
1616 UNREAD (c);
1617 break;
1618 }
1619 }
1620 return i;
1621 }
1622
1623 default:
1624 if (BASE_LEADING_CODE_P (c))
1625 c = read_multibyte (c, readcharfun);
1626 return c;
1627 }
1628 }
1629
1630
1631 /* Read an integer in radix RADIX using READCHARFUN to read
1632 characters. RADIX must be in the interval [2..36]; if it isn't, a
1633 read error is signaled . Value is the integer read. Signals an
1634 error if encountering invalid read syntax or if RADIX is out of
1635 range. */
1636
1637 static Lisp_Object
1638 read_integer (readcharfun, radix)
1639 Lisp_Object readcharfun;
1640 int radix;
1641 {
1642 int number, ndigits, invalid_p, c, sign;
1643
1644 if (radix < 2 || radix > 36)
1645 invalid_p = 1;
1646 else
1647 {
1648 number = ndigits = invalid_p = 0;
1649 sign = 1;
1650
1651 c = READCHAR;
1652 if (c == '-')
1653 {
1654 c = READCHAR;
1655 sign = -1;
1656 }
1657 else if (c == '+')
1658 c = READCHAR;
1659
1660 while (c >= 0)
1661 {
1662 int digit;
1663
1664 if (c >= '0' && c <= '9')
1665 digit = c - '0';
1666 else if (c >= 'a' && c <= 'z')
1667 digit = c - 'a' + 10;
1668 else if (c >= 'A' && c <= 'Z')
1669 digit = c - 'A' + 10;
1670 else
1671 {
1672 UNREAD (c);
1673 break;
1674 }
1675
1676 if (digit < 0 || digit >= radix)
1677 invalid_p = 1;
1678
1679 number = radix * number + digit;
1680 ++ndigits;
1681 c = READCHAR;
1682 }
1683 }
1684
1685 if (ndigits == 0 || invalid_p)
1686 {
1687 char buf[50];
1688 sprintf (buf, "integer, radix %d", radix);
1689 Fsignal (Qinvalid_read_syntax, Fcons (build_string (buf), Qnil));
1690 }
1691
1692 return make_number (sign * number);
1693 }
1694
1695
1696 /* If the next token is ')' or ']' or '.', we store that character
1697 in *PCH and the return value is not interesting. Else, we store
1698 zero in *PCH and we read and return one lisp object.
1699
1700 FIRST_IN_LIST is nonzero if this is the first element of a list. */
1701
1702 static Lisp_Object
1703 read1 (readcharfun, pch, first_in_list)
1704 register Lisp_Object readcharfun;
1705 int *pch;
1706 int first_in_list;
1707 {
1708 register int c;
1709 int uninterned_symbol = 0;
1710
1711 *pch = 0;
1712
1713 retry:
1714
1715 c = READCHAR;
1716 if (c < 0)
1717 end_of_file_error ();
1718
1719 switch (c)
1720 {
1721 case '(':
1722 return read_list (0, readcharfun);
1723
1724 case '[':
1725 return read_vector (readcharfun, 0);
1726
1727 case ')':
1728 case ']':
1729 {
1730 *pch = c;
1731 return Qnil;
1732 }
1733
1734 case '#':
1735 c = READCHAR;
1736 if (c == '^')
1737 {
1738 c = READCHAR;
1739 if (c == '[')
1740 {
1741 Lisp_Object tmp;
1742 tmp = read_vector (readcharfun, 0);
1743 if (XVECTOR (tmp)->size < CHAR_TABLE_STANDARD_SLOTS
1744 || XVECTOR (tmp)->size > CHAR_TABLE_STANDARD_SLOTS + 10)
1745 error ("Invalid size char-table");
1746 XSETCHAR_TABLE (tmp, XCHAR_TABLE (tmp));
1747 XCHAR_TABLE (tmp)->top = Qt;
1748 return tmp;
1749 }
1750 else if (c == '^')
1751 {
1752 c = READCHAR;
1753 if (c == '[')
1754 {
1755 Lisp_Object tmp;
1756 tmp = read_vector (readcharfun, 0);
1757 if (XVECTOR (tmp)->size != SUB_CHAR_TABLE_STANDARD_SLOTS)
1758 error ("Invalid size char-table");
1759 XSETCHAR_TABLE (tmp, XCHAR_TABLE (tmp));
1760 XCHAR_TABLE (tmp)->top = Qnil;
1761 return tmp;
1762 }
1763 Fsignal (Qinvalid_read_syntax,
1764 Fcons (make_string ("#^^", 3), Qnil));
1765 }
1766 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#^", 2), Qnil));
1767 }
1768 if (c == '&')
1769 {
1770 Lisp_Object length;
1771 length = read1 (readcharfun, pch, first_in_list);
1772 c = READCHAR;
1773 if (c == '"')
1774 {
1775 Lisp_Object tmp, val;
1776 int size_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1)
1777 / BITS_PER_CHAR);
1778
1779 UNREAD (c);
1780 tmp = read1 (readcharfun, pch, first_in_list);
1781 if (size_in_chars != XSTRING (tmp)->size
1782 /* We used to print 1 char too many
1783 when the number of bits was a multiple of 8.
1784 Accept such input in case it came from an old version. */
1785 && ! (XFASTINT (length)
1786 == (XSTRING (tmp)->size - 1) * BITS_PER_CHAR))
1787 Fsignal (Qinvalid_read_syntax,
1788 Fcons (make_string ("#&...", 5), Qnil));
1789
1790 val = Fmake_bool_vector (length, Qnil);
1791 bcopy (XSTRING (tmp)->data, XBOOL_VECTOR (val)->data,
1792 size_in_chars);
1793 /* Clear the extraneous bits in the last byte. */
1794 if (XINT (length) != size_in_chars * BITS_PER_CHAR)
1795 XBOOL_VECTOR (val)->data[size_in_chars - 1]
1796 &= (1 << (XINT (length) % BITS_PER_CHAR)) - 1;
1797 return val;
1798 }
1799 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#&...", 5),
1800 Qnil));
1801 }
1802 if (c == '[')
1803 {
1804 /* Accept compiled functions at read-time so that we don't have to
1805 build them using function calls. */
1806 Lisp_Object tmp;
1807 tmp = read_vector (readcharfun, 1);
1808 return Fmake_byte_code (XVECTOR (tmp)->size,
1809 XVECTOR (tmp)->contents);
1810 }
1811 if (c == '(')
1812 {
1813 Lisp_Object tmp;
1814 struct gcpro gcpro1;
1815 int ch;
1816
1817 /* Read the string itself. */
1818 tmp = read1 (readcharfun, &ch, 0);
1819 if (ch != 0 || !STRINGP (tmp))
1820 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
1821 GCPRO1 (tmp);
1822 /* Read the intervals and their properties. */
1823 while (1)
1824 {
1825 Lisp_Object beg, end, plist;
1826
1827 beg = read1 (readcharfun, &ch, 0);
1828 if (ch == ')')
1829 break;
1830 if (ch == 0)
1831 end = read1 (readcharfun, &ch, 0);
1832 if (ch == 0)
1833 plist = read1 (readcharfun, &ch, 0);
1834 if (ch)
1835 Fsignal (Qinvalid_read_syntax,
1836 Fcons (build_string ("invalid string property list"),
1837 Qnil));
1838 Fset_text_properties (beg, end, plist, tmp);
1839 }
1840 UNGCPRO;
1841 return tmp;
1842 }
1843
1844 /* #@NUMBER is used to skip NUMBER following characters.
1845 That's used in .elc files to skip over doc strings
1846 and function definitions. */
1847 if (c == '@')
1848 {
1849 int i, nskip = 0;
1850
1851 /* Read a decimal integer. */
1852 while ((c = READCHAR) >= 0
1853 && c >= '0' && c <= '9')
1854 {
1855 nskip *= 10;
1856 nskip += c - '0';
1857 }
1858 if (c >= 0)
1859 UNREAD (c);
1860
1861 if (load_force_doc_strings && EQ (readcharfun, Qget_file_char))
1862 {
1863 /* If we are supposed to force doc strings into core right now,
1864 record the last string that we skipped,
1865 and record where in the file it comes from. */
1866
1867 /* But first exchange saved_doc_string
1868 with prev_saved_doc_string, so we save two strings. */
1869 {
1870 char *temp = saved_doc_string;
1871 int temp_size = saved_doc_string_size;
1872 file_offset temp_pos = saved_doc_string_position;
1873 int temp_len = saved_doc_string_length;
1874
1875 saved_doc_string = prev_saved_doc_string;
1876 saved_doc_string_size = prev_saved_doc_string_size;
1877 saved_doc_string_position = prev_saved_doc_string_position;
1878 saved_doc_string_length = prev_saved_doc_string_length;
1879
1880 prev_saved_doc_string = temp;
1881 prev_saved_doc_string_size = temp_size;
1882 prev_saved_doc_string_position = temp_pos;
1883 prev_saved_doc_string_length = temp_len;
1884 }
1885
1886 if (saved_doc_string_size == 0)
1887 {
1888 saved_doc_string_size = nskip + 100;
1889 saved_doc_string = (char *) xmalloc (saved_doc_string_size);
1890 }
1891 if (nskip > saved_doc_string_size)
1892 {
1893 saved_doc_string_size = nskip + 100;
1894 saved_doc_string = (char *) xrealloc (saved_doc_string,
1895 saved_doc_string_size);
1896 }
1897
1898 saved_doc_string_position = file_tell (instream);
1899
1900 /* Copy that many characters into saved_doc_string. */
1901 for (i = 0; i < nskip && c >= 0; i++)
1902 saved_doc_string[i] = c = READCHAR;
1903
1904 saved_doc_string_length = i;
1905 }
1906 else
1907 {
1908 /* Skip that many characters. */
1909 for (i = 0; i < nskip && c >= 0; i++)
1910 c = READCHAR;
1911 }
1912
1913 goto retry;
1914 }
1915 if (c == '$')
1916 return Vload_file_name;
1917 if (c == '\'')
1918 return Fcons (Qfunction, Fcons (read0 (readcharfun), Qnil));
1919 /* #:foo is the uninterned symbol named foo. */
1920 if (c == ':')
1921 {
1922 uninterned_symbol = 1;
1923 c = READCHAR;
1924 goto default_label;
1925 }
1926 /* Reader forms that can reuse previously read objects. */
1927 if (c >= '0' && c <= '9')
1928 {
1929 int n = 0;
1930 Lisp_Object tem;
1931
1932 /* Read a non-negative integer. */
1933 while (c >= '0' && c <= '9')
1934 {
1935 n *= 10;
1936 n += c - '0';
1937 c = READCHAR;
1938 }
1939 /* #n=object returns object, but associates it with n for #n#. */
1940 if (c == '=')
1941 {
1942 /* Make a placeholder for #n# to use temporarily */
1943 Lisp_Object placeholder;
1944 Lisp_Object cell;
1945
1946 placeholder = Fcons(Qnil, Qnil);
1947 cell = Fcons (make_number (n), placeholder);
1948 read_objects = Fcons (cell, read_objects);
1949
1950 /* Read the object itself. */
1951 tem = read0 (readcharfun);
1952
1953 /* Now put it everywhere the placeholder was... */
1954 substitute_object_in_subtree (tem, placeholder);
1955
1956 /* ...and #n# will use the real value from now on. */
1957 Fsetcdr (cell, tem);
1958
1959 return tem;
1960 }
1961 /* #n# returns a previously read object. */
1962 if (c == '#')
1963 {
1964 tem = Fassq (make_number (n), read_objects);
1965 if (CONSP (tem))
1966 return XCDR (tem);
1967 /* Fall through to error message. */
1968 }
1969 else if (c == 'r' || c == 'R')
1970 return read_integer (readcharfun, n);
1971
1972 /* Fall through to error message. */
1973 }
1974 else if (c == 'x' || c == 'X')
1975 return read_integer (readcharfun, 16);
1976 else if (c == 'o' || c == 'O')
1977 return read_integer (readcharfun, 8);
1978 else if (c == 'b' || c == 'B')
1979 return read_integer (readcharfun, 2);
1980
1981 UNREAD (c);
1982 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
1983
1984 case ';':
1985 while ((c = READCHAR) >= 0 && c != '\n');
1986 goto retry;
1987
1988 case '\'':
1989 {
1990 return Fcons (Qquote, Fcons (read0 (readcharfun), Qnil));
1991 }
1992
1993 case '`':
1994 if (first_in_list)
1995 goto default_label;
1996 else
1997 {
1998 Lisp_Object value;
1999
2000 new_backquote_flag = 1;
2001 value = read0 (readcharfun);
2002 new_backquote_flag = 0;
2003
2004 return Fcons (Qbackquote, Fcons (value, Qnil));
2005 }
2006
2007 case ',':
2008 if (new_backquote_flag)
2009 {
2010 Lisp_Object comma_type = Qnil;
2011 Lisp_Object value;
2012 int ch = READCHAR;
2013
2014 if (ch == '@')
2015 comma_type = Qcomma_at;
2016 else if (ch == '.')
2017 comma_type = Qcomma_dot;
2018 else
2019 {
2020 if (ch >= 0) UNREAD (ch);
2021 comma_type = Qcomma;
2022 }
2023
2024 new_backquote_flag = 0;
2025 value = read0 (readcharfun);
2026 new_backquote_flag = 1;
2027 return Fcons (comma_type, Fcons (value, Qnil));
2028 }
2029 else
2030 goto default_label;
2031
2032 case '?':
2033 {
2034 c = READCHAR;
2035 if (c < 0)
2036 end_of_file_error ();
2037
2038 if (c == '\\')
2039 c = read_escape (readcharfun, 0);
2040 else if (BASE_LEADING_CODE_P (c))
2041 c = read_multibyte (c, readcharfun);
2042
2043 return make_number (c);
2044 }
2045
2046 case '"':
2047 {
2048 register char *p = read_buffer;
2049 register char *end = read_buffer + read_buffer_size;
2050 register int c;
2051 /* Nonzero if we saw an escape sequence specifying
2052 a multibyte character. */
2053 int force_multibyte = 0;
2054 /* Nonzero if we saw an escape sequence specifying
2055 a single-byte character. */
2056 int force_singlebyte = 0;
2057 int cancel = 0;
2058 int nchars;
2059
2060 while ((c = READCHAR) >= 0
2061 && c != '\"')
2062 {
2063 if (end - p < MAX_MULTIBYTE_LENGTH)
2064 {
2065 char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
2066 p += new - read_buffer;
2067 read_buffer += new - read_buffer;
2068 end = read_buffer + read_buffer_size;
2069 }
2070
2071 if (c == '\\')
2072 {
2073 c = read_escape (readcharfun, 1);
2074
2075 /* C is -1 if \ newline has just been seen */
2076 if (c == -1)
2077 {
2078 if (p == read_buffer)
2079 cancel = 1;
2080 continue;
2081 }
2082
2083 /* If an escape specifies a non-ASCII single-byte character,
2084 this must be a unibyte string. */
2085 if (SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))
2086 && ! ASCII_BYTE_P ((c & ~CHAR_MODIFIER_MASK)))
2087 force_singlebyte = 1;
2088 }
2089
2090 if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)))
2091 {
2092 /* Any modifiers for a multibyte character are invalid. */
2093 if (c & CHAR_MODIFIER_MASK)
2094 error ("Invalid modifier in string");
2095 p += CHAR_STRING (c, p);
2096 force_multibyte = 1;
2097 }
2098 else
2099 {
2100 /* Allow `\C- ' and `\C-?'. */
2101 if (c == (CHAR_CTL | ' '))
2102 c = 0;
2103 else if (c == (CHAR_CTL | '?'))
2104 c = 127;
2105
2106 if (c & CHAR_SHIFT)
2107 {
2108 /* Shift modifier is valid only with [A-Za-z]. */
2109 if ((c & 0377) >= 'A' && (c & 0377) <= 'Z')
2110 c &= ~CHAR_SHIFT;
2111 else if ((c & 0377) >= 'a' && (c & 0377) <= 'z')
2112 c = (c & ~CHAR_SHIFT) - ('a' - 'A');
2113 }
2114
2115 if (c & CHAR_META)
2116 /* Move the meta bit to the right place for a string. */
2117 c = (c & ~CHAR_META) | 0x80;
2118 if (c & ~0xff)
2119 error ("Invalid modifier in string");
2120 *p++ = c;
2121 }
2122 }
2123 if (c < 0)
2124 end_of_file_error ();
2125
2126 /* If purifying, and string starts with \ newline,
2127 return zero instead. This is for doc strings
2128 that we are really going to find in etc/DOC.nn.nn */
2129 if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel)
2130 return make_number (0);
2131
2132 if (force_multibyte)
2133 p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
2134 p - read_buffer, &nchars);
2135 else if (force_singlebyte)
2136 nchars = p - read_buffer;
2137 else if (load_convert_to_unibyte)
2138 {
2139 Lisp_Object string;
2140 p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
2141 p - read_buffer, &nchars);
2142 if (p - read_buffer != nchars)
2143 {
2144 string = make_multibyte_string (read_buffer, nchars,
2145 p - read_buffer);
2146 return Fstring_make_unibyte (string);
2147 }
2148 }
2149 else if (EQ (readcharfun, Qget_file_char)
2150 || EQ (readcharfun, Qlambda))
2151 /* Nowadays, reading directly from a file is used only for
2152 compiled Emacs Lisp files, and those always use the
2153 Emacs internal encoding. Meanwhile, Qlambda is used
2154 for reading dynamic byte code (compiled with
2155 byte-compile-dynamic = t). */
2156 p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
2157 p - read_buffer, &nchars);
2158 else
2159 /* In all other cases, if we read these bytes as
2160 separate characters, treat them as separate characters now. */
2161 nchars = p - read_buffer;
2162
2163 if (read_pure)
2164 return make_pure_string (read_buffer, nchars, p - read_buffer,
2165 (force_multibyte
2166 || (p - read_buffer != nchars)));
2167 return make_specified_string (read_buffer, nchars, p - read_buffer,
2168 (force_multibyte
2169 || (p - read_buffer != nchars)));
2170 }
2171
2172 case '.':
2173 {
2174 int next_char = READCHAR;
2175 UNREAD (next_char);
2176
2177 if (next_char <= 040
2178 || index ("\"'`,(", next_char))
2179 {
2180 *pch = c;
2181 return Qnil;
2182 }
2183
2184 /* Otherwise, we fall through! Note that the atom-reading loop
2185 below will now loop at least once, assuring that we will not
2186 try to UNREAD two characters in a row. */
2187 }
2188 default:
2189 default_label:
2190 if (c <= 040) goto retry;
2191 {
2192 register char *p = read_buffer;
2193 int quoted = 0;
2194
2195 {
2196 register char *end = read_buffer + read_buffer_size;
2197
2198 while (c > 040
2199 && !(c == '\"' || c == '\'' || c == ';' || c == '?'
2200 || c == '(' || c == ')'
2201 || c == '[' || c == ']' || c == '#'
2202 ))
2203 {
2204 if (end - p < MAX_MULTIBYTE_LENGTH)
2205 {
2206 register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
2207 p += new - read_buffer;
2208 read_buffer += new - read_buffer;
2209 end = read_buffer + read_buffer_size;
2210 }
2211 if (c == '\\')
2212 {
2213 c = READCHAR;
2214 quoted = 1;
2215 }
2216
2217 if (! SINGLE_BYTE_CHAR_P (c))
2218 p += CHAR_STRING (c, p);
2219 else
2220 *p++ = c;
2221
2222 c = READCHAR;
2223 }
2224
2225 if (p == end)
2226 {
2227 char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
2228 p += new - read_buffer;
2229 read_buffer += new - read_buffer;
2230 /* end = read_buffer + read_buffer_size; */
2231 }
2232 *p = 0;
2233 if (c >= 0)
2234 UNREAD (c);
2235 }
2236
2237 if (!quoted && !uninterned_symbol)
2238 {
2239 register char *p1;
2240 register Lisp_Object val;
2241 p1 = read_buffer;
2242 if (*p1 == '+' || *p1 == '-') p1++;
2243 /* Is it an integer? */
2244 if (p1 != p)
2245 {
2246 while (p1 != p && (c = *p1) >= '0' && c <= '9') p1++;
2247 /* Integers can have trailing decimal points. */
2248 if (p1 > read_buffer && p1 < p && *p1 == '.') p1++;
2249 if (p1 == p)
2250 /* It is an integer. */
2251 {
2252 if (p1[-1] == '.')
2253 p1[-1] = '\0';
2254 if (sizeof (int) == sizeof (EMACS_INT))
2255 XSETINT (val, atoi (read_buffer));
2256 else if (sizeof (long) == sizeof (EMACS_INT))
2257 XSETINT (val, atol (read_buffer));
2258 else
2259 abort ();
2260 return val;
2261 }
2262 }
2263 if (isfloat_string (read_buffer))
2264 {
2265 /* Compute NaN and infinities using 0.0 in a variable,
2266 to cope with compilers that think they are smarter
2267 than we are. */
2268 double zero = 0.0;
2269
2270 double value;
2271
2272 /* Negate the value ourselves. This treats 0, NaNs,
2273 and infinity properly on IEEE floating point hosts,
2274 and works around a common bug where atof ("-0.0")
2275 drops the sign. */
2276 int negative = read_buffer[0] == '-';
2277
2278 /* The only way p[-1] can be 'F' or 'N', after isfloat_string
2279 returns 1, is if the input ends in e+INF or e+NaN. */
2280 switch (p[-1])
2281 {
2282 case 'F':
2283 value = 1.0 / zero;
2284 break;
2285 case 'N':
2286 value = zero / zero;
2287 break;
2288 default:
2289 value = atof (read_buffer + negative);
2290 break;
2291 }
2292
2293 return make_float (negative ? - value : value);
2294 }
2295 }
2296
2297 if (uninterned_symbol)
2298 return make_symbol (read_buffer);
2299 else
2300 return intern (read_buffer);
2301 }
2302 }
2303 }
2304 \f
2305
2306 /* List of nodes we've seen during substitute_object_in_subtree. */
2307 static Lisp_Object seen_list;
2308
2309 static void
2310 substitute_object_in_subtree (object, placeholder)
2311 Lisp_Object object;
2312 Lisp_Object placeholder;
2313 {
2314 Lisp_Object check_object;
2315
2316 /* We haven't seen any objects when we start. */
2317 seen_list = Qnil;
2318
2319 /* Make all the substitutions. */
2320 check_object
2321 = substitute_object_recurse (object, placeholder, object);
2322
2323 /* Clear seen_list because we're done with it. */
2324 seen_list = Qnil;
2325
2326 /* The returned object here is expected to always eq the
2327 original. */
2328 if (!EQ (check_object, object))
2329 error ("Unexpected mutation error in reader");
2330 }
2331
2332 /* Feval doesn't get called from here, so no gc protection is needed. */
2333 #define SUBSTITUTE(get_val, set_val) \
2334 { \
2335 Lisp_Object old_value = get_val; \
2336 Lisp_Object true_value \
2337 = substitute_object_recurse (object, placeholder,\
2338 old_value); \
2339 \
2340 if (!EQ (old_value, true_value)) \
2341 { \
2342 set_val; \
2343 } \
2344 }
2345
2346 static Lisp_Object
2347 substitute_object_recurse (object, placeholder, subtree)
2348 Lisp_Object object;
2349 Lisp_Object placeholder;
2350 Lisp_Object subtree;
2351 {
2352 /* If we find the placeholder, return the target object. */
2353 if (EQ (placeholder, subtree))
2354 return object;
2355
2356 /* If we've been to this node before, don't explore it again. */
2357 if (!EQ (Qnil, Fmemq (subtree, seen_list)))
2358 return subtree;
2359
2360 /* If this node can be the entry point to a cycle, remember that
2361 we've seen it. It can only be such an entry point if it was made
2362 by #n=, which means that we can find it as a value in
2363 read_objects. */
2364 if (!EQ (Qnil, Frassq (subtree, read_objects)))
2365 seen_list = Fcons (subtree, seen_list);
2366
2367 /* Recurse according to subtree's type.
2368 Every branch must return a Lisp_Object. */
2369 switch (XTYPE (subtree))
2370 {
2371 case Lisp_Vectorlike:
2372 {
2373 int i;
2374 int length = XINT (Flength(subtree));
2375 for (i = 0; i < length; i++)
2376 {
2377 Lisp_Object idx = make_number (i);
2378 SUBSTITUTE (Faref (subtree, idx),
2379 Faset (subtree, idx, true_value));
2380 }
2381 return subtree;
2382 }
2383
2384 case Lisp_Cons:
2385 {
2386 SUBSTITUTE (Fcar_safe (subtree),
2387 Fsetcar (subtree, true_value));
2388 SUBSTITUTE (Fcdr_safe (subtree),
2389 Fsetcdr (subtree, true_value));
2390 return subtree;
2391 }
2392
2393 case Lisp_String:
2394 {
2395 /* Check for text properties in each interval.
2396 substitute_in_interval contains part of the logic. */
2397
2398 INTERVAL root_interval = XSTRING (subtree)->intervals;
2399 Lisp_Object arg = Fcons (object, placeholder);
2400
2401 traverse_intervals (root_interval, 1, 0,
2402 &substitute_in_interval, arg);
2403
2404 return subtree;
2405 }
2406
2407 /* Other types don't recurse any further. */
2408 default:
2409 return subtree;
2410 }
2411 }
2412
2413 /* Helper function for substitute_object_recurse. */
2414 static void
2415 substitute_in_interval (interval, arg)
2416 INTERVAL interval;
2417 Lisp_Object arg;
2418 {
2419 Lisp_Object object = Fcar (arg);
2420 Lisp_Object placeholder = Fcdr (arg);
2421
2422 SUBSTITUTE(interval->plist, interval->plist = true_value);
2423 }
2424
2425 \f
2426 #define LEAD_INT 1
2427 #define DOT_CHAR 2
2428 #define TRAIL_INT 4
2429 #define E_CHAR 8
2430 #define EXP_INT 16
2431
2432 int
2433 isfloat_string (cp)
2434 register char *cp;
2435 {
2436 register int state;
2437
2438 char *start = cp;
2439
2440 state = 0;
2441 if (*cp == '+' || *cp == '-')
2442 cp++;
2443
2444 if (*cp >= '0' && *cp <= '9')
2445 {
2446 state |= LEAD_INT;
2447 while (*cp >= '0' && *cp <= '9')
2448 cp++;
2449 }
2450 if (*cp == '.')
2451 {
2452 state |= DOT_CHAR;
2453 cp++;
2454 }
2455 if (*cp >= '0' && *cp <= '9')
2456 {
2457 state |= TRAIL_INT;
2458 while (*cp >= '0' && *cp <= '9')
2459 cp++;
2460 }
2461 if (*cp == 'e' || *cp == 'E')
2462 {
2463 state |= E_CHAR;
2464 cp++;
2465 if (*cp == '+' || *cp == '-')
2466 cp++;
2467 }
2468
2469 if (*cp >= '0' && *cp <= '9')
2470 {
2471 state |= EXP_INT;
2472 while (*cp >= '0' && *cp <= '9')
2473 cp++;
2474 }
2475 else if (cp == start)
2476 ;
2477 else if (cp[-1] == '+' && cp[0] == 'I' && cp[1] == 'N' && cp[2] == 'F')
2478 {
2479 state |= EXP_INT;
2480 cp += 3;
2481 }
2482 else if (cp[-1] == '+' && cp[0] == 'N' && cp[1] == 'a' && cp[2] == 'N')
2483 {
2484 state |= EXP_INT;
2485 cp += 3;
2486 }
2487
2488 return (((*cp == 0) || (*cp == ' ') || (*cp == '\t') || (*cp == '\n') || (*cp == '\r') || (*cp == '\f'))
2489 && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT)
2490 || state == (DOT_CHAR|TRAIL_INT)
2491 || state == (LEAD_INT|E_CHAR|EXP_INT)
2492 || state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)
2493 || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)));
2494 }
2495
2496 \f
2497 static Lisp_Object
2498 read_vector (readcharfun, bytecodeflag)
2499 Lisp_Object readcharfun;
2500 int bytecodeflag;
2501 {
2502 register int i;
2503 register int size;
2504 register Lisp_Object *ptr;
2505 register Lisp_Object tem, item, vector;
2506 register struct Lisp_Cons *otem;
2507 Lisp_Object len;
2508
2509 tem = read_list (1, readcharfun);
2510 len = Flength (tem);
2511 vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil));
2512
2513 size = XVECTOR (vector)->size;
2514 ptr = XVECTOR (vector)->contents;
2515 for (i = 0; i < size; i++)
2516 {
2517 item = Fcar (tem);
2518 /* If `load-force-doc-strings' is t when reading a lazily-loaded
2519 bytecode object, the docstring containing the bytecode and
2520 constants values must be treated as unibyte and passed to
2521 Fread, to get the actual bytecode string and constants vector. */
2522 if (bytecodeflag && load_force_doc_strings)
2523 {
2524 if (i == COMPILED_BYTECODE)
2525 {
2526 if (!STRINGP (item))
2527 error ("invalid byte code");
2528
2529 /* Delay handling the bytecode slot until we know whether
2530 it is lazily-loaded (we can tell by whether the
2531 constants slot is nil). */
2532 ptr[COMPILED_CONSTANTS] = item;
2533 item = Qnil;
2534 }
2535 else if (i == COMPILED_CONSTANTS)
2536 {
2537 Lisp_Object bytestr = ptr[COMPILED_CONSTANTS];
2538
2539 if (NILP (item))
2540 {
2541 /* Coerce string to unibyte (like string-as-unibyte,
2542 but without generating extra garbage and
2543 guaranteeing no change in the contents). */
2544 XSTRING (bytestr)->size = STRING_BYTES (XSTRING (bytestr));
2545 SET_STRING_BYTES (XSTRING (bytestr), -1);
2546
2547 item = Fread (bytestr);
2548 if (!CONSP (item))
2549 error ("invalid byte code");
2550
2551 otem = XCONS (item);
2552 bytestr = XCAR (item);
2553 item = XCDR (item);
2554 free_cons (otem);
2555 }
2556
2557 /* Now handle the bytecode slot. */
2558 ptr[COMPILED_BYTECODE] = read_pure ? Fpurecopy (bytestr) : bytestr;
2559 }
2560 }
2561 ptr[i] = read_pure ? Fpurecopy (item) : item;
2562 otem = XCONS (tem);
2563 tem = Fcdr (tem);
2564 free_cons (otem);
2565 }
2566 return vector;
2567 }
2568
2569 /* FLAG = 1 means check for ] to terminate rather than ) and .
2570 FLAG = -1 means check for starting with defun
2571 and make structure pure. */
2572
2573 static Lisp_Object
2574 read_list (flag, readcharfun)
2575 int flag;
2576 register Lisp_Object readcharfun;
2577 {
2578 /* -1 means check next element for defun,
2579 0 means don't check,
2580 1 means already checked and found defun. */
2581 int defunflag = flag < 0 ? -1 : 0;
2582 Lisp_Object val, tail;
2583 register Lisp_Object elt, tem;
2584 struct gcpro gcpro1, gcpro2;
2585 /* 0 is the normal case.
2586 1 means this list is a doc reference; replace it with the number 0.
2587 2 means this list is a doc reference; replace it with the doc string. */
2588 int doc_reference = 0;
2589
2590 /* Initialize this to 1 if we are reading a list. */
2591 int first_in_list = flag <= 0;
2592
2593 val = Qnil;
2594 tail = Qnil;
2595
2596 while (1)
2597 {
2598 int ch;
2599 GCPRO2 (val, tail);
2600 elt = read1 (readcharfun, &ch, first_in_list);
2601 UNGCPRO;
2602
2603 first_in_list = 0;
2604
2605 /* While building, if the list starts with #$, treat it specially. */
2606 if (EQ (elt, Vload_file_name)
2607 && ! NILP (elt)
2608 && !NILP (Vpurify_flag))
2609 {
2610 if (NILP (Vdoc_file_name))
2611 /* We have not yet called Snarf-documentation, so assume
2612 this file is described in the DOC-MM.NN file
2613 and Snarf-documentation will fill in the right value later.
2614 For now, replace the whole list with 0. */
2615 doc_reference = 1;
2616 else
2617 /* We have already called Snarf-documentation, so make a relative
2618 file name for this file, so it can be found properly
2619 in the installed Lisp directory.
2620 We don't use Fexpand_file_name because that would make
2621 the directory absolute now. */
2622 elt = concat2 (build_string ("../lisp/"),
2623 Ffile_name_nondirectory (elt));
2624 }
2625 else if (EQ (elt, Vload_file_name)
2626 && ! NILP (elt)
2627 && load_force_doc_strings)
2628 doc_reference = 2;
2629
2630 if (ch)
2631 {
2632 if (flag > 0)
2633 {
2634 if (ch == ']')
2635 return val;
2636 Fsignal (Qinvalid_read_syntax,
2637 Fcons (make_string (") or . in a vector", 18), Qnil));
2638 }
2639 if (ch == ')')
2640 return val;
2641 if (ch == '.')
2642 {
2643 GCPRO2 (val, tail);
2644 if (!NILP (tail))
2645 XCDR (tail) = read0 (readcharfun);
2646 else
2647 val = read0 (readcharfun);
2648 read1 (readcharfun, &ch, 0);
2649 UNGCPRO;
2650 if (ch == ')')
2651 {
2652 if (doc_reference == 1)
2653 return make_number (0);
2654 if (doc_reference == 2)
2655 {
2656 /* Get a doc string from the file we are loading.
2657 If it's in saved_doc_string, get it from there. */
2658 int pos = XINT (XCDR (val));
2659 /* Position is negative for user variables. */
2660 if (pos < 0) pos = -pos;
2661 if (pos >= saved_doc_string_position
2662 && pos < (saved_doc_string_position
2663 + saved_doc_string_length))
2664 {
2665 int start = pos - saved_doc_string_position;
2666 int from, to;
2667
2668 /* Process quoting with ^A,
2669 and find the end of the string,
2670 which is marked with ^_ (037). */
2671 for (from = start, to = start;
2672 saved_doc_string[from] != 037;)
2673 {
2674 int c = saved_doc_string[from++];
2675 if (c == 1)
2676 {
2677 c = saved_doc_string[from++];
2678 if (c == 1)
2679 saved_doc_string[to++] = c;
2680 else if (c == '0')
2681 saved_doc_string[to++] = 0;
2682 else if (c == '_')
2683 saved_doc_string[to++] = 037;
2684 }
2685 else
2686 saved_doc_string[to++] = c;
2687 }
2688
2689 return make_string (saved_doc_string + start,
2690 to - start);
2691 }
2692 /* Look in prev_saved_doc_string the same way. */
2693 else if (pos >= prev_saved_doc_string_position
2694 && pos < (prev_saved_doc_string_position
2695 + prev_saved_doc_string_length))
2696 {
2697 int start = pos - prev_saved_doc_string_position;
2698 int from, to;
2699
2700 /* Process quoting with ^A,
2701 and find the end of the string,
2702 which is marked with ^_ (037). */
2703 for (from = start, to = start;
2704 prev_saved_doc_string[from] != 037;)
2705 {
2706 int c = prev_saved_doc_string[from++];
2707 if (c == 1)
2708 {
2709 c = prev_saved_doc_string[from++];
2710 if (c == 1)
2711 prev_saved_doc_string[to++] = c;
2712 else if (c == '0')
2713 prev_saved_doc_string[to++] = 0;
2714 else if (c == '_')
2715 prev_saved_doc_string[to++] = 037;
2716 }
2717 else
2718 prev_saved_doc_string[to++] = c;
2719 }
2720
2721 return make_string (prev_saved_doc_string + start,
2722 to - start);
2723 }
2724 else
2725 return get_doc_string (val, 0, 0);
2726 }
2727
2728 return val;
2729 }
2730 return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil));
2731 }
2732 return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil));
2733 }
2734 tem = (read_pure && flag <= 0
2735 ? pure_cons (elt, Qnil)
2736 : Fcons (elt, Qnil));
2737 if (!NILP (tail))
2738 XCDR (tail) = tem;
2739 else
2740 val = tem;
2741 tail = tem;
2742 if (defunflag < 0)
2743 defunflag = EQ (elt, Qdefun);
2744 else if (defunflag > 0)
2745 read_pure = 1;
2746 }
2747 }
2748 \f
2749 Lisp_Object Vobarray;
2750 Lisp_Object initial_obarray;
2751
2752 /* oblookup stores the bucket number here, for the sake of Funintern. */
2753
2754 int oblookup_last_bucket_number;
2755
2756 static int hash_string ();
2757 Lisp_Object oblookup ();
2758
2759 /* Get an error if OBARRAY is not an obarray.
2760 If it is one, return it. */
2761
2762 Lisp_Object
2763 check_obarray (obarray)
2764 Lisp_Object obarray;
2765 {
2766 while (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
2767 {
2768 /* If Vobarray is now invalid, force it to be valid. */
2769 if (EQ (Vobarray, obarray)) Vobarray = initial_obarray;
2770
2771 obarray = wrong_type_argument (Qvectorp, obarray);
2772 }
2773 return obarray;
2774 }
2775
2776 /* Intern the C string STR: return a symbol with that name,
2777 interned in the current obarray. */
2778
2779 Lisp_Object
2780 intern (str)
2781 char *str;
2782 {
2783 Lisp_Object tem;
2784 int len = strlen (str);
2785 Lisp_Object obarray;
2786
2787 obarray = Vobarray;
2788 if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
2789 obarray = check_obarray (obarray);
2790 tem = oblookup (obarray, str, len, len);
2791 if (SYMBOLP (tem))
2792 return tem;
2793 return Fintern (make_string (str, len), obarray);
2794 }
2795
2796 /* Create an uninterned symbol with name STR. */
2797
2798 Lisp_Object
2799 make_symbol (str)
2800 char *str;
2801 {
2802 int len = strlen (str);
2803
2804 return Fmake_symbol ((!NILP (Vpurify_flag)
2805 ? make_pure_string (str, len, len, 0)
2806 : make_string (str, len)));
2807 }
2808 \f
2809 DEFUN ("intern", Fintern, Sintern, 1, 2, 0,
2810 "Return the canonical symbol whose name is STRING.\n\
2811 If there is none, one is created by this function and returned.\n\
2812 A second optional argument specifies the obarray to use;\n\
2813 it defaults to the value of `obarray'.")
2814 (string, obarray)
2815 Lisp_Object string, obarray;
2816 {
2817 register Lisp_Object tem, sym, *ptr;
2818
2819 if (NILP (obarray)) obarray = Vobarray;
2820 obarray = check_obarray (obarray);
2821
2822 CHECK_STRING (string, 0);
2823
2824 tem = oblookup (obarray, XSTRING (string)->data,
2825 XSTRING (string)->size,
2826 STRING_BYTES (XSTRING (string)));
2827 if (!INTEGERP (tem))
2828 return tem;
2829
2830 if (!NILP (Vpurify_flag))
2831 string = Fpurecopy (string);
2832 sym = Fmake_symbol (string);
2833 XSYMBOL (sym)->obarray = obarray;
2834
2835 if ((XSTRING (string)->data[0] == ':')
2836 && EQ (obarray, initial_obarray))
2837 XSYMBOL (sym)->value = sym;
2838
2839 ptr = &XVECTOR (obarray)->contents[XINT (tem)];
2840 if (SYMBOLP (*ptr))
2841 XSYMBOL (sym)->next = XSYMBOL (*ptr);
2842 else
2843 XSYMBOL (sym)->next = 0;
2844 *ptr = sym;
2845 return sym;
2846 }
2847
2848 DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0,
2849 "Return the canonical symbol named NAME, or nil if none exists.\n\
2850 NAME may be a string or a symbol. If it is a symbol, that exact\n\
2851 symbol is searched for.\n\
2852 A second optional argument specifies the obarray to use;\n\
2853 it defaults to the value of `obarray'.")
2854 (name, obarray)
2855 Lisp_Object name, obarray;
2856 {
2857 register Lisp_Object tem;
2858 struct Lisp_String *string;
2859
2860 if (NILP (obarray)) obarray = Vobarray;
2861 obarray = check_obarray (obarray);
2862
2863 if (!SYMBOLP (name))
2864 {
2865 CHECK_STRING (name, 0);
2866 string = XSTRING (name);
2867 }
2868 else
2869 string = XSYMBOL (name)->name;
2870
2871 tem = oblookup (obarray, string->data, string->size, STRING_BYTES (string));
2872 if (INTEGERP (tem) || (SYMBOLP (name) && !EQ (name, tem)))
2873 return Qnil;
2874 else
2875 return tem;
2876 }
2877 \f
2878 DEFUN ("unintern", Funintern, Sunintern, 1, 2, 0,
2879 "Delete the symbol named NAME, if any, from OBARRAY.\n\
2880 The value is t if a symbol was found and deleted, nil otherwise.\n\
2881 NAME may be a string or a symbol. If it is a symbol, that symbol\n\
2882 is deleted, if it belongs to OBARRAY--no other symbol is deleted.\n\
2883 OBARRAY defaults to the value of the variable `obarray'.")
2884 (name, obarray)
2885 Lisp_Object name, obarray;
2886 {
2887 register Lisp_Object string, tem;
2888 int hash;
2889
2890 if (NILP (obarray)) obarray = Vobarray;
2891 obarray = check_obarray (obarray);
2892
2893 if (SYMBOLP (name))
2894 XSETSTRING (string, XSYMBOL (name)->name);
2895 else
2896 {
2897 CHECK_STRING (name, 0);
2898 string = name;
2899 }
2900
2901 tem = oblookup (obarray, XSTRING (string)->data,
2902 XSTRING (string)->size,
2903 STRING_BYTES (XSTRING (string)));
2904 if (INTEGERP (tem))
2905 return Qnil;
2906 /* If arg was a symbol, don't delete anything but that symbol itself. */
2907 if (SYMBOLP (name) && !EQ (name, tem))
2908 return Qnil;
2909
2910 XSYMBOL (tem)->obarray = Qnil;
2911
2912 hash = oblookup_last_bucket_number;
2913
2914 if (EQ (XVECTOR (obarray)->contents[hash], tem))
2915 {
2916 if (XSYMBOL (tem)->next)
2917 XSETSYMBOL (XVECTOR (obarray)->contents[hash], XSYMBOL (tem)->next);
2918 else
2919 XSETINT (XVECTOR (obarray)->contents[hash], 0);
2920 }
2921 else
2922 {
2923 Lisp_Object tail, following;
2924
2925 for (tail = XVECTOR (obarray)->contents[hash];
2926 XSYMBOL (tail)->next;
2927 tail = following)
2928 {
2929 XSETSYMBOL (following, XSYMBOL (tail)->next);
2930 if (EQ (following, tem))
2931 {
2932 XSYMBOL (tail)->next = XSYMBOL (following)->next;
2933 break;
2934 }
2935 }
2936 }
2937
2938 return Qt;
2939 }
2940 \f
2941 /* Return the symbol in OBARRAY whose names matches the string
2942 of SIZE characters (SIZE_BYTE bytes) at PTR.
2943 If there is no such symbol in OBARRAY, return nil.
2944
2945 Also store the bucket number in oblookup_last_bucket_number. */
2946
2947 Lisp_Object
2948 oblookup (obarray, ptr, size, size_byte)
2949 Lisp_Object obarray;
2950 register char *ptr;
2951 int size, size_byte;
2952 {
2953 int hash;
2954 int obsize;
2955 register Lisp_Object tail;
2956 Lisp_Object bucket, tem;
2957
2958 if (!VECTORP (obarray)
2959 || (obsize = XVECTOR (obarray)->size) == 0)
2960 {
2961 obarray = check_obarray (obarray);
2962 obsize = XVECTOR (obarray)->size;
2963 }
2964 /* This is sometimes needed in the middle of GC. */
2965 obsize &= ~ARRAY_MARK_FLAG;
2966 /* Combining next two lines breaks VMS C 2.3. */
2967 hash = hash_string (ptr, size_byte);
2968 hash %= obsize;
2969 bucket = XVECTOR (obarray)->contents[hash];
2970 oblookup_last_bucket_number = hash;
2971 if (XFASTINT (bucket) == 0)
2972 ;
2973 else if (!SYMBOLP (bucket))
2974 error ("Bad data in guts of obarray"); /* Like CADR error message */
2975 else
2976 for (tail = bucket; ; XSETSYMBOL (tail, XSYMBOL (tail)->next))
2977 {
2978 if (STRING_BYTES (XSYMBOL (tail)->name) == size_byte
2979 && XSYMBOL (tail)->name->size == size
2980 && !bcmp (XSYMBOL (tail)->name->data, ptr, size_byte))
2981 return tail;
2982 else if (XSYMBOL (tail)->next == 0)
2983 break;
2984 }
2985 XSETINT (tem, hash);
2986 return tem;
2987 }
2988
2989 static int
2990 hash_string (ptr, len)
2991 unsigned char *ptr;
2992 int len;
2993 {
2994 register unsigned char *p = ptr;
2995 register unsigned char *end = p + len;
2996 register unsigned char c;
2997 register int hash = 0;
2998
2999 while (p != end)
3000 {
3001 c = *p++;
3002 if (c >= 0140) c -= 40;
3003 hash = ((hash<<3) + (hash>>28) + c);
3004 }
3005 return hash & 07777777777;
3006 }
3007 \f
3008 void
3009 map_obarray (obarray, fn, arg)
3010 Lisp_Object obarray;
3011 void (*fn) P_ ((Lisp_Object, Lisp_Object));
3012 Lisp_Object arg;
3013 {
3014 register int i;
3015 register Lisp_Object tail;
3016 CHECK_VECTOR (obarray, 1);
3017 for (i = XVECTOR (obarray)->size - 1; i >= 0; i--)
3018 {
3019 tail = XVECTOR (obarray)->contents[i];
3020 if (SYMBOLP (tail))
3021 while (1)
3022 {
3023 (*fn) (tail, arg);
3024 if (XSYMBOL (tail)->next == 0)
3025 break;
3026 XSETSYMBOL (tail, XSYMBOL (tail)->next);
3027 }
3028 }
3029 }
3030
3031 void
3032 mapatoms_1 (sym, function)
3033 Lisp_Object sym, function;
3034 {
3035 call1 (function, sym);
3036 }
3037
3038 DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0,
3039 "Call FUNCTION on every symbol in OBARRAY.\n\
3040 OBARRAY defaults to the value of `obarray'.")
3041 (function, obarray)
3042 Lisp_Object function, obarray;
3043 {
3044 if (NILP (obarray)) obarray = Vobarray;
3045 obarray = check_obarray (obarray);
3046
3047 map_obarray (obarray, mapatoms_1, function);
3048 return Qnil;
3049 }
3050
3051 #define OBARRAY_SIZE 1511
3052
3053 void
3054 init_obarray ()
3055 {
3056 Lisp_Object oblength;
3057 int hash;
3058 Lisp_Object *tem;
3059
3060 XSETFASTINT (oblength, OBARRAY_SIZE);
3061
3062 Qnil = Fmake_symbol (make_pure_string ("nil", 3, 3, 0));
3063 Vobarray = Fmake_vector (oblength, make_number (0));
3064 initial_obarray = Vobarray;
3065 staticpro (&initial_obarray);
3066 /* Intern nil in the obarray */
3067 XSYMBOL (Qnil)->obarray = Vobarray;
3068 /* These locals are to kludge around a pyramid compiler bug. */
3069 hash = hash_string ("nil", 3);
3070 /* Separate statement here to avoid VAXC bug. */
3071 hash %= OBARRAY_SIZE;
3072 tem = &XVECTOR (Vobarray)->contents[hash];
3073 *tem = Qnil;
3074
3075 Qunbound = Fmake_symbol (make_pure_string ("unbound", 7, 7, 0));
3076 XSYMBOL (Qnil)->function = Qunbound;
3077 XSYMBOL (Qunbound)->value = Qunbound;
3078 XSYMBOL (Qunbound)->function = Qunbound;
3079
3080 Qt = intern ("t");
3081 XSYMBOL (Qnil)->value = Qnil;
3082 XSYMBOL (Qnil)->plist = Qnil;
3083 XSYMBOL (Qt)->value = Qt;
3084
3085 /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */
3086 Vpurify_flag = Qt;
3087
3088 Qvariable_documentation = intern ("variable-documentation");
3089 staticpro (&Qvariable_documentation);
3090
3091 read_buffer_size = 100 + MAX_MULTIBYTE_LENGTH;
3092 read_buffer = (char *) xmalloc (read_buffer_size);
3093 }
3094 \f
3095 void
3096 defsubr (sname)
3097 struct Lisp_Subr *sname;
3098 {
3099 Lisp_Object sym;
3100 sym = intern (sname->symbol_name);
3101 XSETSUBR (XSYMBOL (sym)->function, sname);
3102 }
3103
3104 #ifdef NOTDEF /* use fset in subr.el now */
3105 void
3106 defalias (sname, string)
3107 struct Lisp_Subr *sname;
3108 char *string;
3109 {
3110 Lisp_Object sym;
3111 sym = intern (string);
3112 XSETSUBR (XSYMBOL (sym)->function, sname);
3113 }
3114 #endif /* NOTDEF */
3115
3116 /* Define an "integer variable"; a symbol whose value is forwarded
3117 to a C variable of type int. Sample call: */
3118 /* DEFVAR_INT ("indent-tabs-mode", &indent_tabs_mode, "Documentation"); */
3119 void
3120 defvar_int (namestring, address)
3121 char *namestring;
3122 int *address;
3123 {
3124 Lisp_Object sym, val;
3125 sym = intern (namestring);
3126 val = allocate_misc ();
3127 XMISCTYPE (val) = Lisp_Misc_Intfwd;
3128 XINTFWD (val)->intvar = address;
3129 XSYMBOL (sym)->value = val;
3130 }
3131
3132 /* Similar but define a variable whose value is T if address contains 1,
3133 NIL if address contains 0 */
3134 void
3135 defvar_bool (namestring, address)
3136 char *namestring;
3137 int *address;
3138 {
3139 Lisp_Object sym, val;
3140 sym = intern (namestring);
3141 val = allocate_misc ();
3142 XMISCTYPE (val) = Lisp_Misc_Boolfwd;
3143 XBOOLFWD (val)->boolvar = address;
3144 XSYMBOL (sym)->value = val;
3145 Vbyte_boolean_vars = Fcons (sym, Vbyte_boolean_vars);
3146 }
3147
3148 /* Similar but define a variable whose value is the Lisp Object stored
3149 at address. Two versions: with and without gc-marking of the C
3150 variable. The nopro version is used when that variable will be
3151 gc-marked for some other reason, since marking the same slot twice
3152 can cause trouble with strings. */
3153 void
3154 defvar_lisp_nopro (namestring, address)
3155 char *namestring;
3156 Lisp_Object *address;
3157 {
3158 Lisp_Object sym, val;
3159 sym = intern (namestring);
3160 val = allocate_misc ();
3161 XMISCTYPE (val) = Lisp_Misc_Objfwd;
3162 XOBJFWD (val)->objvar = address;
3163 XSYMBOL (sym)->value = val;
3164 }
3165
3166 void
3167 defvar_lisp (namestring, address)
3168 char *namestring;
3169 Lisp_Object *address;
3170 {
3171 defvar_lisp_nopro (namestring, address);
3172 staticpro (address);
3173 }
3174
3175 /* Similar but define a variable whose value is the Lisp Object stored in
3176 the current buffer. address is the address of the slot in the buffer
3177 that is current now. */
3178
3179 void
3180 defvar_per_buffer (namestring, address, type, doc)
3181 char *namestring;
3182 Lisp_Object *address;
3183 Lisp_Object type;
3184 char *doc;
3185 {
3186 Lisp_Object sym, val;
3187 int offset;
3188 extern struct buffer buffer_local_symbols;
3189
3190 sym = intern (namestring);
3191 val = allocate_misc ();
3192 offset = (char *)address - (char *)current_buffer;
3193
3194 XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd;
3195 XBUFFER_OBJFWD (val)->offset = offset;
3196 XSYMBOL (sym)->value = val;
3197 PER_BUFFER_SYMBOL (offset) = sym;
3198 PER_BUFFER_TYPE (offset) = type;
3199
3200 if (PER_BUFFER_IDX (offset) == 0)
3201 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
3202 slot of buffer_local_flags */
3203 abort ();
3204 }
3205
3206
3207 /* Similar but define a variable whose value is the Lisp Object stored
3208 at a particular offset in the current kboard object. */
3209
3210 void
3211 defvar_kboard (namestring, offset)
3212 char *namestring;
3213 int offset;
3214 {
3215 Lisp_Object sym, val;
3216 sym = intern (namestring);
3217 val = allocate_misc ();
3218 XMISCTYPE (val) = Lisp_Misc_Kboard_Objfwd;
3219 XKBOARD_OBJFWD (val)->offset = offset;
3220 XSYMBOL (sym)->value = val;
3221 }
3222 \f
3223 /* Record the value of load-path used at the start of dumping
3224 so we can see if the site changed it later during dumping. */
3225 static Lisp_Object dump_path;
3226
3227 void
3228 init_lread ()
3229 {
3230 char *normal;
3231 int turn_off_warning = 0;
3232
3233 /* Compute the default load-path. */
3234 #ifdef CANNOT_DUMP
3235 normal = PATH_LOADSEARCH;
3236 Vload_path = decode_env_path (0, normal);
3237 #else
3238 if (NILP (Vpurify_flag))
3239 normal = PATH_LOADSEARCH;
3240 else
3241 normal = PATH_DUMPLOADSEARCH;
3242
3243 /* In a dumped Emacs, we normally have to reset the value of
3244 Vload_path from PATH_LOADSEARCH, since the value that was dumped
3245 uses ../lisp, instead of the path of the installed elisp
3246 libraries. However, if it appears that Vload_path was changed
3247 from the default before dumping, don't override that value. */
3248 if (initialized)
3249 {
3250 if (! NILP (Fequal (dump_path, Vload_path)))
3251 {
3252 Vload_path = decode_env_path (0, normal);
3253 if (!NILP (Vinstallation_directory))
3254 {
3255 /* Add to the path the lisp subdir of the
3256 installation dir, if it exists. */
3257 Lisp_Object tem, tem1;
3258 tem = Fexpand_file_name (build_string ("lisp"),
3259 Vinstallation_directory);
3260 tem1 = Ffile_exists_p (tem);
3261 if (!NILP (tem1))
3262 {
3263 if (NILP (Fmember (tem, Vload_path)))
3264 {
3265 turn_off_warning = 1;
3266 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
3267 }
3268 }
3269 else
3270 /* That dir doesn't exist, so add the build-time
3271 Lisp dirs instead. */
3272 Vload_path = nconc2 (Vload_path, dump_path);
3273
3274 /* Add leim under the installation dir, if it exists. */
3275 tem = Fexpand_file_name (build_string ("leim"),
3276 Vinstallation_directory);
3277 tem1 = Ffile_exists_p (tem);
3278 if (!NILP (tem1))
3279 {
3280 if (NILP (Fmember (tem, Vload_path)))
3281 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
3282 }
3283
3284 /* Add site-list under the installation dir, if it exists. */
3285 tem = Fexpand_file_name (build_string ("site-lisp"),
3286 Vinstallation_directory);
3287 tem1 = Ffile_exists_p (tem);
3288 if (!NILP (tem1))
3289 {
3290 if (NILP (Fmember (tem, Vload_path)))
3291 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
3292 }
3293
3294 /* If Emacs was not built in the source directory,
3295 and it is run from where it was built, add to load-path
3296 the lisp, leim and site-lisp dirs under that directory. */
3297
3298 if (NILP (Fequal (Vinstallation_directory, Vsource_directory)))
3299 {
3300 Lisp_Object tem2;
3301
3302 tem = Fexpand_file_name (build_string ("src/Makefile"),
3303 Vinstallation_directory);
3304 tem1 = Ffile_exists_p (tem);
3305
3306 /* Don't be fooled if they moved the entire source tree
3307 AFTER dumping Emacs. If the build directory is indeed
3308 different from the source dir, src/Makefile.in and
3309 src/Makefile will not be found together. */
3310 tem = Fexpand_file_name (build_string ("src/Makefile.in"),
3311 Vinstallation_directory);
3312 tem2 = Ffile_exists_p (tem);
3313 if (!NILP (tem1) && NILP (tem2))
3314 {
3315 tem = Fexpand_file_name (build_string ("lisp"),
3316 Vsource_directory);
3317
3318 if (NILP (Fmember (tem, Vload_path)))
3319 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
3320
3321 tem = Fexpand_file_name (build_string ("leim"),
3322 Vsource_directory);
3323
3324 if (NILP (Fmember (tem, Vload_path)))
3325 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
3326
3327 tem = Fexpand_file_name (build_string ("site-lisp"),
3328 Vsource_directory);
3329
3330 if (NILP (Fmember (tem, Vload_path)))
3331 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
3332 }
3333 }
3334 }
3335 }
3336 }
3337 else
3338 {
3339 /* NORMAL refers to the lisp dir in the source directory. */
3340 /* We used to add ../lisp at the front here, but
3341 that caused trouble because it was copied from dump_path
3342 into Vload_path, aboe, when Vinstallation_directory was non-nil.
3343 It should be unnecessary. */
3344 Vload_path = decode_env_path (0, normal);
3345 dump_path = Vload_path;
3346 }
3347 #endif
3348
3349 #ifndef WINDOWSNT
3350 /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is
3351 almost never correct, thereby causing a warning to be printed out that
3352 confuses users. Since PATH_LOADSEARCH is always overridden by the
3353 EMACSLOADPATH environment variable below, disable the warning on NT. */
3354
3355 /* Warn if dirs in the *standard* path don't exist. */
3356 if (!turn_off_warning)
3357 {
3358 Lisp_Object path_tail;
3359
3360 for (path_tail = Vload_path;
3361 !NILP (path_tail);
3362 path_tail = XCDR (path_tail))
3363 {
3364 Lisp_Object dirfile;
3365 dirfile = Fcar (path_tail);
3366 if (STRINGP (dirfile))
3367 {
3368 dirfile = Fdirectory_file_name (dirfile);
3369 if (access (XSTRING (dirfile)->data, 0) < 0)
3370 dir_warning ("Warning: Lisp directory `%s' does not exist.\n",
3371 XCAR (path_tail));
3372 }
3373 }
3374 }
3375 #endif /* WINDOWSNT */
3376
3377 /* If the EMACSLOADPATH environment variable is set, use its value.
3378 This doesn't apply if we're dumping. */
3379 #ifndef CANNOT_DUMP
3380 if (NILP (Vpurify_flag)
3381 && egetenv ("EMACSLOADPATH"))
3382 #endif
3383 Vload_path = decode_env_path ("EMACSLOADPATH", normal);
3384
3385 Vvalues = Qnil;
3386
3387 load_in_progress = 0;
3388 Vload_file_name = Qnil;
3389
3390 load_descriptor_list = Qnil;
3391
3392 Vstandard_input = Qt;
3393 }
3394
3395 /* Print a warning, using format string FORMAT, that directory DIRNAME
3396 does not exist. Print it on stderr and put it in *Message*. */
3397
3398 void
3399 dir_warning (format, dirname)
3400 char *format;
3401 Lisp_Object dirname;
3402 {
3403 char *buffer
3404 = (char *) alloca (XSTRING (dirname)->size + strlen (format) + 5);
3405
3406 fprintf (stderr, format, XSTRING (dirname)->data);
3407 sprintf (buffer, format, XSTRING (dirname)->data);
3408 /* Don't log the warning before we've initialized!! */
3409 if (initialized)
3410 message_dolog (buffer, strlen (buffer), 0, STRING_MULTIBYTE (dirname));
3411 }
3412
3413 void
3414 syms_of_lread ()
3415 {
3416 defsubr (&Sread);
3417 defsubr (&Sread_from_string);
3418 defsubr (&Sintern);
3419 defsubr (&Sintern_soft);
3420 defsubr (&Sunintern);
3421 defsubr (&Sload);
3422 defsubr (&Seval_buffer);
3423 defsubr (&Seval_region);
3424 defsubr (&Sread_char);
3425 defsubr (&Sread_char_exclusive);
3426 defsubr (&Sread_event);
3427 defsubr (&Sget_file_char);
3428 defsubr (&Smapatoms);
3429
3430 DEFVAR_LISP ("obarray", &Vobarray,
3431 "Symbol table for use by `intern' and `read'.\n\
3432 It is a vector whose length ought to be prime for best results.\n\
3433 The vector's contents don't make sense if examined from Lisp programs;\n\
3434 to find all the symbols in an obarray, use `mapatoms'.");
3435
3436 DEFVAR_LISP ("values", &Vvalues,
3437 "List of values of all expressions which were read, evaluated and printed.\n\
3438 Order is reverse chronological.");
3439
3440 DEFVAR_LISP ("standard-input", &Vstandard_input,
3441 "Stream for read to get input from.\n\
3442 See documentation of `read' for possible values.");
3443 Vstandard_input = Qt;
3444
3445 DEFVAR_LISP ("load-path", &Vload_path,
3446 "*List of directories to search for files to load.\n\
3447 Each element is a string (directory name) or nil (try default directory).\n\
3448 Initialized based on EMACSLOADPATH environment variable, if any,\n\
3449 otherwise to default specified by file `epaths.h' when Emacs was built.");
3450
3451 DEFVAR_BOOL ("load-in-progress", &load_in_progress,
3452 "Non-nil iff inside of `load'.");
3453
3454 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist,
3455 "An alist of expressions to be evalled when particular files are loaded.\n\
3456 Each element looks like (FILENAME FORMS...).\n\
3457 When `load' is run and the file-name argument is FILENAME,\n\
3458 the FORMS in the corresponding element are executed at the end of loading.\n\n\
3459 FILENAME must match exactly! Normally FILENAME is the name of a library,\n\
3460 with no directory specified, since that is how `load' is normally called.\n\
3461 An error in FORMS does not undo the load,\n\
3462 but does prevent execution of the rest of the FORMS.");
3463 Vafter_load_alist = Qnil;
3464
3465 DEFVAR_LISP ("load-history", &Vload_history,
3466 "Alist mapping source file names to symbols and features.\n\
3467 Each alist element is a list that starts with a file name,\n\
3468 except for one element (optional) that starts with nil and describes\n\
3469 definitions evaluated from buffers not visiting files.\n\
3470 The remaining elements of each list are symbols defined as functions\n\
3471 or variables, and cons cells `(provide . FEATURE)', `(require . FEATURE)',\n\
3472 and `(autoload . SYMBOL)'.");
3473 Vload_history = Qnil;
3474
3475 DEFVAR_LISP ("load-file-name", &Vload_file_name,
3476 "Full name of file being loaded by `load'.");
3477 Vload_file_name = Qnil;
3478
3479 DEFVAR_LISP ("user-init-file", &Vuser_init_file,
3480 "File name, including directory, of user's initialization file.\n\
3481 If the file loaded had extension `.elc' and there was a corresponding `.el'\n\
3482 file, this variable contains the name of the .el file, suitable for use\n\
3483 by functions like `custom-save-all' which edit the init file.");
3484 Vuser_init_file = Qnil;
3485
3486 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list,
3487 "Used for internal purposes by `load'.");
3488 Vcurrent_load_list = Qnil;
3489
3490 DEFVAR_LISP ("load-read-function", &Vload_read_function,
3491 "Function used by `load' and `eval-region' for reading expressions.\n\
3492 The default is nil, which means use the function `read'.");
3493 Vload_read_function = Qnil;
3494
3495 DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function,
3496 "Function called in `load' for loading an Emacs lisp source file.\n\
3497 This function is for doing code conversion before reading the source file.\n\
3498 If nil, loading is done without any code conversion.\n\
3499 Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where\n\
3500 FULLNAME is the full name of FILE.\n\
3501 See `load' for the meaning of the remaining arguments.");
3502 Vload_source_file_function = Qnil;
3503
3504 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings,
3505 "Non-nil means `load' should force-load all dynamic doc strings.\n\
3506 This is useful when the file being loaded is a temporary copy.");
3507 load_force_doc_strings = 0;
3508
3509 DEFVAR_BOOL ("load-convert-to-unibyte", &load_convert_to_unibyte,
3510 "Non-nil means `read' converts strings to unibyte whenever possible.\n\
3511 This is normally bound by `load' and `eval-buffer' to control `read',\n\
3512 and is not meant for users to change.");
3513 load_convert_to_unibyte = 0;
3514
3515 DEFVAR_LISP ("source-directory", &Vsource_directory,
3516 "Directory in which Emacs sources were found when Emacs was built.\n\
3517 You cannot count on them to still be there!");
3518 Vsource_directory
3519 = Fexpand_file_name (build_string ("../"),
3520 Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH)));
3521
3522 DEFVAR_LISP ("preloaded-file-list", &Vpreloaded_file_list,
3523 "List of files that were preloaded (when dumping Emacs).");
3524 Vpreloaded_file_list = Qnil;
3525
3526 DEFVAR_LISP ("byte-boolean-vars", &Vbyte_boolean_vars,
3527 "List of all DEFVAR_BOOL variables, used by the byte code optimizer.");
3528 Vbyte_boolean_vars = Qnil;
3529
3530 DEFVAR_BOOL ("load-dangerous-libraries", &load_dangerous_libraries,
3531 "Non-nil means load dangerous compiled Lisp files.\n\
3532 Some versions of XEmacs use different byte codes than Emacs. These\n\
3533 incompatible byte codes can make Emacs crash when it tries to execute\n\
3534 them.");
3535 load_dangerous_libraries = 0;
3536
3537 Vbytecomp_version_regexp = build_string ("^;;;.in Emacs version");
3538 staticpro (&Vbytecomp_version_regexp);
3539
3540 /* Vsource_directory was initialized in init_lread. */
3541
3542 load_descriptor_list = Qnil;
3543 staticpro (&load_descriptor_list);
3544
3545 Qcurrent_load_list = intern ("current-load-list");
3546 staticpro (&Qcurrent_load_list);
3547
3548 Qstandard_input = intern ("standard-input");
3549 staticpro (&Qstandard_input);
3550
3551 Qread_char = intern ("read-char");
3552 staticpro (&Qread_char);
3553
3554 Qget_file_char = intern ("get-file-char");
3555 staticpro (&Qget_file_char);
3556
3557 Qbackquote = intern ("`");
3558 staticpro (&Qbackquote);
3559 Qcomma = intern (",");
3560 staticpro (&Qcomma);
3561 Qcomma_at = intern (",@");
3562 staticpro (&Qcomma_at);
3563 Qcomma_dot = intern (",.");
3564 staticpro (&Qcomma_dot);
3565
3566 Qinhibit_file_name_operation = intern ("inhibit-file-name-operation");
3567 staticpro (&Qinhibit_file_name_operation);
3568
3569 Qascii_character = intern ("ascii-character");
3570 staticpro (&Qascii_character);
3571
3572 Qfunction = intern ("function");
3573 staticpro (&Qfunction);
3574
3575 Qload = intern ("load");
3576 staticpro (&Qload);
3577
3578 Qload_file_name = intern ("load-file-name");
3579 staticpro (&Qload_file_name);
3580
3581 staticpro (&dump_path);
3582
3583 staticpro (&read_objects);
3584 read_objects = Qnil;
3585 staticpro (&seen_list);
3586
3587 }