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.
5 This file is part of GNU Emacs.
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)
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.
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. */
25 #include <sys/types.h>
30 #include "intervals.h"
36 #include "termhooks.h"
39 #include <sys/inode.h>
44 #include <unistd.h> /* to get X_OK */
61 #endif /* HAVE_SETLOCALE */
68 #define file_offset off_t
69 #define file_tell ftello
71 #define file_offset long
72 #define file_tell ftell
79 Lisp_Object Qread_char
, Qget_file_char
, Qstandard_input
, Qcurrent_load_list
;
80 Lisp_Object Qvariable_documentation
, Vvalues
, Vstandard_input
, Vafter_load_alist
;
81 Lisp_Object Qascii_character
, Qload
, Qload_file_name
;
82 Lisp_Object Qbackquote
, Qcomma
, Qcomma_at
, Qcomma_dot
, Qfunction
;
83 Lisp_Object Qinhibit_file_name_operation
;
85 extern Lisp_Object Qevent_symbol_element_mask
;
86 extern Lisp_Object Qfile_exists_p
;
88 /* non-zero if inside `load' */
91 /* Directory in which the sources were found. */
92 Lisp_Object Vsource_directory
;
94 /* Search path for files to be loaded. */
95 Lisp_Object Vload_path
;
97 /* File name of user's init file. */
98 Lisp_Object Vuser_init_file
;
100 /* This is the user-visible association list that maps features to
101 lists of defs in their load files. */
102 Lisp_Object Vload_history
;
104 /* This is used to build the load history. */
105 Lisp_Object Vcurrent_load_list
;
107 /* List of files that were preloaded. */
108 Lisp_Object Vpreloaded_file_list
;
110 /* Name of file actually being read by `load'. */
111 Lisp_Object Vload_file_name
;
113 /* Function to use for reading, in `load' and friends. */
114 Lisp_Object Vload_read_function
;
116 /* The association list of objects read with the #n=object form.
117 Each member of the list has the form (n . object), and is used to
118 look up the object for the corresponding #n# construct.
119 It must be set to nil before all top-level calls to read0. */
120 Lisp_Object read_objects
;
122 /* Nonzero means load should forcibly load all dynamic doc strings. */
123 static int load_force_doc_strings
;
125 /* Nonzero means read should convert strings to unibyte. */
126 static int load_convert_to_unibyte
;
128 /* Function to use for loading an Emacs lisp source file (not
129 compiled) instead of readevalloop. */
130 Lisp_Object Vload_source_file_function
;
132 /* List of all DEFVAR_BOOL variables. Used by the byte optimizer. */
133 Lisp_Object Vbyte_boolean_vars
;
135 /* List of descriptors now open for Fload. */
136 static Lisp_Object load_descriptor_list
;
138 /* File for get_file_char to read from. Use by load. */
139 static FILE *instream
;
141 /* When nonzero, read conses in pure space */
142 static int read_pure
;
144 /* For use within read-from-string (this reader is non-reentrant!!) */
145 static int read_from_string_index
;
146 static int read_from_string_index_byte
;
147 static int read_from_string_limit
;
149 /* Number of bytes left to read in the buffer character
150 that `readchar' has already advanced over. */
151 static int readchar_backlog
;
153 /* This contains the last string skipped with #@. */
154 static char *saved_doc_string
;
155 /* Length of buffer allocated in saved_doc_string. */
156 static int saved_doc_string_size
;
157 /* Length of actual data in saved_doc_string. */
158 static int saved_doc_string_length
;
159 /* This is the file position that string came from. */
160 static file_offset saved_doc_string_position
;
162 /* This contains the previous string skipped with #@.
163 We copy it from saved_doc_string when a new string
164 is put in saved_doc_string. */
165 static char *prev_saved_doc_string
;
166 /* Length of buffer allocated in prev_saved_doc_string. */
167 static int prev_saved_doc_string_size
;
168 /* Length of actual data in prev_saved_doc_string. */
169 static int prev_saved_doc_string_length
;
170 /* This is the file position that string came from. */
171 static file_offset prev_saved_doc_string_position
;
173 /* Nonzero means inside a new-style backquote
174 with no surrounding parentheses.
175 Fread initializes this to zero, so we need not specbind it
176 or worry about what happens to it when there is an error. */
177 static int new_backquote_flag
;
179 /* Handle unreading and rereading of characters.
180 Write READCHAR to read a character,
181 UNREAD(c) to unread c to be read again.
183 These macros actually read/unread a byte code, multibyte characters
184 are not handled here. The caller should manage them if necessary.
187 #define READCHAR readchar (readcharfun)
188 #define UNREAD(c) unreadchar (readcharfun, c)
191 readchar (readcharfun
)
192 Lisp_Object readcharfun
;
197 if (BUFFERP (readcharfun
))
199 register struct buffer
*inbuffer
= XBUFFER (readcharfun
);
201 int pt_byte
= BUF_PT_BYTE (inbuffer
);
202 int orig_pt_byte
= pt_byte
;
204 if (readchar_backlog
> 0)
205 /* We get the address of the byte just passed,
206 which is the last byte of the character.
207 The other bytes in this character are consecutive with it,
208 because the gap can't be in the middle of a character. */
209 return *(BUF_BYTE_ADDRESS (inbuffer
, BUF_PT_BYTE (inbuffer
) - 1)
210 - --readchar_backlog
);
212 if (pt_byte
>= BUF_ZV_BYTE (inbuffer
))
215 readchar_backlog
= -1;
217 if (! NILP (inbuffer
->enable_multibyte_characters
))
219 /* Fetch the character code from the buffer. */
220 unsigned char *p
= BUF_BYTE_ADDRESS (inbuffer
, pt_byte
);
221 BUF_INC_POS (inbuffer
, pt_byte
);
222 c
= STRING_CHAR (p
, pt_byte
- orig_pt_byte
);
226 c
= BUF_FETCH_BYTE (inbuffer
, pt_byte
);
229 SET_BUF_PT_BOTH (inbuffer
, BUF_PT (inbuffer
) + 1, pt_byte
);
233 if (MARKERP (readcharfun
))
235 register struct buffer
*inbuffer
= XMARKER (readcharfun
)->buffer
;
237 int bytepos
= marker_byte_position (readcharfun
);
238 int orig_bytepos
= bytepos
;
240 if (readchar_backlog
> 0)
241 /* We get the address of the byte just passed,
242 which is the last byte of the character.
243 The other bytes in this character are consecutive with it,
244 because the gap can't be in the middle of a character. */
245 return *(BUF_BYTE_ADDRESS (inbuffer
, XMARKER (readcharfun
)->bytepos
- 1)
246 - --readchar_backlog
);
248 if (bytepos
>= BUF_ZV_BYTE (inbuffer
))
251 readchar_backlog
= -1;
253 if (! NILP (inbuffer
->enable_multibyte_characters
))
255 /* Fetch the character code from the buffer. */
256 unsigned char *p
= BUF_BYTE_ADDRESS (inbuffer
, bytepos
);
257 BUF_INC_POS (inbuffer
, bytepos
);
258 c
= STRING_CHAR (p
, bytepos
- orig_bytepos
);
262 c
= BUF_FETCH_BYTE (inbuffer
, bytepos
);
266 XMARKER (readcharfun
)->bytepos
= bytepos
;
267 XMARKER (readcharfun
)->charpos
++;
272 if (EQ (readcharfun
, Qlambda
))
273 return read_bytecode_char (0);
275 if (EQ (readcharfun
, Qget_file_char
))
279 /* Interrupted reads have been observed while reading over the network */
280 while (c
== EOF
&& ferror (instream
) && errno
== EINTR
)
289 if (STRINGP (readcharfun
))
291 if (read_from_string_index
>= read_from_string_limit
)
294 FETCH_STRING_CHAR_ADVANCE (c
, readcharfun
,
295 read_from_string_index
,
296 read_from_string_index_byte
);
301 tem
= call0 (readcharfun
);
308 /* Unread the character C in the way appropriate for the stream READCHARFUN.
309 If the stream is a user function, call it with the char as argument. */
312 unreadchar (readcharfun
, c
)
313 Lisp_Object readcharfun
;
317 /* Don't back up the pointer if we're unreading the end-of-input mark,
318 since readchar didn't advance it when we read it. */
320 else if (BUFFERP (readcharfun
))
322 struct buffer
*b
= XBUFFER (readcharfun
);
323 int bytepos
= BUF_PT_BYTE (b
);
325 if (readchar_backlog
>= 0)
330 if (! NILP (b
->enable_multibyte_characters
))
331 BUF_DEC_POS (b
, bytepos
);
335 BUF_PT_BYTE (b
) = bytepos
;
338 else if (MARKERP (readcharfun
))
340 struct buffer
*b
= XMARKER (readcharfun
)->buffer
;
341 int bytepos
= XMARKER (readcharfun
)->bytepos
;
343 if (readchar_backlog
>= 0)
347 XMARKER (readcharfun
)->charpos
--;
348 if (! NILP (b
->enable_multibyte_characters
))
349 BUF_DEC_POS (b
, bytepos
);
353 XMARKER (readcharfun
)->bytepos
= bytepos
;
356 else if (STRINGP (readcharfun
))
358 read_from_string_index
--;
359 read_from_string_index_byte
360 = string_char_to_byte (readcharfun
, read_from_string_index
);
362 else if (EQ (readcharfun
, Qlambda
))
363 read_bytecode_char (1);
364 else if (EQ (readcharfun
, Qget_file_char
))
365 ungetc (c
, instream
);
367 call1 (readcharfun
, make_number (c
));
370 static Lisp_Object
read0 (), read1 (), read_list (), read_vector ();
371 static int read_multibyte ();
372 static Lisp_Object
substitute_object_recurse ();
373 static void substitute_object_in_subtree (), substitute_in_interval ();
376 /* Get a character from the tty. */
378 extern Lisp_Object
read_char ();
380 /* Read input events until we get one that's acceptable for our purposes.
382 If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed
383 until we get a character we like, and then stuffed into
386 If ASCII_REQUIRED is non-zero, we check function key events to see
387 if the unmodified version of the symbol has a Qascii_character
388 property, and use that character, if present.
390 If ERROR_NONASCII is non-zero, we signal an error if the input we
391 get isn't an ASCII character with modifiers. If it's zero but
392 ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII
395 If INPUT_METHOD is nonzero, we invoke the current input method
396 if the character warrants that. */
399 read_filtered_event (no_switch_frame
, ascii_required
, error_nonascii
,
401 int no_switch_frame
, ascii_required
, error_nonascii
, input_method
;
403 register Lisp_Object val
, delayed_switch_frame
;
405 #ifdef HAVE_WINDOW_SYSTEM
406 if (display_busy_cursor_p
)
407 cancel_busy_cursor ();
410 delayed_switch_frame
= Qnil
;
412 /* Read until we get an acceptable event. */
414 val
= read_char (0, 0, 0,
415 (input_method
? Qnil
: Qt
),
421 /* switch-frame events are put off until after the next ASCII
422 character. This is better than signaling an error just because
423 the last characters were typed to a separate minibuffer frame,
424 for example. Eventually, some code which can deal with
425 switch-frame events will read it and process it. */
427 && EVENT_HAS_PARAMETERS (val
)
428 && EQ (EVENT_HEAD (val
), Qswitch_frame
))
430 delayed_switch_frame
= val
;
436 /* Convert certain symbols to their ASCII equivalents. */
439 Lisp_Object tem
, tem1
;
440 tem
= Fget (val
, Qevent_symbol_element_mask
);
443 tem1
= Fget (Fcar (tem
), Qascii_character
);
444 /* Merge this symbol's modifier bits
445 with the ASCII equivalent of its basic code. */
447 XSETFASTINT (val
, XINT (tem1
) | XINT (Fcar (Fcdr (tem
))));
451 /* If we don't have a character now, deal with it appropriately. */
456 Vunread_command_events
= Fcons (val
, Qnil
);
457 error ("Non-character input-event");
464 if (! NILP (delayed_switch_frame
))
465 unread_switch_frame
= delayed_switch_frame
;
467 #ifdef HAVE_WINDOW_SYSTEM
468 if (display_busy_cursor_p
)
469 start_busy_cursor ();
474 DEFUN ("read-char", Fread_char
, Sread_char
, 0, 2, 0,
475 "Read a character from the command input (keyboard or macro).\n\
476 It is returned as a number.\n\
477 If the user generates an event which is not a character (i.e. a mouse\n\
478 click or function key event), `read-char' signals an error. As an\n\
479 exception, switch-frame events are put off until non-ASCII events can\n\
481 If you want to read non-character events, or ignore them, call\n\
482 `read-event' or `read-char-exclusive' instead.\n\
484 If the optional argument PROMPT is non-nil, display that as a prompt.\n\
485 If the optional argument INHERIT-INPUT-METHOD is non-nil and some\n\
486 input method is turned on in the current buffer, that input method\n\
487 is used for reading a character.")
488 (prompt
, inherit_input_method
)
489 Lisp_Object prompt
, inherit_input_method
;
492 message_with_string ("%s", prompt
, 0);
493 return read_filtered_event (1, 1, 1, ! NILP (inherit_input_method
));
496 DEFUN ("read-event", Fread_event
, Sread_event
, 0, 2, 0,
497 "Read an event object from the input stream.\n\
498 If the optional argument PROMPT is non-nil, display that as a prompt.\n\
499 If the optional argument INHERIT-INPUT-METHOD is non-nil and some\n\
500 input method is turned on in the current buffer, that input method\n\
501 is used for reading a character.")
502 (prompt
, inherit_input_method
)
503 Lisp_Object prompt
, inherit_input_method
;
506 message_with_string ("%s", prompt
, 0);
507 return read_filtered_event (0, 0, 0, ! NILP (inherit_input_method
));
510 DEFUN ("read-char-exclusive", Fread_char_exclusive
, Sread_char_exclusive
, 0, 2, 0,
511 "Read a character from the command input (keyboard or macro).\n\
512 It is returned as a number. Non-character events are ignored.\n\
514 If the optional argument PROMPT is non-nil, display that as a prompt.\n\
515 If the optional argument INHERIT-INPUT-METHOD is non-nil and some\n\
516 input method is turned on in the current buffer, that input method\n\
517 is used for reading a character.")
518 (prompt
, inherit_input_method
)
519 Lisp_Object prompt
, inherit_input_method
;
522 message_with_string ("%s", prompt
, 0);
523 return read_filtered_event (1, 1, 0, ! NILP (inherit_input_method
));
526 DEFUN ("get-file-char", Fget_file_char
, Sget_file_char
, 0, 0, 0,
527 "Don't use this yourself.")
530 register Lisp_Object val
;
531 XSETINT (val
, getc (instream
));
535 static void readevalloop
P_ ((Lisp_Object
, FILE*, Lisp_Object
,
536 Lisp_Object (*) (), int,
537 Lisp_Object
, Lisp_Object
));
538 static Lisp_Object load_unwind
P_ ((Lisp_Object
));
539 static Lisp_Object load_descriptor_unwind
P_ ((Lisp_Object
));
541 /* Non-zero means load dangerous compiled Lisp files. */
543 int load_dangerous_libraries
;
545 /* A regular expression used to detect files compiled with Emacs. */
547 static Lisp_Object Vbytecomp_version_regexp
;
550 /* Value is non-zero if the file asswociated with file descriptor FD
551 is a compiled Lisp file that's safe to load. Only files compiled
552 with Emacs are safe to load. Files compiled with XEmacs can lead
553 to a crash in Fbyte_code because of an incompatible change in the
564 /* Read the first few bytes from the file, and look for a line
565 specifying the byte compiler version used. */
566 nbytes
= emacs_read (fd
, buf
, sizeof buf
- 1);
571 /* Skip to the next newline, skipping over the initial `ELC'
572 with NUL bytes following it. */
573 for (i
= 0; i
< nbytes
&& buf
[i
] != '\n'; ++i
)
577 && fast_c_string_match_ignore_case (Vbytecomp_version_regexp
,
582 lseek (fd
, 0, SEEK_SET
);
587 DEFUN ("load", Fload
, Sload
, 1, 5, 0,
588 "Execute a file of Lisp code named FILE.\n\
589 First try FILE with `.elc' appended, then try with `.el',\n\
590 then try FILE unmodified.\n\
591 This function searches the directories in `load-path'.\n\
592 If optional second arg NOERROR is non-nil,\n\
593 report no error if FILE doesn't exist.\n\
594 Print messages at start and end of loading unless\n\
595 optional third arg NOMESSAGE is non-nil.\n\
596 If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
597 suffixes `.elc' or `.el' to the specified name FILE.\n\
598 If optional fifth arg MUST-SUFFIX is non-nil, insist on\n\
599 the suffix `.elc' or `.el'; don't accept just FILE unless\n\
600 it ends in one of those suffixes or includes a directory name.\n\
601 Return t if file exists.")
602 (file
, noerror
, nomessage
, nosuffix
, must_suffix
)
603 Lisp_Object file
, noerror
, nomessage
, nosuffix
, must_suffix
;
605 register FILE *stream
;
606 register int fd
= -1;
607 register Lisp_Object lispstream
;
608 int count
= specpdl_ptr
- specpdl
;
612 /* 1 means we printed the ".el is newer" message. */
614 /* 1 means we are loading a compiled file. */
623 CHECK_STRING (file
, 0);
625 /* If file name is magic, call the handler. */
626 handler
= Ffind_file_name_handler (file
, Qload
);
628 return call5 (handler
, Qload
, file
, noerror
, nomessage
, nosuffix
);
630 /* Do this after the handler to avoid
631 the need to gcpro noerror, nomessage and nosuffix.
632 (Below here, we care only whether they are nil or not.) */
633 file
= Fsubstitute_in_file_name (file
);
635 /* Avoid weird lossage with null string as arg,
636 since it would try to load a directory as a Lisp file */
637 if (XSTRING (file
)->size
> 0)
639 int size
= STRING_BYTES (XSTRING (file
));
643 if (! NILP (must_suffix
))
645 /* Don't insist on adding a suffix if FILE already ends with one. */
647 && !strcmp (XSTRING (file
)->data
+ size
- 3, ".el"))
650 && !strcmp (XSTRING (file
)->data
+ size
- 4, ".elc"))
652 /* Don't insist on adding a suffix
653 if the argument includes a directory name. */
654 else if (! NILP (Ffile_name_directory (file
)))
658 fd
= openp (Vload_path
, file
,
659 (!NILP (nosuffix
) ? ""
660 : ! NILP (must_suffix
) ? ".elc.gz:.elc:.el.gz:.el"
661 : ".elc:.elc.gz:.el.gz:.el:"),
670 Fsignal (Qfile_error
, Fcons (build_string ("Cannot open load file"),
671 Fcons (file
, Qnil
)));
676 /* Tell startup.el whether or not we found the user's init file. */
677 if (EQ (Qt
, Vuser_init_file
))
678 Vuser_init_file
= found
;
680 /* If FD is 0, that means openp found a magic file. */
683 if (NILP (Fequal (found
, file
)))
684 /* If FOUND is a different file name from FILE,
685 find its handler even if we have already inhibited
686 the `load' operation on FILE. */
687 handler
= Ffind_file_name_handler (found
, Qt
);
689 handler
= Ffind_file_name_handler (found
, Qload
);
690 if (! NILP (handler
))
691 return call5 (handler
, Qload
, found
, noerror
, nomessage
, Qt
);
694 /* Load .elc files directly, but not when they are
695 remote and have no handler! */
696 if (!bcmp (&(XSTRING (found
)->data
[STRING_BYTES (XSTRING (found
)) - 4]),
703 if (!safe_to_load_p (fd
))
706 if (!load_dangerous_libraries
)
707 error ("File `%s' was not compiled in Emacs",
708 XSTRING (found
)->data
);
709 else if (!NILP (nomessage
))
710 message_with_string ("File `%s' not compiled in Emacs", found
, 1);
718 stat ((char *)XSTRING (found
)->data
, &s1
);
719 XSTRING (found
)->data
[STRING_BYTES (XSTRING (found
)) - 1] = 0;
720 result
= stat ((char *)XSTRING (found
)->data
, &s2
);
721 if (result
>= 0 && (unsigned) s1
.st_mtime
< (unsigned) s2
.st_mtime
)
723 /* Make the progress messages mention that source is newer. */
726 /* If we won't print another message, mention this anyway. */
727 if (! NILP (nomessage
))
728 message_with_string ("Source file `%s' newer than byte-compiled file",
731 XSTRING (found
)->data
[STRING_BYTES (XSTRING (found
)) - 1] = 'c';
737 /* We are loading a source file (*.el). */
738 if (!NILP (Vload_source_file_function
))
742 return call4 (Vload_source_file_function
, found
, file
,
743 NILP (noerror
) ? Qnil
: Qt
,
744 NILP (nomessage
) ? Qnil
: Qt
);
750 stream
= fopen ((char *) XSTRING (found
)->data
, fmode
);
751 #else /* not WINDOWSNT */
752 stream
= fdopen (fd
, fmode
);
753 #endif /* not WINDOWSNT */
757 error ("Failure to create stdio stream for %s", XSTRING (file
)->data
);
760 if (! NILP (Vpurify_flag
))
761 Vpreloaded_file_list
= Fcons (file
, Vpreloaded_file_list
);
763 if (NILP (nomessage
))
766 message_with_string ("Loading %s (compiled; note unsafe, not compiled in Emacs)...",
769 message_with_string ("Loading %s (source)...", file
, 1);
771 message_with_string ("Loading %s (compiled; note, source file is newer)...",
773 else /* The typical case; compiled file newer than source file. */
774 message_with_string ("Loading %s...", file
, 1);
778 lispstream
= Fcons (Qnil
, Qnil
);
779 XSETFASTINT (XCAR (lispstream
), (EMACS_UINT
)stream
>> 16);
780 XSETFASTINT (XCDR (lispstream
), (EMACS_UINT
)stream
& 0xffff);
781 record_unwind_protect (load_unwind
, lispstream
);
782 record_unwind_protect (load_descriptor_unwind
, load_descriptor_list
);
783 specbind (Qload_file_name
, found
);
784 specbind (Qinhibit_file_name_operation
, Qnil
);
786 = Fcons (make_number (fileno (stream
)), load_descriptor_list
);
788 readevalloop (Qget_file_char
, stream
, file
, Feval
, 0, Qnil
, Qnil
);
789 unbind_to (count
, Qnil
);
791 /* Run any load-hooks for this file. */
792 temp
= Fassoc (file
, Vafter_load_alist
);
794 Fprogn (Fcdr (temp
));
797 if (saved_doc_string
)
798 free (saved_doc_string
);
799 saved_doc_string
= 0;
800 saved_doc_string_size
= 0;
802 if (prev_saved_doc_string
)
803 xfree (prev_saved_doc_string
);
804 prev_saved_doc_string
= 0;
805 prev_saved_doc_string_size
= 0;
807 if (!noninteractive
&& NILP (nomessage
))
810 message_with_string ("Loading %s (compiled; note unsafe, not compiled in Emacs)...done",
813 message_with_string ("Loading %s (source)...done", file
, 1);
815 message_with_string ("Loading %s (compiled; note, source file is newer)...done",
817 else /* The typical case; compiled file newer than source file. */
818 message_with_string ("Loading %s...done", file
, 1);
824 load_unwind (stream
) /* used as unwind-protect function in load */
827 fclose ((FILE *) (XFASTINT (XCAR (stream
)) << 16
828 | XFASTINT (XCDR (stream
))));
829 if (--load_in_progress
< 0) load_in_progress
= 0;
834 load_descriptor_unwind (oldlist
)
837 load_descriptor_list
= oldlist
;
841 /* Close all descriptors in use for Floads.
842 This is used when starting a subprocess. */
849 for (tail
= load_descriptor_list
; !NILP (tail
); tail
= XCDR (tail
))
850 emacs_close (XFASTINT (XCAR (tail
)));
855 complete_filename_p (pathname
)
856 Lisp_Object pathname
;
858 register unsigned char *s
= XSTRING (pathname
)->data
;
859 return (IS_DIRECTORY_SEP (s
[0])
860 || (XSTRING (pathname
)->size
> 2
861 && IS_DEVICE_SEP (s
[1]) && IS_DIRECTORY_SEP (s
[2]))
871 /* Search for a file whose name is STR, looking in directories
872 in the Lisp list PATH, and trying suffixes from SUFFIX.
873 SUFFIX is a string containing possible suffixes separated by colons.
874 On success, returns a file descriptor. On failure, returns -1.
876 EXEC_ONLY nonzero means don't open the files,
877 just look for one that is executable. In this case,
878 returns 1 on success.
880 If STOREPTR is nonzero, it points to a slot where the name of
881 the file actually found should be stored as a Lisp string.
882 nil is stored there on failure.
884 If the file we find is remote, return 0
885 but store the found remote file name in *STOREPTR.
886 We do not check for remote files if EXEC_ONLY is nonzero. */
889 openp (path
, str
, suffix
, storeptr
, exec_only
)
890 Lisp_Object path
, str
;
892 Lisp_Object
*storeptr
;
898 register char *fn
= buf
;
901 Lisp_Object filename
;
909 if (complete_filename_p (str
))
912 for (; !NILP (path
); path
= Fcdr (path
))
916 filename
= Fexpand_file_name (str
, Fcar (path
));
917 if (!complete_filename_p (filename
))
918 /* If there are non-absolute elts in PATH (eg ".") */
919 /* Of course, this could conceivably lose if luser sets
920 default-directory to be something non-absolute... */
922 filename
= Fexpand_file_name (filename
, current_buffer
->directory
);
923 if (!complete_filename_p (filename
))
924 /* Give up on this path element! */
928 /* Calculate maximum size of any filename made from
929 this path element/specified file name and any possible suffix. */
930 want_size
= strlen (suffix
) + STRING_BYTES (XSTRING (filename
)) + 1;
931 if (fn_size
< want_size
)
932 fn
= (char *) alloca (fn_size
= 100 + want_size
);
936 /* Loop over suffixes. */
939 char *esuffix
= (char *) index (nsuffix
, ':');
940 int lsuffix
= esuffix
? esuffix
- nsuffix
: strlen (nsuffix
);
943 /* Concatenate path element/specified name with the suffix.
944 If the directory starts with /:, remove that. */
945 if (XSTRING (filename
)->size
> 2
946 && XSTRING (filename
)->data
[0] == '/'
947 && XSTRING (filename
)->data
[1] == ':')
949 strncpy (fn
, XSTRING (filename
)->data
+ 2,
950 STRING_BYTES (XSTRING (filename
)) - 2);
951 fn
[STRING_BYTES (XSTRING (filename
)) - 2] = 0;
955 strncpy (fn
, XSTRING (filename
)->data
,
956 STRING_BYTES (XSTRING (filename
)));
957 fn
[STRING_BYTES (XSTRING (filename
))] = 0;
960 if (lsuffix
!= 0) /* Bug happens on CCI if lsuffix is 0. */
961 strncat (fn
, nsuffix
, lsuffix
);
963 /* Check that the file exists and is not a directory. */
967 handler
= Ffind_file_name_handler (filename
, Qfile_exists_p
);
968 if (! NILP (handler
) && ! exec_only
)
973 string
= build_string (fn
);
974 exists
= ! NILP (exec_only
? Ffile_executable_p (string
)
975 : Ffile_readable_p (string
));
977 && ! NILP (Ffile_directory_p (build_string (fn
))))
982 /* We succeeded; return this descriptor and filename. */
984 *storeptr
= build_string (fn
);
991 int exists
= (stat (fn
, &st
) >= 0
992 && (st
.st_mode
& S_IFMT
) != S_IFDIR
);
995 /* Check that we can access or open it. */
997 fd
= (access (fn
, X_OK
) == 0) ? 1 : -1;
999 fd
= emacs_open (fn
, O_RDONLY
, 0);
1003 /* We succeeded; return this descriptor and filename. */
1005 *storeptr
= build_string (fn
);
1012 /* Advance to next suffix. */
1015 nsuffix
+= lsuffix
+ 1;
1026 /* Merge the list we've accumulated of globals from the current input source
1027 into the load_history variable. The details depend on whether
1028 the source has an associated file name or not. */
1031 build_load_history (stream
, source
)
1035 register Lisp_Object tail
, prev
, newelt
;
1036 register Lisp_Object tem
, tem2
;
1037 register int foundit
, loading
;
1039 loading
= stream
|| !NARROWED
;
1041 tail
= Vload_history
;
1044 while (!NILP (tail
))
1048 /* Find the feature's previous assoc list... */
1049 if (!NILP (Fequal (source
, Fcar (tem
))))
1053 /* If we're loading, remove it. */
1057 Vload_history
= Fcdr (tail
);
1059 Fsetcdr (prev
, Fcdr (tail
));
1062 /* Otherwise, cons on new symbols that are not already members. */
1065 tem2
= Vcurrent_load_list
;
1067 while (CONSP (tem2
))
1069 newelt
= Fcar (tem2
);
1071 if (NILP (Fmemq (newelt
, tem
)))
1072 Fsetcar (tail
, Fcons (Fcar (tem
),
1073 Fcons (newelt
, Fcdr (tem
))));
1086 /* If we're loading, cons the new assoc onto the front of load-history,
1087 the most-recently-loaded position. Also do this if we didn't find
1088 an existing member for the current source. */
1089 if (loading
|| !foundit
)
1090 Vload_history
= Fcons (Fnreverse (Vcurrent_load_list
),
1095 unreadpure (junk
) /* Used as unwind-protect function in readevalloop */
1103 readevalloop_1 (old
)
1106 load_convert_to_unibyte
= ! NILP (old
);
1110 /* Signal an `end-of-file' error, if possible with file name
1114 end_of_file_error ()
1118 if (STRINGP (Vload_file_name
))
1119 data
= Fcons (Vload_file_name
, Qnil
);
1123 Fsignal (Qend_of_file
, data
);
1126 /* UNIBYTE specifies how to set load_convert_to_unibyte
1127 for this invocation.
1128 READFUN, if non-nil, is used instead of `read'. */
1131 readevalloop (readcharfun
, stream
, sourcename
, evalfun
, printflag
, unibyte
, readfun
)
1132 Lisp_Object readcharfun
;
1134 Lisp_Object sourcename
;
1135 Lisp_Object (*evalfun
) ();
1137 Lisp_Object unibyte
, readfun
;
1140 register Lisp_Object val
;
1141 int count
= specpdl_ptr
- specpdl
;
1142 struct gcpro gcpro1
;
1143 struct buffer
*b
= 0;
1144 int continue_reading_p
;
1146 if (BUFFERP (readcharfun
))
1147 b
= XBUFFER (readcharfun
);
1148 else if (MARKERP (readcharfun
))
1149 b
= XMARKER (readcharfun
)->buffer
;
1151 specbind (Qstandard_input
, readcharfun
);
1152 specbind (Qcurrent_load_list
, Qnil
);
1153 record_unwind_protect (readevalloop_1
, load_convert_to_unibyte
? Qt
: Qnil
);
1154 load_convert_to_unibyte
= !NILP (unibyte
);
1156 readchar_backlog
= -1;
1158 GCPRO1 (sourcename
);
1160 LOADHIST_ATTACH (sourcename
);
1162 continue_reading_p
= 1;
1163 while (continue_reading_p
)
1165 if (b
!= 0 && NILP (b
->name
))
1166 error ("Reading from killed buffer");
1172 while ((c
= READCHAR
) != '\n' && c
!= -1);
1177 /* Ignore whitespace here, so we can detect eof. */
1178 if (c
== ' ' || c
== '\t' || c
== '\n' || c
== '\f' || c
== '\r')
1181 if (!NILP (Vpurify_flag
) && c
== '(')
1183 int count1
= specpdl_ptr
- specpdl
;
1184 record_unwind_protect (unreadpure
, Qnil
);
1185 val
= read_list (-1, readcharfun
);
1186 unbind_to (count1
, Qnil
);
1191 read_objects
= Qnil
;
1192 if (!NILP (readfun
))
1194 val
= call1 (readfun
, readcharfun
);
1196 /* If READCHARFUN has set point to ZV, we should
1197 stop reading, even if the form read sets point
1198 to a different value when evaluated. */
1199 if (BUFFERP (readcharfun
))
1201 struct buffer
*b
= XBUFFER (readcharfun
);
1202 if (BUF_PT (b
) == BUF_ZV (b
))
1203 continue_reading_p
= 0;
1206 else if (! NILP (Vload_read_function
))
1207 val
= call1 (Vload_read_function
, readcharfun
);
1209 val
= read0 (readcharfun
);
1212 val
= (*evalfun
) (val
);
1216 Vvalues
= Fcons (val
, Vvalues
);
1217 if (EQ (Vstandard_output
, Qt
))
1224 build_load_history (stream
, sourcename
);
1227 unbind_to (count
, Qnil
);
1230 DEFUN ("eval-buffer", Feval_buffer
, Seval_buffer
, 0, 5, "",
1231 "Execute the current buffer as Lisp code.\n\
1232 Programs can pass two arguments, BUFFER and PRINTFLAG.\n\
1233 BUFFER is the buffer to evaluate (nil means use current buffer).\n\
1234 PRINTFLAG controls printing of output:\n\
1235 nil means discard it; anything else is stream for print.\n\
1237 If the optional third argument FILENAME is non-nil,\n\
1238 it specifies the file name to use for `load-history'.\n\
1239 The optional fourth argument UNIBYTE specifies `load-convert-to-unibyte'\n\
1240 for this invocation.\n\
1242 The optional fifth argument DO-ALLOW-PRINT, if not-nil, specifies that\n\
1243 `print' and related functions should work normally even if PRINTFLAG is nil.\n\
1245 This function preserves the position of point.")
1246 (buffer
, printflag
, filename
, unibyte
, do_allow_print
)
1247 Lisp_Object buffer
, printflag
, filename
, unibyte
, do_allow_print
;
1249 int count
= specpdl_ptr
- specpdl
;
1250 Lisp_Object tem
, buf
;
1253 buf
= Fcurrent_buffer ();
1255 buf
= Fget_buffer (buffer
);
1257 error ("No such buffer");
1259 if (NILP (printflag
) && NILP (do_allow_print
))
1264 if (NILP (filename
))
1265 filename
= XBUFFER (buf
)->filename
;
1267 specbind (Qstandard_output
, tem
);
1268 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1269 BUF_SET_PT (XBUFFER (buf
), BUF_BEGV (XBUFFER (buf
)));
1270 readevalloop (buf
, 0, filename
, Feval
, !NILP (printflag
), unibyte
, Qnil
);
1271 unbind_to (count
, Qnil
);
1277 XDEFUN ("eval-current-buffer", Feval_current_buffer
, Seval_current_buffer
, 0, 1, "",
1278 "Execute the current buffer as Lisp code.\n\
1279 Programs can pass argument PRINTFLAG which controls printing of output:\n\
1280 nil means discard it; anything else is stream for print.\n\
1282 If there is no error, point does not move. If there is an error,\n\
1283 point remains at the end of the last character read from the buffer.")
1285 Lisp_Object printflag
;
1287 int count
= specpdl_ptr
- specpdl
;
1288 Lisp_Object tem
, cbuf
;
1290 cbuf
= Fcurrent_buffer ()
1292 if (NILP (printflag
))
1296 specbind (Qstandard_output
, tem
);
1297 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1299 readevalloop (cbuf
, 0, XBUFFER (cbuf
)->filename
, Feval
,
1300 !NILP (printflag
), Qnil
, Qnil
);
1301 return unbind_to (count
, Qnil
);
1305 DEFUN ("eval-region", Feval_region
, Seval_region
, 2, 4, "r",
1306 "Execute the region as Lisp code.\n\
1307 When called from programs, expects two arguments,\n\
1308 giving starting and ending indices in the current buffer\n\
1309 of the text to be executed.\n\
1310 Programs can pass third argument PRINTFLAG which controls output:\n\
1311 nil means discard it; anything else is stream for printing it.\n\
1312 Also the fourth argument READ-FUNCTION, if non-nil, is used\n\
1313 instead of `read' to read each expression. It gets one argument\n\
1314 which is the input stream for reading characters.\n\
1316 This function does not move point.")
1317 (start
, end
, printflag
, read_function
)
1318 Lisp_Object start
, end
, printflag
, read_function
;
1320 int count
= specpdl_ptr
- specpdl
;
1321 Lisp_Object tem
, cbuf
;
1323 cbuf
= Fcurrent_buffer ();
1325 if (NILP (printflag
))
1329 specbind (Qstandard_output
, tem
);
1331 if (NILP (printflag
))
1332 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1333 record_unwind_protect (save_restriction_restore
, save_restriction_save ());
1335 /* This both uses start and checks its type. */
1337 Fnarrow_to_region (make_number (BEGV
), end
);
1338 readevalloop (cbuf
, 0, XBUFFER (cbuf
)->filename
, Feval
,
1339 !NILP (printflag
), Qnil
, read_function
);
1341 return unbind_to (count
, Qnil
);
1345 DEFUN ("read", Fread
, Sread
, 0, 1, 0,
1346 "Read one Lisp expression as text from STREAM, return as Lisp object.\n\
1347 If STREAM is nil, use the value of `standard-input' (which see).\n\
1348 STREAM or the value of `standard-input' may be:\n\
1349 a buffer (read from point and advance it)\n\
1350 a marker (read from where it points and advance it)\n\
1351 a function (call it with no arguments for each character,\n\
1352 call it with a char as argument to push a char back)\n\
1353 a string (takes text from string, starting at the beginning)\n\
1354 t (read text line using minibuffer and use it, or read from\n\
1355 standard input in batch mode).")
1359 extern Lisp_Object
Fread_minibuffer ();
1362 stream
= Vstandard_input
;
1363 if (EQ (stream
, Qt
))
1364 stream
= Qread_char
;
1366 readchar_backlog
= -1;
1367 new_backquote_flag
= 0;
1368 read_objects
= Qnil
;
1370 if (EQ (stream
, Qread_char
))
1371 return Fread_minibuffer (build_string ("Lisp expression: "), Qnil
);
1373 if (STRINGP (stream
))
1374 return Fcar (Fread_from_string (stream
, Qnil
, Qnil
));
1376 return read0 (stream
);
1379 DEFUN ("read-from-string", Fread_from_string
, Sread_from_string
, 1, 3, 0,
1380 "Read one Lisp expression which is represented as text by STRING.\n\
1381 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\
1382 START and END optionally delimit a substring of STRING from which to read;\n\
1383 they default to 0 and (length STRING) respectively.")
1384 (string
, start
, end
)
1385 Lisp_Object string
, start
, end
;
1387 int startval
, endval
;
1390 CHECK_STRING (string
,0);
1393 endval
= XSTRING (string
)->size
;
1396 CHECK_NUMBER (end
, 2);
1397 endval
= XINT (end
);
1398 if (endval
< 0 || endval
> XSTRING (string
)->size
)
1399 args_out_of_range (string
, end
);
1406 CHECK_NUMBER (start
, 1);
1407 startval
= XINT (start
);
1408 if (startval
< 0 || startval
> endval
)
1409 args_out_of_range (string
, start
);
1412 read_from_string_index
= startval
;
1413 read_from_string_index_byte
= string_char_to_byte (string
, startval
);
1414 read_from_string_limit
= endval
;
1416 new_backquote_flag
= 0;
1417 read_objects
= Qnil
;
1419 tem
= read0 (string
);
1420 return Fcons (tem
, make_number (read_from_string_index
));
1423 /* Use this for recursive reads, in contexts where internal tokens
1428 Lisp_Object readcharfun
;
1430 register Lisp_Object val
;
1433 val
= read1 (readcharfun
, &c
, 0);
1435 Fsignal (Qinvalid_read_syntax
, Fcons (Fmake_string (make_number (1),
1442 static int read_buffer_size
;
1443 static char *read_buffer
;
1445 /* Read multibyte form and return it as a character. C is a first
1446 byte of multibyte form, and rest of them are read from
1450 read_multibyte (c
, readcharfun
)
1452 Lisp_Object readcharfun
;
1454 /* We need the actual character code of this multibyte
1456 unsigned char str
[MAX_MULTIBYTE_LENGTH
];
1460 while ((c
= READCHAR
) >= 0xA0
1461 && len
< MAX_MULTIBYTE_LENGTH
)
1464 return STRING_CHAR (str
, len
);
1467 /* Read a \-escape sequence, assuming we already read the `\'. */
1470 read_escape (readcharfun
, stringp
)
1471 Lisp_Object readcharfun
;
1474 register int c
= READCHAR
;
1478 error ("End of file");
1508 error ("Invalid escape character syntax");
1511 c
= read_escape (readcharfun
, 0);
1512 return c
| meta_modifier
;
1517 error ("Invalid escape character syntax");
1520 c
= read_escape (readcharfun
, 0);
1521 return c
| shift_modifier
;
1526 error ("Invalid escape character syntax");
1529 c
= read_escape (readcharfun
, 0);
1530 return c
| hyper_modifier
;
1535 error ("Invalid escape character syntax");
1538 c
= read_escape (readcharfun
, 0);
1539 return c
| alt_modifier
;
1544 error ("Invalid escape character syntax");
1547 c
= read_escape (readcharfun
, 0);
1548 return c
| super_modifier
;
1553 error ("Invalid escape character syntax");
1557 c
= read_escape (readcharfun
, 0);
1558 if ((c
& ~CHAR_MODIFIER_MASK
) == '?')
1559 return 0177 | (c
& CHAR_MODIFIER_MASK
);
1560 else if (! SINGLE_BYTE_CHAR_P ((c
& ~CHAR_MODIFIER_MASK
)))
1561 return c
| ctrl_modifier
;
1562 /* ASCII control chars are made from letters (both cases),
1563 as well as the non-letters within 0100...0137. */
1564 else if ((c
& 0137) >= 0101 && (c
& 0137) <= 0132)
1565 return (c
& (037 | ~0177));
1566 else if ((c
& 0177) >= 0100 && (c
& 0177) <= 0137)
1567 return (c
& (037 | ~0177));
1569 return c
| ctrl_modifier
;
1579 /* An octal escape, as in ANSI C. */
1581 register int i
= c
- '0';
1582 register int count
= 0;
1585 if ((c
= READCHAR
) >= '0' && c
<= '7')
1600 /* A hex escape, as in ANSI C. */
1606 if (c
>= '0' && c
<= '9')
1611 else if ((c
>= 'a' && c
<= 'f')
1612 || (c
>= 'A' && c
<= 'F'))
1615 if (c
>= 'a' && c
<= 'f')
1630 if (BASE_LEADING_CODE_P (c
))
1631 c
= read_multibyte (c
, readcharfun
);
1637 /* Read an integer in radix RADIX using READCHARFUN to read
1638 characters. RADIX must be in the interval [2..36]; if it isn't, a
1639 read error is signaled . Value is the integer read. Signals an
1640 error if encountering invalid read syntax or if RADIX is out of
1644 read_integer (readcharfun
, radix
)
1645 Lisp_Object readcharfun
;
1648 int number
, ndigits
, invalid_p
, c
, sign
;
1650 if (radix
< 2 || radix
> 36)
1654 number
= ndigits
= invalid_p
= 0;
1670 if (c
>= '0' && c
<= '9')
1672 else if (c
>= 'a' && c
<= 'z')
1673 digit
= c
- 'a' + 10;
1674 else if (c
>= 'A' && c
<= 'Z')
1675 digit
= c
- 'A' + 10;
1682 if (digit
< 0 || digit
>= radix
)
1685 number
= radix
* number
+ digit
;
1691 if (ndigits
== 0 || invalid_p
)
1694 sprintf (buf
, "integer, radix %d", radix
);
1695 Fsignal (Qinvalid_read_syntax
, Fcons (build_string (buf
), Qnil
));
1698 return make_number (sign
* number
);
1702 /* If the next token is ')' or ']' or '.', we store that character
1703 in *PCH and the return value is not interesting. Else, we store
1704 zero in *PCH and we read and return one lisp object.
1706 FIRST_IN_LIST is nonzero if this is the first element of a list. */
1709 read1 (readcharfun
, pch
, first_in_list
)
1710 register Lisp_Object readcharfun
;
1715 int uninterned_symbol
= 0;
1723 end_of_file_error ();
1728 return read_list (0, readcharfun
);
1731 return read_vector (readcharfun
, 0);
1748 tmp
= read_vector (readcharfun
, 0);
1749 if (XVECTOR (tmp
)->size
< CHAR_TABLE_STANDARD_SLOTS
1750 || XVECTOR (tmp
)->size
> CHAR_TABLE_STANDARD_SLOTS
+ 10)
1751 error ("Invalid size char-table");
1752 XSETCHAR_TABLE (tmp
, XCHAR_TABLE (tmp
));
1753 XCHAR_TABLE (tmp
)->top
= Qt
;
1762 tmp
= read_vector (readcharfun
, 0);
1763 if (XVECTOR (tmp
)->size
!= SUB_CHAR_TABLE_STANDARD_SLOTS
)
1764 error ("Invalid size char-table");
1765 XSETCHAR_TABLE (tmp
, XCHAR_TABLE (tmp
));
1766 XCHAR_TABLE (tmp
)->top
= Qnil
;
1769 Fsignal (Qinvalid_read_syntax
,
1770 Fcons (make_string ("#^^", 3), Qnil
));
1772 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#^", 2), Qnil
));
1777 length
= read1 (readcharfun
, pch
, first_in_list
);
1781 Lisp_Object tmp
, val
;
1782 int size_in_chars
= ((XFASTINT (length
) + BITS_PER_CHAR
- 1)
1786 tmp
= read1 (readcharfun
, pch
, first_in_list
);
1787 if (size_in_chars
!= XSTRING (tmp
)->size
1788 /* We used to print 1 char too many
1789 when the number of bits was a multiple of 8.
1790 Accept such input in case it came from an old version. */
1791 && ! (XFASTINT (length
)
1792 == (XSTRING (tmp
)->size
- 1) * BITS_PER_CHAR
))
1793 Fsignal (Qinvalid_read_syntax
,
1794 Fcons (make_string ("#&...", 5), Qnil
));
1796 val
= Fmake_bool_vector (length
, Qnil
);
1797 bcopy (XSTRING (tmp
)->data
, XBOOL_VECTOR (val
)->data
,
1799 /* Clear the extraneous bits in the last byte. */
1800 if (XINT (length
) != size_in_chars
* BITS_PER_CHAR
)
1801 XBOOL_VECTOR (val
)->data
[size_in_chars
- 1]
1802 &= (1 << (XINT (length
) % BITS_PER_CHAR
)) - 1;
1805 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#&...", 5),
1810 /* Accept compiled functions at read-time so that we don't have to
1811 build them using function calls. */
1813 tmp
= read_vector (readcharfun
, 1);
1814 return Fmake_byte_code (XVECTOR (tmp
)->size
,
1815 XVECTOR (tmp
)->contents
);
1820 struct gcpro gcpro1
;
1823 /* Read the string itself. */
1824 tmp
= read1 (readcharfun
, &ch
, 0);
1825 if (ch
!= 0 || !STRINGP (tmp
))
1826 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#", 1), Qnil
));
1828 /* Read the intervals and their properties. */
1831 Lisp_Object beg
, end
, plist
;
1833 beg
= read1 (readcharfun
, &ch
, 0);
1837 end
= read1 (readcharfun
, &ch
, 0);
1839 plist
= read1 (readcharfun
, &ch
, 0);
1841 Fsignal (Qinvalid_read_syntax
,
1842 Fcons (build_string ("invalid string property list"),
1844 Fset_text_properties (beg
, end
, plist
, tmp
);
1850 /* #@NUMBER is used to skip NUMBER following characters.
1851 That's used in .elc files to skip over doc strings
1852 and function definitions. */
1857 /* Read a decimal integer. */
1858 while ((c
= READCHAR
) >= 0
1859 && c
>= '0' && c
<= '9')
1867 if (load_force_doc_strings
&& EQ (readcharfun
, Qget_file_char
))
1869 /* If we are supposed to force doc strings into core right now,
1870 record the last string that we skipped,
1871 and record where in the file it comes from. */
1873 /* But first exchange saved_doc_string
1874 with prev_saved_doc_string, so we save two strings. */
1876 char *temp
= saved_doc_string
;
1877 int temp_size
= saved_doc_string_size
;
1878 file_offset temp_pos
= saved_doc_string_position
;
1879 int temp_len
= saved_doc_string_length
;
1881 saved_doc_string
= prev_saved_doc_string
;
1882 saved_doc_string_size
= prev_saved_doc_string_size
;
1883 saved_doc_string_position
= prev_saved_doc_string_position
;
1884 saved_doc_string_length
= prev_saved_doc_string_length
;
1886 prev_saved_doc_string
= temp
;
1887 prev_saved_doc_string_size
= temp_size
;
1888 prev_saved_doc_string_position
= temp_pos
;
1889 prev_saved_doc_string_length
= temp_len
;
1892 if (saved_doc_string_size
== 0)
1894 saved_doc_string_size
= nskip
+ 100;
1895 saved_doc_string
= (char *) xmalloc (saved_doc_string_size
);
1897 if (nskip
> saved_doc_string_size
)
1899 saved_doc_string_size
= nskip
+ 100;
1900 saved_doc_string
= (char *) xrealloc (saved_doc_string
,
1901 saved_doc_string_size
);
1904 saved_doc_string_position
= file_tell (instream
);
1906 /* Copy that many characters into saved_doc_string. */
1907 for (i
= 0; i
< nskip
&& c
>= 0; i
++)
1908 saved_doc_string
[i
] = c
= READCHAR
;
1910 saved_doc_string_length
= i
;
1914 /* Skip that many characters. */
1915 for (i
= 0; i
< nskip
&& c
>= 0; i
++)
1922 return Vload_file_name
;
1924 return Fcons (Qfunction
, Fcons (read0 (readcharfun
), Qnil
));
1925 /* #:foo is the uninterned symbol named foo. */
1928 uninterned_symbol
= 1;
1932 /* Reader forms that can reuse previously read objects. */
1933 if (c
>= '0' && c
<= '9')
1938 /* Read a non-negative integer. */
1939 while (c
>= '0' && c
<= '9')
1945 /* #n=object returns object, but associates it with n for #n#. */
1948 /* Make a placeholder for #n# to use temporarily */
1949 Lisp_Object placeholder
;
1952 placeholder
= Fcons(Qnil
, Qnil
);
1953 cell
= Fcons (make_number (n
), placeholder
);
1954 read_objects
= Fcons (cell
, read_objects
);
1956 /* Read the object itself. */
1957 tem
= read0 (readcharfun
);
1959 /* Now put it everywhere the placeholder was... */
1960 substitute_object_in_subtree (tem
, placeholder
);
1962 /* ...and #n# will use the real value from now on. */
1963 Fsetcdr (cell
, tem
);
1967 /* #n# returns a previously read object. */
1970 tem
= Fassq (make_number (n
), read_objects
);
1973 /* Fall through to error message. */
1975 else if (c
== 'r' || c
== 'R')
1976 return read_integer (readcharfun
, n
);
1978 /* Fall through to error message. */
1980 else if (c
== 'x' || c
== 'X')
1981 return read_integer (readcharfun
, 16);
1982 else if (c
== 'o' || c
== 'O')
1983 return read_integer (readcharfun
, 8);
1984 else if (c
== 'b' || c
== 'B')
1985 return read_integer (readcharfun
, 2);
1988 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#", 1), Qnil
));
1991 while ((c
= READCHAR
) >= 0 && c
!= '\n');
1996 return Fcons (Qquote
, Fcons (read0 (readcharfun
), Qnil
));
2006 new_backquote_flag
= 1;
2007 value
= read0 (readcharfun
);
2008 new_backquote_flag
= 0;
2010 return Fcons (Qbackquote
, Fcons (value
, Qnil
));
2014 if (new_backquote_flag
)
2016 Lisp_Object comma_type
= Qnil
;
2021 comma_type
= Qcomma_at
;
2023 comma_type
= Qcomma_dot
;
2026 if (ch
>= 0) UNREAD (ch
);
2027 comma_type
= Qcomma
;
2030 new_backquote_flag
= 0;
2031 value
= read0 (readcharfun
);
2032 new_backquote_flag
= 1;
2033 return Fcons (comma_type
, Fcons (value
, Qnil
));
2042 end_of_file_error ();
2045 c
= read_escape (readcharfun
, 0);
2046 else if (BASE_LEADING_CODE_P (c
))
2047 c
= read_multibyte (c
, readcharfun
);
2049 return make_number (c
);
2054 register char *p
= read_buffer
;
2055 register char *end
= read_buffer
+ read_buffer_size
;
2057 /* Nonzero if we saw an escape sequence specifying
2058 a multibyte character. */
2059 int force_multibyte
= 0;
2060 /* Nonzero if we saw an escape sequence specifying
2061 a single-byte character. */
2062 int force_singlebyte
= 0;
2066 while ((c
= READCHAR
) >= 0
2069 if (end
- p
< MAX_MULTIBYTE_LENGTH
)
2071 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
2072 p
+= new - read_buffer
;
2073 read_buffer
+= new - read_buffer
;
2074 end
= read_buffer
+ read_buffer_size
;
2079 c
= read_escape (readcharfun
, 1);
2081 /* C is -1 if \ newline has just been seen */
2084 if (p
== read_buffer
)
2089 /* If an escape specifies a non-ASCII single-byte character,
2090 this must be a unibyte string. */
2091 if (SINGLE_BYTE_CHAR_P ((c
& ~CHAR_MODIFIER_MASK
))
2092 && ! ASCII_BYTE_P ((c
& ~CHAR_MODIFIER_MASK
)))
2093 force_singlebyte
= 1;
2096 if (! SINGLE_BYTE_CHAR_P ((c
& ~CHAR_MODIFIER_MASK
)))
2098 /* Any modifiers for a multibyte character are invalid. */
2099 if (c
& CHAR_MODIFIER_MASK
)
2100 error ("Invalid modifier in string");
2101 p
+= CHAR_STRING (c
, p
);
2102 force_multibyte
= 1;
2106 /* Allow `\C- ' and `\C-?'. */
2107 if (c
== (CHAR_CTL
| ' '))
2109 else if (c
== (CHAR_CTL
| '?'))
2114 /* Shift modifier is valid only with [A-Za-z]. */
2115 if ((c
& 0377) >= 'A' && (c
& 0377) <= 'Z')
2117 else if ((c
& 0377) >= 'a' && (c
& 0377) <= 'z')
2118 c
= (c
& ~CHAR_SHIFT
) - ('a' - 'A');
2122 /* Move the meta bit to the right place for a string. */
2123 c
= (c
& ~CHAR_META
) | 0x80;
2125 error ("Invalid modifier in string");
2130 end_of_file_error ();
2132 /* If purifying, and string starts with \ newline,
2133 return zero instead. This is for doc strings
2134 that we are really going to find in etc/DOC.nn.nn */
2135 if (!NILP (Vpurify_flag
) && NILP (Vdoc_file_name
) && cancel
)
2136 return make_number (0);
2138 if (force_multibyte
)
2139 p
= read_buffer
+ str_as_multibyte (read_buffer
, end
- read_buffer
,
2140 p
- read_buffer
, &nchars
);
2141 else if (force_singlebyte
)
2142 nchars
= p
- read_buffer
;
2143 else if (load_convert_to_unibyte
)
2146 p
= read_buffer
+ str_as_multibyte (read_buffer
, end
- read_buffer
,
2147 p
- read_buffer
, &nchars
);
2148 if (p
- read_buffer
!= nchars
)
2150 string
= make_multibyte_string (read_buffer
, nchars
,
2152 return Fstring_make_unibyte (string
);
2155 else if (EQ (readcharfun
, Qget_file_char
)
2156 || EQ (readcharfun
, Qlambda
))
2157 /* Nowadays, reading directly from a file is used only for
2158 compiled Emacs Lisp files, and those always use the
2159 Emacs internal encoding. Meanwhile, Qlambda is used
2160 for reading dynamic byte code (compiled with
2161 byte-compile-dynamic = t). */
2162 p
= read_buffer
+ str_as_multibyte (read_buffer
, end
- read_buffer
,
2163 p
- read_buffer
, &nchars
);
2165 /* In all other cases, if we read these bytes as
2166 separate characters, treat them as separate characters now. */
2167 nchars
= p
- read_buffer
;
2170 return make_pure_string (read_buffer
, nchars
, p
- read_buffer
,
2172 || (p
- read_buffer
!= nchars
)));
2173 return make_specified_string (read_buffer
, nchars
, p
- read_buffer
,
2175 || (p
- read_buffer
!= nchars
)));
2180 int next_char
= READCHAR
;
2183 if (next_char
<= 040
2184 || index ("\"'`,(", next_char
))
2190 /* Otherwise, we fall through! Note that the atom-reading loop
2191 below will now loop at least once, assuring that we will not
2192 try to UNREAD two characters in a row. */
2196 if (c
<= 040) goto retry
;
2198 register char *p
= read_buffer
;
2202 register char *end
= read_buffer
+ read_buffer_size
;
2205 && !(c
== '\"' || c
== '\'' || c
== ';' || c
== '?'
2206 || c
== '(' || c
== ')'
2207 || c
== '[' || c
== ']' || c
== '#'
2210 if (end
- p
< MAX_MULTIBYTE_LENGTH
)
2212 register char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
2213 p
+= new - read_buffer
;
2214 read_buffer
+= new - read_buffer
;
2215 end
= read_buffer
+ read_buffer_size
;
2223 if (! SINGLE_BYTE_CHAR_P (c
))
2224 p
+= CHAR_STRING (c
, p
);
2233 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
2234 p
+= new - read_buffer
;
2235 read_buffer
+= new - read_buffer
;
2236 /* end = read_buffer + read_buffer_size; */
2243 if (!quoted
&& !uninterned_symbol
)
2246 register Lisp_Object val
;
2248 if (*p1
== '+' || *p1
== '-') p1
++;
2249 /* Is it an integer? */
2252 while (p1
!= p
&& (c
= *p1
) >= '0' && c
<= '9') p1
++;
2253 /* Integers can have trailing decimal points. */
2254 if (p1
> read_buffer
&& p1
< p
&& *p1
== '.') p1
++;
2256 /* It is an integer. */
2260 if (sizeof (int) == sizeof (EMACS_INT
))
2261 XSETINT (val
, atoi (read_buffer
));
2262 else if (sizeof (long) == sizeof (EMACS_INT
))
2263 XSETINT (val
, atol (read_buffer
));
2269 if (isfloat_string (read_buffer
))
2271 /* Compute NaN and infinities using 0.0 in a variable,
2272 to cope with compilers that think they are smarter
2278 /* Negate the value ourselves. This treats 0, NaNs,
2279 and infinity properly on IEEE floating point hosts,
2280 and works around a common bug where atof ("-0.0")
2282 int negative
= read_buffer
[0] == '-';
2284 /* The only way p[-1] can be 'F' or 'N', after isfloat_string
2285 returns 1, is if the input ends in e+INF or e+NaN. */
2292 value
= zero
/ zero
;
2295 value
= atof (read_buffer
+ negative
);
2299 return make_float (negative
? - value
: value
);
2303 if (uninterned_symbol
)
2304 return make_symbol (read_buffer
);
2306 return intern (read_buffer
);
2312 /* List of nodes we've seen during substitute_object_in_subtree. */
2313 static Lisp_Object seen_list
;
2316 substitute_object_in_subtree (object
, placeholder
)
2318 Lisp_Object placeholder
;
2320 Lisp_Object check_object
;
2322 /* We haven't seen any objects when we start. */
2325 /* Make all the substitutions. */
2327 = substitute_object_recurse (object
, placeholder
, object
);
2329 /* Clear seen_list because we're done with it. */
2332 /* The returned object here is expected to always eq the
2334 if (!EQ (check_object
, object
))
2335 error ("Unexpected mutation error in reader");
2338 /* Feval doesn't get called from here, so no gc protection is needed. */
2339 #define SUBSTITUTE(get_val, set_val) \
2341 Lisp_Object old_value = get_val; \
2342 Lisp_Object true_value \
2343 = substitute_object_recurse (object, placeholder,\
2346 if (!EQ (old_value, true_value)) \
2353 substitute_object_recurse (object
, placeholder
, subtree
)
2355 Lisp_Object placeholder
;
2356 Lisp_Object subtree
;
2358 /* If we find the placeholder, return the target object. */
2359 if (EQ (placeholder
, subtree
))
2362 /* If we've been to this node before, don't explore it again. */
2363 if (!EQ (Qnil
, Fmemq (subtree
, seen_list
)))
2366 /* If this node can be the entry point to a cycle, remember that
2367 we've seen it. It can only be such an entry point if it was made
2368 by #n=, which means that we can find it as a value in
2370 if (!EQ (Qnil
, Frassq (subtree
, read_objects
)))
2371 seen_list
= Fcons (subtree
, seen_list
);
2373 /* Recurse according to subtree's type.
2374 Every branch must return a Lisp_Object. */
2375 switch (XTYPE (subtree
))
2377 case Lisp_Vectorlike
:
2380 int length
= XINT (Flength(subtree
));
2381 for (i
= 0; i
< length
; i
++)
2383 Lisp_Object idx
= make_number (i
);
2384 SUBSTITUTE (Faref (subtree
, idx
),
2385 Faset (subtree
, idx
, true_value
));
2392 SUBSTITUTE (Fcar_safe (subtree
),
2393 Fsetcar (subtree
, true_value
));
2394 SUBSTITUTE (Fcdr_safe (subtree
),
2395 Fsetcdr (subtree
, true_value
));
2401 /* Check for text properties in each interval.
2402 substitute_in_interval contains part of the logic. */
2404 INTERVAL root_interval
= XSTRING (subtree
)->intervals
;
2405 Lisp_Object arg
= Fcons (object
, placeholder
);
2407 traverse_intervals (root_interval
, 1, 0,
2408 &substitute_in_interval
, arg
);
2413 /* Other types don't recurse any further. */
2419 /* Helper function for substitute_object_recurse. */
2421 substitute_in_interval (interval
, arg
)
2425 Lisp_Object object
= Fcar (arg
);
2426 Lisp_Object placeholder
= Fcdr (arg
);
2428 SUBSTITUTE(interval
->plist
, interval
->plist
= true_value
);
2447 if (*cp
== '+' || *cp
== '-')
2450 if (*cp
>= '0' && *cp
<= '9')
2453 while (*cp
>= '0' && *cp
<= '9')
2461 if (*cp
>= '0' && *cp
<= '9')
2464 while (*cp
>= '0' && *cp
<= '9')
2467 if (*cp
== 'e' || *cp
== 'E')
2471 if (*cp
== '+' || *cp
== '-')
2475 if (*cp
>= '0' && *cp
<= '9')
2478 while (*cp
>= '0' && *cp
<= '9')
2481 else if (cp
== start
)
2483 else if (cp
[-1] == '+' && cp
[0] == 'I' && cp
[1] == 'N' && cp
[2] == 'F')
2488 else if (cp
[-1] == '+' && cp
[0] == 'N' && cp
[1] == 'a' && cp
[2] == 'N')
2494 return (((*cp
== 0) || (*cp
== ' ') || (*cp
== '\t') || (*cp
== '\n') || (*cp
== '\r') || (*cp
== '\f'))
2495 && (state
== (LEAD_INT
|DOT_CHAR
|TRAIL_INT
)
2496 || state
== (DOT_CHAR
|TRAIL_INT
)
2497 || state
== (LEAD_INT
|E_CHAR
|EXP_INT
)
2498 || state
== (LEAD_INT
|DOT_CHAR
|TRAIL_INT
|E_CHAR
|EXP_INT
)
2499 || state
== (DOT_CHAR
|TRAIL_INT
|E_CHAR
|EXP_INT
)));
2504 read_vector (readcharfun
, bytecodeflag
)
2505 Lisp_Object readcharfun
;
2510 register Lisp_Object
*ptr
;
2511 register Lisp_Object tem
, item
, vector
;
2512 register struct Lisp_Cons
*otem
;
2515 tem
= read_list (1, readcharfun
);
2516 len
= Flength (tem
);
2517 vector
= (read_pure
? make_pure_vector (XINT (len
)) : Fmake_vector (len
, Qnil
));
2519 size
= XVECTOR (vector
)->size
;
2520 ptr
= XVECTOR (vector
)->contents
;
2521 for (i
= 0; i
< size
; i
++)
2524 /* If `load-force-doc-strings' is t when reading a lazily-loaded
2525 bytecode object, the docstring containing the bytecode and
2526 constants values must be treated as unibyte and passed to
2527 Fread, to get the actual bytecode string and constants vector. */
2528 if (bytecodeflag
&& load_force_doc_strings
)
2530 if (i
== COMPILED_BYTECODE
)
2532 if (!STRINGP (item
))
2533 error ("invalid byte code");
2535 /* Delay handling the bytecode slot until we know whether
2536 it is lazily-loaded (we can tell by whether the
2537 constants slot is nil). */
2538 ptr
[COMPILED_CONSTANTS
] = item
;
2541 else if (i
== COMPILED_CONSTANTS
)
2543 Lisp_Object bytestr
= ptr
[COMPILED_CONSTANTS
];
2547 /* Coerce string to unibyte (like string-as-unibyte,
2548 but without generating extra garbage and
2549 guaranteeing no change in the contents). */
2550 XSTRING (bytestr
)->size
= STRING_BYTES (XSTRING (bytestr
));
2551 SET_STRING_BYTES (XSTRING (bytestr
), -1);
2553 item
= Fread (bytestr
);
2555 error ("invalid byte code");
2557 otem
= XCONS (item
);
2558 bytestr
= XCAR (item
);
2563 /* Now handle the bytecode slot. */
2564 ptr
[COMPILED_BYTECODE
] = read_pure
? Fpurecopy (bytestr
) : bytestr
;
2567 ptr
[i
] = read_pure
? Fpurecopy (item
) : item
;
2575 /* FLAG = 1 means check for ] to terminate rather than ) and .
2576 FLAG = -1 means check for starting with defun
2577 and make structure pure. */
2580 read_list (flag
, readcharfun
)
2582 register Lisp_Object readcharfun
;
2584 /* -1 means check next element for defun,
2585 0 means don't check,
2586 1 means already checked and found defun. */
2587 int defunflag
= flag
< 0 ? -1 : 0;
2588 Lisp_Object val
, tail
;
2589 register Lisp_Object elt
, tem
;
2590 struct gcpro gcpro1
, gcpro2
;
2591 /* 0 is the normal case.
2592 1 means this list is a doc reference; replace it with the number 0.
2593 2 means this list is a doc reference; replace it with the doc string. */
2594 int doc_reference
= 0;
2596 /* Initialize this to 1 if we are reading a list. */
2597 int first_in_list
= flag
<= 0;
2606 elt
= read1 (readcharfun
, &ch
, first_in_list
);
2611 /* While building, if the list starts with #$, treat it specially. */
2612 if (EQ (elt
, Vload_file_name
)
2614 && !NILP (Vpurify_flag
))
2616 if (NILP (Vdoc_file_name
))
2617 /* We have not yet called Snarf-documentation, so assume
2618 this file is described in the DOC-MM.NN file
2619 and Snarf-documentation will fill in the right value later.
2620 For now, replace the whole list with 0. */
2623 /* We have already called Snarf-documentation, so make a relative
2624 file name for this file, so it can be found properly
2625 in the installed Lisp directory.
2626 We don't use Fexpand_file_name because that would make
2627 the directory absolute now. */
2628 elt
= concat2 (build_string ("../lisp/"),
2629 Ffile_name_nondirectory (elt
));
2631 else if (EQ (elt
, Vload_file_name
)
2633 && load_force_doc_strings
)
2642 Fsignal (Qinvalid_read_syntax
,
2643 Fcons (make_string (") or . in a vector", 18), Qnil
));
2651 XCDR (tail
) = read0 (readcharfun
);
2653 val
= read0 (readcharfun
);
2654 read1 (readcharfun
, &ch
, 0);
2658 if (doc_reference
== 1)
2659 return make_number (0);
2660 if (doc_reference
== 2)
2662 /* Get a doc string from the file we are loading.
2663 If it's in saved_doc_string, get it from there. */
2664 int pos
= XINT (XCDR (val
));
2665 /* Position is negative for user variables. */
2666 if (pos
< 0) pos
= -pos
;
2667 if (pos
>= saved_doc_string_position
2668 && pos
< (saved_doc_string_position
2669 + saved_doc_string_length
))
2671 int start
= pos
- saved_doc_string_position
;
2674 /* Process quoting with ^A,
2675 and find the end of the string,
2676 which is marked with ^_ (037). */
2677 for (from
= start
, to
= start
;
2678 saved_doc_string
[from
] != 037;)
2680 int c
= saved_doc_string
[from
++];
2683 c
= saved_doc_string
[from
++];
2685 saved_doc_string
[to
++] = c
;
2687 saved_doc_string
[to
++] = 0;
2689 saved_doc_string
[to
++] = 037;
2692 saved_doc_string
[to
++] = c
;
2695 return make_string (saved_doc_string
+ start
,
2698 /* Look in prev_saved_doc_string the same way. */
2699 else if (pos
>= prev_saved_doc_string_position
2700 && pos
< (prev_saved_doc_string_position
2701 + prev_saved_doc_string_length
))
2703 int start
= pos
- prev_saved_doc_string_position
;
2706 /* Process quoting with ^A,
2707 and find the end of the string,
2708 which is marked with ^_ (037). */
2709 for (from
= start
, to
= start
;
2710 prev_saved_doc_string
[from
] != 037;)
2712 int c
= prev_saved_doc_string
[from
++];
2715 c
= prev_saved_doc_string
[from
++];
2717 prev_saved_doc_string
[to
++] = c
;
2719 prev_saved_doc_string
[to
++] = 0;
2721 prev_saved_doc_string
[to
++] = 037;
2724 prev_saved_doc_string
[to
++] = c
;
2727 return make_string (prev_saved_doc_string
+ start
,
2731 return get_doc_string (val
, 0, 0);
2736 return Fsignal (Qinvalid_read_syntax
, Fcons (make_string (". in wrong context", 18), Qnil
));
2738 return Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("] in a list", 11), Qnil
));
2740 tem
= (read_pure
&& flag
<= 0
2741 ? pure_cons (elt
, Qnil
)
2742 : Fcons (elt
, Qnil
));
2749 defunflag
= EQ (elt
, Qdefun
);
2750 else if (defunflag
> 0)
2755 Lisp_Object Vobarray
;
2756 Lisp_Object initial_obarray
;
2758 /* oblookup stores the bucket number here, for the sake of Funintern. */
2760 int oblookup_last_bucket_number
;
2762 static int hash_string ();
2763 Lisp_Object
oblookup ();
2765 /* Get an error if OBARRAY is not an obarray.
2766 If it is one, return it. */
2769 check_obarray (obarray
)
2770 Lisp_Object obarray
;
2772 while (!VECTORP (obarray
) || XVECTOR (obarray
)->size
== 0)
2774 /* If Vobarray is now invalid, force it to be valid. */
2775 if (EQ (Vobarray
, obarray
)) Vobarray
= initial_obarray
;
2777 obarray
= wrong_type_argument (Qvectorp
, obarray
);
2782 /* Intern the C string STR: return a symbol with that name,
2783 interned in the current obarray. */
2790 int len
= strlen (str
);
2791 Lisp_Object obarray
;
2794 if (!VECTORP (obarray
) || XVECTOR (obarray
)->size
== 0)
2795 obarray
= check_obarray (obarray
);
2796 tem
= oblookup (obarray
, str
, len
, len
);
2799 return Fintern (make_string (str
, len
), obarray
);
2802 /* Create an uninterned symbol with name STR. */
2808 int len
= strlen (str
);
2810 return Fmake_symbol ((!NILP (Vpurify_flag
)
2811 ? make_pure_string (str
, len
, len
, 0)
2812 : make_string (str
, len
)));
2815 DEFUN ("intern", Fintern
, Sintern
, 1, 2, 0,
2816 "Return the canonical symbol whose name is STRING.\n\
2817 If there is none, one is created by this function and returned.\n\
2818 A second optional argument specifies the obarray to use;\n\
2819 it defaults to the value of `obarray'.")
2821 Lisp_Object string
, obarray
;
2823 register Lisp_Object tem
, sym
, *ptr
;
2825 if (NILP (obarray
)) obarray
= Vobarray
;
2826 obarray
= check_obarray (obarray
);
2828 CHECK_STRING (string
, 0);
2830 tem
= oblookup (obarray
, XSTRING (string
)->data
,
2831 XSTRING (string
)->size
,
2832 STRING_BYTES (XSTRING (string
)));
2833 if (!INTEGERP (tem
))
2836 if (!NILP (Vpurify_flag
))
2837 string
= Fpurecopy (string
);
2838 sym
= Fmake_symbol (string
);
2839 XSYMBOL (sym
)->obarray
= obarray
;
2841 if ((XSTRING (string
)->data
[0] == ':')
2842 && EQ (obarray
, initial_obarray
))
2843 XSYMBOL (sym
)->value
= sym
;
2845 ptr
= &XVECTOR (obarray
)->contents
[XINT (tem
)];
2847 XSYMBOL (sym
)->next
= XSYMBOL (*ptr
);
2849 XSYMBOL (sym
)->next
= 0;
2854 DEFUN ("intern-soft", Fintern_soft
, Sintern_soft
, 1, 2, 0,
2855 "Return the canonical symbol named NAME, or nil if none exists.\n\
2856 NAME may be a string or a symbol. If it is a symbol, that exact\n\
2857 symbol is searched for.\n\
2858 A second optional argument specifies the obarray to use;\n\
2859 it defaults to the value of `obarray'.")
2861 Lisp_Object name
, obarray
;
2863 register Lisp_Object tem
;
2864 struct Lisp_String
*string
;
2866 if (NILP (obarray
)) obarray
= Vobarray
;
2867 obarray
= check_obarray (obarray
);
2869 if (!SYMBOLP (name
))
2871 CHECK_STRING (name
, 0);
2872 string
= XSTRING (name
);
2875 string
= XSYMBOL (name
)->name
;
2877 tem
= oblookup (obarray
, string
->data
, string
->size
, STRING_BYTES (string
));
2878 if (INTEGERP (tem
) || (SYMBOLP (name
) && !EQ (name
, tem
)))
2884 DEFUN ("unintern", Funintern
, Sunintern
, 1, 2, 0,
2885 "Delete the symbol named NAME, if any, from OBARRAY.\n\
2886 The value is t if a symbol was found and deleted, nil otherwise.\n\
2887 NAME may be a string or a symbol. If it is a symbol, that symbol\n\
2888 is deleted, if it belongs to OBARRAY--no other symbol is deleted.\n\
2889 OBARRAY defaults to the value of the variable `obarray'.")
2891 Lisp_Object name
, obarray
;
2893 register Lisp_Object string
, tem
;
2896 if (NILP (obarray
)) obarray
= Vobarray
;
2897 obarray
= check_obarray (obarray
);
2900 XSETSTRING (string
, XSYMBOL (name
)->name
);
2903 CHECK_STRING (name
, 0);
2907 tem
= oblookup (obarray
, XSTRING (string
)->data
,
2908 XSTRING (string
)->size
,
2909 STRING_BYTES (XSTRING (string
)));
2912 /* If arg was a symbol, don't delete anything but that symbol itself. */
2913 if (SYMBOLP (name
) && !EQ (name
, tem
))
2916 XSYMBOL (tem
)->obarray
= Qnil
;
2918 hash
= oblookup_last_bucket_number
;
2920 if (EQ (XVECTOR (obarray
)->contents
[hash
], tem
))
2922 if (XSYMBOL (tem
)->next
)
2923 XSETSYMBOL (XVECTOR (obarray
)->contents
[hash
], XSYMBOL (tem
)->next
);
2925 XSETINT (XVECTOR (obarray
)->contents
[hash
], 0);
2929 Lisp_Object tail
, following
;
2931 for (tail
= XVECTOR (obarray
)->contents
[hash
];
2932 XSYMBOL (tail
)->next
;
2935 XSETSYMBOL (following
, XSYMBOL (tail
)->next
);
2936 if (EQ (following
, tem
))
2938 XSYMBOL (tail
)->next
= XSYMBOL (following
)->next
;
2947 /* Return the symbol in OBARRAY whose names matches the string
2948 of SIZE characters (SIZE_BYTE bytes) at PTR.
2949 If there is no such symbol in OBARRAY, return nil.
2951 Also store the bucket number in oblookup_last_bucket_number. */
2954 oblookup (obarray
, ptr
, size
, size_byte
)
2955 Lisp_Object obarray
;
2957 int size
, size_byte
;
2961 register Lisp_Object tail
;
2962 Lisp_Object bucket
, tem
;
2964 if (!VECTORP (obarray
)
2965 || (obsize
= XVECTOR (obarray
)->size
) == 0)
2967 obarray
= check_obarray (obarray
);
2968 obsize
= XVECTOR (obarray
)->size
;
2970 /* This is sometimes needed in the middle of GC. */
2971 obsize
&= ~ARRAY_MARK_FLAG
;
2972 /* Combining next two lines breaks VMS C 2.3. */
2973 hash
= hash_string (ptr
, size_byte
);
2975 bucket
= XVECTOR (obarray
)->contents
[hash
];
2976 oblookup_last_bucket_number
= hash
;
2977 if (XFASTINT (bucket
) == 0)
2979 else if (!SYMBOLP (bucket
))
2980 error ("Bad data in guts of obarray"); /* Like CADR error message */
2982 for (tail
= bucket
; ; XSETSYMBOL (tail
, XSYMBOL (tail
)->next
))
2984 if (STRING_BYTES (XSYMBOL (tail
)->name
) == size_byte
2985 && XSYMBOL (tail
)->name
->size
== size
2986 && !bcmp (XSYMBOL (tail
)->name
->data
, ptr
, size_byte
))
2988 else if (XSYMBOL (tail
)->next
== 0)
2991 XSETINT (tem
, hash
);
2996 hash_string (ptr
, len
)
3000 register unsigned char *p
= ptr
;
3001 register unsigned char *end
= p
+ len
;
3002 register unsigned char c
;
3003 register int hash
= 0;
3008 if (c
>= 0140) c
-= 40;
3009 hash
= ((hash
<<3) + (hash
>>28) + c
);
3011 return hash
& 07777777777;
3015 map_obarray (obarray
, fn
, arg
)
3016 Lisp_Object obarray
;
3017 void (*fn
) P_ ((Lisp_Object
, Lisp_Object
));
3021 register Lisp_Object tail
;
3022 CHECK_VECTOR (obarray
, 1);
3023 for (i
= XVECTOR (obarray
)->size
- 1; i
>= 0; i
--)
3025 tail
= XVECTOR (obarray
)->contents
[i
];
3030 if (XSYMBOL (tail
)->next
== 0)
3032 XSETSYMBOL (tail
, XSYMBOL (tail
)->next
);
3038 mapatoms_1 (sym
, function
)
3039 Lisp_Object sym
, function
;
3041 call1 (function
, sym
);
3044 DEFUN ("mapatoms", Fmapatoms
, Smapatoms
, 1, 2, 0,
3045 "Call FUNCTION on every symbol in OBARRAY.\n\
3046 OBARRAY defaults to the value of `obarray'.")
3048 Lisp_Object function
, obarray
;
3050 if (NILP (obarray
)) obarray
= Vobarray
;
3051 obarray
= check_obarray (obarray
);
3053 map_obarray (obarray
, mapatoms_1
, function
);
3057 #define OBARRAY_SIZE 1511
3062 Lisp_Object oblength
;
3066 XSETFASTINT (oblength
, OBARRAY_SIZE
);
3068 Qnil
= Fmake_symbol (make_pure_string ("nil", 3, 3, 0));
3069 Vobarray
= Fmake_vector (oblength
, make_number (0));
3070 initial_obarray
= Vobarray
;
3071 staticpro (&initial_obarray
);
3072 /* Intern nil in the obarray */
3073 XSYMBOL (Qnil
)->obarray
= Vobarray
;
3074 /* These locals are to kludge around a pyramid compiler bug. */
3075 hash
= hash_string ("nil", 3);
3076 /* Separate statement here to avoid VAXC bug. */
3077 hash
%= OBARRAY_SIZE
;
3078 tem
= &XVECTOR (Vobarray
)->contents
[hash
];
3081 Qunbound
= Fmake_symbol (make_pure_string ("unbound", 7, 7, 0));
3082 XSYMBOL (Qnil
)->function
= Qunbound
;
3083 XSYMBOL (Qunbound
)->value
= Qunbound
;
3084 XSYMBOL (Qunbound
)->function
= Qunbound
;
3087 XSYMBOL (Qnil
)->value
= Qnil
;
3088 XSYMBOL (Qnil
)->plist
= Qnil
;
3089 XSYMBOL (Qt
)->value
= Qt
;
3091 /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */
3094 Qvariable_documentation
= intern ("variable-documentation");
3095 staticpro (&Qvariable_documentation
);
3097 read_buffer_size
= 100 + MAX_MULTIBYTE_LENGTH
;
3098 read_buffer
= (char *) xmalloc (read_buffer_size
);
3103 struct Lisp_Subr
*sname
;
3106 sym
= intern (sname
->symbol_name
);
3107 XSETSUBR (XSYMBOL (sym
)->function
, sname
);
3110 #ifdef NOTDEF /* use fset in subr.el now */
3112 defalias (sname
, string
)
3113 struct Lisp_Subr
*sname
;
3117 sym
= intern (string
);
3118 XSETSUBR (XSYMBOL (sym
)->function
, sname
);
3122 /* Define an "integer variable"; a symbol whose value is forwarded
3123 to a C variable of type int. Sample call: */
3124 /* DEFVAR_INT ("indent-tabs-mode", &indent_tabs_mode, "Documentation"); */
3126 defvar_int (namestring
, address
)
3130 Lisp_Object sym
, val
;
3131 sym
= intern (namestring
);
3132 val
= allocate_misc ();
3133 XMISCTYPE (val
) = Lisp_Misc_Intfwd
;
3134 XINTFWD (val
)->intvar
= address
;
3135 XSYMBOL (sym
)->value
= val
;
3138 /* Similar but define a variable whose value is T if address contains 1,
3139 NIL if address contains 0 */
3141 defvar_bool (namestring
, address
)
3145 Lisp_Object sym
, val
;
3146 sym
= intern (namestring
);
3147 val
= allocate_misc ();
3148 XMISCTYPE (val
) = Lisp_Misc_Boolfwd
;
3149 XBOOLFWD (val
)->boolvar
= address
;
3150 XSYMBOL (sym
)->value
= val
;
3151 Vbyte_boolean_vars
= Fcons (sym
, Vbyte_boolean_vars
);
3154 /* Similar but define a variable whose value is the Lisp Object stored
3155 at address. Two versions: with and without gc-marking of the C
3156 variable. The nopro version is used when that variable will be
3157 gc-marked for some other reason, since marking the same slot twice
3158 can cause trouble with strings. */
3160 defvar_lisp_nopro (namestring
, address
)
3162 Lisp_Object
*address
;
3164 Lisp_Object sym
, val
;
3165 sym
= intern (namestring
);
3166 val
= allocate_misc ();
3167 XMISCTYPE (val
) = Lisp_Misc_Objfwd
;
3168 XOBJFWD (val
)->objvar
= address
;
3169 XSYMBOL (sym
)->value
= val
;
3173 defvar_lisp (namestring
, address
)
3175 Lisp_Object
*address
;
3177 defvar_lisp_nopro (namestring
, address
);
3178 staticpro (address
);
3181 /* Similar but define a variable whose value is the Lisp Object stored in
3182 the current buffer. address is the address of the slot in the buffer
3183 that is current now. */
3186 defvar_per_buffer (namestring
, address
, type
, doc
)
3188 Lisp_Object
*address
;
3192 Lisp_Object sym
, val
;
3194 extern struct buffer buffer_local_symbols
;
3196 sym
= intern (namestring
);
3197 val
= allocate_misc ();
3198 offset
= (char *)address
- (char *)current_buffer
;
3200 XMISCTYPE (val
) = Lisp_Misc_Buffer_Objfwd
;
3201 XBUFFER_OBJFWD (val
)->offset
= offset
;
3202 XSYMBOL (sym
)->value
= val
;
3203 PER_BUFFER_SYMBOL (offset
) = sym
;
3204 PER_BUFFER_TYPE (offset
) = type
;
3206 if (PER_BUFFER_IDX (offset
) == 0)
3207 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
3208 slot of buffer_local_flags */
3213 /* Similar but define a variable whose value is the Lisp Object stored
3214 at a particular offset in the current kboard object. */
3217 defvar_kboard (namestring
, offset
)
3221 Lisp_Object sym
, val
;
3222 sym
= intern (namestring
);
3223 val
= allocate_misc ();
3224 XMISCTYPE (val
) = Lisp_Misc_Kboard_Objfwd
;
3225 XKBOARD_OBJFWD (val
)->offset
= offset
;
3226 XSYMBOL (sym
)->value
= val
;
3229 /* Record the value of load-path used at the start of dumping
3230 so we can see if the site changed it later during dumping. */
3231 static Lisp_Object dump_path
;
3237 int turn_off_warning
= 0;
3239 /* Compute the default load-path. */
3241 normal
= PATH_LOADSEARCH
;
3242 Vload_path
= decode_env_path (0, normal
);
3244 if (NILP (Vpurify_flag
))
3245 normal
= PATH_LOADSEARCH
;
3247 normal
= PATH_DUMPLOADSEARCH
;
3249 /* In a dumped Emacs, we normally have to reset the value of
3250 Vload_path from PATH_LOADSEARCH, since the value that was dumped
3251 uses ../lisp, instead of the path of the installed elisp
3252 libraries. However, if it appears that Vload_path was changed
3253 from the default before dumping, don't override that value. */
3256 if (! NILP (Fequal (dump_path
, Vload_path
)))
3258 Vload_path
= decode_env_path (0, normal
);
3259 if (!NILP (Vinstallation_directory
))
3261 /* Add to the path the lisp subdir of the
3262 installation dir, if it exists. */
3263 Lisp_Object tem
, tem1
;
3264 tem
= Fexpand_file_name (build_string ("lisp"),
3265 Vinstallation_directory
);
3266 tem1
= Ffile_exists_p (tem
);
3269 if (NILP (Fmember (tem
, Vload_path
)))
3271 turn_off_warning
= 1;
3272 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
3276 /* That dir doesn't exist, so add the build-time
3277 Lisp dirs instead. */
3278 Vload_path
= nconc2 (Vload_path
, dump_path
);
3280 /* Add leim under the installation dir, if it exists. */
3281 tem
= Fexpand_file_name (build_string ("leim"),
3282 Vinstallation_directory
);
3283 tem1
= Ffile_exists_p (tem
);
3286 if (NILP (Fmember (tem
, Vload_path
)))
3287 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
3290 /* Add site-list under the installation dir, if it exists. */
3291 tem
= Fexpand_file_name (build_string ("site-lisp"),
3292 Vinstallation_directory
);
3293 tem1
= Ffile_exists_p (tem
);
3296 if (NILP (Fmember (tem
, Vload_path
)))
3297 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
3300 /* If Emacs was not built in the source directory,
3301 and it is run from where it was built, add to load-path
3302 the lisp, leim and site-lisp dirs under that directory. */
3304 if (NILP (Fequal (Vinstallation_directory
, Vsource_directory
)))
3308 tem
= Fexpand_file_name (build_string ("src/Makefile"),
3309 Vinstallation_directory
);
3310 tem1
= Ffile_exists_p (tem
);
3312 /* Don't be fooled if they moved the entire source tree
3313 AFTER dumping Emacs. If the build directory is indeed
3314 different from the source dir, src/Makefile.in and
3315 src/Makefile will not be found together. */
3316 tem
= Fexpand_file_name (build_string ("src/Makefile.in"),
3317 Vinstallation_directory
);
3318 tem2
= Ffile_exists_p (tem
);
3319 if (!NILP (tem1
) && NILP (tem2
))
3321 tem
= Fexpand_file_name (build_string ("lisp"),
3324 if (NILP (Fmember (tem
, Vload_path
)))
3325 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
3327 tem
= Fexpand_file_name (build_string ("leim"),
3330 if (NILP (Fmember (tem
, Vload_path
)))
3331 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
3333 tem
= Fexpand_file_name (build_string ("site-lisp"),
3336 if (NILP (Fmember (tem
, Vload_path
)))
3337 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
3345 /* NORMAL refers to the lisp dir in the source directory. */
3346 /* We used to add ../lisp at the front here, but
3347 that caused trouble because it was copied from dump_path
3348 into Vload_path, aboe, when Vinstallation_directory was non-nil.
3349 It should be unnecessary. */
3350 Vload_path
= decode_env_path (0, normal
);
3351 dump_path
= Vload_path
;
3356 /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is
3357 almost never correct, thereby causing a warning to be printed out that
3358 confuses users. Since PATH_LOADSEARCH is always overridden by the
3359 EMACSLOADPATH environment variable below, disable the warning on NT. */
3361 /* Warn if dirs in the *standard* path don't exist. */
3362 if (!turn_off_warning
)
3364 Lisp_Object path_tail
;
3366 for (path_tail
= Vload_path
;
3368 path_tail
= XCDR (path_tail
))
3370 Lisp_Object dirfile
;
3371 dirfile
= Fcar (path_tail
);
3372 if (STRINGP (dirfile
))
3374 dirfile
= Fdirectory_file_name (dirfile
);
3375 if (access (XSTRING (dirfile
)->data
, 0) < 0)
3376 dir_warning ("Warning: Lisp directory `%s' does not exist.\n",
3381 #endif /* WINDOWSNT */
3383 /* If the EMACSLOADPATH environment variable is set, use its value.
3384 This doesn't apply if we're dumping. */
3386 if (NILP (Vpurify_flag
)
3387 && egetenv ("EMACSLOADPATH"))
3389 Vload_path
= decode_env_path ("EMACSLOADPATH", normal
);
3393 load_in_progress
= 0;
3394 Vload_file_name
= Qnil
;
3396 load_descriptor_list
= Qnil
;
3398 Vstandard_input
= Qt
;
3401 /* Print a warning, using format string FORMAT, that directory DIRNAME
3402 does not exist. Print it on stderr and put it in *Message*. */
3405 dir_warning (format
, dirname
)
3407 Lisp_Object dirname
;
3410 = (char *) alloca (XSTRING (dirname
)->size
+ strlen (format
) + 5);
3412 fprintf (stderr
, format
, XSTRING (dirname
)->data
);
3413 sprintf (buffer
, format
, XSTRING (dirname
)->data
);
3414 /* Don't log the warning before we've initialized!! */
3416 message_dolog (buffer
, strlen (buffer
), 0, STRING_MULTIBYTE (dirname
));
3423 defsubr (&Sread_from_string
);
3425 defsubr (&Sintern_soft
);
3426 defsubr (&Sunintern
);
3428 defsubr (&Seval_buffer
);
3429 defsubr (&Seval_region
);
3430 defsubr (&Sread_char
);
3431 defsubr (&Sread_char_exclusive
);
3432 defsubr (&Sread_event
);
3433 defsubr (&Sget_file_char
);
3434 defsubr (&Smapatoms
);
3436 DEFVAR_LISP ("obarray", &Vobarray
,
3437 "Symbol table for use by `intern' and `read'.\n\
3438 It is a vector whose length ought to be prime for best results.\n\
3439 The vector's contents don't make sense if examined from Lisp programs;\n\
3440 to find all the symbols in an obarray, use `mapatoms'.");
3442 DEFVAR_LISP ("values", &Vvalues
,
3443 "List of values of all expressions which were read, evaluated and printed.\n\
3444 Order is reverse chronological.");
3446 DEFVAR_LISP ("standard-input", &Vstandard_input
,
3447 "Stream for read to get input from.\n\
3448 See documentation of `read' for possible values.");
3449 Vstandard_input
= Qt
;
3451 DEFVAR_LISP ("load-path", &Vload_path
,
3452 "*List of directories to search for files to load.\n\
3453 Each element is a string (directory name) or nil (try default directory).\n\
3454 Initialized based on EMACSLOADPATH environment variable, if any,\n\
3455 otherwise to default specified by file `epaths.h' when Emacs was built.");
3457 DEFVAR_BOOL ("load-in-progress", &load_in_progress
,
3458 "Non-nil iff inside of `load'.");
3460 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist
,
3461 "An alist of expressions to be evalled when particular files are loaded.\n\
3462 Each element looks like (FILENAME FORMS...).\n\
3463 When `load' is run and the file-name argument is FILENAME,\n\
3464 the FORMS in the corresponding element are executed at the end of loading.\n\n\
3465 FILENAME must match exactly! Normally FILENAME is the name of a library,\n\
3466 with no directory specified, since that is how `load' is normally called.\n\
3467 An error in FORMS does not undo the load,\n\
3468 but does prevent execution of the rest of the FORMS.");
3469 Vafter_load_alist
= Qnil
;
3471 DEFVAR_LISP ("load-history", &Vload_history
,
3472 "Alist mapping source file names to symbols and features.\n\
3473 Each alist element is a list that starts with a file name,\n\
3474 except for one element (optional) that starts with nil and describes\n\
3475 definitions evaluated from buffers not visiting files.\n\
3476 The remaining elements of each list are symbols defined as functions\n\
3477 or variables, and cons cells `(provide . FEATURE)', `(require . FEATURE)',\n\
3478 and `(autoload . SYMBOL)'.");
3479 Vload_history
= Qnil
;
3481 DEFVAR_LISP ("load-file-name", &Vload_file_name
,
3482 "Full name of file being loaded by `load'.");
3483 Vload_file_name
= Qnil
;
3485 DEFVAR_LISP ("user-init-file", &Vuser_init_file
,
3486 "File name, including directory, of user's initialization file.\n\
3487 If the file loaded had extension `.elc' and there was a corresponding `.el'\n\
3488 file, this variable contains the name of the .el file, suitable for use\n\
3489 by functions like `custom-save-all' which edit the init file.");
3490 Vuser_init_file
= Qnil
;
3492 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list
,
3493 "Used for internal purposes by `load'.");
3494 Vcurrent_load_list
= Qnil
;
3496 DEFVAR_LISP ("load-read-function", &Vload_read_function
,
3497 "Function used by `load' and `eval-region' for reading expressions.\n\
3498 The default is nil, which means use the function `read'.");
3499 Vload_read_function
= Qnil
;
3501 DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function
,
3502 "Function called in `load' for loading an Emacs lisp source file.\n\
3503 This function is for doing code conversion before reading the source file.\n\
3504 If nil, loading is done without any code conversion.\n\
3505 Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where\n\
3506 FULLNAME is the full name of FILE.\n\
3507 See `load' for the meaning of the remaining arguments.");
3508 Vload_source_file_function
= Qnil
;
3510 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings
,
3511 "Non-nil means `load' should force-load all dynamic doc strings.\n\
3512 This is useful when the file being loaded is a temporary copy.");
3513 load_force_doc_strings
= 0;
3515 DEFVAR_BOOL ("load-convert-to-unibyte", &load_convert_to_unibyte
,
3516 "Non-nil means `read' converts strings to unibyte whenever possible.\n\
3517 This is normally bound by `load' and `eval-buffer' to control `read',\n\
3518 and is not meant for users to change.");
3519 load_convert_to_unibyte
= 0;
3521 DEFVAR_LISP ("source-directory", &Vsource_directory
,
3522 "Directory in which Emacs sources were found when Emacs was built.\n\
3523 You cannot count on them to still be there!");
3525 = Fexpand_file_name (build_string ("../"),
3526 Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH
)));
3528 DEFVAR_LISP ("preloaded-file-list", &Vpreloaded_file_list
,
3529 "List of files that were preloaded (when dumping Emacs).");
3530 Vpreloaded_file_list
= Qnil
;
3532 DEFVAR_LISP ("byte-boolean-vars", &Vbyte_boolean_vars
,
3533 "List of all DEFVAR_BOOL variables, used by the byte code optimizer.");
3534 Vbyte_boolean_vars
= Qnil
;
3536 DEFVAR_BOOL ("load-dangerous-libraries", &load_dangerous_libraries
,
3537 "Non-nil means load dangerous compiled Lisp files.\n\
3538 Some versions of XEmacs use different byte codes than Emacs. These\n\
3539 incompatible byte codes can make Emacs crash when it tries to execute\n\
3541 load_dangerous_libraries
= 0;
3543 Vbytecomp_version_regexp
= build_string ("^;;;.in Emacs version");
3544 staticpro (&Vbytecomp_version_regexp
);
3546 /* Vsource_directory was initialized in init_lread. */
3548 load_descriptor_list
= Qnil
;
3549 staticpro (&load_descriptor_list
);
3551 Qcurrent_load_list
= intern ("current-load-list");
3552 staticpro (&Qcurrent_load_list
);
3554 Qstandard_input
= intern ("standard-input");
3555 staticpro (&Qstandard_input
);
3557 Qread_char
= intern ("read-char");
3558 staticpro (&Qread_char
);
3560 Qget_file_char
= intern ("get-file-char");
3561 staticpro (&Qget_file_char
);
3563 Qbackquote
= intern ("`");
3564 staticpro (&Qbackquote
);
3565 Qcomma
= intern (",");
3566 staticpro (&Qcomma
);
3567 Qcomma_at
= intern (",@");
3568 staticpro (&Qcomma_at
);
3569 Qcomma_dot
= intern (",.");
3570 staticpro (&Qcomma_dot
);
3572 Qinhibit_file_name_operation
= intern ("inhibit-file-name-operation");
3573 staticpro (&Qinhibit_file_name_operation
);
3575 Qascii_character
= intern ("ascii-character");
3576 staticpro (&Qascii_character
);
3578 Qfunction
= intern ("function");
3579 staticpro (&Qfunction
);
3581 Qload
= intern ("load");
3584 Qload_file_name
= intern ("load-file-name");
3585 staticpro (&Qload_file_name
);
3587 staticpro (&dump_path
);
3589 staticpro (&read_objects
);
3590 read_objects
= Qnil
;
3591 staticpro (&seen_list
);