Mercurial > emacs
annotate src/lread.c @ 16978:71aff157cff2
(Feval_buffer): Doc fix.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Thu, 06 Feb 1997 09:13:29 +0000 |
| parents | c46111ba348b |
| children | f7a1e78fe210 |
| rev | line source |
|---|---|
| 341 | 1 /* Lisp parsing and input streams. |
|
7589
b6993af7a905
Only lusers assume that O_RDONLY == 0.
Michael I. Bushnell <mib@gnu.org>
parents:
7307
diff
changeset
|
2 Copyright (C) 1985, 1986, 1987, 1988, 1989, |
| 11235 | 3 1993, 1994, 1995 Free Software Foundation, Inc. |
| 341 | 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 | |
| 617 | 9 the Free Software Foundation; either version 2, or (at your option) |
| 341 | 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 | |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14130
diff
changeset
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14130
diff
changeset
|
20 Boston, MA 02111-1307, USA. */ |
| 341 | 21 |
| 22 | |
| 7898 | 23 #include <config.h> |
| 341 | 24 #include <stdio.h> |
| 25 #include <sys/types.h> | |
| 26 #include <sys/stat.h> | |
| 27 #include <sys/file.h> | |
|
8083
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
28 #include <errno.h> |
| 341 | 29 #include "lisp.h" |
| 30 | |
| 31 #ifndef standalone | |
| 32 #include "buffer.h" | |
|
4701
05f6a91c2801
Include <paths.h>, not "paths.h".
Roland McGrath <roland@gnu.org>
parents:
4696
diff
changeset
|
33 #include <paths.h> |
| 341 | 34 #include "commands.h" |
|
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
35 #include "keyboard.h" |
|
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
36 #include "termhooks.h" |
| 341 | 37 #endif |
| 38 | |
| 39 #ifdef lint | |
| 40 #include <sys/inode.h> | |
| 41 #endif /* lint */ | |
| 42 | |
|
14972
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
43 #ifdef MSDOS |
|
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
44 #if __DJGPP__ < 2 |
|
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
45 #include <unistd.h> /* to get X_OK */ |
|
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
46 #endif |
|
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
47 #include "msdos.h" |
|
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
48 #endif |
|
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
49 |
| 341 | 50 #ifndef X_OK |
| 51 #define X_OK 01 | |
| 52 #endif | |
| 53 | |
| 54 #ifdef LISP_FLOAT_TYPE | |
|
2781
fde05936aebb
* lread.c, data.c: If STDC_HEADERS is #defined, include <stdlib.h>
Jim Blandy <jimb@redhat.com>
parents:
2654
diff
changeset
|
55 #ifdef STDC_HEADERS |
|
fde05936aebb
* lread.c, data.c: If STDC_HEADERS is #defined, include <stdlib.h>
Jim Blandy <jimb@redhat.com>
parents:
2654
diff
changeset
|
56 #include <stdlib.h> |
|
fde05936aebb
* lread.c, data.c: If STDC_HEADERS is #defined, include <stdlib.h>
Jim Blandy <jimb@redhat.com>
parents:
2654
diff
changeset
|
57 #endif |
|
5496
24f0d2908e61
[MSDOS]: Use text mode for all files but ".elc" files.
Richard M. Stallman <rms@gnu.org>
parents:
5243
diff
changeset
|
58 |
| 341 | 59 #include <math.h> |
| 60 #endif /* LISP_FLOAT_TYPE */ | |
| 61 | |
| 14950 | 62 #ifdef HAVE_SETLOCALE |
| 63 #include <locale.h> | |
| 64 #endif /* HAVE_SETLOCALE */ | |
| 65 | |
| 8596 | 66 #ifndef O_RDONLY |
| 67 #define O_RDONLY 0 | |
| 68 #endif | |
| 69 | |
|
8083
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
70 extern int errno; |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
71 |
|
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
72 Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list; |
| 341 | 73 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
74 Lisp_Object Qascii_character, Qload, Qload_file_name; |
|
13235
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
75 Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
76 Lisp_Object Qinhibit_file_name_operation; |
|
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
77 |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
78 extern Lisp_Object Qevent_symbol_element_mask; |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
79 extern Lisp_Object Qfile_exists_p; |
| 341 | 80 |
| 81 /* non-zero if inside `load' */ | |
| 82 int load_in_progress; | |
| 83 | |
|
13601
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
84 /* Directory in which the sources were found. */ |
|
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
85 Lisp_Object Vsource_directory; |
|
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
86 |
| 341 | 87 /* Search path for files to be loaded. */ |
| 88 Lisp_Object Vload_path; | |
| 89 | |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
90 /* This is the user-visible association list that maps features to |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
91 lists of defs in their load files. */ |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
92 Lisp_Object Vload_history; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
93 |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
94 /* This is used to build the load history. */ |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
95 Lisp_Object Vcurrent_load_list; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
96 |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
97 /* Name of file actually being read by `load'. */ |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
98 Lisp_Object Vload_file_name; |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
99 |
|
11079
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
100 /* Function to use for reading, in `load' and friends. */ |
|
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
101 Lisp_Object Vload_read_function; |
|
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
102 |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
103 /* The association list of objects read with the #n=object form. |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
104 Each member of the list has the form (n . object), and is used to |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
105 look up the object for the corresponding #n# construct. |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
106 It must be set to nil before all top-level calls to read0. */ |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
107 Lisp_Object read_objects; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
108 |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
109 /* Nonzero means load should forcibly load all dynamic doc strings. */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
110 static int load_force_doc_strings; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
111 |
|
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
112 /* List of descriptors now open for Fload. */ |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
113 static Lisp_Object load_descriptor_list; |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
114 |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
115 /* File for get_file_char to read from. Use by load. */ |
| 341 | 116 static FILE *instream; |
| 117 | |
| 118 /* When nonzero, read conses in pure space */ | |
| 119 static int read_pure; | |
| 120 | |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
121 /* For use within read-from-string (this reader is non-reentrant!!) */ |
| 341 | 122 static int read_from_string_index; |
| 123 static int read_from_string_limit; | |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
124 |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
125 /* This contains the last string skipped with #@. */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
126 static char *saved_doc_string; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
127 /* Length of buffer allocated in saved_doc_string. */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
128 static int saved_doc_string_size; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
129 /* Length of actual data in saved_doc_string. */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
130 static int saved_doc_string_length; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
131 /* This is the file position that string came from. */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
132 static int saved_doc_string_position; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
133 |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
134 /* Nonzero means inside a new-style backquote |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
135 with no surrounding parentheses. |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
136 Fread initializes this to zero, so we need not specbind it |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
137 or worry about what happens to it when there is an error. */ |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
138 static int new_backquote_flag; |
| 341 | 139 |
| 140 /* Handle unreading and rereading of characters. | |
| 141 Write READCHAR to read a character, | |
| 142 UNREAD(c) to unread c to be read again. */ | |
| 143 | |
| 144 #define READCHAR readchar (readcharfun) | |
| 145 #define UNREAD(c) unreadchar (readcharfun, c) | |
| 146 | |
| 147 static int | |
| 148 readchar (readcharfun) | |
| 149 Lisp_Object readcharfun; | |
| 150 { | |
| 151 Lisp_Object tem; | |
| 152 register struct buffer *inbuffer; | |
| 153 register int c, mpos; | |
| 154 | |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
155 if (BUFFERP (readcharfun)) |
| 341 | 156 { |
| 157 inbuffer = XBUFFER (readcharfun); | |
| 158 | |
| 159 if (BUF_PT (inbuffer) >= BUF_ZV (inbuffer)) | |
| 160 return -1; | |
| 161 c = *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer, BUF_PT (inbuffer)); | |
| 162 SET_BUF_PT (inbuffer, BUF_PT (inbuffer) + 1); | |
| 163 | |
| 164 return c; | |
| 165 } | |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
166 if (MARKERP (readcharfun)) |
| 341 | 167 { |
| 168 inbuffer = XMARKER (readcharfun)->buffer; | |
| 169 | |
| 170 mpos = marker_position (readcharfun); | |
| 171 | |
| 172 if (mpos > BUF_ZV (inbuffer) - 1) | |
| 173 return -1; | |
| 174 c = *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer, mpos); | |
| 175 if (mpos != BUF_GPT (inbuffer)) | |
| 176 XMARKER (readcharfun)->bufpos++; | |
| 177 else | |
| 178 Fset_marker (readcharfun, make_number (mpos + 1), | |
| 179 Fmarker_buffer (readcharfun)); | |
| 180 return c; | |
| 181 } | |
| 182 if (EQ (readcharfun, Qget_file_char)) | |
|
8083
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
183 { |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
184 c = getc (instream); |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
185 #ifdef EINTR |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
186 /* Interrupted reads have been observed while reading over the network */ |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
187 while (c == EOF && ferror (instream) && errno == EINTR) |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
188 { |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
189 clearerr (instream); |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
190 c = getc (instream); |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
191 } |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
192 #endif |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
193 return c; |
|
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
194 } |
| 341 | 195 |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
196 if (STRINGP (readcharfun)) |
| 341 | 197 { |
| 198 register int c; | |
| 199 /* This used to be return of a conditional expression, | |
| 200 but that truncated -1 to a char on VMS. */ | |
| 201 if (read_from_string_index < read_from_string_limit) | |
| 202 c = XSTRING (readcharfun)->data[read_from_string_index++]; | |
| 203 else | |
| 204 c = -1; | |
| 205 return c; | |
| 206 } | |
| 207 | |
| 208 tem = call0 (readcharfun); | |
| 209 | |
| 485 | 210 if (NILP (tem)) |
| 341 | 211 return -1; |
| 212 return XINT (tem); | |
| 213 } | |
| 214 | |
| 215 /* Unread the character C in the way appropriate for the stream READCHARFUN. | |
| 216 If the stream is a user function, call it with the char as argument. */ | |
| 217 | |
| 218 static void | |
| 219 unreadchar (readcharfun, c) | |
| 220 Lisp_Object readcharfun; | |
| 221 int c; | |
| 222 { | |
|
6471
4e6b54b64d94
(unreadchar): Don't back up the pointer when unreading EOF.
Karl Heuer <kwzh@gnu.org>
parents:
6470
diff
changeset
|
223 if (c == -1) |
|
4e6b54b64d94
(unreadchar): Don't back up the pointer when unreading EOF.
Karl Heuer <kwzh@gnu.org>
parents:
6470
diff
changeset
|
224 /* Don't back up the pointer if we're unreading the end-of-input mark, |
|
4e6b54b64d94
(unreadchar): Don't back up the pointer when unreading EOF.
Karl Heuer <kwzh@gnu.org>
parents:
6470
diff
changeset
|
225 since readchar didn't advance it when we read it. */ |
|
4e6b54b64d94
(unreadchar): Don't back up the pointer when unreading EOF.
Karl Heuer <kwzh@gnu.org>
parents:
6470
diff
changeset
|
226 ; |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
227 else if (BUFFERP (readcharfun)) |
| 341 | 228 { |
| 229 if (XBUFFER (readcharfun) == current_buffer) | |
|
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
16012
diff
changeset
|
230 SET_PT (PT - 1); |
| 341 | 231 else |
| 232 SET_BUF_PT (XBUFFER (readcharfun), BUF_PT (XBUFFER (readcharfun)) - 1); | |
| 233 } | |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
234 else if (MARKERP (readcharfun)) |
| 341 | 235 XMARKER (readcharfun)->bufpos--; |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
236 else if (STRINGP (readcharfun)) |
| 341 | 237 read_from_string_index--; |
| 238 else if (EQ (readcharfun, Qget_file_char)) | |
| 239 ungetc (c, instream); | |
| 240 else | |
| 241 call1 (readcharfun, make_number (c)); | |
| 242 } | |
| 243 | |
| 244 static Lisp_Object read0 (), read1 (), read_list (), read_vector (); | |
| 245 | |
| 246 /* get a character from the tty */ | |
| 247 | |
|
1519
5d0837ebee9c
* lread.c (read_char): Add an extern declaration for this,
Jim Blandy <jimb@redhat.com>
parents:
1092
diff
changeset
|
248 extern Lisp_Object read_char (); |
|
5d0837ebee9c
* lread.c (read_char): Add an extern declaration for this,
Jim Blandy <jimb@redhat.com>
parents:
1092
diff
changeset
|
249 |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
250 /* Read input events until we get one that's acceptable for our purposes. |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
251 |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
252 If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
253 until we get a character we like, and then stuffed into |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
254 unread_switch_frame. |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
255 |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
256 If ASCII_REQUIRED is non-zero, we check function key events to see |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
257 if the unmodified version of the symbol has a Qascii_character |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
258 property, and use that character, if present. |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
259 |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
260 If ERROR_NONASCII is non-zero, we signal an error if the input we |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
261 get isn't an ASCII character with modifiers. If it's zero but |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
262 ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
263 character. */ |
|
14483
7f49c41db1e8
(Fread_char_exclusive): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
14300
diff
changeset
|
264 |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
265 Lisp_Object |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
266 read_filtered_event (no_switch_frame, ascii_required, error_nonascii) |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
267 int no_switch_frame, ascii_required, error_nonascii; |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
268 { |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
269 #ifdef standalone |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
270 return make_number (getchar ()); |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
271 #else |
|
6503
7c566d0e4b3d
(read_filtered_event, intern): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6471
diff
changeset
|
272 register Lisp_Object val, delayed_switch_frame; |
|
7c566d0e4b3d
(read_filtered_event, intern): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6471
diff
changeset
|
273 |
|
7c566d0e4b3d
(read_filtered_event, intern): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6471
diff
changeset
|
274 delayed_switch_frame = Qnil; |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
275 |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
276 /* Read until we get an acceptable event. */ |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
277 retry: |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
278 val = read_char (0, 0, 0, Qnil, 0); |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
279 |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
280 if (BUFFERP (val)) |
|
5888
0d02ee7ee659
(read_filtered_event): Retry read_char after a buffer change.
Karl Heuer <kwzh@gnu.org>
parents:
5687
diff
changeset
|
281 goto retry; |
|
0d02ee7ee659
(read_filtered_event): Retry read_char after a buffer change.
Karl Heuer <kwzh@gnu.org>
parents:
5687
diff
changeset
|
282 |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
283 /* switch-frame events are put off until after the next ASCII |
| 14036 | 284 character. This is better than signaling an error just because |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
285 the last characters were typed to a separate minibuffer frame, |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
286 for example. Eventually, some code which can deal with |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
287 switch-frame events will read it and process it. */ |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
288 if (no_switch_frame |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
289 && EVENT_HAS_PARAMETERS (val) |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
290 && EQ (EVENT_HEAD (val), Qswitch_frame)) |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
291 { |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
292 delayed_switch_frame = val; |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
293 goto retry; |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
294 } |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
295 |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
296 if (ascii_required) |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
297 { |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
298 /* Convert certain symbols to their ASCII equivalents. */ |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
299 if (SYMBOLP (val)) |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
300 { |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
301 Lisp_Object tem, tem1, tem2; |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
302 tem = Fget (val, Qevent_symbol_element_mask); |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
303 if (!NILP (tem)) |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
304 { |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
305 tem1 = Fget (Fcar (tem), Qascii_character); |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
306 /* Merge this symbol's modifier bits |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
307 with the ASCII equivalent of its basic code. */ |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
308 if (!NILP (tem1)) |
|
9313
ed68c3822e4b
(read_filtered_event, init_obarray): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9274
diff
changeset
|
309 XSETFASTINT (val, XINT (tem1) | XINT (Fcar (Fcdr (tem)))); |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
310 } |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
311 } |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
312 |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
313 /* If we don't have a character now, deal with it appropriately. */ |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
314 if (!INTEGERP (val)) |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
315 { |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
316 if (error_nonascii) |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
317 { |
|
7106
06542cc6ddcd
(read_filtered_event): Use Vunread_command_events.
Richard M. Stallman <rms@gnu.org>
parents:
7028
diff
changeset
|
318 Vunread_command_events = Fcons (val, Qnil); |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
319 error ("Non-character input-event"); |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
320 } |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
321 else |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
322 goto retry; |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
323 } |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
324 } |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
325 |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
326 if (! NILP (delayed_switch_frame)) |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
327 unread_switch_frame = delayed_switch_frame; |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
328 |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
329 return val; |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
330 #endif |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
331 } |
|
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
332 |
| 341 | 333 DEFUN ("read-char", Fread_char, Sread_char, 0, 0, 0, |
| 334 "Read a character from the command input (keyboard or macro).\n\ | |
| 851 | 335 It is returned as a number.\n\ |
| 336 If the user generates an event which is not a character (i.e. a mouse\n\ | |
|
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
337 click or function key event), `read-char' signals an error. As an\n\ |
|
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
338 exception, switch-frame events are put off until non-ASCII events can\n\ |
|
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
339 be read.\n\ |
|
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
340 If you want to read non-character events, or ignore them, call\n\ |
|
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
341 `read-event' or `read-char-exclusive' instead.") |
| 341 | 342 () |
| 343 { | |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
344 return read_filtered_event (1, 1, 1); |
| 341 | 345 } |
| 346 | |
| 347 DEFUN ("read-event", Fread_event, Sread_event, 0, 0, 0, | |
| 348 "Read an event object from the input stream.") | |
| 349 () | |
| 350 { | |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
351 return read_filtered_event (0, 0, 0); |
| 341 | 352 } |
| 353 | |
| 354 DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 0, 0, | |
| 355 "Read a character from the command input (keyboard or macro).\n\ | |
|
14483
7f49c41db1e8
(Fread_char_exclusive): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
14300
diff
changeset
|
356 It is returned as a number. Non-character events are ignored.") |
| 341 | 357 () |
| 358 { | |
|
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
359 return read_filtered_event (1, 1, 0); |
| 341 | 360 } |
| 361 | |
| 362 DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0, | |
| 363 "Don't use this yourself.") | |
| 364 () | |
| 365 { | |
| 366 register Lisp_Object val; | |
|
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
367 XSETINT (val, getc (instream)); |
| 341 | 368 return val; |
| 369 } | |
| 370 | |
| 371 static void readevalloop (); | |
| 372 static Lisp_Object load_unwind (); | |
|
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
373 static Lisp_Object load_descriptor_unwind (); |
| 341 | 374 |
| 375 DEFUN ("load", Fload, Sload, 1, 4, 0, | |
| 376 "Execute a file of Lisp code named FILE.\n\ | |
| 377 First try FILE with `.elc' appended, then try with `.el',\n\ | |
| 378 then try FILE unmodified.\n\ | |
| 379 This function searches the directories in `load-path'.\n\ | |
| 380 If optional second arg NOERROR is non-nil,\n\ | |
| 381 report no error if FILE doesn't exist.\n\ | |
| 382 Print messages at start and end of loading unless\n\ | |
| 383 optional third arg NOMESSAGE is non-nil.\n\ | |
| 384 If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\ | |
| 385 suffixes `.elc' or `.el' to the specified name FILE.\n\ | |
| 386 Return t if file exists.") | |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
387 (file, noerror, nomessage, nosuffix) |
|
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
388 Lisp_Object file, noerror, nomessage, nosuffix; |
| 341 | 389 { |
| 390 register FILE *stream; | |
| 391 register int fd = -1; | |
| 392 register Lisp_Object lispstream; | |
| 393 int count = specpdl_ptr - specpdl; | |
| 394 Lisp_Object temp; | |
| 395 struct gcpro gcpro1; | |
| 396 Lisp_Object found; | |
|
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
397 /* 1 means we printed the ".el is newer" message. */ |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
398 int newer = 0; |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
399 /* 1 means we are loading a compiled file. */ |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
400 int compiled = 0; |
|
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
401 Lisp_Object handler; |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
402 #ifdef DOS_NT |
|
5496
24f0d2908e61
[MSDOS]: Use text mode for all files but ".elc" files.
Richard M. Stallman <rms@gnu.org>
parents:
5243
diff
changeset
|
403 char *dosmode = "rt"; |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
404 #endif /* DOS_NT */ |
| 341 | 405 |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
406 CHECK_STRING (file, 0); |
| 341 | 407 |
|
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
408 /* If file name is magic, call the handler. */ |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
409 handler = Ffind_file_name_handler (file, Qload); |
|
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
410 if (!NILP (handler)) |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
411 return call5 (handler, Qload, file, noerror, nomessage, nosuffix); |
|
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
412 |
|
10014
d149c4dc84f3
(Fload): Call Fsubstitute_in_file_name after trying handler.
Richard M. Stallman <rms@gnu.org>
parents:
9938
diff
changeset
|
413 /* Do this after the handler to avoid |
|
d149c4dc84f3
(Fload): Call Fsubstitute_in_file_name after trying handler.
Richard M. Stallman <rms@gnu.org>
parents:
9938
diff
changeset
|
414 the need to gcpro noerror, nomessage and nosuffix. |
|
d149c4dc84f3
(Fload): Call Fsubstitute_in_file_name after trying handler.
Richard M. Stallman <rms@gnu.org>
parents:
9938
diff
changeset
|
415 (Below here, we care only whether they are nil or not.) */ |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
416 file = Fsubstitute_in_file_name (file); |
|
10014
d149c4dc84f3
(Fload): Call Fsubstitute_in_file_name after trying handler.
Richard M. Stallman <rms@gnu.org>
parents:
9938
diff
changeset
|
417 |
| 341 | 418 /* Avoid weird lossage with null string as arg, |
| 419 since it would try to load a directory as a Lisp file */ | |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
420 if (XSTRING (file)->size > 0) |
| 341 | 421 { |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
422 GCPRO1 (file); |
|
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
423 fd = openp (Vload_path, file, !NILP (nosuffix) ? "" : ".elc:.el:", |
| 341 | 424 &found, 0); |
|
6392
58e075552627
(openp, Fload): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6072
diff
changeset
|
425 UNGCPRO; |
| 341 | 426 } |
| 427 | |
| 428 if (fd < 0) | |
| 429 { | |
| 485 | 430 if (NILP (noerror)) |
| 341 | 431 while (1) |
| 432 Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"), | |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
433 Fcons (file, Qnil))); |
| 341 | 434 else |
| 435 return Qnil; | |
| 436 } | |
| 437 | |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
438 /* If FD is 0, that means openp found a remote file. */ |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
439 if (fd == 0) |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
440 { |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
441 handler = Ffind_file_name_handler (found, Qload); |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
442 return call5 (handler, Qload, found, noerror, nomessage, Qt); |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
443 } |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
444 |
| 341 | 445 if (!bcmp (&(XSTRING (found)->data[XSTRING (found)->size - 4]), |
| 446 ".elc", 4)) | |
| 447 { | |
| 448 struct stat s1, s2; | |
| 449 int result; | |
| 450 | |
|
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
451 compiled = 1; |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
452 |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
453 #ifdef DOS_NT |
|
5496
24f0d2908e61
[MSDOS]: Use text mode for all files but ".elc" files.
Richard M. Stallman <rms@gnu.org>
parents:
5243
diff
changeset
|
454 dosmode = "rb"; |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
455 #endif /* DOS_NT */ |
|
6072
8af8f6b469e1
(Fload): Cast the args to stat.
Richard M. Stallman <rms@gnu.org>
parents:
5888
diff
changeset
|
456 stat ((char *)XSTRING (found)->data, &s1); |
| 341 | 457 XSTRING (found)->data[XSTRING (found)->size - 1] = 0; |
|
6072
8af8f6b469e1
(Fload): Cast the args to stat.
Richard M. Stallman <rms@gnu.org>
parents:
5888
diff
changeset
|
458 result = stat ((char *)XSTRING (found)->data, &s2); |
| 341 | 459 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) |
|
1758
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
460 { |
|
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
461 /* Make the progress messages mention that source is newer. */ |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
462 newer = 1; |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
463 |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
464 /* If we won't print another message, mention this anyway. */ |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
465 if (! NILP (nomessage)) |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
466 message ("Source file `%s' newer than byte-compiled file", |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
467 XSTRING (found)->data); |
|
1758
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
468 } |
| 341 | 469 XSTRING (found)->data[XSTRING (found)->size - 1] = 'c'; |
| 470 } | |
| 471 | |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
472 #ifdef DOS_NT |
|
5496
24f0d2908e61
[MSDOS]: Use text mode for all files but ".elc" files.
Richard M. Stallman <rms@gnu.org>
parents:
5243
diff
changeset
|
473 close (fd); |
|
24f0d2908e61
[MSDOS]: Use text mode for all files but ".elc" files.
Richard M. Stallman <rms@gnu.org>
parents:
5243
diff
changeset
|
474 stream = fopen ((char *) XSTRING (found)->data, dosmode); |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
475 #else /* not DOS_NT */ |
| 341 | 476 stream = fdopen (fd, "r"); |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
477 #endif /* not DOS_NT */ |
| 341 | 478 if (stream == 0) |
| 479 { | |
| 480 close (fd); | |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
481 error ("Failure to create stdio stream for %s", XSTRING (file)->data); |
| 341 | 482 } |
| 483 | |
|
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
484 if (NILP (nomessage)) |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
485 { |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
486 if (newer) |
|
16165
a95e975275d8
(Fload): Move ... to ends of messages.
Richard M. Stallman <rms@gnu.org>
parents:
16141
diff
changeset
|
487 message ("Loading %s (compiled; note, source file is newer)...", |
|
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
488 XSTRING (file)->data); |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
489 else if (compiled) |
|
16165
a95e975275d8
(Fload): Move ... to ends of messages.
Richard M. Stallman <rms@gnu.org>
parents:
16141
diff
changeset
|
490 message ("Loading %s (compiled)...", XSTRING (file)->data); |
|
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
491 else |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
492 message ("Loading %s...", XSTRING (file)->data); |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
493 } |
| 341 | 494 |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
495 GCPRO1 (file); |
|
9361
c11cc966dc6a
(Fload, load_unwind): Store stream pointer as a cons of two integers,
Karl Heuer <kwzh@gnu.org>
parents:
9358
diff
changeset
|
496 lispstream = Fcons (Qnil, Qnil); |
|
c11cc966dc6a
(Fload, load_unwind): Store stream pointer as a cons of two integers,
Karl Heuer <kwzh@gnu.org>
parents:
9358
diff
changeset
|
497 XSETFASTINT (XCONS (lispstream)->car, (EMACS_UINT)stream >> 16); |
|
c11cc966dc6a
(Fload, load_unwind): Store stream pointer as a cons of two integers,
Karl Heuer <kwzh@gnu.org>
parents:
9358
diff
changeset
|
498 XSETFASTINT (XCONS (lispstream)->cdr, (EMACS_UINT)stream & 0xffff); |
| 341 | 499 record_unwind_protect (load_unwind, lispstream); |
|
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
500 record_unwind_protect (load_descriptor_unwind, load_descriptor_list); |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
501 specbind (Qload_file_name, found); |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
502 specbind (Qinhibit_file_name_operation, Qnil); |
|
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
503 load_descriptor_list |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
504 = Fcons (make_number (fileno (stream)), load_descriptor_list); |
| 341 | 505 load_in_progress++; |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
506 readevalloop (Qget_file_char, stream, file, Feval, 0); |
| 341 | 507 unbind_to (count, Qnil); |
| 508 | |
| 509 /* Run any load-hooks for this file. */ | |
|
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
510 temp = Fassoc (file, Vafter_load_alist); |
| 485 | 511 if (!NILP (temp)) |
| 341 | 512 Fprogn (Fcdr (temp)); |
| 513 UNGCPRO; | |
| 514 | |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
515 if (saved_doc_string) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
516 free (saved_doc_string); |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
517 saved_doc_string = 0; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
518 saved_doc_string_size = 0; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
519 |
| 485 | 520 if (!noninteractive && NILP (nomessage)) |
|
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
521 { |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
522 if (newer) |
|
16165
a95e975275d8
(Fload): Move ... to ends of messages.
Richard M. Stallman <rms@gnu.org>
parents:
16141
diff
changeset
|
523 message ("Loading %s (compiled; note, source file is newer)...done", |
|
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
524 XSTRING (file)->data); |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
525 else if (compiled) |
|
16165
a95e975275d8
(Fload): Move ... to ends of messages.
Richard M. Stallman <rms@gnu.org>
parents:
16141
diff
changeset
|
526 message ("Loading %s (compiled)...done", XSTRING (file)->data); |
|
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
527 else |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
528 message ("Loading %s...done", XSTRING (file)->data); |
|
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
529 } |
| 341 | 530 return Qt; |
| 531 } | |
| 532 | |
| 533 static Lisp_Object | |
| 534 load_unwind (stream) /* used as unwind-protect function in load */ | |
| 535 Lisp_Object stream; | |
| 536 { | |
|
9552
c1d477aec340
(load_unwind): Cast argument of fclose.
Richard M. Stallman <rms@gnu.org>
parents:
9466
diff
changeset
|
537 fclose ((FILE *) (XFASTINT (XCONS (stream)->car) << 16 |
|
c1d477aec340
(load_unwind): Cast argument of fclose.
Richard M. Stallman <rms@gnu.org>
parents:
9466
diff
changeset
|
538 | XFASTINT (XCONS (stream)->cdr))); |
| 341 | 539 if (--load_in_progress < 0) load_in_progress = 0; |
| 540 return Qnil; | |
| 541 } | |
| 542 | |
|
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
543 static Lisp_Object |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
544 load_descriptor_unwind (oldlist) |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
545 Lisp_Object oldlist; |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
546 { |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
547 load_descriptor_list = oldlist; |
|
9361
c11cc966dc6a
(Fload, load_unwind): Store stream pointer as a cons of two integers,
Karl Heuer <kwzh@gnu.org>
parents:
9358
diff
changeset
|
548 return Qnil; |
|
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
549 } |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
550 |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
551 /* Close all descriptors in use for Floads. |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
552 This is used when starting a subprocess. */ |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
553 |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
554 void |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
555 close_load_descs () |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
556 { |
|
15091
e05dd165b889
(close_load_descs) [WINDOWS_NT]: Don't actually do anything.
Richard M. Stallman <rms@gnu.org>
parents:
14972
diff
changeset
|
557 #ifndef WINDOWSNT |
|
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
558 Lisp_Object tail; |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
559 for (tail = load_descriptor_list; !NILP (tail); tail = XCONS (tail)->cdr) |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
560 close (XFASTINT (XCONS (tail)->car)); |
|
15091
e05dd165b889
(close_load_descs) [WINDOWS_NT]: Don't actually do anything.
Richard M. Stallman <rms@gnu.org>
parents:
14972
diff
changeset
|
561 #endif |
|
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
562 } |
| 341 | 563 |
| 564 static int | |
| 565 complete_filename_p (pathname) | |
| 566 Lisp_Object pathname; | |
| 567 { | |
| 568 register unsigned char *s = XSTRING (pathname)->data; | |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
569 return (IS_DIRECTORY_SEP (s[0]) |
|
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
570 || (XSTRING (pathname)->size > 2 |
|
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
571 && IS_DEVICE_SEP (s[1]) && IS_DIRECTORY_SEP (s[2])) |
| 341 | 572 #ifdef ALTOS |
| 573 || *s == '@' | |
| 574 #endif | |
| 575 #ifdef VMS | |
| 576 || index (s, ':') | |
| 577 #endif /* VMS */ | |
| 578 ); | |
| 579 } | |
| 580 | |
| 581 /* Search for a file whose name is STR, looking in directories | |
| 582 in the Lisp list PATH, and trying suffixes from SUFFIX. | |
| 583 SUFFIX is a string containing possible suffixes separated by colons. | |
| 584 On success, returns a file descriptor. On failure, returns -1. | |
| 585 | |
| 586 EXEC_ONLY nonzero means don't open the files, | |
| 587 just look for one that is executable. In this case, | |
| 588 returns 1 on success. | |
| 589 | |
| 590 If STOREPTR is nonzero, it points to a slot where the name of | |
| 591 the file actually found should be stored as a Lisp string. | |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
592 nil is stored there on failure. |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
593 |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
594 If the file we find is remote, return 0 |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
595 but store the found remote file name in *STOREPTR. |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
596 We do not check for remote files if EXEC_ONLY is nonzero. */ |
| 341 | 597 |
| 598 int | |
| 599 openp (path, str, suffix, storeptr, exec_only) | |
| 600 Lisp_Object path, str; | |
| 601 char *suffix; | |
| 602 Lisp_Object *storeptr; | |
| 603 int exec_only; | |
| 604 { | |
| 605 register int fd; | |
| 606 int fn_size = 100; | |
| 607 char buf[100]; | |
| 608 register char *fn = buf; | |
| 609 int absolute = 0; | |
| 610 int want_size; | |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
611 Lisp_Object filename; |
| 341 | 612 struct stat st; |
|
6392
58e075552627
(openp, Fload): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6072
diff
changeset
|
613 struct gcpro gcpro1; |
| 341 | 614 |
|
6392
58e075552627
(openp, Fload): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6072
diff
changeset
|
615 GCPRO1 (str); |
| 341 | 616 if (storeptr) |
| 617 *storeptr = Qnil; | |
| 618 | |
| 619 if (complete_filename_p (str)) | |
| 620 absolute = 1; | |
| 621 | |
| 485 | 622 for (; !NILP (path); path = Fcdr (path)) |
| 341 | 623 { |
| 624 char *nsuffix; | |
| 625 | |
| 626 filename = Fexpand_file_name (str, Fcar (path)); | |
| 627 if (!complete_filename_p (filename)) | |
| 628 /* If there are non-absolute elts in PATH (eg ".") */ | |
| 629 /* Of course, this could conceivably lose if luser sets | |
| 630 default-directory to be something non-absolute... */ | |
| 631 { | |
| 632 filename = Fexpand_file_name (filename, current_buffer->directory); | |
| 633 if (!complete_filename_p (filename)) | |
| 634 /* Give up on this path element! */ | |
| 635 continue; | |
| 636 } | |
| 637 | |
| 638 /* Calculate maximum size of any filename made from | |
| 639 this path element/specified file name and any possible suffix. */ | |
| 640 want_size = strlen (suffix) + XSTRING (filename)->size + 1; | |
| 641 if (fn_size < want_size) | |
| 642 fn = (char *) alloca (fn_size = 100 + want_size); | |
| 643 | |
| 644 nsuffix = suffix; | |
| 645 | |
| 646 /* Loop over suffixes. */ | |
| 647 while (1) | |
| 648 { | |
| 649 char *esuffix = (char *) index (nsuffix, ':'); | |
| 650 int lsuffix = esuffix ? esuffix - nsuffix : strlen (nsuffix); | |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
651 Lisp_Object handler; |
| 341 | 652 |
|
16383
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
653 /* Concatenate path element/specified name with the suffix. |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
654 If the directory starts with /:, remove that. */ |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
655 if (XSTRING (filename)->size > 2 |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
656 && XSTRING (filename)->data[0] == '/' |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
657 && XSTRING (filename)->data[1] == ':') |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
658 { |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
659 strncpy (fn, XSTRING (filename)->data + 2, |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
660 XSTRING (filename)->size - 2); |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
661 fn[XSTRING (filename)->size - 2] = 0; |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
662 } |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
663 else |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
664 { |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
665 strncpy (fn, XSTRING (filename)->data, XSTRING (filename)->size); |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
666 fn[XSTRING (filename)->size] = 0; |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
667 } |
|
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
668 |
| 341 | 669 if (lsuffix != 0) /* Bug happens on CCI if lsuffix is 0. */ |
| 670 strncat (fn, nsuffix, lsuffix); | |
| 671 | |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
672 /* Check that the file exists and is not a directory. */ |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
673 if (absolute) |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
674 handler = Qnil; |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
675 else |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
676 handler = Ffind_file_name_handler (filename, Qfile_exists_p); |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
677 if (! NILP (handler) && ! exec_only) |
| 341 | 678 { |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
679 Lisp_Object string; |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
680 int exists; |
| 341 | 681 |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
682 string = build_string (fn); |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
683 exists = ! NILP (exec_only ? Ffile_executable_p (string) |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
684 : Ffile_readable_p (string)); |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
685 if (exists |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
686 && ! NILP (Ffile_directory_p (build_string (fn)))) |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
687 exists = 0; |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
688 |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
689 if (exists) |
| 341 | 690 { |
| 691 /* We succeeded; return this descriptor and filename. */ | |
| 692 if (storeptr) | |
| 693 *storeptr = build_string (fn); | |
|
8906
93f3d6f5753c
(openp): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8828
diff
changeset
|
694 UNGCPRO; |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
695 return 0; |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
696 } |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
697 } |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
698 else |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
699 { |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
700 int exists = (stat (fn, &st) >= 0 |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
701 && (st.st_mode & S_IFMT) != S_IFDIR); |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
702 if (exists) |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
703 { |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
704 /* Check that we can access or open it. */ |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
705 if (exec_only) |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
706 fd = (access (fn, X_OK) == 0) ? 1 : -1; |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
707 else |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
708 fd = open (fn, O_RDONLY, 0); |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
709 |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
710 if (fd >= 0) |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
711 { |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
712 /* We succeeded; return this descriptor and filename. */ |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
713 if (storeptr) |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
714 *storeptr = build_string (fn); |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
715 UNGCPRO; |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
716 return fd; |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
717 } |
| 341 | 718 } |
| 719 } | |
| 720 | |
| 721 /* Advance to next suffix. */ | |
| 722 if (esuffix == 0) | |
| 723 break; | |
| 724 nsuffix += lsuffix + 1; | |
| 725 } | |
|
6392
58e075552627
(openp, Fload): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6072
diff
changeset
|
726 if (absolute) |
|
8906
93f3d6f5753c
(openp): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8828
diff
changeset
|
727 break; |
| 341 | 728 } |
| 729 | |
|
8906
93f3d6f5753c
(openp): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8828
diff
changeset
|
730 UNGCPRO; |
|
93f3d6f5753c
(openp): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8828
diff
changeset
|
731 return -1; |
| 341 | 732 } |
| 733 | |
| 734 | |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
735 /* Merge the list we've accumulated of globals from the current input source |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
736 into the load_history variable. The details depend on whether |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
737 the source has an associated file name or not. */ |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
738 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
739 static void |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
740 build_load_history (stream, source) |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
741 FILE *stream; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
742 Lisp_Object source; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
743 { |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
744 register Lisp_Object tail, prev, newelt; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
745 register Lisp_Object tem, tem2; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
746 register int foundit, loading; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
747 |
|
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
748 /* Don't bother recording anything for preloaded files. */ |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
749 if (!NILP (Vpurify_flag)) |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
750 return; |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
751 |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
752 loading = stream || !NARROWED; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
753 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
754 tail = Vload_history; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
755 prev = Qnil; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
756 foundit = 0; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
757 while (!NILP (tail)) |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
758 { |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
759 tem = Fcar (tail); |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
760 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
761 /* Find the feature's previous assoc list... */ |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
762 if (!NILP (Fequal (source, Fcar (tem)))) |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
763 { |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
764 foundit = 1; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
765 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
766 /* If we're loading, remove it. */ |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
767 if (loading) |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
768 { |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
769 if (NILP (prev)) |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
770 Vload_history = Fcdr (tail); |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
771 else |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
772 Fsetcdr (prev, Fcdr (tail)); |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
773 } |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
774 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
775 /* Otherwise, cons on new symbols that are not already members. */ |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
776 else |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
777 { |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
778 tem2 = Vcurrent_load_list; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
779 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
780 while (CONSP (tem2)) |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
781 { |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
782 newelt = Fcar (tem2); |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
783 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
784 if (NILP (Fmemq (newelt, tem))) |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
785 Fsetcar (tail, Fcons (Fcar (tem), |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
786 Fcons (newelt, Fcdr (tem)))); |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
787 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
788 tem2 = Fcdr (tem2); |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
789 QUIT; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
790 } |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
791 } |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
792 } |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
793 else |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
794 prev = tail; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
795 tail = Fcdr (tail); |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
796 QUIT; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
797 } |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
798 |
|
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
799 /* If we're loading, cons the new assoc onto the front of load-history, |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
800 the most-recently-loaded position. Also do this if we didn't find |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
801 an existing member for the current source. */ |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
802 if (loading || !foundit) |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
803 Vload_history = Fcons (Fnreverse (Vcurrent_load_list), |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
804 Vload_history); |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
805 } |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
806 |
| 341 | 807 Lisp_Object |
| 808 unreadpure () /* Used as unwind-protect function in readevalloop */ | |
| 809 { | |
| 810 read_pure = 0; | |
| 811 return Qnil; | |
| 812 } | |
| 813 | |
| 814 static void | |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
815 readevalloop (readcharfun, stream, sourcename, evalfun, printflag) |
| 341 | 816 Lisp_Object readcharfun; |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
817 FILE *stream; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
818 Lisp_Object sourcename; |
| 341 | 819 Lisp_Object (*evalfun) (); |
| 820 int printflag; | |
| 821 { | |
| 822 register int c; | |
| 823 register Lisp_Object val; | |
| 824 int count = specpdl_ptr - specpdl; | |
|
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
825 struct gcpro gcpro1; |
|
5185
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
826 struct buffer *b = 0; |
|
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
827 |
|
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
828 if (BUFFERP (readcharfun)) |
|
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
829 b = XBUFFER (readcharfun); |
|
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
830 else if (MARKERP (readcharfun)) |
|
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
831 b = XMARKER (readcharfun)->buffer; |
| 341 | 832 |
| 833 specbind (Qstandard_input, readcharfun); | |
|
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
834 specbind (Qcurrent_load_list, Qnil); |
| 341 | 835 |
|
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
836 GCPRO1 (sourcename); |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
837 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
838 LOADHIST_ATTACH (sourcename); |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
839 |
| 341 | 840 while (1) |
| 841 { | |
|
5185
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
842 if (b != 0 && NILP (b->name)) |
|
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
843 error ("Reading from killed buffer"); |
|
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
844 |
| 341 | 845 instream = stream; |
| 846 c = READCHAR; | |
| 847 if (c == ';') | |
| 848 { | |
| 849 while ((c = READCHAR) != '\n' && c != -1); | |
| 850 continue; | |
| 851 } | |
| 852 if (c < 0) break; | |
|
10163
70b04b218216
(readevalloop): Ignore ^M here.
Richard M. Stallman <rms@gnu.org>
parents:
10014
diff
changeset
|
853 |
|
70b04b218216
(readevalloop): Ignore ^M here.
Richard M. Stallman <rms@gnu.org>
parents:
10014
diff
changeset
|
854 /* Ignore whitespace here, so we can detect eof. */ |
|
70b04b218216
(readevalloop): Ignore ^M here.
Richard M. Stallman <rms@gnu.org>
parents:
10014
diff
changeset
|
855 if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r') |
|
70b04b218216
(readevalloop): Ignore ^M here.
Richard M. Stallman <rms@gnu.org>
parents:
10014
diff
changeset
|
856 continue; |
| 341 | 857 |
| 485 | 858 if (!NILP (Vpurify_flag) && c == '(') |
| 341 | 859 { |
|
8182
94f524e0d5cd
(readevalloop): Correctly unbind the unwind protect.
Richard M. Stallman <rms@gnu.org>
parents:
8083
diff
changeset
|
860 int count1 = specpdl_ptr - specpdl; |
| 341 | 861 record_unwind_protect (unreadpure, Qnil); |
| 862 val = read_list (-1, readcharfun); | |
|
8182
94f524e0d5cd
(readevalloop): Correctly unbind the unwind protect.
Richard M. Stallman <rms@gnu.org>
parents:
8083
diff
changeset
|
863 unbind_to (count1, Qnil); |
| 341 | 864 } |
| 865 else | |
| 866 { | |
| 867 UNREAD (c); | |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
868 read_objects = Qnil; |
|
11079
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
869 if (NILP (Vload_read_function)) |
|
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
870 val = read0 (readcharfun); |
|
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
871 else |
|
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
872 val = call1 (Vload_read_function, readcharfun); |
| 341 | 873 } |
| 874 | |
| 875 val = (*evalfun) (val); | |
| 876 if (printflag) | |
| 877 { | |
| 878 Vvalues = Fcons (val, Vvalues); | |
| 879 if (EQ (Vstandard_output, Qt)) | |
| 880 Fprin1 (val, Qnil); | |
| 881 else | |
| 882 Fprint (val, Qnil); | |
| 883 } | |
| 884 } | |
| 885 | |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
886 build_load_history (stream, sourcename); |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
887 UNGCPRO; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
888 |
| 341 | 889 unbind_to (count, Qnil); |
| 890 } | |
| 891 | |
| 892 #ifndef standalone | |
| 893 | |
| 732 | 894 DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 2, "", |
|
675
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
895 "Execute the current buffer as Lisp code.\n\ |
|
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
896 Programs can pass two arguments, BUFFER and PRINTFLAG.\n\ |
|
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
897 BUFFER is the buffer to evaluate (nil means use current buffer).\n\ |
|
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
898 PRINTFLAG controls printing of output:\n\ |
| 672 | 899 nil means discard it; anything else is stream for print.\n\ |
| 900 \n\ | |
|
16978
71aff157cff2
(Feval_buffer): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
16937
diff
changeset
|
901 This function preserves the position of point.") |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
902 (buffer, printflag) |
|
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
903 Lisp_Object buffer, printflag; |
| 672 | 904 { |
| 905 int count = specpdl_ptr - specpdl; | |
| 906 Lisp_Object tem, buf; | |
| 907 | |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
908 if (NILP (buffer)) |
| 672 | 909 buf = Fcurrent_buffer (); |
| 910 else | |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
911 buf = Fget_buffer (buffer); |
| 673 | 912 if (NILP (buf)) |
| 672 | 913 error ("No such buffer."); |
| 914 | |
| 673 | 915 if (NILP (printflag)) |
| 672 | 916 tem = Qsymbolp; |
| 917 else | |
| 918 tem = printflag; | |
| 919 specbind (Qstandard_output, tem); | |
| 920 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
| 921 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); | |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
922 readevalloop (buf, 0, XBUFFER (buf)->filename, Feval, !NILP (printflag)); |
|
1924
21bd3a2189d3
* keyboard.c (recursive_edit_1, command_loop_1): Pass the proper
Jim Blandy <jimb@redhat.com>
parents:
1887
diff
changeset
|
923 unbind_to (count, Qnil); |
| 672 | 924 |
| 925 return Qnil; | |
| 926 } | |
| 927 | |
| 928 #if 0 | |
| 341 | 929 DEFUN ("eval-current-buffer", Feval_current_buffer, Seval_current_buffer, 0, 1, "", |
| 930 "Execute the current buffer as Lisp code.\n\ | |
| 931 Programs can pass argument PRINTFLAG which controls printing of output:\n\ | |
| 932 nil means discard it; anything else is stream for print.\n\ | |
| 933 \n\ | |
| 934 If there is no error, point does not move. If there is an error,\n\ | |
| 935 point remains at the end of the last character read from the buffer.") | |
| 936 (printflag) | |
| 937 Lisp_Object printflag; | |
| 938 { | |
| 939 int count = specpdl_ptr - specpdl; | |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
940 Lisp_Object tem, cbuf; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
941 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
942 cbuf = Fcurrent_buffer () |
| 341 | 943 |
| 485 | 944 if (NILP (printflag)) |
| 341 | 945 tem = Qsymbolp; |
| 946 else | |
| 947 tem = printflag; | |
| 948 specbind (Qstandard_output, tem); | |
| 949 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
| 950 SET_PT (BEGV); | |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
951 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag)); |
| 341 | 952 return unbind_to (count, Qnil); |
| 953 } | |
| 672 | 954 #endif |
| 341 | 955 |
| 956 DEFUN ("eval-region", Feval_region, Seval_region, 2, 3, "r", | |
| 957 "Execute the region as Lisp code.\n\ | |
| 958 When called from programs, expects two arguments,\n\ | |
| 959 giving starting and ending indices in the current buffer\n\ | |
| 960 of the text to be executed.\n\ | |
| 961 Programs can pass third argument PRINTFLAG which controls output:\n\ | |
| 962 nil means discard it; anything else is stream for printing it.\n\ | |
| 963 \n\ | |
| 964 If there is no error, point does not move. If there is an error,\n\ | |
| 965 point remains at the end of the last character read from the buffer.") | |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
966 (start, end, printflag) |
|
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
967 Lisp_Object start, end, printflag; |
| 341 | 968 { |
| 969 int count = specpdl_ptr - specpdl; | |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
970 Lisp_Object tem, cbuf; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
971 |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
972 cbuf = Fcurrent_buffer (); |
| 341 | 973 |
| 485 | 974 if (NILP (printflag)) |
| 341 | 975 tem = Qsymbolp; |
| 976 else | |
| 977 tem = printflag; | |
| 978 specbind (Qstandard_output, tem); | |
| 979 | |
| 485 | 980 if (NILP (printflag)) |
| 341 | 981 record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
| 982 record_unwind_protect (save_restriction_restore, save_restriction_save ()); | |
| 983 | |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
984 /* This both uses start and checks its type. */ |
|
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
985 Fgoto_char (start); |
|
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
986 Fnarrow_to_region (make_number (BEGV), end); |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
987 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag)); |
| 341 | 988 |
| 989 return unbind_to (count, Qnil); | |
| 990 } | |
| 991 | |
| 992 #endif /* standalone */ | |
| 993 | |
| 994 DEFUN ("read", Fread, Sread, 0, 1, 0, | |
| 995 "Read one Lisp expression as text from STREAM, return as Lisp object.\n\ | |
| 996 If STREAM is nil, use the value of `standard-input' (which see).\n\ | |
| 997 STREAM or the value of `standard-input' may be:\n\ | |
| 998 a buffer (read from point and advance it)\n\ | |
| 999 a marker (read from where it points and advance it)\n\ | |
| 1000 a function (call it with no arguments for each character,\n\ | |
| 1001 call it with a char as argument to push a char back)\n\ | |
| 1002 a string (takes text from string, starting at the beginning)\n\ | |
| 1003 t (read text line using minibuffer and use it).") | |
|
12545
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1004 (stream) |
|
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1005 Lisp_Object stream; |
| 341 | 1006 { |
| 1007 extern Lisp_Object Fread_minibuffer (); | |
| 1008 | |
|
12545
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1009 if (NILP (stream)) |
|
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1010 stream = Vstandard_input; |
|
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1011 if (EQ (stream, Qt)) |
|
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1012 stream = Qread_char; |
| 341 | 1013 |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1014 new_backquote_flag = 0; |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1015 read_objects = Qnil; |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1016 |
| 341 | 1017 #ifndef standalone |
|
12545
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1018 if (EQ (stream, Qread_char)) |
| 341 | 1019 return Fread_minibuffer (build_string ("Lisp expression: "), Qnil); |
| 1020 #endif | |
| 1021 | |
|
12545
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1022 if (STRINGP (stream)) |
|
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1023 return Fcar (Fread_from_string (stream, Qnil, Qnil)); |
| 341 | 1024 |
|
12545
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1025 return read0 (stream); |
| 341 | 1026 } |
| 1027 | |
| 1028 DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0, | |
| 1029 "Read one Lisp expression which is represented as text by STRING.\n\ | |
| 1030 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\ | |
| 1031 START and END optionally delimit a substring of STRING from which to read;\n\ | |
| 1032 they default to 0 and (length STRING) respectively.") | |
| 1033 (string, start, end) | |
| 1034 Lisp_Object string, start, end; | |
| 1035 { | |
| 1036 int startval, endval; | |
| 1037 Lisp_Object tem; | |
| 1038 | |
| 1039 CHECK_STRING (string,0); | |
| 1040 | |
| 485 | 1041 if (NILP (end)) |
| 341 | 1042 endval = XSTRING (string)->size; |
| 1043 else | |
| 1044 { CHECK_NUMBER (end,2); | |
| 1045 endval = XINT (end); | |
| 1046 if (endval < 0 || endval > XSTRING (string)->size) | |
| 1047 args_out_of_range (string, end); | |
| 1048 } | |
| 1049 | |
| 485 | 1050 if (NILP (start)) |
| 341 | 1051 startval = 0; |
| 1052 else | |
| 1053 { CHECK_NUMBER (start,1); | |
| 1054 startval = XINT (start); | |
| 1055 if (startval < 0 || startval > endval) | |
| 1056 args_out_of_range (string, start); | |
| 1057 } | |
| 1058 | |
| 1059 read_from_string_index = startval; | |
| 1060 read_from_string_limit = endval; | |
| 1061 | |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1062 new_backquote_flag = 0; |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1063 read_objects = Qnil; |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1064 |
| 341 | 1065 tem = read0 (string); |
| 1066 return Fcons (tem, make_number (read_from_string_index)); | |
| 1067 } | |
| 1068 | |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1069 /* Use this for recursive reads, in contexts where internal tokens |
|
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1070 are not allowed. */ |
| 341 | 1071 static Lisp_Object |
| 1072 read0 (readcharfun) | |
| 1073 Lisp_Object readcharfun; | |
| 1074 { | |
| 1075 register Lisp_Object val; | |
| 1076 char c; | |
| 1077 | |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1078 val = read1 (readcharfun, &c, 0); |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1079 if (c) |
|
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1080 Fsignal (Qinvalid_read_syntax, Fcons (make_string (&c, 1), Qnil)); |
| 341 | 1081 |
| 1082 return val; | |
| 1083 } | |
| 1084 | |
| 1085 static int read_buffer_size; | |
| 1086 static char *read_buffer; | |
| 1087 | |
| 1088 static int | |
| 1089 read_escape (readcharfun) | |
| 1090 Lisp_Object readcharfun; | |
| 1091 { | |
| 1092 register int c = READCHAR; | |
| 1093 switch (c) | |
| 1094 { | |
|
15091
e05dd165b889
(close_load_descs) [WINDOWS_NT]: Don't actually do anything.
Richard M. Stallman <rms@gnu.org>
parents:
14972
diff
changeset
|
1095 case -1: |
|
e05dd165b889
(close_load_descs) [WINDOWS_NT]: Don't actually do anything.
Richard M. Stallman <rms@gnu.org>
parents:
14972
diff
changeset
|
1096 error ("End of file"); |
|
e05dd165b889
(close_load_descs) [WINDOWS_NT]: Don't actually do anything.
Richard M. Stallman <rms@gnu.org>
parents:
14972
diff
changeset
|
1097 |
| 341 | 1098 case 'a': |
| 485 | 1099 return '\007'; |
| 341 | 1100 case 'b': |
| 1101 return '\b'; | |
|
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1102 case 'd': |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1103 return 0177; |
| 341 | 1104 case 'e': |
| 1105 return 033; | |
| 1106 case 'f': | |
| 1107 return '\f'; | |
| 1108 case 'n': | |
| 1109 return '\n'; | |
| 1110 case 'r': | |
| 1111 return '\r'; | |
| 1112 case 't': | |
| 1113 return '\t'; | |
| 1114 case 'v': | |
| 1115 return '\v'; | |
| 1116 case '\n': | |
| 1117 return -1; | |
| 1118 | |
| 1119 case 'M': | |
| 1120 c = READCHAR; | |
| 1121 if (c != '-') | |
| 1122 error ("Invalid escape character syntax"); | |
| 1123 c = READCHAR; | |
| 1124 if (c == '\\') | |
| 1125 c = read_escape (readcharfun); | |
|
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1126 return c | meta_modifier; |
|
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1127 |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1128 case 'S': |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1129 c = READCHAR; |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1130 if (c != '-') |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1131 error ("Invalid escape character syntax"); |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1132 c = READCHAR; |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1133 if (c == '\\') |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1134 c = read_escape (readcharfun); |
|
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1135 return c | shift_modifier; |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1136 |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1137 case 'H': |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1138 c = READCHAR; |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1139 if (c != '-') |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1140 error ("Invalid escape character syntax"); |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1141 c = READCHAR; |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1142 if (c == '\\') |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1143 c = read_escape (readcharfun); |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1144 return c | hyper_modifier; |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1145 |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1146 case 'A': |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1147 c = READCHAR; |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1148 if (c != '-') |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1149 error ("Invalid escape character syntax"); |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1150 c = READCHAR; |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1151 if (c == '\\') |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1152 c = read_escape (readcharfun); |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1153 return c | alt_modifier; |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1154 |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1155 case 's': |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1156 c = READCHAR; |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1157 if (c != '-') |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1158 error ("Invalid escape character syntax"); |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1159 c = READCHAR; |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1160 if (c == '\\') |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1161 c = read_escape (readcharfun); |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1162 return c | super_modifier; |
| 341 | 1163 |
| 1164 case 'C': | |
| 1165 c = READCHAR; | |
| 1166 if (c != '-') | |
| 1167 error ("Invalid escape character syntax"); | |
| 1168 case '^': | |
| 1169 c = READCHAR; | |
| 1170 if (c == '\\') | |
| 1171 c = read_escape (readcharfun); | |
|
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1172 if ((c & 0177) == '?') |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1173 return 0177 | c; |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1174 /* ASCII control chars are made from letters (both cases), |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1175 as well as the non-letters within 0100...0137. */ |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1176 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132) |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1177 return (c & (037 | ~0177)); |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1178 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137) |
|
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1179 return (c & (037 | ~0177)); |
| 341 | 1180 else |
|
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1181 return c | ctrl_modifier; |
| 341 | 1182 |
| 1183 case '0': | |
| 1184 case '1': | |
| 1185 case '2': | |
| 1186 case '3': | |
| 1187 case '4': | |
| 1188 case '5': | |
| 1189 case '6': | |
| 1190 case '7': | |
| 1191 /* An octal escape, as in ANSI C. */ | |
| 1192 { | |
| 1193 register int i = c - '0'; | |
| 1194 register int count = 0; | |
| 1195 while (++count < 3) | |
| 1196 { | |
| 1197 if ((c = READCHAR) >= '0' && c <= '7') | |
| 1198 { | |
| 1199 i *= 8; | |
| 1200 i += c - '0'; | |
| 1201 } | |
| 1202 else | |
| 1203 { | |
| 1204 UNREAD (c); | |
| 1205 break; | |
| 1206 } | |
| 1207 } | |
| 1208 return i; | |
| 1209 } | |
| 1210 | |
| 1211 case 'x': | |
| 1212 /* A hex escape, as in ANSI C. */ | |
| 1213 { | |
| 1214 int i = 0; | |
| 1215 while (1) | |
| 1216 { | |
| 1217 c = READCHAR; | |
| 1218 if (c >= '0' && c <= '9') | |
| 1219 { | |
| 1220 i *= 16; | |
| 1221 i += c - '0'; | |
| 1222 } | |
| 1223 else if ((c >= 'a' && c <= 'f') | |
| 1224 || (c >= 'A' && c <= 'F')) | |
| 1225 { | |
| 1226 i *= 16; | |
| 1227 if (c >= 'a' && c <= 'f') | |
| 1228 i += c - 'a' + 10; | |
| 1229 else | |
| 1230 i += c - 'A' + 10; | |
| 1231 } | |
| 1232 else | |
| 1233 { | |
| 1234 UNREAD (c); | |
| 1235 break; | |
| 1236 } | |
| 1237 } | |
| 1238 return i; | |
| 1239 } | |
| 1240 | |
| 1241 default: | |
| 1242 return c; | |
| 1243 } | |
| 1244 } | |
| 1245 | |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1246 /* If the next token is ')' or ']' or '.', we store that character |
|
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1247 in *PCH and the return value is not interesting. Else, we store |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1248 zero in *PCH and we read and return one lisp object. |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1249 |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1250 FIRST_IN_LIST is nonzero if this is the first element of a list. */ |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1251 |
| 341 | 1252 static Lisp_Object |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1253 read1 (readcharfun, pch, first_in_list) |
| 341 | 1254 register Lisp_Object readcharfun; |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1255 char *pch; |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1256 int first_in_list; |
| 341 | 1257 { |
| 1258 register int c; | |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1259 int uninterned_symbol = 0; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1260 |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1261 *pch = 0; |
| 341 | 1262 |
| 1263 retry: | |
| 1264 | |
| 1265 c = READCHAR; | |
| 1266 if (c < 0) return Fsignal (Qend_of_file, Qnil); | |
| 1267 | |
| 1268 switch (c) | |
| 1269 { | |
| 1270 case '(': | |
| 1271 return read_list (0, readcharfun); | |
| 1272 | |
| 1273 case '[': | |
| 1274 return read_vector (readcharfun); | |
| 1275 | |
| 1276 case ')': | |
| 1277 case ']': | |
| 1278 { | |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1279 *pch = c; |
|
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1280 return Qnil; |
| 341 | 1281 } |
| 1282 | |
| 1283 case '#': | |
|
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1284 c = READCHAR; |
|
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1285 if (c == '^') |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1286 { |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1287 c = READCHAR; |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1288 if (c == '[') |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1289 { |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1290 Lisp_Object tmp; |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1291 tmp = read_vector (readcharfun); |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1292 if (XVECTOR (tmp)->size < CHAR_TABLE_STANDARD_SLOTS |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1293 || XVECTOR (tmp)->size > CHAR_TABLE_STANDARD_SLOTS + 10) |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1294 error ("Invalid size char-table"); |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1295 XSETCHAR_TABLE (tmp, XCHAR_TABLE (tmp)); |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1296 return tmp; |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1297 } |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1298 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#^", 2), Qnil)); |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1299 } |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1300 if (c == '&') |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1301 { |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1302 Lisp_Object length; |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1303 length = read1 (readcharfun, pch, first_in_list); |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1304 c = READCHAR; |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1305 if (c == '"') |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1306 { |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1307 Lisp_Object tmp, val; |
|
16925
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1308 int size_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1) |
|
13363
941c37982f37
(BITS_PER_SHORT, BITS_PER_INT, BITS_PER_LONG):
Karl Heuer <kwzh@gnu.org>
parents:
13235
diff
changeset
|
1309 / BITS_PER_CHAR); |
|
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1310 |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1311 UNREAD (c); |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1312 tmp = read1 (readcharfun, pch, first_in_list); |
|
16925
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1313 if (size_in_chars != XSTRING (tmp)->size |
|
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1314 /* We used to print 1 char too many |
|
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1315 when the number of bits was a multiple of 8. |
|
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1316 Accept such input in case it came from an old version. */ |
|
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1317 && ! (XFASTINT (length) |
|
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1318 == (XSTRING (tmp)->size - 1) * BITS_PER_CHAR)) |
|
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1319 Fsignal (Qinvalid_read_syntax, |
| 16856 | 1320 Fcons (make_string ("#&...", 5), Qnil)); |
|
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1321 |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1322 val = Fmake_bool_vector (length, Qnil); |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1323 bcopy (XSTRING (tmp)->data, XBOOL_VECTOR (val)->data, |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1324 size_in_chars); |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1325 return val; |
|
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1326 } |
| 16856 | 1327 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#&...", 5), |
|
16855
d10bb3a79eff
(read1): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
16487
diff
changeset
|
1328 Qnil)); |
|
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1329 } |
|
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1330 if (c == '[') |
|
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1331 { |
|
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1332 /* Accept compiled functions at read-time so that we don't have to |
|
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1333 build them using function calls. */ |
|
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1334 Lisp_Object tmp; |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1335 tmp = read_vector (readcharfun); |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1336 return Fmake_byte_code (XVECTOR (tmp)->size, |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1337 XVECTOR (tmp)->contents); |
|
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1338 } |
|
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1339 #ifdef USE_TEXT_PROPERTIES |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1340 if (c == '(') |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1341 { |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1342 Lisp_Object tmp; |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1343 struct gcpro gcpro1; |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1344 char ch; |
|
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1345 |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1346 /* Read the string itself. */ |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1347 tmp = read1 (readcharfun, &ch, 0); |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1348 if (ch != 0 || !STRINGP (tmp)) |
|
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1349 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1350 GCPRO1 (tmp); |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1351 /* Read the intervals and their properties. */ |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1352 while (1) |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1353 { |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1354 Lisp_Object beg, end, plist; |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1355 |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1356 beg = read1 (readcharfun, &ch, 0); |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1357 if (ch == ')') |
|
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1358 break; |
|
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1359 if (ch == 0) |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1360 end = read1 (readcharfun, &ch, 0); |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1361 if (ch == 0) |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1362 plist = read1 (readcharfun, &ch, 0); |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1363 if (ch) |
|
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1364 Fsignal (Qinvalid_read_syntax, |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1365 Fcons (build_string ("invalid string property list"), |
|
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1366 Qnil)); |
|
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1367 Fset_text_properties (beg, end, plist, tmp); |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1368 } |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1369 UNGCPRO; |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1370 return tmp; |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1371 } |
|
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1372 #endif |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1373 /* #@NUMBER is used to skip NUMBER following characters. |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1374 That's used in .elc files to skip over doc strings |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1375 and function definitions. */ |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1376 if (c == '@') |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1377 { |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1378 int i, nskip = 0; |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1379 |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1380 /* Read a decimal integer. */ |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1381 while ((c = READCHAR) >= 0 |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1382 && c >= '0' && c <= '9') |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1383 { |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1384 nskip *= 10; |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1385 nskip += c - '0'; |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1386 } |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1387 if (c >= 0) |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1388 UNREAD (c); |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1389 |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1390 #ifndef DOS_NT /* I don't know if filepos works right on MSDOS and Windoze. */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1391 if (load_force_doc_strings && EQ (readcharfun, Qget_file_char)) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1392 { |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1393 /* If we are supposed to force doc strings into core right now, |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1394 record the last string that we skipped, |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1395 and record where in the file it comes from. */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1396 if (saved_doc_string_size == 0) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1397 { |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1398 saved_doc_string_size = nskip + 100; |
|
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
1399 saved_doc_string = (char *) xmalloc (saved_doc_string_size); |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1400 } |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1401 if (nskip > saved_doc_string_size) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1402 { |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1403 saved_doc_string_size = nskip + 100; |
|
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
1404 saved_doc_string = (char *) xrealloc (saved_doc_string, |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
1405 saved_doc_string_size); |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1406 } |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1407 |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1408 saved_doc_string_position = ftell (instream); |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1409 |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1410 /* Copy that many characters into saved_doc_string. */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1411 for (i = 0; i < nskip && c >= 0; i++) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1412 saved_doc_string[i] = c = READCHAR; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1413 |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1414 saved_doc_string_length = i; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1415 } |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1416 else |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1417 #endif /* not DOS_NT */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1418 { |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1419 /* Skip that many characters. */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1420 for (i = 0; i < nskip && c >= 0; i++) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1421 c = READCHAR; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1422 } |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1423 goto retry; |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1424 } |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1425 if (c == '$') |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1426 return Vload_file_name; |
|
13235
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
1427 if (c == '\'') |
|
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
1428 return Fcons (Qfunction, Fcons (read0 (readcharfun), Qnil)); |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1429 /* #:foo is the uninterned symbol named foo. */ |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1430 if (c == ':') |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1431 { |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1432 uninterned_symbol = 1; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1433 c = READCHAR; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1434 goto default_label; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1435 } |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1436 /* Reader forms that can reuse previously read objects. */ |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1437 if (c >= '0' && c <= '9') |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1438 { |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1439 int n = 0; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1440 Lisp_Object tem; |
|
13235
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
1441 |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1442 /* Read a non-negative integer. */ |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1443 while (c >= '0' && c <= '9') |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1444 { |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1445 n *= 10; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1446 n += c - '0'; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1447 c = READCHAR; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1448 } |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1449 /* #n=object returns object, but associates it with n for #n#. */ |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1450 if (c == '=') |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1451 { |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1452 tem = read0 (readcharfun); |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1453 read_objects = Fcons (Fcons (make_number (n), tem), read_objects); |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1454 return tem; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1455 } |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1456 /* #n# returns a previously read object. */ |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1457 if (c == '#') |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1458 { |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1459 tem = Fassq (make_number (n), read_objects); |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1460 if (CONSP (tem)) |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1461 return XCDR (tem); |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1462 /* Fall through to error message. */ |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1463 } |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1464 /* Fall through to error message. */ |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1465 } |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1466 |
|
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1467 UNREAD (c); |
|
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1468 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); |
| 341 | 1469 |
| 1470 case ';': | |
| 1471 while ((c = READCHAR) >= 0 && c != '\n'); | |
| 1472 goto retry; | |
| 1473 | |
| 1474 case '\'': | |
| 1475 { | |
| 1476 return Fcons (Qquote, Fcons (read0 (readcharfun), Qnil)); | |
| 1477 } | |
| 1478 | |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1479 case '`': |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1480 if (first_in_list) |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1481 goto default_label; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1482 else |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1483 { |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1484 Lisp_Object value; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1485 |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1486 new_backquote_flag = 1; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1487 value = read0 (readcharfun); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1488 new_backquote_flag = 0; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1489 |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1490 return Fcons (Qbackquote, Fcons (value, Qnil)); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1491 } |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1492 |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1493 case ',': |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1494 if (new_backquote_flag) |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1495 { |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1496 Lisp_Object comma_type = Qnil; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1497 Lisp_Object value; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1498 int ch = READCHAR; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1499 |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1500 if (ch == '@') |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1501 comma_type = Qcomma_at; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1502 else if (ch == '.') |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1503 comma_type = Qcomma_dot; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1504 else |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1505 { |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1506 if (ch >= 0) UNREAD (ch); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1507 comma_type = Qcomma; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1508 } |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1509 |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1510 new_backquote_flag = 0; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1511 value = read0 (readcharfun); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1512 new_backquote_flag = 1; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1513 return Fcons (comma_type, Fcons (value, Qnil)); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1514 } |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1515 else |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1516 goto default_label; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1517 |
| 341 | 1518 case '?': |
| 1519 { | |
| 1520 register Lisp_Object val; | |
| 1521 | |
| 1522 c = READCHAR; | |
| 1523 if (c < 0) return Fsignal (Qend_of_file, Qnil); | |
| 1524 | |
| 1525 if (c == '\\') | |
|
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
1526 XSETINT (val, read_escape (readcharfun)); |
| 341 | 1527 else |
|
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
1528 XSETINT (val, c); |
| 341 | 1529 |
| 1530 return val; | |
| 1531 } | |
| 1532 | |
| 1533 case '\"': | |
| 1534 { | |
| 1535 register char *p = read_buffer; | |
| 1536 register char *end = read_buffer + read_buffer_size; | |
| 1537 register int c; | |
| 1538 int cancel = 0; | |
| 1539 | |
| 1540 while ((c = READCHAR) >= 0 | |
| 1541 && c != '\"') | |
| 1542 { | |
| 1543 if (p == end) | |
| 1544 { | |
| 1545 char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | |
| 1546 p += new - read_buffer; | |
| 1547 read_buffer += new - read_buffer; | |
| 1548 end = read_buffer + read_buffer_size; | |
| 1549 } | |
| 1550 if (c == '\\') | |
| 1551 c = read_escape (readcharfun); | |
| 1552 /* c is -1 if \ newline has just been seen */ | |
|
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1553 if (c == -1) |
| 341 | 1554 { |
| 1555 if (p == read_buffer) | |
| 1556 cancel = 1; | |
| 1557 } | |
| 1558 else | |
|
6470
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1559 { |
|
7144
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1560 /* Allow `\C- ' and `\C-?'. */ |
|
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1561 if (c == (CHAR_CTL | ' ')) |
|
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1562 c = 0; |
|
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1563 else if (c == (CHAR_CTL | '?')) |
|
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1564 c = 127; |
|
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1565 |
|
6470
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1566 if (c & CHAR_META) |
|
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1567 /* Move the meta bit to the right place for a string. */ |
|
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1568 c = (c & ~CHAR_META) | 0x80; |
|
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1569 if (c & ~0xff) |
|
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1570 error ("Invalid modifier in string"); |
|
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1571 *p++ = c; |
|
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1572 } |
| 341 | 1573 } |
| 1574 if (c < 0) return Fsignal (Qend_of_file, Qnil); | |
| 1575 | |
| 1576 /* If purifying, and string starts with \ newline, | |
| 1577 return zero instead. This is for doc strings | |
| 604 | 1578 that we are really going to find in etc/DOC.nn.nn */ |
| 485 | 1579 if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel) |
| 341 | 1580 return make_number (0); |
| 1581 | |
| 1582 if (read_pure) | |
| 1583 return make_pure_string (read_buffer, p - read_buffer); | |
| 1584 else | |
| 1585 return make_string (read_buffer, p - read_buffer); | |
| 1586 } | |
| 1587 | |
| 762 | 1588 case '.': |
| 1589 { | |
| 1590 #ifdef LISP_FLOAT_TYPE | |
| 1591 /* If a period is followed by a number, then we should read it | |
| 1592 as a floating point number. Otherwise, it denotes a dotted | |
| 1593 pair. */ | |
| 1594 int next_char = READCHAR; | |
| 1595 UNREAD (next_char); | |
| 1596 | |
| 9871 | 1597 if (! (next_char >= '0' && next_char <= '9')) |
| 762 | 1598 #endif |
| 1599 { | |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1600 *pch = c; |
|
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1601 return Qnil; |
| 762 | 1602 } |
| 1603 | |
| 1604 /* Otherwise, we fall through! Note that the atom-reading loop | |
| 1605 below will now loop at least once, assuring that we will not | |
| 1606 try to UNREAD two characters in a row. */ | |
| 1607 } | |
| 341 | 1608 default: |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1609 default_label: |
| 341 | 1610 if (c <= 040) goto retry; |
| 1611 { | |
| 1612 register char *p = read_buffer; | |
|
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1613 int quoted = 0; |
| 341 | 1614 |
| 1615 { | |
| 1616 register char *end = read_buffer + read_buffer_size; | |
| 1617 | |
| 1618 while (c > 040 && | |
| 1619 !(c == '\"' || c == '\'' || c == ';' || c == '?' | |
| 1620 || c == '(' || c == ')' | |
| 762 | 1621 #ifndef LISP_FLOAT_TYPE |
| 1622 /* If we have floating-point support, then we need | |
| 1623 to allow <digits><dot><digits>. */ | |
| 341 | 1624 || c =='.' |
| 1625 #endif /* not LISP_FLOAT_TYPE */ | |
| 1626 || c == '[' || c == ']' || c == '#' | |
| 1627 )) | |
| 1628 { | |
| 1629 if (p == end) | |
| 1630 { | |
| 1631 register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | |
| 1632 p += new - read_buffer; | |
| 1633 read_buffer += new - read_buffer; | |
| 1634 end = read_buffer + read_buffer_size; | |
| 1635 } | |
| 1636 if (c == '\\') | |
|
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1637 { |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1638 c = READCHAR; |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1639 quoted = 1; |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1640 } |
| 341 | 1641 *p++ = c; |
| 1642 c = READCHAR; | |
| 1643 } | |
| 1644 | |
| 1645 if (p == end) | |
| 1646 { | |
| 1647 char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | |
| 1648 p += new - read_buffer; | |
| 1649 read_buffer += new - read_buffer; | |
| 1650 /* end = read_buffer + read_buffer_size; */ | |
| 1651 } | |
| 1652 *p = 0; | |
| 1653 if (c >= 0) | |
| 1654 UNREAD (c); | |
| 1655 } | |
| 1656 | |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1657 if (!quoted && !uninterned_symbol) |
|
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1658 { |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1659 register char *p1; |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1660 register Lisp_Object val; |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1661 p1 = read_buffer; |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1662 if (*p1 == '+' || *p1 == '-') p1++; |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1663 /* Is it an integer? */ |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1664 if (p1 != p) |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1665 { |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1666 while (p1 != p && (c = *p1) >= '0' && c <= '9') p1++; |
|
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1667 #ifdef LISP_FLOAT_TYPE |
|
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1668 /* Integers can have trailing decimal points. */ |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1669 if (p1 > read_buffer && p1 < p && *p1 == '.') p1++; |
|
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1670 #endif |
|
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1671 if (p1 == p) |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1672 /* It is an integer. */ |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1673 { |
|
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1674 #ifdef LISP_FLOAT_TYPE |
|
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1675 if (p1[-1] == '.') |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1676 p1[-1] = '\0'; |
|
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1677 #endif |
|
11699
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
1678 if (sizeof (int) == sizeof (EMACS_INT)) |
|
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
1679 XSETINT (val, atoi (read_buffer)); |
|
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
1680 else if (sizeof (long) == sizeof (EMACS_INT)) |
|
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
1681 XSETINT (val, atol (read_buffer)); |
|
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
1682 else |
|
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
1683 abort (); |
|
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1684 return val; |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1685 } |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1686 } |
| 341 | 1687 #ifdef LISP_FLOAT_TYPE |
|
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1688 if (isfloat_string (read_buffer)) |
|
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1689 return make_float (atof (read_buffer)); |
| 341 | 1690 #endif |
|
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
1691 } |
| 341 | 1692 |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1693 if (uninterned_symbol) |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1694 return make_symbol (read_buffer); |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1695 else |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1696 return intern (read_buffer); |
| 341 | 1697 } |
| 1698 } | |
| 1699 } | |
| 1700 | |
| 1701 #ifdef LISP_FLOAT_TYPE | |
| 1702 | |
| 1703 #define LEAD_INT 1 | |
| 1704 #define DOT_CHAR 2 | |
| 1705 #define TRAIL_INT 4 | |
| 1706 #define E_CHAR 8 | |
| 1707 #define EXP_INT 16 | |
| 1708 | |
| 1709 int | |
| 1710 isfloat_string (cp) | |
| 1711 register char *cp; | |
| 1712 { | |
| 1713 register state; | |
| 1714 | |
| 1715 state = 0; | |
| 1716 if (*cp == '+' || *cp == '-') | |
| 1717 cp++; | |
| 1718 | |
| 9871 | 1719 if (*cp >= '0' && *cp <= '9') |
| 341 | 1720 { |
| 1721 state |= LEAD_INT; | |
| 9871 | 1722 while (*cp >= '0' && *cp <= '9') |
| 1723 cp++; | |
| 341 | 1724 } |
| 1725 if (*cp == '.') | |
| 1726 { | |
| 1727 state |= DOT_CHAR; | |
| 1728 cp++; | |
| 1729 } | |
| 9871 | 1730 if (*cp >= '0' && *cp <= '9') |
| 341 | 1731 { |
| 1732 state |= TRAIL_INT; | |
| 9871 | 1733 while (*cp >= '0' && *cp <= '9') |
| 341 | 1734 cp++; |
| 1735 } | |
|
16342
b91af71f45f1
(isfloat_string): Accept E like e.
Richard M. Stallman <rms@gnu.org>
parents:
16228
diff
changeset
|
1736 if (*cp == 'e' || *cp == 'E') |
| 341 | 1737 { |
| 1738 state |= E_CHAR; | |
| 1739 cp++; | |
|
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
1740 if (*cp == '+' || *cp == '-') |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
1741 cp++; |
| 341 | 1742 } |
| 1743 | |
| 9871 | 1744 if (*cp >= '0' && *cp <= '9') |
| 341 | 1745 { |
| 1746 state |= EXP_INT; | |
| 9871 | 1747 while (*cp >= '0' && *cp <= '9') |
| 341 | 1748 cp++; |
| 1749 } | |
|
11172
e1ca77e22c12
(isfloat_string): Permit trailing space.
Richard M. Stallman <rms@gnu.org>
parents:
11079
diff
changeset
|
1750 return (((*cp == 0) || (*cp == ' ') || (*cp == '\t') || (*cp == '\n') || (*cp == '\r') || (*cp == '\f')) |
| 341 | 1751 && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT) |
| 826 | 1752 || state == (DOT_CHAR|TRAIL_INT) |
| 341 | 1753 || state == (LEAD_INT|E_CHAR|EXP_INT) |
| 826 | 1754 || state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT) |
| 1755 || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT))); | |
| 341 | 1756 } |
| 1757 #endif /* LISP_FLOAT_TYPE */ | |
| 1758 | |
| 1759 static Lisp_Object | |
| 1760 read_vector (readcharfun) | |
| 1761 Lisp_Object readcharfun; | |
| 1762 { | |
| 1763 register int i; | |
| 1764 register int size; | |
| 1765 register Lisp_Object *ptr; | |
| 1766 register Lisp_Object tem, vector; | |
| 1767 register struct Lisp_Cons *otem; | |
| 1768 Lisp_Object len; | |
| 1769 | |
| 1770 tem = read_list (1, readcharfun); | |
| 1771 len = Flength (tem); | |
| 1772 vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil)); | |
| 1773 | |
| 1774 | |
| 1775 size = XVECTOR (vector)->size; | |
| 1776 ptr = XVECTOR (vector)->contents; | |
| 1777 for (i = 0; i < size; i++) | |
| 1778 { | |
| 1779 ptr[i] = read_pure ? Fpurecopy (Fcar (tem)) : Fcar (tem); | |
| 1780 otem = XCONS (tem); | |
| 1781 tem = Fcdr (tem); | |
| 1782 free_cons (otem); | |
| 1783 } | |
| 1784 return vector; | |
| 1785 } | |
| 1786 | |
| 1787 /* flag = 1 means check for ] to terminate rather than ) and . | |
| 1788 flag = -1 means check for starting with defun | |
| 1789 and make structure pure. */ | |
| 1790 | |
| 1791 static Lisp_Object | |
| 1792 read_list (flag, readcharfun) | |
| 1793 int flag; | |
| 1794 register Lisp_Object readcharfun; | |
| 1795 { | |
| 1796 /* -1 means check next element for defun, | |
| 1797 0 means don't check, | |
| 1798 1 means already checked and found defun. */ | |
| 1799 int defunflag = flag < 0 ? -1 : 0; | |
| 1800 Lisp_Object val, tail; | |
| 1801 register Lisp_Object elt, tem; | |
| 1802 struct gcpro gcpro1, gcpro2; | |
|
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1803 /* 0 is the normal case. |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1804 1 means this list is a doc reference; replace it with the number 0. |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1805 2 means this list is a doc reference; replace it with the doc string. */ |
|
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1806 int doc_reference = 0; |
| 341 | 1807 |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1808 /* Initialize this to 1 if we are reading a list. */ |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1809 int first_in_list = flag <= 0; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1810 |
| 341 | 1811 val = Qnil; |
| 1812 tail = Qnil; | |
| 1813 | |
| 1814 while (1) | |
| 1815 { | |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1816 char ch; |
| 341 | 1817 GCPRO2 (val, tail); |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1818 elt = read1 (readcharfun, &ch, first_in_list); |
| 341 | 1819 UNGCPRO; |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1820 |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1821 first_in_list = 0; |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1822 |
|
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1823 /* While building, if the list starts with #$, treat it specially. */ |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1824 if (EQ (elt, Vload_file_name) |
|
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1825 && !NILP (Vpurify_flag)) |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1826 { |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1827 if (NILP (Vdoc_file_name)) |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1828 /* We have not yet called Snarf-documentation, so assume |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1829 this file is described in the DOC-MM.NN file |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1830 and Snarf-documentation will fill in the right value later. |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1831 For now, replace the whole list with 0. */ |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1832 doc_reference = 1; |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1833 else |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1834 /* We have already called Snarf-documentation, so make a relative |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1835 file name for this file, so it can be found properly |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1836 in the installed Lisp directory. |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1837 We don't use Fexpand_file_name because that would make |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1838 the directory absolute now. */ |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1839 elt = concat2 (build_string ("../lisp/"), |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1840 Ffile_name_nondirectory (elt)); |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1841 } |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1842 else if (EQ (elt, Vload_file_name) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1843 && load_force_doc_strings) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1844 doc_reference = 2; |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1845 |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1846 if (ch) |
| 341 | 1847 { |
| 1848 if (flag > 0) | |
| 1849 { | |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1850 if (ch == ']') |
| 341 | 1851 return val; |
|
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1852 Fsignal (Qinvalid_read_syntax, |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1853 Fcons (make_string (") or . in a vector", 18), Qnil)); |
| 341 | 1854 } |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1855 if (ch == ')') |
| 341 | 1856 return val; |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1857 if (ch == '.') |
| 341 | 1858 { |
| 1859 GCPRO2 (val, tail); | |
| 485 | 1860 if (!NILP (tail)) |
| 341 | 1861 XCONS (tail)->cdr = read0 (readcharfun); |
| 1862 else | |
| 1863 val = read0 (readcharfun); | |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1864 read1 (readcharfun, &ch, 0); |
| 341 | 1865 UNGCPRO; |
|
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1866 if (ch == ')') |
|
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1867 { |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1868 if (doc_reference == 1) |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1869 return make_number (0); |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1870 if (doc_reference == 2) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1871 { |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1872 /* Get a doc string from the file we are loading. |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1873 If it's in saved_doc_string, get it from there. */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1874 int pos = XINT (XCONS (val)->cdr); |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1875 if (pos >= saved_doc_string_position |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1876 && pos < (saved_doc_string_position |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1877 + saved_doc_string_length)) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1878 { |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1879 int start = pos - saved_doc_string_position; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1880 int from, to; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1881 |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1882 /* Process quoting with ^A, |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1883 and find the end of the string, |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1884 which is marked with ^_ (037). */ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1885 for (from = start, to = start; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1886 saved_doc_string[from] != 037;) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1887 { |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1888 int c = saved_doc_string[from++]; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1889 if (c == 1) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1890 { |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1891 c = saved_doc_string[from++]; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1892 if (c == 1) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1893 saved_doc_string[to++] = c; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1894 else if (c == '0') |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1895 saved_doc_string[to++] = 0; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1896 else if (c == '_') |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1897 saved_doc_string[to++] = 037; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1898 } |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1899 else |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1900 saved_doc_string[to++] = c; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1901 } |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1902 |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1903 return make_string (saved_doc_string + start, |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1904 to - start); |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1905 } |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1906 else |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1907 return read_doc_string (val); |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1908 } |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1909 |
|
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1910 return val; |
|
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
1911 } |
| 341 | 1912 return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil)); |
| 1913 } | |
| 1914 return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil)); | |
| 1915 } | |
| 1916 tem = (read_pure && flag <= 0 | |
| 1917 ? pure_cons (elt, Qnil) | |
| 1918 : Fcons (elt, Qnil)); | |
| 485 | 1919 if (!NILP (tail)) |
| 341 | 1920 XCONS (tail)->cdr = tem; |
| 1921 else | |
| 1922 val = tem; | |
| 1923 tail = tem; | |
| 1924 if (defunflag < 0) | |
| 1925 defunflag = EQ (elt, Qdefun); | |
| 1926 else if (defunflag > 0) | |
| 1927 read_pure = 1; | |
| 1928 } | |
| 1929 } | |
| 1930 | |
| 1931 Lisp_Object Vobarray; | |
| 1932 Lisp_Object initial_obarray; | |
| 1933 | |
|
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1934 /* oblookup stores the bucket number here, for the sake of Funintern. */ |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1935 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1936 int oblookup_last_bucket_number; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1937 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1938 static int hash_string (); |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1939 Lisp_Object oblookup (); |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1940 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1941 /* Get an error if OBARRAY is not an obarray. |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1942 If it is one, return it. */ |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1943 |
| 341 | 1944 Lisp_Object |
| 1945 check_obarray (obarray) | |
| 1946 Lisp_Object obarray; | |
| 1947 { | |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
1948 while (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) |
| 341 | 1949 { |
| 1950 /* If Vobarray is now invalid, force it to be valid. */ | |
| 1951 if (EQ (Vobarray, obarray)) Vobarray = initial_obarray; | |
| 1952 | |
| 1953 obarray = wrong_type_argument (Qvectorp, obarray); | |
| 1954 } | |
| 1955 return obarray; | |
| 1956 } | |
| 1957 | |
|
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1958 /* Intern the C string STR: return a symbol with that name, |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1959 interned in the current obarray. */ |
| 341 | 1960 |
| 1961 Lisp_Object | |
| 1962 intern (str) | |
| 1963 char *str; | |
| 1964 { | |
| 1965 Lisp_Object tem; | |
| 1966 int len = strlen (str); | |
|
6503
7c566d0e4b3d
(read_filtered_event, intern): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6471
diff
changeset
|
1967 Lisp_Object obarray; |
| 341 | 1968 |
|
6503
7c566d0e4b3d
(read_filtered_event, intern): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6471
diff
changeset
|
1969 obarray = Vobarray; |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
1970 if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) |
| 341 | 1971 obarray = check_obarray (obarray); |
| 1972 tem = oblookup (obarray, str, len); | |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
1973 if (SYMBOLP (tem)) |
| 341 | 1974 return tem; |
| 485 | 1975 return Fintern ((!NILP (Vpurify_flag) |
| 341 | 1976 ? make_pure_string (str, len) |
| 1977 : make_string (str, len)), | |
| 1978 obarray); | |
| 1979 } | |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1980 |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1981 /* Create an uninterned symbol with name STR. */ |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1982 |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1983 Lisp_Object |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1984 make_symbol (str) |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1985 char *str; |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1986 { |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1987 int len = strlen (str); |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1988 |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1989 return Fmake_symbol ((!NILP (Vpurify_flag) |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1990 ? make_pure_string (str, len) |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1991 : make_string (str, len))); |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1992 } |
|
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
1993 |
| 341 | 1994 DEFUN ("intern", Fintern, Sintern, 1, 2, 0, |
| 1995 "Return the canonical symbol whose name is STRING.\n\ | |
| 1996 If there is none, one is created by this function and returned.\n\ | |
| 1997 A second optional argument specifies the obarray to use;\n\ | |
| 1998 it defaults to the value of `obarray'.") | |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
1999 (string, obarray) |
|
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2000 Lisp_Object string, obarray; |
| 341 | 2001 { |
| 2002 register Lisp_Object tem, sym, *ptr; | |
| 2003 | |
| 485 | 2004 if (NILP (obarray)) obarray = Vobarray; |
| 341 | 2005 obarray = check_obarray (obarray); |
| 2006 | |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2007 CHECK_STRING (string, 0); |
| 341 | 2008 |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2009 tem = oblookup (obarray, XSTRING (string)->data, XSTRING (string)->size); |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2010 if (!INTEGERP (tem)) |
| 341 | 2011 return tem; |
| 2012 | |
| 485 | 2013 if (!NILP (Vpurify_flag)) |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2014 string = Fpurecopy (string); |
|
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2015 sym = Fmake_symbol (string); |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2016 XSYMBOL (sym)->obarray = obarray; |
| 341 | 2017 |
| 2018 ptr = &XVECTOR (obarray)->contents[XINT (tem)]; | |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2019 if (SYMBOLP (*ptr)) |
| 341 | 2020 XSYMBOL (sym)->next = XSYMBOL (*ptr); |
| 2021 else | |
| 2022 XSYMBOL (sym)->next = 0; | |
| 2023 *ptr = sym; | |
| 2024 return sym; | |
| 2025 } | |
| 2026 | |
| 2027 DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0, | |
| 2028 "Return the canonical symbol whose name is STRING, or nil if none exists.\n\ | |
| 2029 A second optional argument specifies the obarray to use;\n\ | |
| 2030 it defaults to the value of `obarray'.") | |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2031 (string, obarray) |
|
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2032 Lisp_Object string, obarray; |
| 341 | 2033 { |
| 2034 register Lisp_Object tem; | |
| 2035 | |
| 485 | 2036 if (NILP (obarray)) obarray = Vobarray; |
| 341 | 2037 obarray = check_obarray (obarray); |
| 2038 | |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2039 CHECK_STRING (string, 0); |
| 341 | 2040 |
|
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2041 tem = oblookup (obarray, XSTRING (string)->data, XSTRING (string)->size); |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2042 if (!INTEGERP (tem)) |
| 341 | 2043 return tem; |
| 2044 return Qnil; | |
| 2045 } | |
|
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2046 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2047 DEFUN ("unintern", Funintern, Sunintern, 1, 2, 0, |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2048 "Delete the symbol named NAME, if any, from OBARRAY.\n\ |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2049 The value is t if a symbol was found and deleted, nil otherwise.\n\ |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2050 NAME may be a string or a symbol. If it is a symbol, that symbol\n\ |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2051 is deleted, if it belongs to OBARRAY--no other symbol is deleted.\n\ |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2052 OBARRAY defaults to the value of the variable `obarray'.") |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2053 (name, obarray) |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2054 Lisp_Object name, obarray; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2055 { |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2056 register Lisp_Object string, tem; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2057 int hash; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2058 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2059 if (NILP (obarray)) obarray = Vobarray; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2060 obarray = check_obarray (obarray); |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2061 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2062 if (SYMBOLP (name)) |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2063 XSETSTRING (string, XSYMBOL (name)->name); |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2064 else |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2065 { |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2066 CHECK_STRING (name, 0); |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2067 string = name; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2068 } |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2069 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2070 tem = oblookup (obarray, XSTRING (string)->data, XSTRING (string)->size); |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2071 if (INTEGERP (tem)) |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2072 return Qnil; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2073 /* If arg was a symbol, don't delete anything but that symbol itself. */ |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2074 if (SYMBOLP (name) && !EQ (name, tem)) |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2075 return Qnil; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2076 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2077 hash = oblookup_last_bucket_number; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2078 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2079 if (EQ (XVECTOR (obarray)->contents[hash], tem)) |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2080 { |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2081 if (XSYMBOL (tem)->next) |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2082 XSETSYMBOL (XVECTOR (obarray)->contents[hash], XSYMBOL (tem)->next); |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2083 else |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2084 XSETINT (XVECTOR (obarray)->contents[hash], 0); |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2085 } |
|
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2086 else |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2087 { |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2088 Lisp_Object tail, following; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2089 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2090 for (tail = XVECTOR (obarray)->contents[hash]; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2091 XSYMBOL (tail)->next; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2092 tail = following) |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2093 { |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2094 XSETSYMBOL (following, XSYMBOL (tail)->next); |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2095 if (EQ (following, tem)) |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2096 { |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2097 XSYMBOL (tail)->next = XSYMBOL (following)->next; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2098 break; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2099 } |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2100 } |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2101 } |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2102 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2103 return Qt; |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2104 } |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2105 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2106 /* Return the symbol in OBARRAY whose names matches the string |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2107 of SIZE characters at PTR. If there is no such symbol in OBARRAY, |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2108 return nil. |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2109 |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2110 Also store the bucket number in oblookup_last_bucket_number. */ |
| 341 | 2111 |
| 2112 Lisp_Object | |
|
11868
129b45ef421b
(oblookup): Delete argument hashp.
Karl Heuer <kwzh@gnu.org>
parents:
11735
diff
changeset
|
2113 oblookup (obarray, ptr, size) |
| 341 | 2114 Lisp_Object obarray; |
| 2115 register char *ptr; | |
| 2116 register int size; | |
| 2117 { | |
| 8828 | 2118 int hash; |
| 2119 int obsize; | |
| 341 | 2120 register Lisp_Object tail; |
| 2121 Lisp_Object bucket, tem; | |
| 2122 | |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2123 if (!VECTORP (obarray) |
| 5243 | 2124 || (obsize = XVECTOR (obarray)->size) == 0) |
| 341 | 2125 { |
| 2126 obarray = check_obarray (obarray); | |
| 2127 obsize = XVECTOR (obarray)->size; | |
| 2128 } | |
|
13455
4f5a9ce67782
(oblookup): Clear ARRAY_MARK_FLAG in obsize.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
2129 /* This is sometimes needed in the middle of GC. */ |
|
4f5a9ce67782
(oblookup): Clear ARRAY_MARK_FLAG in obsize.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
2130 obsize &= ~ARRAY_MARK_FLAG; |
| 341 | 2131 /* Combining next two lines breaks VMS C 2.3. */ |
| 2132 hash = hash_string (ptr, size); | |
| 2133 hash %= obsize; | |
| 2134 bucket = XVECTOR (obarray)->contents[hash]; | |
|
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2135 oblookup_last_bucket_number = hash; |
| 341 | 2136 if (XFASTINT (bucket) == 0) |
| 2137 ; | |
|
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2138 else if (!SYMBOLP (bucket)) |
| 341 | 2139 error ("Bad data in guts of obarray"); /* Like CADR error message */ |
|
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2140 else |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2141 for (tail = bucket; ; XSETSYMBOL (tail, XSYMBOL (tail)->next)) |
| 341 | 2142 { |
|
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2143 if (XSYMBOL (tail)->name->size == size |
|
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2144 && !bcmp (XSYMBOL (tail)->name->data, ptr, size)) |
| 341 | 2145 return tail; |
| 2146 else if (XSYMBOL (tail)->next == 0) | |
| 2147 break; | |
| 2148 } | |
|
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
2149 XSETINT (tem, hash); |
| 341 | 2150 return tem; |
| 2151 } | |
| 2152 | |
| 2153 static int | |
| 2154 hash_string (ptr, len) | |
| 2155 unsigned char *ptr; | |
| 2156 int len; | |
| 2157 { | |
| 2158 register unsigned char *p = ptr; | |
| 2159 register unsigned char *end = p + len; | |
| 2160 register unsigned char c; | |
| 2161 register int hash = 0; | |
| 2162 | |
| 2163 while (p != end) | |
| 2164 { | |
| 2165 c = *p++; | |
| 2166 if (c >= 0140) c -= 40; | |
| 2167 hash = ((hash<<3) + (hash>>28) + c); | |
| 2168 } | |
| 2169 return hash & 07777777777; | |
| 2170 } | |
|
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2171 |
| 341 | 2172 void |
| 2173 map_obarray (obarray, fn, arg) | |
| 2174 Lisp_Object obarray; | |
| 2175 int (*fn) (); | |
| 2176 Lisp_Object arg; | |
| 2177 { | |
| 2178 register int i; | |
| 2179 register Lisp_Object tail; | |
| 2180 CHECK_VECTOR (obarray, 1); | |
| 2181 for (i = XVECTOR (obarray)->size - 1; i >= 0; i--) | |
| 2182 { | |
| 2183 tail = XVECTOR (obarray)->contents[i]; | |
| 2184 if (XFASTINT (tail) != 0) | |
| 2185 while (1) | |
| 2186 { | |
| 2187 (*fn) (tail, arg); | |
| 2188 if (XSYMBOL (tail)->next == 0) | |
| 2189 break; | |
|
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
2190 XSETSYMBOL (tail, XSYMBOL (tail)->next); |
| 341 | 2191 } |
| 2192 } | |
| 2193 } | |
| 2194 | |
| 2195 mapatoms_1 (sym, function) | |
| 2196 Lisp_Object sym, function; | |
| 2197 { | |
| 2198 call1 (function, sym); | |
| 2199 } | |
| 2200 | |
| 2201 DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0, | |
| 2202 "Call FUNCTION on every symbol in OBARRAY.\n\ | |
| 2203 OBARRAY defaults to the value of `obarray'.") | |
| 2204 (function, obarray) | |
| 2205 Lisp_Object function, obarray; | |
| 2206 { | |
| 2207 Lisp_Object tem; | |
| 2208 | |
| 485 | 2209 if (NILP (obarray)) obarray = Vobarray; |
| 341 | 2210 obarray = check_obarray (obarray); |
| 2211 | |
| 2212 map_obarray (obarray, mapatoms_1, function); | |
| 2213 return Qnil; | |
| 2214 } | |
| 2215 | |
|
5117
951396781a0e
(OBARRAY_SIZE): Increase from 509.
Richard M. Stallman <rms@gnu.org>
parents:
5017
diff
changeset
|
2216 #define OBARRAY_SIZE 1511 |
| 341 | 2217 |
| 2218 void | |
| 2219 init_obarray () | |
| 2220 { | |
| 2221 Lisp_Object oblength; | |
| 2222 int hash; | |
| 2223 Lisp_Object *tem; | |
| 2224 | |
|
9313
ed68c3822e4b
(read_filtered_event, init_obarray): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9274
diff
changeset
|
2225 XSETFASTINT (oblength, OBARRAY_SIZE); |
| 341 | 2226 |
| 2227 Qnil = Fmake_symbol (make_pure_string ("nil", 3)); | |
| 2228 Vobarray = Fmake_vector (oblength, make_number (0)); | |
| 2229 initial_obarray = Vobarray; | |
| 2230 staticpro (&initial_obarray); | |
| 2231 /* Intern nil in the obarray */ | |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2232 XSYMBOL (Qnil)->obarray = Vobarray; |
| 341 | 2233 /* These locals are to kludge around a pyramid compiler bug. */ |
| 2234 hash = hash_string ("nil", 3); | |
| 2235 /* Separate statement here to avoid VAXC bug. */ | |
| 2236 hash %= OBARRAY_SIZE; | |
| 2237 tem = &XVECTOR (Vobarray)->contents[hash]; | |
| 2238 *tem = Qnil; | |
| 2239 | |
| 2240 Qunbound = Fmake_symbol (make_pure_string ("unbound", 7)); | |
| 2241 XSYMBOL (Qnil)->function = Qunbound; | |
| 2242 XSYMBOL (Qunbound)->value = Qunbound; | |
| 2243 XSYMBOL (Qunbound)->function = Qunbound; | |
| 2244 | |
| 2245 Qt = intern ("t"); | |
| 2246 XSYMBOL (Qnil)->value = Qnil; | |
| 2247 XSYMBOL (Qnil)->plist = Qnil; | |
| 2248 XSYMBOL (Qt)->value = Qt; | |
| 2249 | |
| 2250 /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */ | |
| 2251 Vpurify_flag = Qt; | |
| 2252 | |
| 2253 Qvariable_documentation = intern ("variable-documentation"); | |
|
16228
fa7a56c543df
(init_obarray): staticpro Qvariable_documentation.
Erik Naggum <erik@naggum.no>
parents:
16165
diff
changeset
|
2254 staticpro (&Qvariable_documentation); |
| 341 | 2255 |
| 2256 read_buffer_size = 100; | |
| 2257 read_buffer = (char *) malloc (read_buffer_size); | |
| 2258 } | |
| 2259 | |
| 2260 void | |
| 2261 defsubr (sname) | |
| 2262 struct Lisp_Subr *sname; | |
| 2263 { | |
| 2264 Lisp_Object sym; | |
| 2265 sym = intern (sname->symbol_name); | |
|
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
2266 XSETSUBR (XSYMBOL (sym)->function, sname); |
| 341 | 2267 } |
| 2268 | |
| 2269 #ifdef NOTDEF /* use fset in subr.el now */ | |
| 2270 void | |
| 2271 defalias (sname, string) | |
| 2272 struct Lisp_Subr *sname; | |
| 2273 char *string; | |
| 2274 { | |
| 2275 Lisp_Object sym; | |
| 2276 sym = intern (string); | |
|
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
2277 XSETSUBR (XSYMBOL (sym)->function, sname); |
| 341 | 2278 } |
| 2279 #endif /* NOTDEF */ | |
| 2280 | |
| 2281 /* Define an "integer variable"; a symbol whose value is forwarded | |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2282 to a C variable of type int. Sample call: */ |
|
10606
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2283 /* DEFVAR_INT ("indent-tabs-mode", &indent_tabs_mode, "Documentation"); */ |
| 341 | 2284 void |
|
7765
688637ba31c5
(defvar_bool, defvar_int, defvar_lisp, defvar_lisp_nopro):
Richard M. Stallman <rms@gnu.org>
parents:
7675
diff
changeset
|
2285 defvar_int (namestring, address) |
| 341 | 2286 char *namestring; |
| 2287 int *address; | |
| 2288 { | |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2289 Lisp_Object sym, val; |
| 341 | 2290 sym = intern (namestring); |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2291 val = allocate_misc (); |
|
11242
36e8e27c8625
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_kboard)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2292 XMISCTYPE (val) = Lisp_Misc_Intfwd; |
|
9913
c921977bb0ce
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_per_buffer): Use accessor
Karl Heuer <kwzh@gnu.org>
parents:
9871
diff
changeset
|
2293 XINTFWD (val)->intvar = address; |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2294 XSYMBOL (sym)->value = val; |
| 341 | 2295 } |
| 2296 | |
| 2297 /* Similar but define a variable whose value is T if address contains 1, | |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2298 NIL if address contains 0 */ |
| 341 | 2299 void |
|
7765
688637ba31c5
(defvar_bool, defvar_int, defvar_lisp, defvar_lisp_nopro):
Richard M. Stallman <rms@gnu.org>
parents:
7675
diff
changeset
|
2300 defvar_bool (namestring, address) |
| 341 | 2301 char *namestring; |
| 2302 int *address; | |
| 2303 { | |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2304 Lisp_Object sym, val; |
| 341 | 2305 sym = intern (namestring); |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2306 val = allocate_misc (); |
|
11242
36e8e27c8625
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_kboard)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2307 XMISCTYPE (val) = Lisp_Misc_Boolfwd; |
|
9913
c921977bb0ce
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_per_buffer): Use accessor
Karl Heuer <kwzh@gnu.org>
parents:
9871
diff
changeset
|
2308 XBOOLFWD (val)->boolvar = address; |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2309 XSYMBOL (sym)->value = val; |
| 341 | 2310 } |
| 2311 | |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2312 /* Similar but define a variable whose value is the Lisp Object stored |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2313 at address. Two versions: with and without gc-marking of the C |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2314 variable. The nopro version is used when that variable will be |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2315 gc-marked for some other reason, since marking the same slot twice |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2316 can cause trouble with strings. */ |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2317 void |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2318 defvar_lisp_nopro (namestring, address) |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2319 char *namestring; |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2320 Lisp_Object *address; |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2321 { |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2322 Lisp_Object sym, val; |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2323 sym = intern (namestring); |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2324 val = allocate_misc (); |
|
11242
36e8e27c8625
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_kboard)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2325 XMISCTYPE (val) = Lisp_Misc_Objfwd; |
|
9913
c921977bb0ce
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_per_buffer): Use accessor
Karl Heuer <kwzh@gnu.org>
parents:
9871
diff
changeset
|
2326 XOBJFWD (val)->objvar = address; |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2327 XSYMBOL (sym)->value = val; |
|
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2328 } |
| 341 | 2329 |
| 2330 void | |
|
7765
688637ba31c5
(defvar_bool, defvar_int, defvar_lisp, defvar_lisp_nopro):
Richard M. Stallman <rms@gnu.org>
parents:
7675
diff
changeset
|
2331 defvar_lisp (namestring, address) |
| 341 | 2332 char *namestring; |
| 2333 Lisp_Object *address; | |
| 2334 { | |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2335 defvar_lisp_nopro (namestring, address); |
| 341 | 2336 staticpro (address); |
| 2337 } | |
| 2338 | |
| 2339 #ifndef standalone | |
| 2340 | |
| 2341 /* Similar but define a variable whose value is the Lisp Object stored in | |
|
9363
4ccd5f13788d
(defvar_per_buffer): Access buffer_local_flags as Lisp_Object, not int.
Karl Heuer <kwzh@gnu.org>
parents:
9361
diff
changeset
|
2342 the current buffer. address is the address of the slot in the buffer |
|
4ccd5f13788d
(defvar_per_buffer): Access buffer_local_flags as Lisp_Object, not int.
Karl Heuer <kwzh@gnu.org>
parents:
9361
diff
changeset
|
2343 that is current now. */ |
| 341 | 2344 |
| 2345 void | |
|
1009
bf78b5ea9b3a
* lread.c (defvar_per_buffer): Support new TYPE argument, by
Jim Blandy <jimb@redhat.com>
parents:
851
diff
changeset
|
2346 defvar_per_buffer (namestring, address, type, doc) |
| 341 | 2347 char *namestring; |
| 2348 Lisp_Object *address; | |
|
1009
bf78b5ea9b3a
* lread.c (defvar_per_buffer): Support new TYPE argument, by
Jim Blandy <jimb@redhat.com>
parents:
851
diff
changeset
|
2349 Lisp_Object type; |
| 341 | 2350 char *doc; |
| 2351 { | |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2352 Lisp_Object sym, val; |
| 341 | 2353 int offset; |
| 2354 extern struct buffer buffer_local_symbols; | |
| 2355 | |
| 2356 sym = intern (namestring); | |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2357 val = allocate_misc (); |
| 341 | 2358 offset = (char *)address - (char *)current_buffer; |
| 2359 | |
|
11242
36e8e27c8625
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_kboard)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2360 XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd; |
|
9913
c921977bb0ce
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_per_buffer): Use accessor
Karl Heuer <kwzh@gnu.org>
parents:
9871
diff
changeset
|
2361 XBUFFER_OBJFWD (val)->offset = offset; |
|
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2362 XSYMBOL (sym)->value = val; |
| 341 | 2363 *(Lisp_Object *)(offset + (char *)&buffer_local_symbols) = sym; |
|
1009
bf78b5ea9b3a
* lread.c (defvar_per_buffer): Support new TYPE argument, by
Jim Blandy <jimb@redhat.com>
parents:
851
diff
changeset
|
2364 *(Lisp_Object *)(offset + (char *)&buffer_local_types) = type; |
|
9363
4ccd5f13788d
(defvar_per_buffer): Access buffer_local_flags as Lisp_Object, not int.
Karl Heuer <kwzh@gnu.org>
parents:
9361
diff
changeset
|
2365 if (XINT (*(Lisp_Object *)(offset + (char *)&buffer_local_flags)) == 0) |
| 341 | 2366 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding |
| 2367 slot of buffer_local_flags */ | |
| 2368 abort (); | |
| 2369 } | |
| 2370 | |
| 2371 #endif /* standalone */ | |
|
10606
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2372 |
|
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2373 /* Similar but define a variable whose value is the Lisp Object stored |
|
11020
0951bb12c8ee
(defvar_kboard): Renamed from defvar_display.
Karl Heuer <kwzh@gnu.org>
parents:
10650
diff
changeset
|
2374 at a particular offset in the current kboard object. */ |
|
10606
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2375 |
|
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2376 void |
|
11020
0951bb12c8ee
(defvar_kboard): Renamed from defvar_display.
Karl Heuer <kwzh@gnu.org>
parents:
10650
diff
changeset
|
2377 defvar_kboard (namestring, offset) |
|
10606
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2378 char *namestring; |
|
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2379 int offset; |
|
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2380 { |
|
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2381 Lisp_Object sym, val; |
|
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2382 sym = intern (namestring); |
|
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2383 val = allocate_misc (); |
|
11242
36e8e27c8625
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_kboard)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2384 XMISCTYPE (val) = Lisp_Misc_Kboard_Objfwd; |
|
11020
0951bb12c8ee
(defvar_kboard): Renamed from defvar_display.
Karl Heuer <kwzh@gnu.org>
parents:
10650
diff
changeset
|
2385 XKBOARD_OBJFWD (val)->offset = offset; |
|
10606
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2386 XSYMBOL (sym)->value = val; |
|
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2387 } |
| 341 | 2388 |
|
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2389 /* Record the value of load-path used at the start of dumping |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2390 so we can see if the site changed it later during dumping. */ |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2391 static Lisp_Object dump_path; |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2392 |
| 364 | 2393 init_lread () |
| 341 | 2394 { |
| 617 | 2395 char *normal; |
|
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2396 int turn_off_warning = 0; |
| 341 | 2397 |
|
14945
4cd74c2aca79
(init_lread): Specify LC_NUMERIC locale.
Richard M. Stallman <rms@gnu.org>
parents:
14483
diff
changeset
|
2398 #ifdef HAVE_SETLOCALE |
|
4cd74c2aca79
(init_lread): Specify LC_NUMERIC locale.
Richard M. Stallman <rms@gnu.org>
parents:
14483
diff
changeset
|
2399 /* Make sure numbers are parsed as we expect. */ |
|
4cd74c2aca79
(init_lread): Specify LC_NUMERIC locale.
Richard M. Stallman <rms@gnu.org>
parents:
14483
diff
changeset
|
2400 setlocale (LC_NUMERIC, "C"); |
|
4cd74c2aca79
(init_lread): Specify LC_NUMERIC locale.
Richard M. Stallman <rms@gnu.org>
parents:
14483
diff
changeset
|
2401 #endif /* HAVE_SETLOCALE */ |
|
4cd74c2aca79
(init_lread): Specify LC_NUMERIC locale.
Richard M. Stallman <rms@gnu.org>
parents:
14483
diff
changeset
|
2402 |
| 364 | 2403 /* Compute the default load-path. */ |
| 617 | 2404 #ifdef CANNOT_DUMP |
| 2405 normal = PATH_LOADSEARCH; | |
| 638 | 2406 Vload_path = decode_env_path (0, normal); |
| 617 | 2407 #else |
| 2408 if (NILP (Vpurify_flag)) | |
| 2409 normal = PATH_LOADSEARCH; | |
| 2410 else | |
| 2411 normal = PATH_DUMPLOADSEARCH; | |
| 2412 | |
| 2413 /* In a dumped Emacs, we normally have to reset the value of | |
| 2414 Vload_path from PATH_LOADSEARCH, since the value that was dumped | |
| 2415 uses ../lisp, instead of the path of the installed elisp | |
| 2416 libraries. However, if it appears that Vload_path was changed | |
| 2417 from the default before dumping, don't override that value. */ | |
| 621 | 2418 if (initialized) |
| 2419 { | |
| 2420 if (! NILP (Fequal (dump_path, Vload_path))) | |
|
4482
09d0f4b26641
(init_lread): Normally put Vinvocation_directory
Richard M. Stallman <rms@gnu.org>
parents:
3704
diff
changeset
|
2421 { |
|
09d0f4b26641
(init_lread): Normally put Vinvocation_directory
Richard M. Stallman <rms@gnu.org>
parents:
3704
diff
changeset
|
2422 Vload_path = decode_env_path (0, normal); |
|
5617
0b312b3fa24e
(init_lread): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5568
diff
changeset
|
2423 if (!NILP (Vinstallation_directory)) |
|
4482
09d0f4b26641
(init_lread): Normally put Vinvocation_directory
Richard M. Stallman <rms@gnu.org>
parents:
3704
diff
changeset
|
2424 { |
|
5617
0b312b3fa24e
(init_lread): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5568
diff
changeset
|
2425 /* Add to the path the lisp subdir of the |
|
7004
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2426 installation dir, if it exists. */ |
|
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2427 Lisp_Object tem, tem1; |
|
5617
0b312b3fa24e
(init_lread): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5568
diff
changeset
|
2428 tem = Fexpand_file_name (build_string ("lisp"), |
|
0b312b3fa24e
(init_lread): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5568
diff
changeset
|
2429 Vinstallation_directory); |
|
7004
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2430 tem1 = Ffile_exists_p (tem); |
|
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2431 if (!NILP (tem1)) |
|
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2432 { |
|
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2433 if (NILP (Fmember (tem, Vload_path))) |
|
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2434 { |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2435 turn_off_warning = 1; |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2436 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil)); |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2437 } |
|
7004
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2438 } |
|
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2439 else |
|
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2440 /* That dir doesn't exist, so add the build-time |
|
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2441 Lisp dirs instead. */ |
|
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
2442 Vload_path = nconc2 (Vload_path, dump_path); |
|
11311
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
2443 |
|
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
2444 /* Add site-list under the installation dir, if it exists. */ |
|
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
2445 tem = Fexpand_file_name (build_string ("site-lisp"), |
|
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
2446 Vinstallation_directory); |
|
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
2447 tem1 = Ffile_exists_p (tem); |
|
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
2448 if (!NILP (tem1)) |
|
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
2449 { |
|
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
2450 if (NILP (Fmember (tem, Vload_path))) |
|
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
2451 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil)); |
|
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
2452 } |
|
4482
09d0f4b26641
(init_lread): Normally put Vinvocation_directory
Richard M. Stallman <rms@gnu.org>
parents:
3704
diff
changeset
|
2453 } |
|
09d0f4b26641
(init_lread): Normally put Vinvocation_directory
Richard M. Stallman <rms@gnu.org>
parents:
3704
diff
changeset
|
2454 } |
| 621 | 2455 } |
| 2456 else | |
|
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2457 { |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2458 /* ../lisp refers to the build directory. |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2459 NORMAL refers to the lisp dir in the source directory. */ |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2460 Vload_path = Fcons (build_string ("../lisp"), |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2461 decode_env_path (0, normal)); |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2462 dump_path = Vload_path; |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2463 } |
| 364 | 2464 #endif |
| 2465 | |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
2466 #ifndef WINDOWSNT |
|
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
2467 /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is |
|
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
2468 almost never correct, thereby causing a warning to be printed out that |
| 14036 | 2469 confuses users. Since PATH_LOADSEARCH is always overridden by the |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
2470 EMACSLOADPATH environment variable below, disable the warning on NT. */ |
|
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
2471 |
| 341 | 2472 /* Warn if dirs in the *standard* path don't exist. */ |
|
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2473 if (!turn_off_warning) |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2474 { |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2475 Lisp_Object path_tail; |
| 341 | 2476 |
|
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2477 for (path_tail = Vload_path; |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2478 !NILP (path_tail); |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2479 path_tail = XCONS (path_tail)->cdr) |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2480 { |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2481 Lisp_Object dirfile; |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2482 dirfile = Fcar (path_tail); |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2483 if (STRINGP (dirfile)) |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2484 { |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2485 dirfile = Fdirectory_file_name (dirfile); |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2486 if (access (XSTRING (dirfile)->data, 0) < 0) |
|
16487
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2487 dir_warning ("Warning: Lisp directory `%s' does not exist.\n", |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2488 XCONS (path_tail)->car); |
|
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2489 } |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2490 } |
|
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2491 } |
|
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
2492 #endif /* WINDOWSNT */ |
| 617 | 2493 |
| 2494 /* If the EMACSLOADPATH environment variable is set, use its value. | |
| 2495 This doesn't apply if we're dumping. */ | |
|
11955
d972c95e7577
(init_lread) [CANNOT_DUMP]: Set Vload_path to EMACSLOADPATH.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11868
diff
changeset
|
2496 #ifndef CANNOT_DUMP |
| 617 | 2497 if (NILP (Vpurify_flag) |
| 2498 && egetenv ("EMACSLOADPATH")) | |
|
11955
d972c95e7577
(init_lread) [CANNOT_DUMP]: Set Vload_path to EMACSLOADPATH.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11868
diff
changeset
|
2499 #endif |
| 364 | 2500 Vload_path = decode_env_path ("EMACSLOADPATH", normal); |
| 2501 | |
| 2502 Vvalues = Qnil; | |
| 2503 | |
| 341 | 2504 load_in_progress = 0; |
|
15283
b2be450a8da4
(init_lread): Init Vload_file_name to Qnil.
Karl Heuer <kwzh@gnu.org>
parents:
15091
diff
changeset
|
2505 Vload_file_name = Qnil; |
|
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
2506 |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
2507 load_descriptor_list = Qnil; |
| 341 | 2508 } |
| 2509 | |
|
16487
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2510 /* Print a warning, using format string FORMAT, that directory DIRNAME |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2511 does not exist. Print it on stderr and put it in *Message*. */ |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2512 |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2513 dir_warning (format, dirname) |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2514 char *format; |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2515 Lisp_Object dirname; |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2516 { |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2517 char *buffer |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2518 = (char *) alloca (XSTRING (dirname)->size + strlen (format) + 5); |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2519 |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2520 fprintf (stderr, format, XSTRING (dirname)->data); |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2521 sprintf (buffer, format, XSTRING (dirname)->data); |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2522 message_dolog (buffer, strlen (buffer), 0); |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2523 } |
|
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
2524 |
| 341 | 2525 void |
| 364 | 2526 syms_of_lread () |
| 341 | 2527 { |
| 2528 defsubr (&Sread); | |
| 2529 defsubr (&Sread_from_string); | |
| 2530 defsubr (&Sintern); | |
| 2531 defsubr (&Sintern_soft); | |
|
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2532 defsubr (&Sunintern); |
| 341 | 2533 defsubr (&Sload); |
| 672 | 2534 defsubr (&Seval_buffer); |
| 341 | 2535 defsubr (&Seval_region); |
| 2536 defsubr (&Sread_char); | |
| 2537 defsubr (&Sread_char_exclusive); | |
| 2538 defsubr (&Sread_event); | |
| 2539 defsubr (&Sget_file_char); | |
| 2540 defsubr (&Smapatoms); | |
| 2541 | |
| 2542 DEFVAR_LISP ("obarray", &Vobarray, | |
| 2543 "Symbol table for use by `intern' and `read'.\n\ | |
| 2544 It is a vector whose length ought to be prime for best results.\n\ | |
| 2545 The vector's contents don't make sense if examined from Lisp programs;\n\ | |
| 2546 to find all the symbols in an obarray, use `mapatoms'."); | |
| 2547 | |
| 2548 DEFVAR_LISP ("values", &Vvalues, | |
| 2549 "List of values of all expressions which were read, evaluated and printed.\n\ | |
| 2550 Order is reverse chronological."); | |
| 2551 | |
| 2552 DEFVAR_LISP ("standard-input", &Vstandard_input, | |
| 2553 "Stream for read to get input from.\n\ | |
| 2554 See documentation of `read' for possible values."); | |
| 2555 Vstandard_input = Qt; | |
| 2556 | |
| 2557 DEFVAR_LISP ("load-path", &Vload_path, | |
| 2558 "*List of directories to search for files to load.\n\ | |
| 2559 Each element is a string (directory name) or nil (try default directory).\n\ | |
| 2560 Initialized based on EMACSLOADPATH environment variable, if any,\n\ | |
|
1887
ab56990c27c4
(syms_of_lread): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1827
diff
changeset
|
2561 otherwise to default specified by file `paths.h' when Emacs was built."); |
| 341 | 2562 |
| 2563 DEFVAR_BOOL ("load-in-progress", &load_in_progress, | |
| 2564 "Non-nil iff inside of `load'."); | |
| 2565 | |
| 2566 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist, | |
| 2567 "An alist of expressions to be evalled when particular files are loaded.\n\ | |
| 2568 Each element looks like (FILENAME FORMS...).\n\ | |
| 2569 When `load' is run and the file-name argument is FILENAME,\n\ | |
| 2570 the FORMS in the corresponding element are executed at the end of loading.\n\n\ | |
| 2571 FILENAME must match exactly! Normally FILENAME is the name of a library,\n\ | |
| 2572 with no directory specified, since that is how `load' is normally called.\n\ | |
| 2573 An error in FORMS does not undo the load,\n\ | |
| 2574 but does prevent execution of the rest of the FORMS."); | |
| 2575 Vafter_load_alist = Qnil; | |
| 2576 | |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2577 DEFVAR_LISP ("load-history", &Vload_history, |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2578 "Alist mapping source file names to symbols and features.\n\ |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2579 Each alist element is a list that starts with a file name,\n\ |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2580 except for one element (optional) that starts with nil and describes\n\ |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2581 definitions evaluated from buffers not visiting files.\n\ |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2582 The remaining elements of each list are symbols defined as functions\n\ |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2583 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'."); |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2584 Vload_history = Qnil; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2585 |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
2586 DEFVAR_LISP ("load-file-name", &Vload_file_name, |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
2587 "Full name of file being loaded by `load'."); |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
2588 Vload_file_name = Qnil; |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
2589 |
|
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
2590 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list, |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
2591 "Used for internal purposes by `load'."); |
|
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2592 Vcurrent_load_list = Qnil; |
|
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
2593 |
|
11079
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
2594 DEFVAR_LISP ("load-read-function", &Vload_read_function, |
|
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
2595 "Function used by `load' and `eval-region' for reading expressions.\n\ |
|
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
2596 The default is nil, which means use the function `read'."); |
|
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
2597 Vload_read_function = Qnil; |
|
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
2598 |
|
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2599 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings, |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2600 "Non-nil means `load' should force-load all dynamic doc strings.\n\ |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2601 This is useful when the file being loaded is a temporary copy."); |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2602 load_force_doc_strings = 0; |
|
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2603 |
|
13601
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
2604 DEFVAR_LISP ("source-directory", &Vsource_directory, |
|
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
2605 "Directory in which Emacs sources were found when Emacs was built.\n\ |
|
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
2606 You cannot count on them to still be there!"); |
|
14300
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2607 Vsource_directory |
|
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2608 = Fexpand_file_name (build_string ("../"), |
|
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2609 Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH))); |
|
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2610 |
|
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2611 /* Vsource_directory was initialized in init_lread. */ |
|
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2612 |
|
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
2613 load_descriptor_list = Qnil; |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
2614 staticpro (&load_descriptor_list); |
|
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
2615 |
|
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
2616 Qcurrent_load_list = intern ("current-load-list"); |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
2617 staticpro (&Qcurrent_load_list); |
|
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
2618 |
| 341 | 2619 Qstandard_input = intern ("standard-input"); |
| 2620 staticpro (&Qstandard_input); | |
| 2621 | |
| 2622 Qread_char = intern ("read-char"); | |
| 2623 staticpro (&Qread_char); | |
| 2624 | |
| 2625 Qget_file_char = intern ("get-file-char"); | |
| 2626 staticpro (&Qget_file_char); | |
|
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
2627 |
|
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2628 Qbackquote = intern ("`"); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2629 staticpro (&Qbackquote); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2630 Qcomma = intern (","); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2631 staticpro (&Qcomma); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2632 Qcomma_at = intern (",@"); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2633 staticpro (&Qcomma_at); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2634 Qcomma_dot = intern (",."); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2635 staticpro (&Qcomma_dot); |
|
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2636 |
|
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
2637 Qinhibit_file_name_operation = intern ("inhibit-file-name-operation"); |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
2638 staticpro (&Qinhibit_file_name_operation); |
|
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
2639 |
|
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
2640 Qascii_character = intern ("ascii-character"); |
|
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
2641 staticpro (&Qascii_character); |
|
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
2642 |
|
13235
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
2643 Qfunction = intern ("function"); |
|
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
2644 staticpro (&Qfunction); |
|
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
2645 |
|
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
2646 Qload = intern ("load"); |
|
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
2647 staticpro (&Qload); |
|
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
2648 |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
2649 Qload_file_name = intern ("load-file-name"); |
|
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
2650 staticpro (&Qload_file_name); |
|
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2651 |
|
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
2652 staticpro (&dump_path); |
|
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2653 |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2654 staticpro (&read_objects); |
|
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2655 read_objects = Qnil; |
| 341 | 2656 } |
