428
|
1 /* Lisp parsing and input streams.
|
|
2 Copyright (C) 1985-1989, 1992-1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995 Tinker Systems.
|
1261
|
4 Copyright (C) 1996, 2001, 2002, 2003 Ben Wing.
|
428
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Mule 2.0, FSF 19.30. */
|
|
24
|
|
25 /* This file has been Mule-ized. */
|
|
26
|
|
27 #include <config.h>
|
|
28 #include "lisp.h"
|
|
29
|
|
30 #include "buffer.h"
|
|
31 #include "bytecode.h"
|
|
32 #include "elhash.h"
|
1292
|
33 #include "file-coding.h"
|
428
|
34 #include "lstream.h"
|
|
35 #include "opaque.h"
|
1292
|
36 #include "profile.h"
|
428
|
37
|
|
38 #include "sysfile.h"
|
|
39 #include "sysfloat.h"
|
771
|
40 #ifdef WIN32_NATIVE
|
|
41 #include "syswindows.h"
|
|
42 #endif
|
428
|
43
|
|
44 Lisp_Object Qread_char, Qstandard_input;
|
|
45 Lisp_Object Qvariable_documentation;
|
|
46 #define LISP_BACKQUOTES
|
|
47 #ifdef LISP_BACKQUOTES
|
|
48 /*
|
|
49 Nonzero means inside a new-style backquote
|
|
50 with no surrounding parentheses.
|
|
51 Fread initializes this to zero, so we need not specbind it
|
|
52 or worry about what happens to it when there is an error.
|
|
53
|
|
54 XEmacs:
|
|
55 Nested backquotes are perfectly legal and fail utterly with
|
|
56 this silliness. */
|
|
57 static int new_backquote_flag, old_backquote_flag;
|
|
58 Lisp_Object Qbackquote, Qbacktick, Qcomma, Qcomma_at, Qcomma_dot;
|
|
59 #endif
|
|
60 Lisp_Object Qvariable_domain; /* I18N3 */
|
|
61 Lisp_Object Vvalues, Vstandard_input, Vafter_load_alist;
|
|
62 Lisp_Object Qcurrent_load_list;
|
1292
|
63 Lisp_Object Qload, Qload_file_name, Qload_internal, Qfset;
|
428
|
64
|
|
65 /* Hash-table that maps directory names to hashes of their contents. */
|
|
66 static Lisp_Object Vlocate_file_hash_table;
|
|
67
|
|
68 Lisp_Object Qexists, Qreadable, Qwritable, Qexecutable;
|
|
69
|
|
70 /* See read_escape() for an explanation of this. */
|
|
71 #if 0
|
|
72 int fail_on_bucky_bit_character_escapes;
|
|
73 #endif
|
|
74
|
|
75 /* This symbol is also used in fns.c */
|
|
76 #define FEATUREP_SYNTAX
|
|
77
|
|
78 #ifdef FEATUREP_SYNTAX
|
|
79 Lisp_Object Qfeaturep;
|
|
80 #endif
|
|
81
|
|
82 /* non-zero if inside `load' */
|
|
83 int load_in_progress;
|
|
84
|
|
85 /* Whether Fload_internal() should check whether the .el is newer
|
|
86 when loading .elc */
|
|
87 int load_warn_when_source_newer;
|
|
88 /* Whether Fload_internal() should check whether the .elc doesn't exist */
|
|
89 int load_warn_when_source_only;
|
|
90 /* Whether Fload_internal() should ignore .elc files when no suffix is given */
|
|
91 int load_ignore_elc_files;
|
1123
|
92 /* Whether Fload_internal() should ignore out-of-date .elc files when no
|
|
93 suffix is given */
|
|
94 int load_ignore_out_of_date_elc_files;
|
|
95 /* Always display messages showing when a file is loaded, regardless of
|
|
96 whether the flag to `load' tries to suppress them. */
|
|
97 int load_always_display_messages;
|
|
98 /* Show the full path in loading messages. */
|
|
99 int load_show_full_path_in_messages;
|
428
|
100
|
|
101 /* Search path for files to be loaded. */
|
|
102 Lisp_Object Vload_path;
|
|
103
|
|
104 /* Search path for files when dumping. */
|
|
105 /* Lisp_Object Vdump_load_path; */
|
|
106
|
|
107 /* This is the user-visible association list that maps features to
|
|
108 lists of defs in their load files. */
|
|
109 Lisp_Object Vload_history;
|
|
110
|
|
111 /* This is used to build the load history. */
|
|
112 Lisp_Object Vcurrent_load_list;
|
|
113
|
|
114 /* Name of file actually being read by `load'. */
|
|
115 Lisp_Object Vload_file_name;
|
|
116
|
|
117 /* Same as Vload_file_name but not Lisp-accessible. This ensures that
|
|
118 our #$ checks are reliable. */
|
|
119 Lisp_Object Vload_file_name_internal;
|
|
120
|
|
121 Lisp_Object Vload_file_name_internal_the_purecopy;
|
|
122
|
|
123 /* Function to use for reading, in `load' and friends. */
|
|
124 Lisp_Object Vload_read_function;
|
|
125
|
|
126 /* The association list of objects read with the #n=object form.
|
|
127 Each member of the list has the form (n . object), and is used to
|
|
128 look up the object for the corresponding #n# construct.
|
|
129 It must be set to nil before all top-level calls to read0. */
|
|
130 Lisp_Object Vread_objects;
|
|
131
|
|
132 /* Nonzero means load should forcibly load all dynamic doc strings. */
|
|
133 /* Note that this always happens (with some special behavior) when
|
|
134 purify_flag is set. */
|
|
135 static int load_force_doc_strings;
|
|
136
|
|
137 /* List of descriptors now open for Fload_internal. */
|
|
138 static Lisp_Object Vload_descriptor_list;
|
|
139
|
|
140 /* In order to implement "load_force_doc_strings", we keep
|
|
141 a list of all the compiled-function objects and such
|
|
142 that we have created in the process of loading this file.
|
|
143 See the rant below.
|
|
144
|
|
145 We specbind this just like Vload_file_name, so there's no
|
|
146 problems with recursive loading. */
|
|
147 static Lisp_Object Vload_force_doc_string_list;
|
|
148
|
|
149 /* A resizing-buffer stream used to temporarily hold data while reading */
|
|
150 static Lisp_Object Vread_buffer_stream;
|
|
151
|
|
152 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
153 Lisp_Object Vcurrent_compiled_function_annotation;
|
|
154 #endif
|
|
155
|
|
156 static int load_byte_code_version;
|
|
157
|
|
158 /* An array describing all known built-in structure types */
|
|
159 static structure_type_dynarr *the_structure_type_dynarr;
|
|
160
|
|
161 #if 0 /* FSF stuff */
|
|
162 /* For use within read-from-string (this reader is non-reentrant!!) */
|
|
163 static int read_from_string_index;
|
|
164 static int read_from_string_limit;
|
|
165 #endif
|
|
166
|
|
167 #if 0 /* More FSF implementation kludges. */
|
|
168 /* In order to implement load-force-doc-string, FSF saves the
|
|
169 #@-quoted string when it's seen, and goes back and retrieves
|
|
170 it later.
|
|
171
|
|
172 This approach is not only kludgy, but it in general won't work
|
|
173 correctly because there's no stack of remembered #@-quoted-strings
|
|
174 and those strings don't generally appear in the file in the same
|
|
175 order as their #$ references. (Yes, that is amazingly stupid too.
|
|
176
|
|
177 It would be trivially easy to always encode the #@ string
|
|
178 [which is a comment, anyway] in the middle of the (#$ . INT) cons
|
|
179 reference. That way, it would be really easy to implement
|
|
180 load-force-doc-string in a non-kludgy way by just retrieving the
|
|
181 string immediately, because it's delivered on a silver platter.)
|
|
182
|
|
183 And finally, this stupid approach doesn't work under Mule, or
|
|
184 under MS-DOS or Windows NT, or under VMS, or any other place
|
|
185 where you either can't do an ftell() or don't get back a byte
|
|
186 count.
|
|
187
|
|
188 Oh, and one more lossage in this approach: If you attempt to
|
|
189 dump any ELC files that were compiled with `byte-compile-dynamic'
|
|
190 (as opposed to just `byte-compile-dynamic-docstring'), you
|
|
191 get hosed. FMH! (as the illustrious JWZ was prone to utter)
|
|
192
|
|
193 The approach we use is clean, solves all of these problems, and is
|
|
194 probably easier to implement anyway. We just save a list of all
|
|
195 the containing objects that have (#$ . INT) conses in them (this
|
|
196 will only be compiled-function objects and lists), and when the
|
|
197 file is finished loading, we go through and fill in all the
|
814
|
198 doc strings at once. --ben */
|
428
|
199
|
|
200 /* This contains the last string skipped with #@. */
|
|
201 static char *saved_doc_string;
|
|
202 /* Length of buffer allocated in saved_doc_string. */
|
|
203 static int saved_doc_string_size;
|
|
204 /* Length of actual data in saved_doc_string. */
|
|
205 static int saved_doc_string_length;
|
|
206 /* This is the file position that string came from. */
|
|
207 static int saved_doc_string_position;
|
|
208 #endif
|
|
209
|
1123
|
210 static int locate_file_open_or_access_file (Ibyte *fn, int access_mode);
|
428
|
211 EXFUN (Fread_from_string, 3);
|
|
212
|
|
213 /* When errors are signaled, the actual readcharfun should not be used
|
|
214 as an argument if it is an lstream, so that lstreams don't escape
|
|
215 to the Lisp level. */
|
1261
|
216 #define READCHARFUN_MAYBE(x) (LSTREAMP (x) \
|
|
217 ? (build_msg_string ("internal input stream")) \
|
428
|
218 : (x))
|
|
219
|
|
220
|
2268
|
221 static DECLARE_DOESNT_RETURN (read_syntax_error (const char *));
|
|
222
|
428
|
223 static DOESNT_RETURN
|
442
|
224 read_syntax_error (const char *string)
|
428
|
225 {
|
563
|
226 signal_error (Qinvalid_read_syntax, string, Qunbound);
|
428
|
227 }
|
|
228
|
|
229 static Lisp_Object
|
442
|
230 continuable_read_syntax_error (const char *string)
|
428
|
231 {
|
563
|
232 return signal_continuable_error (Qinvalid_read_syntax, string, Qunbound);
|
428
|
233 }
|
|
234
|
|
235
|
|
236 /* Handle unreading and rereading of characters. */
|
867
|
237 static Ichar
|
428
|
238 readchar (Lisp_Object readcharfun)
|
|
239 {
|
|
240 /* This function can GC */
|
|
241
|
|
242 if (BUFFERP (readcharfun))
|
|
243 {
|
867
|
244 Ichar c;
|
428
|
245 struct buffer *b = XBUFFER (readcharfun);
|
|
246
|
|
247 if (!BUFFER_LIVE_P (b))
|
563
|
248 invalid_operation ("Reading from killed buffer", Qunbound);
|
428
|
249
|
|
250 if (BUF_PT (b) >= BUF_ZV (b))
|
|
251 return -1;
|
|
252 c = BUF_FETCH_CHAR (b, BUF_PT (b));
|
|
253 BUF_SET_PT (b, BUF_PT (b) + 1);
|
|
254
|
|
255 return c;
|
|
256 }
|
|
257 else if (LSTREAMP (readcharfun))
|
|
258 {
|
867
|
259 Ichar c = Lstream_get_ichar (XLSTREAM (readcharfun));
|
428
|
260 #ifdef DEBUG_XEMACS /* testing Mule */
|
|
261 static int testing_mule = 0; /* Change via debugger */
|
444
|
262 if (testing_mule)
|
|
263 {
|
|
264 if (c >= 0x20 && c <= 0x7E) stderr_out ("%c", c);
|
|
265 else if (c == '\n') stderr_out ("\\n\n");
|
|
266 else stderr_out ("\\%o ", c);
|
|
267 }
|
|
268 #endif /* testing Mule */
|
428
|
269 return c;
|
|
270 }
|
|
271 else if (MARKERP (readcharfun))
|
|
272 {
|
867
|
273 Ichar c;
|
665
|
274 Charbpos mpos = marker_position (readcharfun);
|
428
|
275 struct buffer *inbuffer = XMARKER (readcharfun)->buffer;
|
|
276
|
|
277 if (mpos >= BUF_ZV (inbuffer))
|
|
278 return -1;
|
|
279 c = BUF_FETCH_CHAR (inbuffer, mpos);
|
|
280 set_marker_position (readcharfun, mpos + 1);
|
|
281 return c;
|
|
282 }
|
|
283 else
|
|
284 {
|
|
285 Lisp_Object tem = call0 (readcharfun);
|
|
286
|
|
287 if (!CHAR_OR_CHAR_INTP (tem))
|
|
288 return -1;
|
|
289 return XCHAR_OR_CHAR_INT (tem);
|
|
290 }
|
|
291 }
|
|
292
|
|
293 /* Unread the character C in the way appropriate for the stream READCHARFUN.
|
|
294 If the stream is a user function, call it with the char as argument. */
|
|
295
|
|
296 static void
|
867
|
297 unreadchar (Lisp_Object readcharfun, Ichar c)
|
428
|
298 {
|
|
299 if (c == -1)
|
|
300 /* Don't back up the pointer if we're unreading the end-of-input mark,
|
|
301 since readchar didn't advance it when we read it. */
|
|
302 ;
|
|
303 else if (BUFFERP (readcharfun))
|
|
304 BUF_SET_PT (XBUFFER (readcharfun), BUF_PT (XBUFFER (readcharfun)) - 1);
|
|
305 else if (LSTREAMP (readcharfun))
|
|
306 {
|
867
|
307 Lstream_unget_ichar (XLSTREAM (readcharfun), c);
|
428
|
308 #ifdef DEBUG_XEMACS /* testing Mule */
|
|
309 {
|
|
310 static int testing_mule = 0; /* Set this using debugger */
|
|
311 if (testing_mule)
|
|
312 fprintf (stderr,
|
|
313 (c >= 0x20 && c <= 0x7E) ? "UU%c" :
|
|
314 ((c == '\n') ? "UU\\n\n" : "UU\\%o"), c);
|
|
315 }
|
|
316 #endif
|
|
317 }
|
|
318 else if (MARKERP (readcharfun))
|
|
319 set_marker_position (readcharfun, marker_position (readcharfun) - 1);
|
|
320 else
|
|
321 call1 (readcharfun, make_char (c));
|
|
322 }
|
|
323
|
|
324 static Lisp_Object read0 (Lisp_Object readcharfun);
|
|
325 static Lisp_Object read1 (Lisp_Object readcharfun);
|
|
326 static Lisp_Object read_list (Lisp_Object readcharfun,
|
867
|
327 Ichar terminator,
|
428
|
328 int allow_dotted_lists,
|
|
329 int check_for_doc_references);
|
|
330
|
|
331 static void readevalloop (Lisp_Object readcharfun,
|
|
332 Lisp_Object sourcefile,
|
|
333 Lisp_Object (*evalfun) (Lisp_Object),
|
|
334 int printflag);
|
|
335
|
|
336 static Lisp_Object
|
|
337 load_unwind (Lisp_Object stream) /* used as unwind-protect function in load */
|
|
338 {
|
|
339 Lstream_close (XLSTREAM (stream));
|
|
340 return Qnil;
|
|
341 }
|
|
342
|
|
343 /* The plague is coming.
|
|
344
|
|
345 Ring around the rosy, pocket full of posy,
|
|
346 Ashes ashes, they all fall down.
|
|
347 */
|
|
348 void
|
|
349 ebolify_bytecode_constants (Lisp_Object vector)
|
|
350 {
|
|
351 int len = XVECTOR_LENGTH (vector);
|
|
352 int i;
|
|
353
|
|
354 for (i = 0; i < len; i++)
|
|
355 {
|
|
356 Lisp_Object el = XVECTOR_DATA (vector)[i];
|
|
357
|
|
358 /* We don't check for `eq', `equal', and the others that have
|
|
359 bytecode opcodes. This might lose if someone passes #'eq or
|
|
360 something to `funcall', but who would really do that? As
|
|
361 they say in law, we've made a "good-faith effort" to
|
|
362 unfuckify ourselves. And doing it this way avoids screwing
|
|
363 up args to `make-hash-table' and such. As it is, we have to
|
|
364 add an extra Ebola check in decode_weak_list_type(). --ben */
|
|
365 if (EQ (el, Qassoc)) el = Qold_assoc;
|
|
366 else if (EQ (el, Qdelq)) el = Qold_delq;
|
|
367 #if 0
|
|
368 /* I think this is a bad idea because it will probably mess
|
|
369 with keymap code. */
|
|
370 else if (EQ (el, Qdelete)) el = Qold_delete;
|
|
371 #endif
|
|
372 else if (EQ (el, Qrassq)) el = Qold_rassq;
|
|
373 else if (EQ (el, Qrassoc)) el = Qold_rassoc;
|
|
374
|
|
375 XVECTOR_DATA (vector)[i] = el;
|
|
376 }
|
|
377 }
|
|
378
|
|
379 static Lisp_Object
|
558
|
380 pas_de_holgazan_ici (int fd, Lisp_Object victim)
|
428
|
381 {
|
|
382 Lisp_Object tem;
|
|
383 EMACS_INT pos;
|
|
384
|
|
385 if (!INTP (XCDR (victim)))
|
563
|
386 invalid_byte_code ("Bogus doc string reference", victim);
|
428
|
387 pos = XINT (XCDR (victim));
|
|
388 if (pos < 0)
|
|
389 pos = -pos; /* kludge to mark a user variable */
|
814
|
390 tem = unparesseuxify_doc_string (fd, pos, 0, Vload_file_name_internal, 0);
|
428
|
391 if (!STRINGP (tem))
|
563
|
392 signal_error_1 (Qinvalid_byte_code, tem);
|
428
|
393 return tem;
|
|
394 }
|
|
395
|
|
396 static Lisp_Object
|
|
397 load_force_doc_string_unwind (Lisp_Object oldlist)
|
|
398 {
|
|
399 struct gcpro gcpro1;
|
|
400 Lisp_Object list = Vload_force_doc_string_list;
|
|
401 Lisp_Object tail;
|
|
402 int fd = XINT (XCAR (Vload_descriptor_list));
|
|
403
|
|
404 GCPRO1 (list);
|
|
405 /* restore the old value first just in case an error occurs. */
|
|
406 Vload_force_doc_string_list = oldlist;
|
|
407
|
|
408 LIST_LOOP (tail, list)
|
|
409 {
|
|
410 Lisp_Object john = Fcar (tail);
|
|
411 if (CONSP (john))
|
|
412 {
|
|
413 assert (CONSP (XCAR (john)));
|
|
414 assert (!purify_flag); /* should have been handled in read_list() */
|
558
|
415 XCAR (john) = pas_de_holgazan_ici (fd, XCAR (john));
|
428
|
416 }
|
|
417 else
|
|
418 {
|
|
419 Lisp_Object doc;
|
|
420
|
|
421 assert (COMPILED_FUNCTIONP (john));
|
|
422 if (CONSP (XCOMPILED_FUNCTION (john)->instructions))
|
|
423 {
|
|
424 struct gcpro ngcpro1;
|
558
|
425 Lisp_Object juan = (pas_de_holgazan_ici
|
814
|
426 (fd,
|
|
427 XCOMPILED_FUNCTION (john)->instructions));
|
428
|
428 Lisp_Object ivan;
|
|
429
|
|
430 NGCPRO1 (juan);
|
|
431 ivan = Fread (juan);
|
|
432 if (!CONSP (ivan))
|
563
|
433 invalid_byte_code ("invalid lazy-loaded byte code", ivan);
|
428
|
434 XCOMPILED_FUNCTION (john)->instructions = XCAR (ivan);
|
|
435 /* v18 or v19 bytecode file. Need to Ebolify. */
|
|
436 if (XCOMPILED_FUNCTION (john)->flags.ebolified
|
|
437 && VECTORP (XCDR (ivan)))
|
|
438 ebolify_bytecode_constants (XCDR (ivan));
|
|
439 XCOMPILED_FUNCTION (john)->constants = XCDR (ivan);
|
|
440 NUNGCPRO;
|
|
441 }
|
|
442 doc = compiled_function_documentation (XCOMPILED_FUNCTION (john));
|
|
443 if (CONSP (doc))
|
|
444 {
|
|
445 assert (!purify_flag); /* should have been handled in
|
|
446 read_compiled_function() */
|
558
|
447 doc = pas_de_holgazan_ici (fd, doc);
|
428
|
448 set_compiled_function_documentation (XCOMPILED_FUNCTION (john),
|
|
449 doc);
|
|
450 }
|
|
451 }
|
|
452 }
|
|
453
|
|
454 if (!NILP (list))
|
|
455 free_list (list);
|
|
456
|
|
457 UNGCPRO;
|
|
458 return Qnil;
|
|
459 }
|
|
460
|
|
461 /* Close all descriptors in use for Fload_internal.
|
|
462 This is used when starting a subprocess. */
|
|
463
|
|
464 void
|
|
465 close_load_descs (void)
|
|
466 {
|
|
467 Lisp_Object tail;
|
|
468 LIST_LOOP (tail, Vload_descriptor_list)
|
771
|
469 retry_close (XINT (XCAR (tail)));
|
428
|
470 }
|
|
471
|
|
472 #ifdef I18N3
|
|
473 Lisp_Object Vfile_domain;
|
|
474 #endif /* I18N3 */
|
|
475
|
|
476 DEFUN ("load-internal", Fload_internal, 1, 6, 0, /*
|
|
477 Execute a file of Lisp code named FILE; no coding-system frobbing.
|
|
478 This function is identical to `load' except for the handling of the
|
|
479 CODESYS and USED-CODESYS arguments under XEmacs/Mule. (When Mule
|
|
480 support is not present, both functions are identical and ignore the
|
|
481 CODESYS and USED-CODESYS arguments.)
|
|
482
|
|
483 If support for Mule exists in this Emacs, the file is decoded
|
|
484 according to CODESYS; if omitted, no conversion happens. If
|
|
485 USED-CODESYS is non-nil, it should be a symbol, and the actual coding
|
|
486 system that was used for the decoding is stored into it. It will in
|
|
487 general be different from CODESYS if CODESYS specifies automatic
|
|
488 encoding detection or end-of-line detection.
|
|
489 */
|
444
|
490 (file, noerror, nomessage, nosuffix, codesys, used_codesys))
|
428
|
491 {
|
|
492 /* This function can GC */
|
|
493 int fd = -1;
|
|
494 int speccount = specpdl_depth ();
|
|
495 int source_only = 0;
|
1123
|
496 /* NEWER and OLDER are filenames w/o directory, used in loading messages
|
|
497 to e.g. warn of newer .el files when the .elc is being loaded. */
|
428
|
498 Lisp_Object newer = Qnil;
|
1123
|
499 Lisp_Object older = Qnil;
|
428
|
500 Lisp_Object handler = Qnil;
|
|
501 Lisp_Object found = Qnil;
|
1292
|
502 Lisp_Object retval;
|
1123
|
503 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
|
428
|
504 int reading_elc = 0;
|
780
|
505 int from_require = EQ (nomessage, Qrequire);
|
1261
|
506 int message_p = NILP (nomessage) || load_always_display_messages;
|
428
|
507 struct stat s1, s2;
|
1261
|
508 Ibyte *spaces = alloca_ibytes (load_in_progress * 2 + 10);
|
|
509 int i;
|
1292
|
510 PROFILE_DECLARE ();
|
428
|
511
|
1266
|
512 GCPRO4 (file, newer, older, found);
|
428
|
513 CHECK_STRING (file);
|
|
514
|
1292
|
515 PROFILE_RECORD_ENTERING_SECTION (Qload_internal);
|
|
516
|
428
|
517 /* If file name is magic, call the handler. */
|
|
518 handler = Ffind_file_name_handler (file, Qload);
|
|
519 if (!NILP (handler))
|
1292
|
520 {
|
|
521 retval = call5 (handler, Qload, file, noerror, nomessage, nosuffix);
|
|
522 goto done;
|
|
523 }
|
428
|
524
|
|
525 /* Do this after the handler to avoid
|
|
526 the need to gcpro noerror, nomessage and nosuffix.
|
|
527 (Below here, we care only whether they are nil or not.) */
|
|
528 file = Fsubstitute_in_file_name (file);
|
|
529 if (!NILP (used_codesys))
|
|
530 CHECK_SYMBOL (used_codesys);
|
|
531
|
1261
|
532 if (noninteractive)
|
|
533 {
|
|
534 for (i = 0; i < load_in_progress * 2; i++)
|
|
535 spaces[i] = ' ';
|
|
536 spaces[i] = '\0';
|
|
537 }
|
|
538 else
|
|
539 spaces[0] = '\0';
|
|
540
|
428
|
541 /* Avoid weird lossage with null string as arg,
|
|
542 since it would try to load a directory as a Lisp file.
|
|
543 Unix truly sucks. */
|
|
544 if (XSTRING_LENGTH (file) > 0)
|
|
545 {
|
867
|
546 Ibyte *foundstr;
|
428
|
547 int foundlen;
|
|
548
|
|
549 fd = locate_file (Vload_path, file,
|
|
550 ((!NILP (nosuffix)) ? Qnil :
|
|
551 build_string (load_ignore_elc_files ? ".el:" :
|
|
552 ".elc:.el:")),
|
|
553 &found,
|
|
554 -1);
|
|
555
|
|
556 if (fd < 0)
|
|
557 {
|
444
|
558 if (NILP (noerror))
|
563
|
559 signal_error (Qfile_error, "Cannot open load file", file);
|
428
|
560 else
|
|
561 {
|
1292
|
562 retval = Qnil;
|
|
563 goto done;
|
428
|
564 }
|
|
565 }
|
|
566
|
2367
|
567 foundstr = alloca_ibytes (XSTRING_LENGTH (found) + 1);
|
771
|
568 qxestrcpy (foundstr, XSTRING_DATA (found));
|
|
569 foundlen = qxestrlen (foundstr);
|
428
|
570
|
|
571 /* The omniscient JWZ thinks this is worthless, but I beg to
|
|
572 differ. --ben */
|
|
573 if (load_ignore_elc_files)
|
1123
|
574 newer = Ffile_name_nondirectory (found);
|
|
575 else if ((load_warn_when_source_newer ||
|
|
576 load_ignore_out_of_date_elc_files) &&
|
428
|
577 !memcmp (".elc", foundstr + foundlen - 4, 4))
|
|
578 {
|
771
|
579 if (! qxe_fstat (fd, &s1)) /* can't fail, right? */
|
428
|
580 {
|
|
581 int result;
|
|
582 /* temporarily hack the 'c' off the end of the filename */
|
|
583 foundstr[foundlen - 1] = '\0';
|
771
|
584 result = qxe_stat (foundstr, &s2);
|
428
|
585 if (result >= 0 &&
|
|
586 (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
|
1123
|
587 {
|
|
588 /* .elc exists and is out-of-date wrt .el */
|
|
589 Lisp_Object el_name = make_string (foundstr, foundlen - 1);
|
|
590 struct gcpro nngcpro1;
|
|
591 NNGCPRO1 (el_name);
|
|
592 newer = Ffile_name_nondirectory (el_name);
|
|
593 if (load_ignore_out_of_date_elc_files)
|
|
594 {
|
|
595 int newfd =
|
|
596 locate_file_open_or_access_file
|
|
597 (XSTRING_DATA (el_name), -1);
|
|
598
|
|
599 if (newfd >= 0)
|
|
600 {
|
|
601 older = Ffile_name_nondirectory (found);
|
|
602 found = el_name;
|
|
603 retry_close (fd);
|
|
604 fd = newfd;
|
|
605 }
|
|
606 }
|
|
607 NNUNGCPRO;
|
|
608 }
|
428
|
609 /* put the 'c' back on (kludge-o-rama) */
|
|
610 foundstr[foundlen - 1] = 'c';
|
|
611 }
|
|
612 }
|
|
613 else if (load_warn_when_source_only &&
|
|
614 /* `found' ends in ".el" */
|
|
615 !memcmp (".el", foundstr + foundlen - 3, 3) &&
|
|
616 /* `file' does not end in ".el" */
|
|
617 memcmp (".el",
|
|
618 XSTRING_DATA (file) + XSTRING_LENGTH (file) - 3,
|
|
619 3))
|
1123
|
620 source_only = 1;
|
428
|
621
|
|
622 if (!memcmp (".elc", foundstr + foundlen - 4, 4))
|
|
623 reading_elc = 1;
|
|
624 }
|
|
625
|
1123
|
626 #define PRINT_LOADING_MESSAGE_1(loading, done) \
|
|
627 do { \
|
|
628 if (load_ignore_elc_files) \
|
|
629 { \
|
|
630 if (message_p) \
|
1261
|
631 message (loading done, spaces, \
|
1123
|
632 XSTRING_DATA (load_show_full_path_in_messages ? \
|
|
633 found : newer)); \
|
|
634 } \
|
|
635 else if (!NILP (older)) \
|
|
636 { \
|
|
637 assert (load_ignore_out_of_date_elc_files); \
|
1261
|
638 message (loading done " (file %s is out-of-date)", spaces, \
|
1123
|
639 XSTRING_DATA (load_show_full_path_in_messages ? \
|
|
640 found : newer), \
|
|
641 XSTRING_DATA (older)); \
|
|
642 } \
|
|
643 else if (!NILP (newer)) \
|
1261
|
644 message (loading done " (file %s is newer)", spaces, \
|
1123
|
645 XSTRING_DATA (load_show_full_path_in_messages ? \
|
|
646 found : file), \
|
|
647 XSTRING_DATA (newer)); \
|
|
648 else if (source_only) \
|
1261
|
649 message (loading done " (file %s.elc does not exist)", spaces, \
|
1123
|
650 XSTRING_DATA (load_show_full_path_in_messages ? \
|
|
651 found : file), \
|
|
652 XSTRING_DATA (Ffile_name_nondirectory (file))); \
|
|
653 else if (message_p) \
|
1261
|
654 message (loading done, spaces, \
|
1123
|
655 XSTRING_DATA (load_show_full_path_in_messages ? \
|
|
656 found : file)); \
|
428
|
657 } while (0)
|
|
658
|
1261
|
659 #define PRINT_LOADING_MESSAGE(done) \
|
|
660 do { \
|
|
661 if (from_require) \
|
|
662 PRINT_LOADING_MESSAGE_1 ("%sRequiring %s...", done); \
|
|
663 else \
|
|
664 PRINT_LOADING_MESSAGE_1 ("%sLoading %s...", done); \
|
780
|
665 } while (0)
|
|
666
|
428
|
667 PRINT_LOADING_MESSAGE ("");
|
|
668
|
|
669 {
|
|
670 /* Lisp_Object's must be malloc'ed, not stack-allocated */
|
|
671 Lisp_Object lispstream = Qnil;
|
442
|
672 const int block_size = 8192;
|
428
|
673 struct gcpro ngcpro1;
|
|
674
|
|
675 NGCPRO1 (lispstream);
|
|
676 lispstream = make_filedesc_input_stream (fd, 0, -1, LSTR_CLOSING);
|
|
677 /* 64K is used for normal files; 8K should be OK here because Lisp
|
|
678 files aren't really all that big. */
|
|
679 Lstream_set_buffering (XLSTREAM (lispstream), LSTREAM_BLOCKN_BUFFERED,
|
|
680 block_size);
|
771
|
681 lispstream = make_coding_input_stream
|
|
682 (XLSTREAM (lispstream), get_coding_system_for_text_file (codesys, 1),
|
800
|
683 CODING_DECODE, 0);
|
428
|
684 Lstream_set_buffering (XLSTREAM (lispstream), LSTREAM_BLOCKN_BUFFERED,
|
|
685 block_size);
|
|
686 /* NOTE: Order of these is very important. Don't rearrange them. */
|
853
|
687 internal_bind_int (&load_in_progress, 1 + load_in_progress);
|
428
|
688 record_unwind_protect (load_unwind, lispstream);
|
853
|
689 internal_bind_lisp_object (&Vload_descriptor_list,
|
|
690 Fcons (make_int (fd), Vload_descriptor_list));
|
|
691 internal_bind_lisp_object (&Vload_file_name_internal, found);
|
|
692 internal_bind_lisp_object (&Vload_file_name_internal_the_purecopy, Qnil);
|
|
693 /* this is not a simple internal_bind. */
|
428
|
694 record_unwind_protect (load_force_doc_string_unwind,
|
|
695 Vload_force_doc_string_list);
|
853
|
696 Vload_force_doc_string_list = Qnil;
|
428
|
697 specbind (Qload_file_name, found);
|
|
698 #ifdef I18N3
|
853
|
699 /* set it to nil; a call to #'domain will set it. */
|
|
700 internal_bind_lisp_object (&Vfile_domain, Qnil);
|
428
|
701 #endif
|
|
702
|
|
703 /* Now determine what sort of ELC file we're reading in. */
|
853
|
704 internal_bind_int (&load_byte_code_version, load_byte_code_version);
|
428
|
705 if (reading_elc)
|
|
706 {
|
|
707 char elc_header[8];
|
|
708 int num_read;
|
|
709
|
|
710 num_read = Lstream_read (XLSTREAM (lispstream), elc_header, 8);
|
|
711 if (num_read < 8
|
|
712 || strncmp (elc_header, ";ELC", 4))
|
|
713 {
|
|
714 /* Huh? Probably not a valid ELC file. */
|
|
715 load_byte_code_version = 100; /* no Ebolification needed */
|
|
716 Lstream_unread (XLSTREAM (lispstream), elc_header, num_read);
|
|
717 }
|
|
718 else
|
|
719 load_byte_code_version = elc_header[4];
|
|
720 }
|
|
721 else
|
|
722 load_byte_code_version = 100; /* no Ebolification needed */
|
|
723
|
|
724 readevalloop (lispstream, file, Feval, 0);
|
|
725 if (!NILP (used_codesys))
|
|
726 Fset (used_codesys,
|
|
727 XCODING_SYSTEM_NAME
|
771
|
728 (coding_stream_detected_coding_system (XLSTREAM (lispstream))));
|
|
729 unbind_to (speccount);
|
428
|
730
|
|
731 NUNGCPRO;
|
|
732 }
|
|
733
|
|
734 {
|
|
735 Lisp_Object tem;
|
|
736 /* #### Disgusting kludge */
|
|
737 /* Run any load-hooks for this file. */
|
|
738 /* #### An even more disgusting kludge. There is horrible code */
|
|
739 /* that is relying on the fact that dumped lisp files are found */
|
|
740 /* via `load-path' search. */
|
|
741 Lisp_Object name = file;
|
|
742
|
1123
|
743 if (!NILP (Ffile_name_absolute_p (file)))
|
|
744 name = Ffile_name_nondirectory (file);
|
428
|
745
|
1261
|
746 tem = Fassoc (name, Vafter_load_alist);
|
428
|
747 if (!NILP (tem))
|
|
748 {
|
|
749 struct gcpro ngcpro1;
|
|
750
|
|
751 NGCPRO1 (tem);
|
|
752 /* Use eval so that errors give a semi-meaningful backtrace. --Stig */
|
|
753 tem = Fcons (Qprogn, Fcdr (tem));
|
|
754 Feval (tem);
|
|
755 NUNGCPRO;
|
|
756 }
|
|
757 }
|
|
758
|
|
759 if (!noninteractive)
|
|
760 PRINT_LOADING_MESSAGE ("done");
|
|
761
|
1292
|
762 retval = Qt;
|
|
763 done:
|
|
764 PROFILE_RECORD_EXITING_SECTION (Qload_internal);
|
428
|
765 UNGCPRO;
|
1292
|
766 return retval;
|
428
|
767 }
|
|
768
|
|
769
|
|
770 /* ------------------------------- */
|
|
771 /* locate_file */
|
|
772 /* ------------------------------- */
|
|
773
|
|
774 static int
|
|
775 decode_mode_1 (Lisp_Object mode)
|
|
776 {
|
|
777 if (EQ (mode, Qexists))
|
|
778 return F_OK;
|
|
779 else if (EQ (mode, Qexecutable))
|
|
780 return X_OK;
|
|
781 else if (EQ (mode, Qwritable))
|
|
782 return W_OK;
|
|
783 else if (EQ (mode, Qreadable))
|
|
784 return R_OK;
|
|
785 else if (INTP (mode))
|
|
786 {
|
|
787 check_int_range (XINT (mode), 0, 7);
|
|
788 return XINT (mode);
|
|
789 }
|
|
790 else
|
563
|
791 invalid_argument ("Invalid value", mode);
|
428
|
792 return 0; /* unreached */
|
|
793 }
|
|
794
|
|
795 static int
|
|
796 decode_mode (Lisp_Object mode)
|
|
797 {
|
|
798 if (NILP (mode))
|
|
799 return R_OK;
|
|
800 else if (CONSP (mode))
|
|
801 {
|
|
802 int mask = 0;
|
2367
|
803 EXTERNAL_LIST_LOOP_2 (elt, mode)
|
|
804 mask |= decode_mode_1 (elt);
|
428
|
805 return mask;
|
|
806 }
|
|
807 else
|
|
808 return decode_mode_1 (mode);
|
|
809 }
|
|
810
|
|
811 DEFUN ("locate-file", Flocate_file, 2, 4, 0, /*
|
|
812 Search for FILENAME through PATH-LIST.
|
|
813
|
|
814 If SUFFIXES is non-nil, it should be a list of suffixes to append to
|
|
815 file name when searching.
|
|
816
|
|
817 If MODE is non-nil, it should be a symbol or a list of symbol representing
|
|
818 requirements. Allowed symbols are `exists', `executable', `writable', and
|
|
819 `readable'. If MODE is nil, it defaults to `readable'.
|
|
820
|
|
821 `locate-file' keeps hash tables of the directories it searches through,
|
|
822 in order to speed things up. It tries valiantly to not get confused in
|
|
823 the face of a changing and unpredictable environment, but can occasionally
|
|
824 get tripped up. In this case, you will have to call
|
|
825 `locate-file-clear-hashing' to get it back on track. See that function
|
|
826 for details.
|
|
827 */
|
|
828 (filename, path_list, suffixes, mode))
|
|
829 {
|
|
830 /* This function can GC */
|
|
831 Lisp_Object tp;
|
|
832
|
|
833 CHECK_STRING (filename);
|
|
834
|
|
835 if (LISTP (suffixes))
|
|
836 {
|
2367
|
837 EXTERNAL_LIST_LOOP_2 (elt, suffixes)
|
|
838 CHECK_STRING (elt);
|
428
|
839 }
|
|
840 else
|
|
841 CHECK_STRING (suffixes);
|
|
842
|
|
843 locate_file (path_list, filename, suffixes, &tp, decode_mode (mode));
|
|
844 return tp;
|
|
845 }
|
|
846
|
|
847 /* Recalculate the hash table for the given string. DIRECTORY should
|
|
848 better have been through Fexpand_file_name() by now. */
|
|
849
|
|
850 static Lisp_Object
|
|
851 locate_file_refresh_hashing (Lisp_Object directory)
|
|
852 {
|
|
853 Lisp_Object hash =
|
771
|
854 make_directory_hash_table (XSTRING_DATA (directory));
|
428
|
855
|
|
856 if (!NILP (hash))
|
|
857 Fputhash (directory, hash, Vlocate_file_hash_table);
|
|
858 return hash;
|
|
859 }
|
|
860
|
|
861 /* find the hash table for the given directory, recalculating if necessary */
|
|
862
|
|
863 static Lisp_Object
|
|
864 locate_file_find_directory_hash_table (Lisp_Object directory)
|
|
865 {
|
|
866 Lisp_Object hash = Fgethash (directory, Vlocate_file_hash_table, Qnil);
|
|
867 if (NILP (hash))
|
|
868 return locate_file_refresh_hashing (directory);
|
|
869 else
|
|
870 return hash;
|
|
871 }
|
|
872
|
|
873 /* The SUFFIXES argument in any of the locate_file* functions can be
|
|
874 nil, a list, or a string (for backward compatibility), with the
|
|
875 following semantics:
|
|
876
|
|
877 a) nil - no suffix, just search for file name intact
|
|
878 (semantically different from "empty suffix list", which
|
|
879 would be meaningless.)
|
|
880 b) list - list of suffixes to append to file name. Each of these
|
|
881 must be a string.
|
|
882 c) string - colon-separated suffixes to append to file name (backward
|
|
883 compatibility).
|
|
884
|
|
885 All of this got hairy, so I decided to use a mapper. Calling a
|
|
886 function for each suffix shouldn't slow things down, since
|
|
887 locate_file is rarely called with enough suffixes for funcalls to
|
|
888 make any difference. */
|
|
889
|
|
890 /* Map FUN over SUFFIXES, as described above. FUN will be called with a
|
|
891 char * containing the current file name, and ARG. Mapping stops when
|
|
892 FUN returns non-zero. */
|
|
893 static void
|
|
894 locate_file_map_suffixes (Lisp_Object filename, Lisp_Object suffixes,
|
867
|
895 int (*fun) (Ibyte *, void *),
|
428
|
896 void *arg)
|
|
897 {
|
|
898 /* This function can GC */
|
867
|
899 Ibyte *fn;
|
428
|
900 int fn_len, max;
|
|
901
|
|
902 /* Calculate maximum size of any filename made from
|
|
903 this path element/specified file name and any possible suffix. */
|
|
904 if (CONSP (suffixes))
|
|
905 {
|
|
906 /* We must traverse the list, so why not do it right. */
|
|
907 Lisp_Object tail;
|
|
908 max = 0;
|
|
909 LIST_LOOP (tail, suffixes)
|
|
910 {
|
|
911 if (XSTRING_LENGTH (XCAR (tail)) > max)
|
|
912 max = XSTRING_LENGTH (XCAR (tail));
|
|
913 }
|
|
914 }
|
|
915 else if (NILP (suffixes))
|
|
916 max = 0;
|
|
917 else
|
|
918 /* Just take the easy way out */
|
|
919 max = XSTRING_LENGTH (suffixes);
|
|
920
|
|
921 fn_len = XSTRING_LENGTH (filename);
|
2367
|
922 fn = alloca_ibytes (max + fn_len + 1);
|
771
|
923 memcpy (fn, XSTRING_DATA (filename), fn_len);
|
428
|
924
|
|
925 /* Loop over suffixes. */
|
|
926 if (!STRINGP (suffixes))
|
|
927 {
|
|
928 if (NILP (suffixes))
|
|
929 {
|
|
930 /* Case a) discussed in the comment above. */
|
|
931 fn[fn_len] = 0;
|
|
932 if ((*fun) (fn, arg))
|
|
933 return;
|
|
934 }
|
|
935 else
|
|
936 {
|
|
937 /* Case b) */
|
|
938 Lisp_Object tail;
|
|
939 LIST_LOOP (tail, suffixes)
|
|
940 {
|
|
941 memcpy (fn + fn_len, XSTRING_DATA (XCAR (tail)),
|
|
942 XSTRING_LENGTH (XCAR (tail)));
|
|
943 fn[fn_len + XSTRING_LENGTH (XCAR (tail))] = 0;
|
|
944 if ((*fun) (fn, arg))
|
|
945 return;
|
|
946 }
|
|
947 }
|
|
948 }
|
|
949 else
|
|
950 {
|
|
951 /* Case c) */
|
867
|
952 const Ibyte *nsuffix = XSTRING_DATA (suffixes);
|
428
|
953
|
|
954 while (1)
|
|
955 {
|
867
|
956 Ibyte *esuffix = qxestrchr (nsuffix, ':');
|
771
|
957 Bytecount lsuffix = esuffix ? esuffix - nsuffix :
|
|
958 qxestrlen (nsuffix);
|
428
|
959
|
|
960 /* Concatenate path element/specified name with the suffix. */
|
771
|
961 qxestrncpy (fn + fn_len, nsuffix, lsuffix);
|
428
|
962 fn[fn_len + lsuffix] = 0;
|
|
963
|
|
964 if ((*fun) (fn, arg))
|
|
965 return;
|
|
966
|
|
967 /* Advance to next suffix. */
|
|
968 if (esuffix == 0)
|
|
969 break;
|
|
970 nsuffix += lsuffix + 1;
|
|
971 }
|
|
972 }
|
|
973 }
|
|
974
|
771
|
975 struct locate_file_in_directory_mapper_closure
|
|
976 {
|
428
|
977 int fd;
|
|
978 Lisp_Object *storeptr;
|
|
979 int mode;
|
|
980 };
|
|
981
|
1123
|
982 /* open() or access() a file to be returned by locate_file(). if
|
|
983 ACCESS_MODE >= 0, do an access() with that mode, else open(). Does
|
|
984 various magic, e.g. opening the file read-only and binary and setting
|
|
985 the close-on-exec flag on the file. */
|
|
986
|
|
987 static int
|
|
988 locate_file_open_or_access_file (Ibyte *fn, int access_mode)
|
|
989 {
|
|
990 int val;
|
|
991
|
|
992 /* Check that we can access or open it. */
|
|
993 if (access_mode >= 0)
|
|
994 val = qxe_access (fn, access_mode);
|
|
995 else
|
|
996 {
|
|
997 val = qxe_open (fn, O_RDONLY | OPEN_BINARY, 0);
|
|
998
|
|
999 #ifndef WIN32_NATIVE
|
|
1000 if (val >= 0)
|
|
1001 /* If we actually opened the file, set close-on-exec flag
|
|
1002 on the new descriptor so that subprocesses can't whack
|
|
1003 at it. */
|
|
1004 (void) fcntl (val, F_SETFD, FD_CLOEXEC);
|
|
1005 #endif
|
|
1006 }
|
|
1007
|
|
1008 return val;
|
|
1009 }
|
|
1010
|
428
|
1011 static int
|
867
|
1012 locate_file_in_directory_mapper (Ibyte *fn, void *arg)
|
428
|
1013 {
|
|
1014 struct locate_file_in_directory_mapper_closure *closure =
|
771
|
1015 (struct locate_file_in_directory_mapper_closure *) arg;
|
428
|
1016 struct stat st;
|
|
1017
|
|
1018 /* Ignore file if it's a directory. */
|
771
|
1019 if (qxe_stat (fn, &st) >= 0
|
428
|
1020 && (st.st_mode & S_IFMT) != S_IFDIR)
|
|
1021 {
|
|
1022 /* Check that we can access or open it. */
|
1123
|
1023 closure->fd = locate_file_open_or_access_file (fn, closure->mode);
|
428
|
1024
|
|
1025 if (closure->fd >= 0)
|
|
1026 {
|
|
1027 /* We succeeded; return this descriptor and filename. */
|
|
1028 if (closure->storeptr)
|
771
|
1029 *closure->storeptr = build_intstring (fn);
|
428
|
1030
|
|
1031 return 1;
|
|
1032 }
|
|
1033 }
|
|
1034 /* Keep mapping. */
|
|
1035 return 0;
|
|
1036 }
|
|
1037
|
|
1038
|
|
1039 /* look for STR in PATH, optionally adding SUFFIXES. DIRECTORY need
|
|
1040 not have been expanded. */
|
|
1041
|
|
1042 static int
|
|
1043 locate_file_in_directory (Lisp_Object directory, Lisp_Object str,
|
|
1044 Lisp_Object suffixes, Lisp_Object *storeptr,
|
|
1045 int mode)
|
|
1046 {
|
|
1047 /* This function can GC */
|
|
1048 struct locate_file_in_directory_mapper_closure closure;
|
|
1049 Lisp_Object filename = Qnil;
|
|
1050 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1051
|
|
1052 GCPRO3 (directory, str, filename);
|
|
1053
|
|
1054 filename = Fexpand_file_name (str, directory);
|
|
1055 if (NILP (filename) || NILP (Ffile_name_absolute_p (filename)))
|
|
1056 /* If there are non-absolute elts in PATH (eg ".") */
|
|
1057 /* Of course, this could conceivably lose if luser sets
|
|
1058 default-directory to be something non-absolute ... */
|
|
1059 {
|
|
1060 if (NILP (filename))
|
|
1061 /* NIL means current directory */
|
|
1062 filename = current_buffer->directory;
|
|
1063 else
|
|
1064 filename = Fexpand_file_name (filename,
|
|
1065 current_buffer->directory);
|
|
1066 if (NILP (Ffile_name_absolute_p (filename)))
|
|
1067 {
|
|
1068 /* Give up on this directory! */
|
|
1069 UNGCPRO;
|
|
1070 return -1;
|
|
1071 }
|
|
1072 }
|
|
1073
|
|
1074 closure.fd = -1;
|
|
1075 closure.storeptr = storeptr;
|
|
1076 closure.mode = mode;
|
|
1077
|
771
|
1078 locate_file_map_suffixes (filename, suffixes,
|
|
1079 locate_file_in_directory_mapper,
|
428
|
1080 &closure);
|
|
1081
|
|
1082 UNGCPRO;
|
|
1083 return closure.fd;
|
|
1084 }
|
|
1085
|
|
1086 /* do the same as locate_file() but don't use any hash tables. */
|
|
1087
|
|
1088 static int
|
|
1089 locate_file_without_hash (Lisp_Object path, Lisp_Object str,
|
|
1090 Lisp_Object suffixes, Lisp_Object *storeptr,
|
|
1091 int mode)
|
|
1092 {
|
|
1093 /* This function can GC */
|
|
1094 int absolute = !NILP (Ffile_name_absolute_p (str));
|
|
1095
|
2367
|
1096 EXTERNAL_LIST_LOOP_2 (elt, path)
|
428
|
1097 {
|
2367
|
1098 int val = locate_file_in_directory (elt, str, suffixes, storeptr,
|
428
|
1099 mode);
|
|
1100 if (val >= 0)
|
|
1101 return val;
|
|
1102 if (absolute)
|
|
1103 break;
|
|
1104 }
|
|
1105 return -1;
|
|
1106 }
|
|
1107
|
|
1108 static int
|
867
|
1109 locate_file_construct_suffixed_files_mapper (Ibyte *fn, void *arg)
|
428
|
1110 {
|
771
|
1111 Lisp_Object *tail = (Lisp_Object *) arg;
|
|
1112 *tail = Fcons (build_intstring (fn), *tail);
|
428
|
1113 return 0;
|
|
1114 }
|
|
1115
|
|
1116 /* Construct a list of all files to search for.
|
|
1117 It makes sense to have this despite locate_file_map_suffixes()
|
|
1118 because we need Lisp strings to access the hash-table, and it would
|
|
1119 be inefficient to create them on the fly, again and again for each
|
|
1120 path component. See locate_file(). */
|
|
1121
|
|
1122 static Lisp_Object
|
|
1123 locate_file_construct_suffixed_files (Lisp_Object filename,
|
|
1124 Lisp_Object suffixes)
|
|
1125 {
|
|
1126 Lisp_Object tail = Qnil;
|
|
1127 struct gcpro gcpro1;
|
|
1128 GCPRO1 (tail);
|
|
1129
|
|
1130 locate_file_map_suffixes (filename, suffixes,
|
|
1131 locate_file_construct_suffixed_files_mapper,
|
|
1132 &tail);
|
|
1133
|
|
1134 UNGCPRO;
|
|
1135 return Fnreverse (tail);
|
|
1136 }
|
|
1137
|
|
1138 DEFUN ("locate-file-clear-hashing", Flocate_file_clear_hashing, 1, 1, 0, /*
|
|
1139 Clear the hash records for the specified list of directories.
|
|
1140 `locate-file' uses a hashing scheme to speed lookup, and will correctly
|
|
1141 track the following environmental changes:
|
|
1142
|
|
1143 -- changes of any sort to the list of directories to be searched.
|
|
1144 -- addition and deletion of non-shadowing files (see below) from the
|
|
1145 directories in the list.
|
|
1146 -- byte-compilation of a .el file into a .elc file.
|
|
1147
|
|
1148 `locate-file' will primarily get confused if you add a file that shadows
|
|
1149 \(i.e. has the same name as) another file further down in the directory list.
|
|
1150 In this case, you must call `locate-file-clear-hashing'.
|
|
1151
|
|
1152 If PATH is t, it means to fully clear all the accumulated hashes. This
|
|
1153 can be used if the internal tables grow too large, or when dumping.
|
|
1154 */
|
|
1155 (path))
|
|
1156 {
|
|
1157 if (EQ (path, Qt))
|
|
1158 Fclrhash (Vlocate_file_hash_table);
|
|
1159 else
|
|
1160 {
|
2367
|
1161 EXTERNAL_LIST_LOOP_2 (elt, path)
|
428
|
1162 {
|
2367
|
1163 Lisp_Object pathel = Fexpand_file_name (elt, Qnil);
|
428
|
1164 Fremhash (pathel, Vlocate_file_hash_table);
|
|
1165 }
|
|
1166 }
|
|
1167 return Qnil;
|
|
1168 }
|
|
1169
|
|
1170 /* Search for a file whose name is STR, looking in directories
|
|
1171 in the Lisp list PATH, and trying suffixes from SUFFIXES.
|
|
1172 SUFFIXES is a list of possible suffixes, or (for backward
|
|
1173 compatibility) a string containing possible suffixes separated by
|
|
1174 colons.
|
|
1175 On success, returns a file descriptor. On failure, returns -1.
|
|
1176
|
|
1177 MODE nonnegative means don't open the files,
|
|
1178 just look for one for which access(file,MODE) succeeds. In this case,
|
951
|
1179 returns a nonnegative value on success. On failure, returns -1.
|
428
|
1180
|
|
1181 If STOREPTR is nonzero, it points to a slot where the name of
|
|
1182 the file actually found should be stored as a Lisp string.
|
|
1183 Nil is stored there on failure.
|
|
1184
|
|
1185 Called openp() in FSFmacs. */
|
|
1186
|
|
1187 int
|
|
1188 locate_file (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
|
|
1189 Lisp_Object *storeptr, int mode)
|
|
1190 {
|
|
1191 /* This function can GC */
|
|
1192 Lisp_Object suffixtab = Qnil;
|
2367
|
1193 Lisp_Object pathel_expanded;
|
428
|
1194 int val;
|
|
1195 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
|
|
1196
|
|
1197 if (storeptr)
|
|
1198 *storeptr = Qnil;
|
|
1199
|
|
1200 /* Is it really necessary to gcpro path and str? It shouldn't be
|
|
1201 unless some caller has fucked up. There are known instances that
|
|
1202 call us with build_string("foo:bar") as SUFFIXES, though. */
|
|
1203 GCPRO4 (path, str, suffixes, suffixtab);
|
|
1204
|
|
1205 /* if this filename has directory components, it's too complicated
|
|
1206 to try and use the hash tables. */
|
|
1207 if (!NILP (Ffile_name_directory (str)))
|
|
1208 {
|
|
1209 val = locate_file_without_hash (path, str, suffixes, storeptr, mode);
|
|
1210 UNGCPRO;
|
|
1211 return val;
|
|
1212 }
|
|
1213
|
|
1214 suffixtab = locate_file_construct_suffixed_files (str, suffixes);
|
|
1215
|
2367
|
1216 {
|
|
1217 EXTERNAL_LIST_LOOP_2 (pathel, path)
|
|
1218 {
|
|
1219 Lisp_Object hash_table;
|
|
1220 int found = 0;
|
|
1221
|
|
1222 /* If this path element is relative, we have to look by hand. */
|
|
1223 if (NILP (pathel) || NILP (Ffile_name_absolute_p (pathel)))
|
|
1224 {
|
|
1225 val = locate_file_in_directory (pathel, str, suffixes, storeptr,
|
|
1226 mode);
|
|
1227 if (val >= 0)
|
428
|
1228 {
|
2367
|
1229 UNGCPRO;
|
|
1230 return val;
|
428
|
1231 }
|
2367
|
1232 continue;
|
|
1233 }
|
|
1234
|
|
1235 pathel_expanded = Fexpand_file_name (pathel, Qnil);
|
|
1236 hash_table = locate_file_find_directory_hash_table (pathel_expanded);
|
|
1237
|
|
1238 if (!NILP (hash_table))
|
|
1239 {
|
|
1240 /* Loop over suffixes. */
|
|
1241 LIST_LOOP_2 (elt, suffixtab)
|
|
1242 if (!NILP (Fgethash (elt, hash_table, Qnil)))
|
|
1243 {
|
|
1244 found = 1;
|
|
1245 break;
|
|
1246 }
|
|
1247 }
|
|
1248
|
|
1249 if (found)
|
|
1250 {
|
|
1251 /* This is a likely candidate. Look by hand in this directory
|
|
1252 so we don't get thrown off if someone byte-compiles a file. */
|
|
1253 val = locate_file_in_directory (pathel, str, suffixes, storeptr,
|
|
1254 mode);
|
|
1255 if (val >= 0)
|
|
1256 {
|
|
1257 UNGCPRO;
|
|
1258 return val;
|
|
1259 }
|
|
1260
|
|
1261 /* Hmm ... the file isn't actually there. (Or possibly it's
|
|
1262 a directory ...) So refresh our hashing. */
|
|
1263 locate_file_refresh_hashing (pathel_expanded);
|
|
1264 }
|
|
1265 }
|
428
|
1266 }
|
|
1267
|
|
1268 /* File is probably not there, but check the hard way just in case. */
|
|
1269 val = locate_file_without_hash (path, str, suffixes, storeptr, mode);
|
|
1270 if (val >= 0)
|
|
1271 {
|
|
1272 /* Sneaky user added a file without telling us. */
|
|
1273 Flocate_file_clear_hashing (path);
|
|
1274 }
|
|
1275
|
|
1276 UNGCPRO;
|
|
1277 return val;
|
|
1278 }
|
|
1279
|
|
1280
|
|
1281 #ifdef LOADHIST
|
|
1282
|
|
1283 /* Merge the list we've accumulated of globals from the current input source
|
|
1284 into the load_history variable. The details depend on whether
|
|
1285 the source has an associated file name or not. */
|
|
1286
|
|
1287 static void
|
|
1288 build_load_history (int loading, Lisp_Object source)
|
|
1289 {
|
|
1290 REGISTER Lisp_Object tail, prev, newelt;
|
|
1291 REGISTER Lisp_Object tem, tem2;
|
|
1292 int foundit;
|
|
1293
|
|
1294 #if !defined(LOADHIST_DUMPED)
|
|
1295 /* Don't bother recording anything for preloaded files. */
|
|
1296 if (purify_flag)
|
|
1297 return;
|
|
1298 #endif
|
|
1299
|
|
1300 tail = Vload_history;
|
|
1301 prev = Qnil;
|
|
1302 foundit = 0;
|
|
1303 while (!NILP (tail))
|
|
1304 {
|
|
1305 tem = Fcar (tail);
|
|
1306
|
|
1307 /* Find the feature's previous assoc list... */
|
|
1308 if (internal_equal (source, Fcar (tem), 0))
|
|
1309 {
|
|
1310 foundit = 1;
|
|
1311
|
|
1312 /* If we're loading, remove it. */
|
|
1313 if (loading)
|
|
1314 {
|
|
1315 if (NILP (prev))
|
|
1316 Vload_history = Fcdr (tail);
|
|
1317 else
|
|
1318 Fsetcdr (prev, Fcdr (tail));
|
|
1319 }
|
|
1320
|
|
1321 /* Otherwise, cons on new symbols that are not already members. */
|
|
1322 else
|
|
1323 {
|
|
1324 tem2 = Vcurrent_load_list;
|
|
1325
|
|
1326 while (CONSP (tem2))
|
|
1327 {
|
|
1328 newelt = XCAR (tem2);
|
|
1329
|
|
1330 if (NILP (Fmemq (newelt, tem)))
|
|
1331 Fsetcar (tail, Fcons (Fcar (tem),
|
|
1332 Fcons (newelt, Fcdr (tem))));
|
|
1333
|
|
1334 tem2 = XCDR (tem2);
|
|
1335 QUIT;
|
|
1336 }
|
|
1337 }
|
|
1338 }
|
|
1339 else
|
|
1340 prev = tail;
|
|
1341 tail = Fcdr (tail);
|
|
1342 QUIT;
|
|
1343 }
|
|
1344
|
|
1345 /* If we're loading, cons the new assoc onto the front of load-history,
|
|
1346 the most-recently-loaded position. Also do this if we didn't find
|
|
1347 an existing member for the current source. */
|
|
1348 if (loading || !foundit)
|
|
1349 Vload_history = Fcons (Fnreverse (Vcurrent_load_list),
|
|
1350 Vload_history);
|
|
1351 }
|
|
1352
|
|
1353 #else /* !LOADHIST */
|
|
1354 #define build_load_history(x,y)
|
|
1355 #endif /* !LOADHIST */
|
|
1356
|
|
1357
|
|
1358 static void
|
|
1359 readevalloop (Lisp_Object readcharfun,
|
|
1360 Lisp_Object sourcename,
|
|
1361 Lisp_Object (*evalfun) (Lisp_Object),
|
|
1362 int printflag)
|
|
1363 {
|
|
1364 /* This function can GC */
|
867
|
1365 REGISTER Ichar c;
|
1849
|
1366 Lisp_Object val = Qnil;
|
428
|
1367 int speccount = specpdl_depth ();
|
|
1368 struct gcpro gcpro1, gcpro2;
|
|
1369 struct buffer *b = 0;
|
|
1370
|
|
1371 if (BUFFERP (readcharfun))
|
|
1372 b = XBUFFER (readcharfun);
|
|
1373 else if (MARKERP (readcharfun))
|
|
1374 b = XMARKER (readcharfun)->buffer;
|
|
1375
|
|
1376 /* Don't do this. It is not necessary, and it needlessly exposes
|
|
1377 READCHARFUN (which can be a stream) to Lisp. --hniksic */
|
|
1378 /*specbind (Qstandard_input, readcharfun);*/
|
|
1379
|
|
1380 specbind (Qcurrent_load_list, Qnil);
|
|
1381
|
|
1382 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
1383 Vcurrent_compiled_function_annotation = Qnil;
|
|
1384 #endif
|
|
1385 GCPRO2 (val, sourcename);
|
|
1386
|
|
1387 LOADHIST_ATTACH (sourcename);
|
|
1388
|
|
1389 while (1)
|
|
1390 {
|
|
1391 QUIT;
|
|
1392
|
|
1393 if (b != 0 && !BUFFER_LIVE_P (b))
|
563
|
1394 invalid_operation ("Reading from killed buffer", Qunbound);
|
428
|
1395
|
|
1396 c = readchar (readcharfun);
|
|
1397 if (c == ';')
|
|
1398 {
|
|
1399 /* Skip comment */
|
|
1400 while ((c = readchar (readcharfun)) != '\n' && c != -1)
|
|
1401 QUIT;
|
|
1402 continue;
|
|
1403 }
|
|
1404 if (c < 0)
|
|
1405 break;
|
|
1406
|
|
1407 /* Ignore whitespace here, so we can detect eof. */
|
|
1408 if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r')
|
|
1409 continue;
|
|
1410
|
814
|
1411 unreadchar (readcharfun, c);
|
|
1412 Vread_objects = Qnil;
|
|
1413 if (NILP (Vload_read_function))
|
|
1414 val = read0 (readcharfun);
|
428
|
1415 else
|
814
|
1416 val = call1 (Vload_read_function, readcharfun);
|
428
|
1417 val = (*evalfun) (val);
|
|
1418 if (printflag)
|
|
1419 {
|
|
1420 Vvalues = Fcons (val, Vvalues);
|
|
1421 if (EQ (Vstandard_output, Qt))
|
|
1422 Fprin1 (val, Qnil);
|
|
1423 else
|
|
1424 Fprint (val, Qnil);
|
|
1425 }
|
|
1426 }
|
|
1427
|
|
1428 build_load_history (LSTREAMP (readcharfun) ||
|
|
1429 /* This looks weird, but it's what's in FSFmacs */
|
|
1430 (b ? BUF_NARROWED (b) : BUF_NARROWED (current_buffer)),
|
|
1431 sourcename);
|
|
1432 UNGCPRO;
|
|
1433
|
771
|
1434 unbind_to (speccount);
|
428
|
1435 }
|
|
1436
|
|
1437 DEFUN ("eval-buffer", Feval_buffer, 0, 2, "bBuffer: ", /*
|
|
1438 Execute BUFFER as Lisp code.
|
|
1439 Programs can pass two arguments, BUFFER and PRINTFLAG.
|
|
1440 BUFFER is the buffer to evaluate (nil means use current buffer).
|
|
1441 PRINTFLAG controls printing of output:
|
444
|
1442 nil means discard it; anything else is a stream for printing.
|
428
|
1443
|
|
1444 If there is no error, point does not move. If there is an error,
|
|
1445 point remains at the end of the last character read from the buffer.
|
|
1446 */
|
444
|
1447 (buffer, printflag))
|
428
|
1448 {
|
|
1449 /* This function can GC */
|
|
1450 int speccount = specpdl_depth ();
|
|
1451 Lisp_Object tem, buf;
|
|
1452
|
444
|
1453 if (NILP (buffer))
|
428
|
1454 buf = Fcurrent_buffer ();
|
|
1455 else
|
444
|
1456 buf = Fget_buffer (buffer);
|
428
|
1457 if (NILP (buf))
|
563
|
1458 invalid_argument ("No such buffer", Qunbound);
|
428
|
1459
|
|
1460 if (NILP (printflag))
|
|
1461 tem = Qsymbolp; /* #### #@[]*&$#*[& SI:NULL-STREAM */
|
|
1462 else
|
|
1463 tem = printflag;
|
|
1464 specbind (Qstandard_output, tem);
|
|
1465 record_unwind_protect (save_excursion_restore, save_excursion_save ());
|
|
1466 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
|
|
1467 readevalloop (buf, XBUFFER (buf)->filename, Feval,
|
|
1468 !NILP (printflag));
|
|
1469
|
771
|
1470 return unbind_to (speccount);
|
428
|
1471 }
|
|
1472
|
|
1473 #if 0
|
826
|
1474 DEFUN ("eval-current-buffer", Feval_current_buffer, 0, 1, "", /*
|
428
|
1475 Execute the current buffer as Lisp code.
|
|
1476 Programs can pass argument PRINTFLAG which controls printing of output:
|
|
1477 nil means discard it; anything else is stream for print.
|
|
1478
|
|
1479 If there is no error, point does not move. If there is an error,
|
|
1480 point remains at the end of the last character read from the buffer.
|
|
1481 */
|
|
1482 (printflag))
|
|
1483 {
|
|
1484 code omitted;
|
|
1485 }
|
|
1486 #endif /* 0 */
|
|
1487
|
|
1488 DEFUN ("eval-region", Feval_region, 2, 3, "r", /*
|
|
1489 Execute the region as Lisp code.
|
444
|
1490 When called from programs, expects two arguments START and END
|
428
|
1491 giving starting and ending indices in the current buffer
|
|
1492 of the text to be executed.
|
444
|
1493 Programs can pass third optional argument STREAM which controls output:
|
428
|
1494 nil means discard it; anything else is stream for printing it.
|
|
1495
|
|
1496 If there is no error, point does not move. If there is an error,
|
|
1497 point remains at the end of the last character read from the buffer.
|
|
1498
|
|
1499 Note: Before evaling the region, this function narrows the buffer to it.
|
|
1500 If the code being eval'd should happen to trigger a redisplay you may
|
|
1501 see some text temporarily disappear because of this.
|
|
1502 */
|
444
|
1503 (start, end, stream))
|
428
|
1504 {
|
|
1505 /* This function can GC */
|
|
1506 int speccount = specpdl_depth ();
|
|
1507 Lisp_Object tem;
|
|
1508 Lisp_Object cbuf = Fcurrent_buffer ();
|
|
1509
|
444
|
1510 if (NILP (stream))
|
428
|
1511 tem = Qsymbolp; /* #### #@[]*&$#*[& SI:NULL-STREAM */
|
|
1512 else
|
444
|
1513 tem = stream;
|
428
|
1514 specbind (Qstandard_output, tem);
|
|
1515
|
444
|
1516 if (NILP (stream))
|
428
|
1517 record_unwind_protect (save_excursion_restore, save_excursion_save ());
|
844
|
1518 record_unwind_protect (save_restriction_restore,
|
|
1519 save_restriction_save (current_buffer));
|
428
|
1520
|
444
|
1521 /* This both uses start and checks its type. */
|
|
1522 Fgoto_char (start, cbuf);
|
|
1523 Fnarrow_to_region (make_int (BUF_BEGV (current_buffer)), end, cbuf);
|
428
|
1524 readevalloop (cbuf, XBUFFER (cbuf)->filename, Feval,
|
444
|
1525 !NILP (stream));
|
428
|
1526
|
771
|
1527 return unbind_to (speccount);
|
428
|
1528 }
|
|
1529
|
|
1530 DEFUN ("read", Fread, 0, 1, 0, /*
|
|
1531 Read one Lisp expression as text from STREAM, return as Lisp object.
|
|
1532 If STREAM is nil, use the value of `standard-input' (which see).
|
|
1533 STREAM or the value of `standard-input' may be:
|
|
1534 a buffer (read from point and advance it)
|
|
1535 a marker (read from where it points and advance it)
|
|
1536 a function (call it with no arguments for each character,
|
|
1537 call it with a char as argument to push a char back)
|
|
1538 a string (takes text from string, starting at the beginning)
|
|
1539 t (read text line using minibuffer and use it).
|
|
1540 */
|
|
1541 (stream))
|
|
1542 {
|
|
1543 if (NILP (stream))
|
|
1544 stream = Vstandard_input;
|
|
1545 if (EQ (stream, Qt))
|
|
1546 stream = Qread_char;
|
|
1547
|
|
1548 Vread_objects = Qnil;
|
|
1549
|
|
1550 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
1551 Vcurrent_compiled_function_annotation = Qnil;
|
|
1552 #endif
|
|
1553 if (EQ (stream, Qread_char))
|
|
1554 {
|
|
1555 Lisp_Object val = call1 (Qread_from_minibuffer,
|
771
|
1556 build_msg_string ("Lisp expression: "));
|
428
|
1557 return Fcar (Fread_from_string (val, Qnil, Qnil));
|
|
1558 }
|
|
1559
|
|
1560 if (STRINGP (stream))
|
|
1561 return Fcar (Fread_from_string (stream, Qnil, Qnil));
|
|
1562
|
|
1563 return read0 (stream);
|
|
1564 }
|
|
1565
|
|
1566 DEFUN ("read-from-string", Fread_from_string, 1, 3, 0, /*
|
|
1567 Read one Lisp expression which is represented as text by STRING.
|
|
1568 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).
|
|
1569 START and END optionally delimit a substring of STRING from which to read;
|
|
1570 they default to 0 and (length STRING) respectively.
|
|
1571 */
|
|
1572 (string, start, end))
|
|
1573 {
|
|
1574 Bytecount startval, endval;
|
|
1575 Lisp_Object tem;
|
|
1576 Lisp_Object lispstream = Qnil;
|
|
1577 struct gcpro gcpro1;
|
|
1578
|
|
1579 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
1580 Vcurrent_compiled_function_annotation = Qnil;
|
|
1581 #endif
|
|
1582 GCPRO1 (lispstream);
|
|
1583 CHECK_STRING (string);
|
|
1584 get_string_range_byte (string, start, end, &startval, &endval,
|
|
1585 GB_HISTORICAL_STRING_BEHAVIOR);
|
|
1586 lispstream = make_lisp_string_input_stream (string, startval,
|
|
1587 endval - startval);
|
|
1588
|
|
1589 Vread_objects = Qnil;
|
|
1590
|
|
1591 tem = read0 (lispstream);
|
|
1592 /* Yeah, it's ugly. Gonna make something of it?
|
|
1593 At least our reader is reentrant ... */
|
|
1594 tem =
|
|
1595 (Fcons (tem, make_int
|
793
|
1596 (string_index_byte_to_char
|
771
|
1597 (string,
|
428
|
1598 startval + Lstream_byte_count (XLSTREAM (lispstream))))));
|
|
1599 Lstream_delete (XLSTREAM (lispstream));
|
|
1600 UNGCPRO;
|
|
1601 return tem;
|
|
1602 }
|
|
1603
|
|
1604
|
|
1605
|
|
1606 /* Use this for recursive reads, in contexts where internal tokens
|
|
1607 are not allowed. See also read1(). */
|
|
1608 static Lisp_Object
|
|
1609 read0 (Lisp_Object readcharfun)
|
|
1610 {
|
|
1611 Lisp_Object val = read1 (readcharfun);
|
|
1612
|
|
1613 if (CONSP (val) && UNBOUNDP (XCAR (val)))
|
|
1614 {
|
867
|
1615 Ichar c = XCHAR (XCDR (val));
|
853
|
1616 free_cons (val);
|
428
|
1617 return Fsignal (Qinvalid_read_syntax,
|
|
1618 list1 (Fchar_to_string (make_char (c))));
|
|
1619 }
|
|
1620
|
|
1621 return val;
|
|
1622 }
|
|
1623
|
867
|
1624 static Ichar
|
428
|
1625 read_escape (Lisp_Object readcharfun)
|
|
1626 {
|
|
1627 /* This function can GC */
|
867
|
1628 Ichar c = readchar (readcharfun);
|
428
|
1629
|
|
1630 if (c < 0)
|
563
|
1631 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1632
|
|
1633 switch (c)
|
|
1634 {
|
|
1635 case 'a': return '\007';
|
|
1636 case 'b': return '\b';
|
|
1637 case 'd': return 0177;
|
|
1638 case 'e': return 033;
|
|
1639 case 'f': return '\f';
|
|
1640 case 'n': return '\n';
|
|
1641 case 'r': return '\r';
|
|
1642 case 't': return '\t';
|
|
1643 case 'v': return '\v';
|
|
1644 case '\n': return -1;
|
|
1645
|
|
1646 case 'M':
|
|
1647 c = readchar (readcharfun);
|
|
1648 if (c < 0)
|
563
|
1649 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1650 if (c != '-')
|
563
|
1651 syntax_error ("Invalid escape character syntax", Qunbound);
|
428
|
1652 c = readchar (readcharfun);
|
|
1653 if (c < 0)
|
563
|
1654 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1655 if (c == '\\')
|
|
1656 c = read_escape (readcharfun);
|
|
1657 return c | 0200;
|
|
1658
|
|
1659 /* Originally, FSF_KEYS provided a degree of FSF Emacs
|
|
1660 compatibility by defining character "modifiers" alt, super,
|
|
1661 hyper and shift to infest the characters (i.e. integers).
|
|
1662
|
|
1663 However, this doesn't cut it for XEmacs 20, which
|
|
1664 distinguishes characters from integers. Without Mule, ?\H-a
|
|
1665 simply returns ?a because every character is clipped into
|
|
1666 0-255. Under Mule it is much worse -- ?\H-a with FSF_KEYS
|
|
1667 produces an illegal character, and moves us to crash-land.
|
|
1668
|
|
1669 For these reasons, FSF_KEYS hack is useless and without hope
|
|
1670 of ever working under XEmacs 20. */
|
|
1671 #ifdef FSF_KEYS
|
831
|
1672 /* Deleted */
|
|
1673 #endif
|
428
|
1674
|
|
1675 case 'C':
|
|
1676 c = readchar (readcharfun);
|
|
1677 if (c < 0)
|
563
|
1678 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1679 if (c != '-')
|
563
|
1680 syntax_error ("Invalid escape character syntax", Qunbound);
|
428
|
1681 case '^':
|
|
1682 c = readchar (readcharfun);
|
|
1683 if (c < 0)
|
563
|
1684 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1685 if (c == '\\')
|
|
1686 c = read_escape (readcharfun);
|
|
1687 /* FSFmacs junk for non-ASCII controls.
|
|
1688 Not used here. */
|
|
1689 if (c == '?')
|
|
1690 return 0177;
|
|
1691 else
|
|
1692 return c & (0200 | 037);
|
|
1693
|
|
1694 case '0':
|
|
1695 case '1':
|
|
1696 case '2':
|
|
1697 case '3':
|
|
1698 case '4':
|
|
1699 case '5':
|
|
1700 case '6':
|
|
1701 case '7':
|
|
1702 /* An octal escape, as in ANSI C. */
|
|
1703 {
|
867
|
1704 REGISTER Ichar i = c - '0';
|
428
|
1705 REGISTER int count = 0;
|
|
1706 while (++count < 3)
|
|
1707 {
|
|
1708 if ((c = readchar (readcharfun)) >= '0' && c <= '7')
|
|
1709 i = (i << 3) + (c - '0');
|
|
1710 else
|
|
1711 {
|
|
1712 unreadchar (readcharfun, c);
|
|
1713 break;
|
|
1714 }
|
|
1715 }
|
831
|
1716 if (i >= 0400)
|
|
1717 syntax_error ("Attempt to create non-ASCII/ISO-8859-1 character",
|
|
1718 make_int (i));
|
428
|
1719 return i;
|
|
1720 }
|
|
1721
|
|
1722 case 'x':
|
|
1723 /* A hex escape, as in ANSI C, except that we only allow latin-1
|
|
1724 characters to be read this way. What is "\x4e03" supposed to
|
|
1725 mean, anyways, if the internal representation is hidden?
|
|
1726 This is also consistent with the treatment of octal escapes. */
|
|
1727 {
|
867
|
1728 REGISTER Ichar i = 0;
|
428
|
1729 REGISTER int count = 0;
|
|
1730 while (++count <= 2)
|
|
1731 {
|
|
1732 c = readchar (readcharfun);
|
867
|
1733 /* Remember, can't use isdigit(), isalpha() etc. on Ichars */
|
428
|
1734 if (c >= '0' && c <= '9') i = (i << 4) + (c - '0');
|
|
1735 else if (c >= 'a' && c <= 'f') i = (i << 4) + (c - 'a') + 10;
|
|
1736 else if (c >= 'A' && c <= 'F') i = (i << 4) + (c - 'A') + 10;
|
|
1737 else
|
|
1738 {
|
|
1739 unreadchar (readcharfun, c);
|
|
1740 break;
|
|
1741 }
|
|
1742 }
|
|
1743 return i;
|
|
1744 }
|
|
1745
|
|
1746 #ifdef MULE
|
|
1747 /* #### need some way of reading an extended character with
|
|
1748 an escape sequence. */
|
|
1749 #endif
|
|
1750
|
|
1751 default:
|
|
1752 return c;
|
|
1753 }
|
|
1754 }
|
|
1755
|
|
1756
|
|
1757
|
|
1758 /* read symbol-constituent stuff into `Vread_buffer_stream'. */
|
|
1759 static Bytecount
|
867
|
1760 read_atom_0 (Lisp_Object readcharfun, Ichar firstchar, int *saw_a_backslash)
|
428
|
1761 {
|
|
1762 /* This function can GC */
|
867
|
1763 Ichar c = ((firstchar) >= 0 ? firstchar : readchar (readcharfun));
|
428
|
1764 Lstream_rewind (XLSTREAM (Vread_buffer_stream));
|
|
1765
|
|
1766 *saw_a_backslash = 0;
|
|
1767
|
|
1768 while (c > 040 /* #### - comma should be here as should backquote */
|
|
1769 && !(c == '\"' || c == '\'' || c == ';'
|
|
1770 || c == '(' || c == ')'
|
|
1771 || c == '[' || c == ']' || c == '#'
|
|
1772 ))
|
|
1773 {
|
|
1774 if (c == '\\')
|
|
1775 {
|
|
1776 c = readchar (readcharfun);
|
|
1777 if (c < 0)
|
563
|
1778 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1779 *saw_a_backslash = 1;
|
|
1780 }
|
867
|
1781 Lstream_put_ichar (XLSTREAM (Vread_buffer_stream), c);
|
428
|
1782 QUIT;
|
|
1783 c = readchar (readcharfun);
|
|
1784 }
|
|
1785
|
|
1786 if (c >= 0)
|
|
1787 unreadchar (readcharfun, c);
|
|
1788 /* blasted terminating 0 */
|
867
|
1789 Lstream_put_ichar (XLSTREAM (Vread_buffer_stream), 0);
|
428
|
1790 Lstream_flush (XLSTREAM (Vread_buffer_stream));
|
|
1791
|
|
1792 return Lstream_byte_count (XLSTREAM (Vread_buffer_stream)) - 1;
|
|
1793 }
|
|
1794
|
867
|
1795 static Lisp_Object parse_integer (const Ibyte *buf, Bytecount len, int base);
|
428
|
1796
|
|
1797 static Lisp_Object
|
|
1798 read_atom (Lisp_Object readcharfun,
|
867
|
1799 Ichar firstchar,
|
428
|
1800 int uninterned_symbol)
|
|
1801 {
|
|
1802 /* This function can GC */
|
|
1803 int saw_a_backslash;
|
|
1804 Bytecount len = read_atom_0 (readcharfun, firstchar, &saw_a_backslash);
|
|
1805 char *read_ptr = (char *)
|
|
1806 resizing_buffer_stream_ptr (XLSTREAM (Vread_buffer_stream));
|
|
1807
|
|
1808 /* Is it an integer? */
|
|
1809 if (! (saw_a_backslash || uninterned_symbol))
|
|
1810 {
|
|
1811 /* If a token had any backslashes in it, it is disqualified from
|
|
1812 being an integer or a float. This means that 123\456 is a
|
|
1813 symbol, as is \123 (which is the way (intern "123") prints).
|
|
1814 Also, if token was preceded by #:, it's always a symbol.
|
|
1815 */
|
|
1816 char *p = read_ptr + len;
|
|
1817 char *p1 = read_ptr;
|
|
1818
|
|
1819 if (*p1 == '+' || *p1 == '-') p1++;
|
|
1820 if (p1 != p)
|
|
1821 {
|
|
1822 int c;
|
|
1823
|
|
1824 while (p1 != p && (c = *p1) >= '0' && c <= '9')
|
|
1825 p1++;
|
|
1826 /* Integers can have trailing decimal points. */
|
|
1827 if (p1 > read_ptr && p1 < p && *p1 == '.')
|
|
1828 p1++;
|
|
1829 if (p1 == p)
|
|
1830 {
|
|
1831 /* It is an integer. */
|
|
1832 if (p1[-1] == '.')
|
|
1833 p1[-1] = '\0';
|
|
1834 #if 0
|
|
1835 {
|
|
1836 int number = 0;
|
|
1837 if (sizeof (int) == sizeof (EMACS_INT))
|
|
1838 number = atoi (read_buffer);
|
|
1839 else if (sizeof (long) == sizeof (EMACS_INT))
|
|
1840 number = atol (read_buffer);
|
|
1841 else
|
|
1842 abort ();
|
|
1843 return make_int (number);
|
|
1844 }
|
|
1845 #else
|
867
|
1846 return parse_integer ((Ibyte *) read_ptr, len, 10);
|
428
|
1847 #endif
|
|
1848 }
|
|
1849 }
|
1983
|
1850 #ifdef HAVE_RATIO
|
|
1851 if (isratio_string (read_ptr))
|
|
1852 {
|
2013
|
1853 /* GMP ratio_set_string has no effect with initial + sign */
|
2010
|
1854 if (*read_ptr == '+')
|
|
1855 read_ptr++;
|
1983
|
1856 ratio_set_string (scratch_ratio, read_ptr, 0);
|
|
1857 ratio_canonicalize (scratch_ratio);
|
|
1858 return Fcanonicalize_number (make_ratio_rt (scratch_ratio));
|
|
1859 }
|
|
1860 #endif
|
428
|
1861 if (isfloat_string (read_ptr))
|
|
1862 return make_float (atof (read_ptr));
|
|
1863 }
|
|
1864
|
|
1865 {
|
|
1866 Lisp_Object sym;
|
|
1867 if (uninterned_symbol)
|
867
|
1868 sym = Fmake_symbol ( make_string ((Ibyte *) read_ptr, len));
|
428
|
1869 else
|
|
1870 {
|
867
|
1871 Lisp_Object name = make_string ((Ibyte *) read_ptr, len);
|
428
|
1872 sym = Fintern (name, Qnil);
|
|
1873 }
|
|
1874 return sym;
|
|
1875 }
|
|
1876 }
|
|
1877
|
|
1878
|
|
1879 static Lisp_Object
|
867
|
1880 parse_integer (const Ibyte *buf, Bytecount len, int base)
|
428
|
1881 {
|
867
|
1882 const Ibyte *lim = buf + len;
|
|
1883 const Ibyte *p = buf;
|
428
|
1884 EMACS_UINT num = 0;
|
|
1885 int negativland = 0;
|
|
1886
|
|
1887 if (*p == '-')
|
|
1888 {
|
|
1889 negativland = 1;
|
|
1890 p++;
|
|
1891 }
|
|
1892 else if (*p == '+')
|
|
1893 {
|
|
1894 p++;
|
|
1895 }
|
|
1896
|
|
1897 if (p == lim)
|
|
1898 goto loser;
|
|
1899
|
|
1900 for (; (p < lim) && (*p != '\0'); p++)
|
|
1901 {
|
|
1902 int c = *p;
|
|
1903 EMACS_UINT onum;
|
|
1904
|
|
1905 if (isdigit (c))
|
|
1906 c = c - '0';
|
|
1907 else if (isupper (c))
|
|
1908 c = c - 'A' + 10;
|
|
1909 else if (islower (c))
|
|
1910 c = c - 'a' + 10;
|
|
1911 else
|
|
1912 goto loser;
|
|
1913
|
|
1914 if (c < 0 || c >= base)
|
|
1915 goto loser;
|
|
1916
|
|
1917 onum = num;
|
|
1918 num = num * base + c;
|
|
1919 if (num < onum)
|
|
1920 goto overflow;
|
|
1921 }
|
|
1922
|
|
1923 {
|
|
1924 EMACS_INT int_result = negativland ? - (EMACS_INT) num : (EMACS_INT) num;
|
|
1925 Lisp_Object result = make_int (int_result);
|
|
1926 if (num && ((XINT (result) < 0) != negativland))
|
|
1927 goto overflow;
|
|
1928 if (XINT (result) != int_result)
|
|
1929 goto overflow;
|
|
1930 return result;
|
|
1931 }
|
|
1932 overflow:
|
1983
|
1933 #ifdef HAVE_BIGNUM
|
|
1934 {
|
1995
|
1935 bignum_set_string (scratch_bignum, (const char *) buf, 0);
|
1983
|
1936 return make_bignum_bg (scratch_bignum);
|
|
1937 }
|
|
1938 #else
|
428
|
1939 return Fsignal (Qinvalid_read_syntax,
|
771
|
1940 list3 (build_msg_string
|
428
|
1941 ("Integer constant overflow in reader"),
|
|
1942 make_string (buf, len),
|
|
1943 make_int (base)));
|
1983
|
1944 #endif /* HAVE_BIGNUM */
|
428
|
1945 loser:
|
|
1946 return Fsignal (Qinvalid_read_syntax,
|
771
|
1947 list3 (build_msg_string
|
428
|
1948 ("Invalid integer constant in reader"),
|
|
1949 make_string (buf, len),
|
|
1950 make_int (base)));
|
|
1951 }
|
|
1952
|
|
1953
|
|
1954 static Lisp_Object
|
|
1955 read_integer (Lisp_Object readcharfun, int base)
|
|
1956 {
|
|
1957 /* This function can GC */
|
|
1958 int saw_a_backslash;
|
|
1959 Bytecount len = read_atom_0 (readcharfun, -1, &saw_a_backslash);
|
|
1960 return (parse_integer
|
|
1961 (resizing_buffer_stream_ptr (XLSTREAM (Vread_buffer_stream)),
|
|
1962 ((saw_a_backslash)
|
|
1963 ? 0 /* make parse_integer signal error */
|
|
1964 : len),
|
|
1965 base));
|
|
1966 }
|
|
1967
|
|
1968 static Lisp_Object
|
|
1969 read_bit_vector (Lisp_Object readcharfun)
|
|
1970 {
|
|
1971 unsigned_char_dynarr *dyn = Dynarr_new (unsigned_char);
|
440
|
1972 Lisp_Object val;
|
428
|
1973
|
|
1974 while (1)
|
|
1975 {
|
444
|
1976 unsigned char bit;
|
867
|
1977 Ichar c = readchar (readcharfun);
|
444
|
1978 if (c == '0')
|
|
1979 bit = 0;
|
|
1980 else if (c == '1')
|
|
1981 bit = 1;
|
|
1982 else
|
|
1983 {
|
|
1984 if (c >= 0)
|
|
1985 unreadchar (readcharfun, c);
|
|
1986 break;
|
|
1987 }
|
|
1988 Dynarr_add (dyn, bit);
|
428
|
1989 }
|
|
1990
|
440
|
1991 val = make_bit_vector_from_byte_vector (Dynarr_atp (dyn, 0),
|
|
1992 Dynarr_length (dyn));
|
|
1993 Dynarr_free (dyn);
|
|
1994
|
|
1995 return val;
|
428
|
1996 }
|
|
1997
|
|
1998
|
|
1999
|
|
2000 /* structures */
|
|
2001
|
|
2002 struct structure_type *
|
|
2003 define_structure_type (Lisp_Object type,
|
|
2004 int (*validate) (Lisp_Object data,
|
578
|
2005 Error_Behavior errb),
|
428
|
2006 Lisp_Object (*instantiate) (Lisp_Object data))
|
|
2007 {
|
|
2008 struct structure_type st;
|
|
2009
|
|
2010 st.type = type;
|
|
2011 st.keywords = Dynarr_new (structure_keyword_entry);
|
|
2012 st.validate = validate;
|
|
2013 st.instantiate = instantiate;
|
|
2014 Dynarr_add (the_structure_type_dynarr, st);
|
|
2015
|
|
2016 return Dynarr_atp (the_structure_type_dynarr,
|
|
2017 Dynarr_length (the_structure_type_dynarr) - 1);
|
|
2018 }
|
|
2019
|
|
2020 void
|
|
2021 define_structure_type_keyword (struct structure_type *st, Lisp_Object keyword,
|
|
2022 int (*validate) (Lisp_Object keyword,
|
|
2023 Lisp_Object value,
|
578
|
2024 Error_Behavior errb))
|
428
|
2025 {
|
|
2026 struct structure_keyword_entry en;
|
|
2027
|
|
2028 en.keyword = keyword;
|
|
2029 en.validate = validate;
|
|
2030 Dynarr_add (st->keywords, en);
|
|
2031 }
|
|
2032
|
|
2033 static struct structure_type *
|
|
2034 recognized_structure_type (Lisp_Object type)
|
|
2035 {
|
|
2036 int i;
|
|
2037
|
|
2038 for (i = 0; i < Dynarr_length (the_structure_type_dynarr); i++)
|
|
2039 {
|
|
2040 struct structure_type *st = Dynarr_atp (the_structure_type_dynarr, i);
|
|
2041 if (EQ (st->type, type))
|
|
2042 return st;
|
|
2043 }
|
|
2044
|
|
2045 return 0;
|
|
2046 }
|
|
2047
|
|
2048 static Lisp_Object
|
|
2049 read_structure (Lisp_Object readcharfun)
|
|
2050 {
|
867
|
2051 Ichar c = readchar (readcharfun);
|
428
|
2052 Lisp_Object list = Qnil;
|
|
2053 Lisp_Object orig_list = Qnil;
|
|
2054 Lisp_Object already_seen = Qnil;
|
|
2055 int keyword_count;
|
|
2056 struct structure_type *st;
|
|
2057 struct gcpro gcpro1, gcpro2;
|
|
2058
|
|
2059 GCPRO2 (orig_list, already_seen);
|
|
2060 if (c != '(')
|
442
|
2061 RETURN_UNGCPRO (continuable_read_syntax_error ("#s not followed by paren"));
|
428
|
2062 list = read_list (readcharfun, ')', 0, 0);
|
|
2063 orig_list = list;
|
|
2064 {
|
|
2065 int len = XINT (Flength (list));
|
|
2066 if (len == 0)
|
442
|
2067 RETURN_UNGCPRO (continuable_read_syntax_error
|
428
|
2068 ("structure type not specified"));
|
|
2069 if (!(len & 1))
|
|
2070 RETURN_UNGCPRO
|
442
|
2071 (continuable_read_syntax_error
|
428
|
2072 ("structures must have alternating keyword/value pairs"));
|
|
2073 }
|
|
2074
|
|
2075 st = recognized_structure_type (XCAR (list));
|
|
2076 if (!st)
|
|
2077 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax,
|
771
|
2078 list2 (build_msg_string
|
428
|
2079 ("unrecognized structure type"),
|
|
2080 XCAR (list))));
|
|
2081
|
|
2082 list = Fcdr (list);
|
|
2083 keyword_count = Dynarr_length (st->keywords);
|
|
2084 while (!NILP (list))
|
|
2085 {
|
|
2086 Lisp_Object keyword, value;
|
|
2087 int i;
|
|
2088 struct structure_keyword_entry *en = NULL;
|
|
2089
|
|
2090 keyword = Fcar (list);
|
|
2091 list = Fcdr (list);
|
|
2092 value = Fcar (list);
|
|
2093 list = Fcdr (list);
|
|
2094
|
|
2095 if (!NILP (memq_no_quit (keyword, already_seen)))
|
|
2096 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax,
|
771
|
2097 list2 (build_msg_string
|
428
|
2098 ("structure keyword already seen"),
|
|
2099 keyword)));
|
|
2100
|
|
2101 for (i = 0; i < keyword_count; i++)
|
|
2102 {
|
|
2103 en = Dynarr_atp (st->keywords, i);
|
|
2104 if (EQ (keyword, en->keyword))
|
|
2105 break;
|
|
2106 }
|
|
2107
|
|
2108 if (i == keyword_count)
|
|
2109 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax,
|
771
|
2110 list2 (build_msg_string
|
428
|
2111 ("unrecognized structure keyword"),
|
|
2112 keyword)));
|
|
2113
|
|
2114 if (en->validate && ! (en->validate) (keyword, value, ERROR_ME))
|
|
2115 RETURN_UNGCPRO
|
|
2116 (Fsignal (Qinvalid_read_syntax,
|
771
|
2117 list3 (build_msg_string
|
428
|
2118 ("invalid value for structure keyword"),
|
|
2119 keyword, value)));
|
|
2120
|
|
2121 already_seen = Fcons (keyword, already_seen);
|
|
2122 }
|
|
2123
|
|
2124 if (st->validate && ! (st->validate) (orig_list, ERROR_ME))
|
|
2125 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax,
|
771
|
2126 list2 (build_msg_string
|
428
|
2127 ("invalid structure initializer"),
|
|
2128 orig_list)));
|
|
2129
|
|
2130 RETURN_UNGCPRO ((st->instantiate) (XCDR (orig_list)));
|
|
2131 }
|
|
2132
|
|
2133
|
|
2134 static Lisp_Object read_compiled_function (Lisp_Object readcharfun,
|
|
2135 int terminator);
|
|
2136 static Lisp_Object read_vector (Lisp_Object readcharfun, int terminator);
|
|
2137
|
|
2138 /* Get the next character; filter out whitespace and comments */
|
|
2139
|
867
|
2140 static Ichar
|
428
|
2141 reader_nextchar (Lisp_Object readcharfun)
|
|
2142 {
|
|
2143 /* This function can GC */
|
867
|
2144 Ichar c;
|
428
|
2145
|
|
2146 retry:
|
|
2147 QUIT;
|
|
2148 c = readchar (readcharfun);
|
|
2149 if (c < 0)
|
563
|
2150 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
2151
|
|
2152 switch (c)
|
|
2153 {
|
|
2154 default:
|
|
2155 {
|
|
2156 /* Ignore whitespace and control characters */
|
|
2157 if (c <= 040)
|
|
2158 goto retry;
|
|
2159 return c;
|
|
2160 }
|
|
2161
|
|
2162 case ';':
|
|
2163 {
|
|
2164 /* Comment */
|
|
2165 while ((c = readchar (readcharfun)) >= 0 && c != '\n')
|
|
2166 QUIT;
|
|
2167 goto retry;
|
|
2168 }
|
|
2169 }
|
|
2170 }
|
|
2171
|
|
2172 #if 0
|
|
2173 static Lisp_Object
|
|
2174 list2_pure (int pure, Lisp_Object a, Lisp_Object b)
|
|
2175 {
|
|
2176 return pure ? pure_cons (a, pure_cons (b, Qnil)) : list2 (a, b);
|
|
2177 }
|
|
2178 #endif
|
|
2179
|
|
2180 /* Read the next Lisp object from the stream READCHARFUN and return it.
|
|
2181 If the return value is a cons whose car is Qunbound, then read1()
|
|
2182 encountered a misplaced token (e.g. a right bracket, right paren,
|
|
2183 or dot followed by a non-number). To filter this stuff out,
|
|
2184 use read0(). */
|
|
2185
|
|
2186 static Lisp_Object
|
|
2187 read1 (Lisp_Object readcharfun)
|
|
2188 {
|
867
|
2189 Ichar c;
|
428
|
2190
|
|
2191 retry:
|
|
2192 c = reader_nextchar (readcharfun);
|
|
2193
|
|
2194 switch (c)
|
|
2195 {
|
|
2196 case '(':
|
|
2197 {
|
|
2198 #ifdef LISP_BACKQUOTES /* old backquote compatibility in lisp reader */
|
|
2199 /* if this is disabled, then other code in eval.c must be enabled */
|
867
|
2200 Ichar ch = reader_nextchar (readcharfun);
|
428
|
2201 switch (ch)
|
|
2202 {
|
|
2203 case '`':
|
|
2204 {
|
|
2205 Lisp_Object tem;
|
853
|
2206 int speccount = internal_bind_int (&old_backquote_flag,
|
|
2207 1 + old_backquote_flag);
|
428
|
2208 tem = read0 (readcharfun);
|
771
|
2209 unbind_to (speccount);
|
428
|
2210 ch = reader_nextchar (readcharfun);
|
|
2211 if (ch != ')')
|
|
2212 {
|
|
2213 unreadchar (readcharfun, ch);
|
|
2214 return Fsignal (Qinvalid_read_syntax,
|
771
|
2215 list1 (build_msg_string
|
428
|
2216 ("Weird old-backquote syntax")));
|
|
2217 }
|
|
2218 return list2 (Qbacktick, tem);
|
|
2219 }
|
|
2220 case ',':
|
|
2221 {
|
|
2222 if (old_backquote_flag)
|
|
2223 {
|
|
2224 Lisp_Object tem, comma_type;
|
|
2225 ch = readchar (readcharfun);
|
|
2226 if (ch == '@')
|
|
2227 comma_type = Qcomma_at;
|
|
2228 else
|
|
2229 {
|
|
2230 if (ch >= 0)
|
|
2231 unreadchar (readcharfun, ch);
|
|
2232 comma_type = Qcomma;
|
|
2233 }
|
|
2234 tem = read0 (readcharfun);
|
|
2235 ch = reader_nextchar (readcharfun);
|
|
2236 if (ch != ')')
|
|
2237 {
|
|
2238 unreadchar (readcharfun, ch);
|
|
2239 return Fsignal (Qinvalid_read_syntax,
|
771
|
2240 list1 (build_msg_string
|
428
|
2241 ("Weird old-backquote syntax")));
|
|
2242 }
|
|
2243 return list2 (comma_type, tem);
|
|
2244 }
|
|
2245 else
|
|
2246 {
|
|
2247 unreadchar (readcharfun, ch);
|
|
2248 #if 0
|
|
2249 return Fsignal (Qinvalid_read_syntax,
|
771
|
2250 list1 (build_msg_string ("Comma outside of backquote")));
|
428
|
2251 #else
|
|
2252 /* #### - yuck....but this is reverse compatible. */
|
|
2253 /* mostly this is required by edebug, which does its own
|
|
2254 annotated reading. We need to have an annotated_read
|
|
2255 function that records (with markers) the buffer
|
|
2256 positions of the elements that make up lists, then that
|
|
2257 can be used in edebug and bytecomp and the check above
|
|
2258 can go back in. --Stig */
|
|
2259 break;
|
|
2260 #endif
|
|
2261 }
|
|
2262 }
|
|
2263 default:
|
|
2264 unreadchar (readcharfun, ch);
|
|
2265 } /* switch(ch) */
|
|
2266 #endif /* old backquote crap... */
|
|
2267 return read_list (readcharfun, ')', 1, 1);
|
|
2268 }
|
|
2269 case '[':
|
|
2270 return read_vector (readcharfun, ']');
|
|
2271
|
|
2272 case ')':
|
|
2273 case ']':
|
|
2274 /* #### - huh? these don't do what they seem... */
|
|
2275 return noseeum_cons (Qunbound, make_char (c));
|
|
2276 case '.':
|
|
2277 {
|
|
2278 /* If a period is followed by a number, then we should read it
|
|
2279 as a floating point number. Otherwise, it denotes a dotted
|
|
2280 pair.
|
|
2281 */
|
|
2282 c = readchar (readcharfun);
|
|
2283 unreadchar (readcharfun, c);
|
|
2284
|
867
|
2285 /* Can't use isdigit on Ichars */
|
428
|
2286 if (c < '0' || c > '9')
|
|
2287 return noseeum_cons (Qunbound, make_char ('.'));
|
|
2288
|
|
2289 /* Note that read_atom will loop
|
|
2290 at least once, assuring that we will not try to UNREAD
|
|
2291 two characters in a row.
|
|
2292 (I think this doesn't matter anymore because there should
|
|
2293 be no more danger in unreading multiple characters) */
|
|
2294 return read_atom (readcharfun, '.', 0);
|
|
2295 }
|
|
2296
|
|
2297 case '#':
|
|
2298 {
|
|
2299 c = readchar (readcharfun);
|
|
2300 switch (c)
|
|
2301 {
|
|
2302 #if 0 /* FSFmacs silly char-table syntax */
|
|
2303 case '^':
|
|
2304 #endif
|
|
2305 #if 0 /* FSFmacs silly bool-vector syntax */
|
|
2306 case '&':
|
|
2307 #endif
|
|
2308 /* "#["-- byte-code constant syntax */
|
|
2309 /* purecons #[...] syntax */
|
|
2310 case '[': return read_compiled_function (readcharfun, ']'
|
|
2311 /*, purify_flag */ );
|
|
2312 /* "#:"-- gensym syntax */
|
|
2313 case ':': return read_atom (readcharfun, -1, 1);
|
|
2314 /* #'x => (function x) */
|
|
2315 case '\'': return list2 (Qfunction, read0 (readcharfun));
|
|
2316 #if 0
|
|
2317 /* RMS uses this syntax for fat-strings.
|
|
2318 If we use it for vectors, then obscure bugs happen.
|
|
2319 */
|
|
2320 /* "#(" -- Scheme/CL vector syntax */
|
|
2321 case '(': return read_vector (readcharfun, ')');
|
|
2322 #endif
|
|
2323 #if 0 /* FSFmacs */
|
|
2324 case '(':
|
|
2325 {
|
|
2326 Lisp_Object tmp;
|
|
2327 struct gcpro gcpro1;
|
|
2328
|
|
2329 /* Read the string itself. */
|
|
2330 tmp = read1 (readcharfun);
|
|
2331 if (!STRINGP (tmp))
|
|
2332 {
|
|
2333 if (CONSP (tmp) && UNBOUNDP (XCAR (tmp)))
|
853
|
2334 free_cons (tmp);
|
428
|
2335 return Fsignal (Qinvalid_read_syntax,
|
|
2336 list1 (build_string ("#")));
|
|
2337 }
|
|
2338 GCPRO1 (tmp);
|
|
2339 /* Read the intervals and their properties. */
|
|
2340 while (1)
|
|
2341 {
|
|
2342 Lisp_Object beg, end, plist;
|
867
|
2343 Ichar ch;
|
428
|
2344 int invalid = 0;
|
|
2345
|
|
2346 beg = read1 (readcharfun);
|
|
2347 if (CONSP (beg) && UNBOUNDP (XCAR (beg)))
|
|
2348 {
|
|
2349 ch = XCHAR (XCDR (beg));
|
853
|
2350 free_cons (beg);
|
428
|
2351 if (ch == ')')
|
|
2352 break;
|
|
2353 else
|
|
2354 invalid = 1;
|
|
2355 }
|
|
2356 if (!invalid)
|
|
2357 {
|
|
2358 end = read1 (readcharfun);
|
|
2359 if (CONSP (end) && UNBOUNDP (XCAR (end)))
|
|
2360 {
|
853
|
2361 free_cons (end);
|
428
|
2362 invalid = 1;
|
|
2363 }
|
|
2364 }
|
|
2365 if (!invalid)
|
|
2366 {
|
|
2367 plist = read1 (readcharfun);
|
|
2368 if (CONSP (plist) && UNBOUNDP (XCAR (plist)))
|
|
2369 {
|
853
|
2370 free_cons (plist);
|
428
|
2371 invalid = 1;
|
|
2372 }
|
|
2373 }
|
|
2374 if (invalid)
|
|
2375 RETURN_UNGCPRO
|
|
2376 (Fsignal (Qinvalid_read_syntax,
|
|
2377 list2
|
771
|
2378 (build_msg_string ("invalid string property list"),
|
428
|
2379 XCDR (plist))));
|
|
2380 Fset_text_properties (beg, end, plist, tmp);
|
|
2381 }
|
|
2382 UNGCPRO;
|
|
2383 return tmp;
|
|
2384 }
|
|
2385 #endif /* 0 */
|
|
2386 case '@':
|
|
2387 {
|
|
2388 /* #@NUMBER is used to skip NUMBER following characters.
|
|
2389 That's used in .elc files to skip over doc strings
|
|
2390 and function definitions. */
|
|
2391 int i, nskip = 0;
|
|
2392
|
|
2393 /* Read a decimal integer. */
|
|
2394 while ((c = readchar (readcharfun)) >= 0
|
|
2395 && c >= '0' && c <= '9')
|
|
2396 nskip = (10 * nskip) + (c - '0');
|
|
2397 if (c >= 0)
|
|
2398 unreadchar (readcharfun, c);
|
|
2399
|
|
2400 /* FSF has code here that maybe caches the skipped
|
|
2401 string. See above for why this is totally
|
|
2402 losing. We handle this differently. */
|
|
2403
|
|
2404 /* Skip that many characters. */
|
|
2405 for (i = 0; i < nskip && c >= 0; i++)
|
|
2406 c = readchar (readcharfun);
|
|
2407
|
|
2408 goto retry;
|
|
2409 }
|
|
2410 case '$': return Vload_file_name_internal;
|
|
2411 /* bit vectors */
|
|
2412 case '*': return read_bit_vector (readcharfun);
|
|
2413 /* #o10 => 8 -- octal constant syntax */
|
|
2414 case 'o': return read_integer (readcharfun, 8);
|
|
2415 /* #xdead => 57005 -- hex constant syntax */
|
|
2416 case 'x': return read_integer (readcharfun, 16);
|
|
2417 /* #b010 => 2 -- binary constant syntax */
|
|
2418 case 'b': return read_integer (readcharfun, 2);
|
|
2419 /* #s(foobar key1 val1 key2 val2) -- structure syntax */
|
|
2420 case 's': return read_structure (readcharfun);
|
|
2421 case '<':
|
|
2422 {
|
|
2423 unreadchar (readcharfun, c);
|
|
2424 return Fsignal (Qinvalid_read_syntax,
|
771
|
2425 list1 (build_msg_string ("Cannot read unreadable object")));
|
428
|
2426 }
|
|
2427 #ifdef FEATUREP_SYNTAX
|
|
2428 case '+':
|
|
2429 case '-':
|
|
2430 {
|
456
|
2431 Lisp_Object feature_exp, obj, tem;
|
428
|
2432 struct gcpro gcpro1, gcpro2;
|
|
2433
|
456
|
2434 feature_exp = read0(readcharfun);
|
428
|
2435 obj = read0(readcharfun);
|
|
2436
|
|
2437 /* the call to `featurep' may GC. */
|
456
|
2438 GCPRO2 (feature_exp, obj);
|
|
2439 tem = call1 (Qfeaturep, feature_exp);
|
428
|
2440 UNGCPRO;
|
|
2441
|
|
2442 if (c == '+' && NILP(tem)) goto retry;
|
|
2443 if (c == '-' && !NILP(tem)) goto retry;
|
|
2444 return obj;
|
|
2445 }
|
|
2446 #endif
|
|
2447 case '0': case '1': case '2': case '3': case '4':
|
|
2448 case '5': case '6': case '7': case '8': case '9':
|
|
2449 /* Reader forms that can reuse previously read objects. */
|
|
2450 {
|
|
2451 int n = 0;
|
|
2452 Lisp_Object found;
|
|
2453
|
|
2454 /* Using read_integer() here is impossible, because it
|
|
2455 chokes on `='. Using parse_integer() is too hard.
|
|
2456 So we simply read it in, and ignore overflows, which
|
|
2457 is safe. */
|
|
2458 while (c >= '0' && c <= '9')
|
|
2459 {
|
|
2460 n *= 10;
|
|
2461 n += c - '0';
|
|
2462 c = readchar (readcharfun);
|
|
2463 }
|
|
2464 found = assq_no_quit (make_int (n), Vread_objects);
|
|
2465 if (c == '=')
|
|
2466 {
|
|
2467 /* #n=object returns object, but associates it with
|
|
2468 n for #n#. */
|
|
2469 Lisp_Object obj;
|
|
2470 if (CONSP (found))
|
|
2471 return Fsignal (Qinvalid_read_syntax,
|
771
|
2472 list2 (build_msg_string
|
428
|
2473 ("Multiply defined symbol label"),
|
|
2474 make_int (n)));
|
|
2475 obj = read0 (readcharfun);
|
|
2476 Vread_objects = Fcons (Fcons (make_int (n), obj),
|
|
2477 Vread_objects);
|
|
2478 return obj;
|
|
2479 }
|
|
2480 else if (c == '#')
|
|
2481 {
|
|
2482 /* #n# returns a previously read object. */
|
|
2483 if (CONSP (found))
|
|
2484 return XCDR (found);
|
|
2485 else
|
|
2486 return Fsignal (Qinvalid_read_syntax,
|
771
|
2487 list2 (build_msg_string
|
428
|
2488 ("Undefined symbol label"),
|
|
2489 make_int (n)));
|
|
2490 }
|
|
2491 return Fsignal (Qinvalid_read_syntax,
|
|
2492 list1 (build_string ("#")));
|
|
2493 }
|
|
2494 default:
|
|
2495 {
|
|
2496 unreadchar (readcharfun, c);
|
|
2497 return Fsignal (Qinvalid_read_syntax,
|
|
2498 list1 (build_string ("#")));
|
|
2499 }
|
|
2500 }
|
|
2501 }
|
|
2502
|
|
2503 /* Quote */
|
|
2504 case '\'': return list2 (Qquote, read0 (readcharfun));
|
|
2505
|
|
2506 #ifdef LISP_BACKQUOTES
|
|
2507 case '`':
|
|
2508 {
|
|
2509 Lisp_Object tem;
|
853
|
2510 int speccount = internal_bind_int (&new_backquote_flag,
|
|
2511 1 + new_backquote_flag);
|
428
|
2512 tem = read0 (readcharfun);
|
771
|
2513 unbind_to (speccount);
|
428
|
2514 return list2 (Qbackquote, tem);
|
|
2515 }
|
|
2516
|
|
2517 case ',':
|
|
2518 {
|
|
2519 if (new_backquote_flag)
|
|
2520 {
|
|
2521 Lisp_Object comma_type = Qnil;
|
|
2522 int ch = readchar (readcharfun);
|
|
2523
|
|
2524 if (ch == '@')
|
|
2525 comma_type = Qcomma_at;
|
|
2526 else if (ch == '.')
|
|
2527 comma_type = Qcomma_dot;
|
|
2528 else
|
|
2529 {
|
|
2530 if (ch >= 0)
|
|
2531 unreadchar (readcharfun, ch);
|
|
2532 comma_type = Qcomma;
|
|
2533 }
|
|
2534 return list2 (comma_type, read0 (readcharfun));
|
|
2535 }
|
|
2536 else
|
|
2537 {
|
|
2538 /* YUCK. 99.999% backwards compatibility. The Right
|
|
2539 Thing(tm) is to signal an error here, because it's
|
|
2540 really invalid read syntax. Instead, this permits
|
|
2541 commas to begin symbols (unless they're inside
|
|
2542 backquotes). If an error is signalled here in the
|
|
2543 future, then commas should be invalid read syntax
|
|
2544 outside of backquotes anywhere they're found (i.e.
|
|
2545 they must be quoted in symbols) -- Stig */
|
|
2546 return read_atom (readcharfun, c, 0);
|
|
2547 }
|
|
2548 }
|
|
2549 #endif
|
|
2550
|
|
2551 case '?':
|
|
2552 {
|
|
2553 /* Evil GNU Emacs "character" (ie integer) syntax */
|
|
2554 c = readchar (readcharfun);
|
|
2555 if (c < 0)
|
|
2556 return Fsignal (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun)));
|
|
2557
|
|
2558 if (c == '\\')
|
|
2559 c = read_escape (readcharfun);
|
|
2560 return make_char (c);
|
|
2561 }
|
|
2562
|
|
2563 case '\"':
|
|
2564 {
|
|
2565 /* String */
|
|
2566 #ifdef I18N3
|
|
2567 /* #### If the input stream is translating, then the string
|
|
2568 should be marked as translatable by setting its
|
|
2569 `string-translatable' property to t. .el and .elc files
|
|
2570 normally are translating input streams. See Fgettext()
|
|
2571 and print_internal(). */
|
|
2572 #endif
|
|
2573 int cancel = 0;
|
|
2574
|
|
2575 Lstream_rewind (XLSTREAM (Vread_buffer_stream));
|
|
2576 while ((c = readchar (readcharfun)) >= 0
|
|
2577 && c != '\"')
|
|
2578 {
|
|
2579 if (c == '\\')
|
|
2580 c = read_escape (readcharfun);
|
|
2581 /* c is -1 if \ newline has just been seen */
|
|
2582 if (c == -1)
|
|
2583 {
|
|
2584 if (Lstream_byte_count (XLSTREAM (Vread_buffer_stream)) == 0)
|
|
2585 cancel = 1;
|
|
2586 }
|
|
2587 else
|
867
|
2588 Lstream_put_ichar (XLSTREAM (Vread_buffer_stream), c);
|
428
|
2589 QUIT;
|
|
2590 }
|
|
2591 if (c < 0)
|
|
2592 return Fsignal (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun)));
|
|
2593
|
|
2594 /* If purifying, and string starts with \ newline,
|
|
2595 return zero instead. This is for doc strings
|
|
2596 that we are really going to find in lib-src/DOC.nn.nn */
|
|
2597 if (purify_flag && NILP (Vinternal_doc_file_name) && cancel)
|
|
2598 return Qzero;
|
|
2599
|
|
2600 Lstream_flush (XLSTREAM (Vread_buffer_stream));
|
|
2601 return
|
|
2602 make_string
|
|
2603 (resizing_buffer_stream_ptr (XLSTREAM (Vread_buffer_stream)),
|
|
2604 Lstream_byte_count (XLSTREAM (Vread_buffer_stream)));
|
|
2605 }
|
|
2606
|
|
2607 default:
|
|
2608 {
|
|
2609 /* Ignore whitespace and control characters */
|
|
2610 if (c <= 040)
|
|
2611 goto retry;
|
|
2612 return read_atom (readcharfun, c, 0);
|
|
2613 }
|
|
2614 }
|
|
2615 }
|
|
2616
|
|
2617
|
|
2618
|
|
2619 #define LEAD_INT 1
|
|
2620 #define DOT_CHAR 2
|
|
2621 #define TRAIL_INT 4
|
|
2622 #define E_CHAR 8
|
|
2623 #define EXP_INT 16
|
|
2624
|
|
2625 int
|
442
|
2626 isfloat_string (const char *cp)
|
428
|
2627 {
|
|
2628 int state = 0;
|
867
|
2629 const Ibyte *ucp = (const Ibyte *) cp;
|
428
|
2630
|
|
2631 if (*ucp == '+' || *ucp == '-')
|
|
2632 ucp++;
|
|
2633
|
|
2634 if (*ucp >= '0' && *ucp <= '9')
|
|
2635 {
|
|
2636 state |= LEAD_INT;
|
|
2637 while (*ucp >= '0' && *ucp <= '9')
|
|
2638 ucp++;
|
|
2639 }
|
|
2640 if (*ucp == '.')
|
|
2641 {
|
|
2642 state |= DOT_CHAR;
|
|
2643 ucp++;
|
|
2644 }
|
|
2645 if (*ucp >= '0' && *ucp <= '9')
|
|
2646 {
|
|
2647 state |= TRAIL_INT;
|
|
2648 while (*ucp >= '0' && *ucp <= '9')
|
|
2649 ucp++;
|
|
2650 }
|
|
2651 if (*ucp == 'e' || *ucp == 'E')
|
|
2652 {
|
|
2653 state |= E_CHAR;
|
|
2654 ucp++;
|
|
2655 if ((*ucp == '+') || (*ucp == '-'))
|
|
2656 ucp++;
|
|
2657 }
|
|
2658
|
|
2659 if (*ucp >= '0' && *ucp <= '9')
|
|
2660 {
|
|
2661 state |= EXP_INT;
|
|
2662 while (*ucp >= '0' && *ucp <= '9')
|
|
2663 ucp++;
|
|
2664 }
|
|
2665 return (((*ucp == 0) || (*ucp == ' ') || (*ucp == '\t') || (*ucp == '\n')
|
|
2666 || (*ucp == '\r') || (*ucp == '\f'))
|
|
2667 && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT)
|
|
2668 || state == (DOT_CHAR|TRAIL_INT)
|
|
2669 || state == (LEAD_INT|E_CHAR|EXP_INT)
|
|
2670 || state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)
|
|
2671 || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)));
|
|
2672 }
|
1983
|
2673
|
|
2674 #ifdef HAVE_RATIO
|
|
2675 int
|
|
2676 isratio_string (const char *cp)
|
|
2677 {
|
2010
|
2678 /* Possible minus/plus sign */
|
|
2679 if (*cp == '-' || *cp == '+')
|
1983
|
2680 cp++;
|
|
2681
|
|
2682 /* Numerator */
|
|
2683 if (*cp < '0' || *cp > '9')
|
|
2684 return 0;
|
|
2685
|
|
2686 do {
|
|
2687 cp++;
|
|
2688 } while (*cp >= '0' && *cp <= '9');
|
|
2689
|
|
2690 /* Slash */
|
|
2691 if (*cp++ != '/')
|
|
2692 return 0;
|
|
2693
|
|
2694 /* Denominator */
|
|
2695 if (*cp < '0' || *cp > '9')
|
|
2696 return 0;
|
|
2697
|
|
2698 do {
|
|
2699 cp++;
|
|
2700 } while (*cp >= '0' && *cp <= '9');
|
|
2701
|
|
2702 return *cp == '\0' || *cp == ' ' || *cp =='\t' || *cp == '\n' ||
|
|
2703 *cp == '\r' || *cp == '\f';
|
|
2704 }
|
|
2705 #endif
|
428
|
2706
|
|
2707 static void *
|
|
2708 sequence_reader (Lisp_Object readcharfun,
|
867
|
2709 Ichar terminator,
|
428
|
2710 void *state,
|
|
2711 void * (*conser) (Lisp_Object readcharfun,
|
|
2712 void *state, Charcount len))
|
|
2713 {
|
|
2714 Charcount len;
|
|
2715
|
|
2716 for (len = 0; ; len++)
|
|
2717 {
|
867
|
2718 Ichar ch;
|
428
|
2719
|
|
2720 QUIT;
|
|
2721 ch = reader_nextchar (readcharfun);
|
|
2722
|
|
2723 if (ch == terminator)
|
|
2724 return state;
|
|
2725 else
|
|
2726 unreadchar (readcharfun, ch);
|
|
2727 #ifdef FEATUREP_SYNTAX
|
|
2728 if (ch == ']')
|
442
|
2729 read_syntax_error ("\"]\" in a list");
|
428
|
2730 else if (ch == ')')
|
442
|
2731 read_syntax_error ("\")\" in a vector");
|
428
|
2732 #endif
|
|
2733 state = ((conser) (readcharfun, state, len));
|
|
2734 }
|
|
2735 }
|
|
2736
|
|
2737
|
|
2738 struct read_list_state
|
|
2739 {
|
|
2740 Lisp_Object head;
|
|
2741 Lisp_Object tail;
|
|
2742 int length;
|
|
2743 int allow_dotted_lists;
|
867
|
2744 Ichar terminator;
|
428
|
2745 };
|
|
2746
|
|
2747 static void *
|
2286
|
2748 read_list_conser (Lisp_Object readcharfun, void *state, Charcount UNUSED (len))
|
428
|
2749 {
|
|
2750 struct read_list_state *s = (struct read_list_state *) state;
|
|
2751 Lisp_Object elt;
|
|
2752
|
|
2753 elt = read1 (readcharfun);
|
|
2754
|
|
2755 if (CONSP (elt) && UNBOUNDP (XCAR (elt)))
|
|
2756 {
|
|
2757 Lisp_Object tem = elt;
|
867
|
2758 Ichar ch;
|
428
|
2759
|
|
2760 elt = XCDR (elt);
|
853
|
2761 free_cons (tem);
|
428
|
2762 tem = Qnil;
|
|
2763 ch = XCHAR (elt);
|
|
2764 #ifdef FEATUREP_SYNTAX
|
|
2765 if (ch == s->terminator) /* deal with #+, #- reader macros */
|
|
2766 {
|
|
2767 unreadchar (readcharfun, s->terminator);
|
|
2768 goto done;
|
|
2769 }
|
|
2770 else if (ch == ']')
|
442
|
2771 read_syntax_error ("']' in a list");
|
428
|
2772 else if (ch == ')')
|
442
|
2773 read_syntax_error ("')' in a vector");
|
428
|
2774 else
|
|
2775 #endif
|
|
2776 if (ch != '.')
|
563
|
2777 signal_error (Qinternal_error, "BUG! Internal reader error", elt);
|
428
|
2778 else if (!s->allow_dotted_lists)
|
442
|
2779 read_syntax_error ("\".\" in a vector");
|
428
|
2780 else
|
|
2781 {
|
|
2782 if (!NILP (s->tail))
|
|
2783 XCDR (s->tail) = read0 (readcharfun);
|
|
2784 else
|
|
2785 s->head = read0 (readcharfun);
|
|
2786 elt = read1 (readcharfun);
|
|
2787 if (CONSP (elt) && UNBOUNDP (XCAR (elt)))
|
|
2788 {
|
|
2789 ch = XCHAR (XCDR (elt));
|
853
|
2790 free_cons (elt);
|
428
|
2791 if (ch == s->terminator)
|
|
2792 {
|
|
2793 unreadchar (readcharfun, s->terminator);
|
|
2794 goto done;
|
|
2795 }
|
|
2796 }
|
442
|
2797 read_syntax_error (". in wrong context");
|
428
|
2798 }
|
|
2799 }
|
|
2800
|
|
2801 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
2802 if (s->length == 1 && s->allow_dotted_lists && EQ (XCAR (s->head), Qfset))
|
|
2803 {
|
|
2804 if (CONSP (elt) && EQ (XCAR (elt), Qquote) && CONSP (XCDR (elt)))
|
|
2805 Vcurrent_compiled_function_annotation = XCAR (XCDR (elt));
|
|
2806 else
|
|
2807 Vcurrent_compiled_function_annotation = elt;
|
|
2808 }
|
|
2809 #endif
|
|
2810
|
|
2811 elt = Fcons (elt, Qnil);
|
|
2812 if (!NILP (s->tail))
|
|
2813 XCDR (s->tail) = elt;
|
|
2814 else
|
|
2815 s->head = elt;
|
|
2816 s->tail = elt;
|
|
2817 done:
|
|
2818 s->length++;
|
|
2819 return s;
|
|
2820 }
|
|
2821
|
|
2822
|
814
|
2823 /* allow_dotted_lists means that something like (foo bar . baz)
|
|
2824 is acceptable. If -1, means check for starting with defun
|
|
2825 and make structure pure. (not implemented, probably for very
|
|
2826 good reasons)
|
|
2827
|
|
2828 If check_for_doc_references, look for (#$ . INT) doc references
|
|
2829 in the list and record if load_force_doc_strings is non-zero.
|
|
2830 (Such doc references will be destroyed during the loadup phase
|
|
2831 by replacing with Qzero, because Snarf-documentation will fill
|
|
2832 them in again.)
|
|
2833
|
|
2834 WARNING: If you set this, you sure as hell better not call
|
|
2835 free_list() on the returned list here.
|
|
2836 */
|
428
|
2837
|
|
2838 static Lisp_Object
|
|
2839 read_list (Lisp_Object readcharfun,
|
867
|
2840 Ichar terminator,
|
428
|
2841 int allow_dotted_lists,
|
|
2842 int check_for_doc_references)
|
|
2843 {
|
|
2844 struct read_list_state s;
|
|
2845 struct gcpro gcpro1, gcpro2;
|
|
2846 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
2847 Lisp_Object old_compiled_function_annotation =
|
|
2848 Vcurrent_compiled_function_annotation;
|
|
2849 #endif
|
|
2850
|
|
2851 s.head = Qnil;
|
|
2852 s.tail = Qnil;
|
|
2853 s.length = 0;
|
|
2854 s.allow_dotted_lists = allow_dotted_lists;
|
|
2855 s.terminator = terminator;
|
|
2856 GCPRO2 (s.head, s.tail);
|
|
2857
|
|
2858 sequence_reader (readcharfun, terminator, &s, read_list_conser);
|
|
2859 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
2860 Vcurrent_compiled_function_annotation = old_compiled_function_annotation;
|
|
2861 #endif
|
|
2862
|
|
2863 if ((purify_flag || load_force_doc_strings) && check_for_doc_references)
|
|
2864 {
|
|
2865 /* check now for any doc string references and record them
|
|
2866 for later. */
|
|
2867 Lisp_Object tail;
|
|
2868
|
|
2869 /* We might be dealing with an imperfect list so don't
|
|
2870 use LIST_LOOP */
|
|
2871 for (tail = s.head; CONSP (tail); tail = XCDR (tail))
|
|
2872 {
|
|
2873 Lisp_Object holding_cons = Qnil;
|
|
2874
|
|
2875 {
|
|
2876 Lisp_Object elem = XCAR (tail);
|
|
2877 /* elem might be (#$ . INT) ... */
|
|
2878 if (CONSP (elem) && EQ (XCAR (elem), Vload_file_name_internal))
|
|
2879 holding_cons = tail;
|
|
2880 /* or it might be (quote (#$ . INT)) i.e.
|
|
2881 (quote . ((#$ . INT) . nil)) in the case of
|
|
2882 `autoload' (autoload evaluates its arguments, while
|
|
2883 `defvar', `defun', etc. don't). */
|
|
2884 if (CONSP (elem) && EQ (XCAR (elem), Qquote)
|
|
2885 && CONSP (XCDR (elem)))
|
|
2886 {
|
|
2887 elem = XCAR (XCDR (elem));
|
|
2888 if (CONSP (elem) && EQ (XCAR (elem), Vload_file_name_internal))
|
|
2889 holding_cons = XCDR (XCAR (tail));
|
|
2890 }
|
|
2891 }
|
|
2892
|
|
2893 if (CONSP (holding_cons))
|
|
2894 {
|
|
2895 if (purify_flag)
|
|
2896 {
|
|
2897 if (NILP (Vinternal_doc_file_name))
|
|
2898 /* We have not yet called Snarf-documentation, so
|
|
2899 assume this file is described in the DOC file
|
|
2900 and Snarf-documentation will fill in the right
|
|
2901 value later. For now, replace the whole list
|
|
2902 with 0. */
|
|
2903 XCAR (holding_cons) = Qzero;
|
|
2904 else
|
|
2905 /* We have already called Snarf-documentation, so
|
|
2906 make a relative file name for this file, so it
|
|
2907 can be found properly in the installed Lisp
|
|
2908 directory. We don't use Fexpand_file_name
|
|
2909 because that would make the directory absolute
|
|
2910 now. */
|
|
2911 XCAR (XCAR (holding_cons)) =
|
|
2912 concat2 (build_string ("../lisp/"),
|
|
2913 Ffile_name_nondirectory
|
|
2914 (Vload_file_name_internal));
|
|
2915 }
|
|
2916 else
|
|
2917 /* Not pure. Just add to Vload_force_doc_string_list,
|
|
2918 and the string will be filled in properly in
|
|
2919 load_force_doc_string_unwind(). */
|
|
2920 Vload_force_doc_string_list =
|
|
2921 /* We pass the cons that holds the (#$ . INT) so we
|
|
2922 can modify it in-place. */
|
|
2923 Fcons (holding_cons, Vload_force_doc_string_list);
|
|
2924 }
|
|
2925 }
|
|
2926 }
|
|
2927
|
|
2928 UNGCPRO;
|
|
2929 return s.head;
|
|
2930 }
|
|
2931
|
|
2932 static Lisp_Object
|
|
2933 read_vector (Lisp_Object readcharfun,
|
867
|
2934 Ichar terminator)
|
428
|
2935 {
|
|
2936 Lisp_Object tem;
|
|
2937 Lisp_Object *p;
|
|
2938 int len;
|
|
2939 int i;
|
|
2940 struct read_list_state s;
|
|
2941 struct gcpro gcpro1, gcpro2;
|
|
2942
|
|
2943 s.head = Qnil;
|
|
2944 s.tail = Qnil;
|
|
2945 s.length = 0;
|
|
2946 s.allow_dotted_lists = 0;
|
|
2947 GCPRO2 (s.head, s.tail);
|
|
2948
|
|
2949 sequence_reader (readcharfun, terminator, &s, read_list_conser);
|
|
2950
|
|
2951 UNGCPRO;
|
|
2952 tem = s.head;
|
|
2953 len = XINT (Flength (tem));
|
|
2954
|
814
|
2955 s.head = make_vector (len, Qnil);
|
428
|
2956
|
|
2957 for (i = 0, p = &(XVECTOR_DATA (s.head)[0]);
|
|
2958 i < len;
|
|
2959 i++, p++)
|
|
2960 {
|
853
|
2961 Lisp_Object otem = tem;
|
428
|
2962 tem = Fcar (tem);
|
|
2963 *p = tem;
|
853
|
2964 tem = XCDR (otem);
|
428
|
2965 free_cons (otem);
|
|
2966 }
|
|
2967 return s.head;
|
|
2968 }
|
|
2969
|
|
2970 static Lisp_Object
|
867
|
2971 read_compiled_function (Lisp_Object readcharfun, Ichar terminator)
|
428
|
2972 {
|
|
2973 /* Accept compiled functions at read-time so that we don't
|
|
2974 have to build them at load-time. */
|
|
2975 Lisp_Object stuff;
|
|
2976 Lisp_Object make_byte_code_args[COMPILED_DOMAIN + 1];
|
|
2977 struct gcpro gcpro1;
|
|
2978 int len;
|
|
2979 int iii;
|
|
2980 int saw_a_doc_ref = 0;
|
|
2981
|
|
2982 /* Note: we tell read_list not to search for doc references
|
|
2983 because we need to handle the "doc reference" for the
|
|
2984 instructions and constants differently. */
|
|
2985 stuff = read_list (readcharfun, terminator, 0, 0);
|
|
2986 len = XINT (Flength (stuff));
|
|
2987 if (len < COMPILED_STACK_DEPTH + 1 || len > COMPILED_DOMAIN + 1)
|
|
2988 return
|
442
|
2989 continuable_read_syntax_error ("#[...] used with wrong number of elements");
|
428
|
2990
|
|
2991 for (iii = 0; CONSP (stuff); iii++)
|
|
2992 {
|
853
|
2993 Lisp_Object victim = stuff;
|
428
|
2994 make_byte_code_args[iii] = Fcar (stuff);
|
|
2995 if ((purify_flag || load_force_doc_strings)
|
|
2996 && CONSP (make_byte_code_args[iii])
|
|
2997 && EQ (XCAR (make_byte_code_args[iii]), Vload_file_name_internal))
|
|
2998 {
|
|
2999 if (purify_flag && iii == COMPILED_DOC_STRING)
|
|
3000 {
|
|
3001 /* same as in read_list(). */
|
|
3002 if (NILP (Vinternal_doc_file_name))
|
|
3003 make_byte_code_args[iii] = Qzero;
|
|
3004 else
|
|
3005 XCAR (make_byte_code_args[iii]) =
|
|
3006 concat2 (build_string ("../lisp/"),
|
|
3007 Ffile_name_nondirectory
|
|
3008 (Vload_file_name_internal));
|
|
3009 }
|
|
3010 else
|
|
3011 saw_a_doc_ref = 1;
|
|
3012 }
|
|
3013 stuff = Fcdr (stuff);
|
|
3014 free_cons (victim);
|
|
3015 }
|
|
3016 GCPRO1 (make_byte_code_args[0]);
|
|
3017 gcpro1.nvars = len;
|
|
3018
|
|
3019 /* v18 or v19 bytecode file. Need to Ebolify. */
|
|
3020 if (load_byte_code_version < 20 && VECTORP (make_byte_code_args[2]))
|
|
3021 ebolify_bytecode_constants (make_byte_code_args[2]);
|
|
3022
|
|
3023 /* make-byte-code looks at purify_flag, which should have the same
|
|
3024 * value as our "read-pure" argument */
|
|
3025 stuff = Fmake_byte_code (len, make_byte_code_args);
|
|
3026 XCOMPILED_FUNCTION (stuff)->flags.ebolified = (load_byte_code_version < 20);
|
|
3027 if (saw_a_doc_ref)
|
|
3028 Vload_force_doc_string_list = Fcons (stuff, Vload_force_doc_string_list);
|
|
3029 UNGCPRO;
|
|
3030 return stuff;
|
|
3031 }
|
|
3032
|
|
3033
|
|
3034
|
|
3035 void
|
|
3036 init_lread (void)
|
|
3037 {
|
|
3038 Vvalues = Qnil;
|
|
3039
|
|
3040 load_in_progress = 0;
|
|
3041
|
|
3042 Vload_descriptor_list = Qnil;
|
|
3043
|
|
3044 /* kludge: locate-file does not work for a null load-path, even if
|
|
3045 the file name is absolute. */
|
|
3046
|
|
3047 Vload_path = Fcons (build_string (""), Qnil);
|
|
3048
|
|
3049 /* This used to get initialized in init_lread because all streams
|
|
3050 got closed when dumping occurs. This is no longer true --
|
|
3051 Vread_buffer_stream is a resizing output stream, and there is no
|
|
3052 reason to close it at dump-time.
|
|
3053
|
|
3054 Vread_buffer_stream is set to Qnil in vars_of_lread, and this
|
|
3055 will initialize it only once, at dump-time. */
|
|
3056 if (NILP (Vread_buffer_stream))
|
|
3057 Vread_buffer_stream = make_resizing_buffer_output_stream ();
|
|
3058
|
|
3059 Vload_force_doc_string_list = Qnil;
|
|
3060 }
|
|
3061
|
|
3062 void
|
|
3063 syms_of_lread (void)
|
|
3064 {
|
|
3065 DEFSUBR (Fread);
|
|
3066 DEFSUBR (Fread_from_string);
|
|
3067 DEFSUBR (Fload_internal);
|
|
3068 DEFSUBR (Flocate_file);
|
|
3069 DEFSUBR (Flocate_file_clear_hashing);
|
|
3070 DEFSUBR (Feval_buffer);
|
|
3071 DEFSUBR (Feval_region);
|
|
3072
|
563
|
3073 DEFSYMBOL (Qstandard_input);
|
|
3074 DEFSYMBOL (Qread_char);
|
|
3075 DEFSYMBOL (Qcurrent_load_list);
|
|
3076 DEFSYMBOL (Qload);
|
|
3077 DEFSYMBOL (Qload_file_name);
|
1292
|
3078 DEFSYMBOL (Qload_internal);
|
563
|
3079 DEFSYMBOL (Qfset);
|
428
|
3080
|
|
3081 #ifdef LISP_BACKQUOTES
|
563
|
3082 DEFSYMBOL (Qbackquote);
|
428
|
3083 defsymbol (&Qbacktick, "`");
|
|
3084 defsymbol (&Qcomma, ",");
|
|
3085 defsymbol (&Qcomma_at, ",@");
|
|
3086 defsymbol (&Qcomma_dot, ",.");
|
|
3087 #endif
|
|
3088
|
563
|
3089 DEFSYMBOL (Qexists);
|
|
3090 DEFSYMBOL (Qreadable);
|
|
3091 DEFSYMBOL (Qwritable);
|
|
3092 DEFSYMBOL (Qexecutable);
|
428
|
3093 }
|
|
3094
|
|
3095 void
|
|
3096 structure_type_create (void)
|
|
3097 {
|
|
3098 the_structure_type_dynarr = Dynarr_new (structure_type);
|
|
3099 }
|
|
3100
|
|
3101 void
|
|
3102 reinit_vars_of_lread (void)
|
|
3103 {
|
|
3104 Vread_buffer_stream = Qnil;
|
|
3105 staticpro_nodump (&Vread_buffer_stream);
|
|
3106 }
|
|
3107
|
|
3108 void
|
|
3109 vars_of_lread (void)
|
|
3110 {
|
|
3111 DEFVAR_LISP ("values", &Vvalues /*
|
|
3112 List of values of all expressions which were read, evaluated and printed.
|
|
3113 Order is reverse chronological.
|
|
3114 */ );
|
|
3115
|
|
3116 DEFVAR_LISP ("standard-input", &Vstandard_input /*
|
|
3117 Stream for read to get input from.
|
|
3118 See documentation of `read' for possible values.
|
|
3119 */ );
|
|
3120 Vstandard_input = Qt;
|
|
3121
|
|
3122 DEFVAR_LISP ("load-path", &Vload_path /*
|
|
3123 *List of directories to search for files to load.
|
|
3124 Each element is a string (directory name) or nil (try default directory).
|
|
3125
|
|
3126 Note that the elements of this list *may not* begin with "~", so you must
|
|
3127 call `expand-file-name' on them before adding them to this list.
|
|
3128
|
|
3129 Initialized based on EMACSLOADPATH environment variable, if any,
|
|
3130 otherwise to default specified in by file `paths.h' when XEmacs was built.
|
|
3131 If there were no paths specified in `paths.h', then XEmacs chooses a default
|
|
3132 value for this variable by looking around in the file-system near the
|
|
3133 directory in which the XEmacs executable resides.
|
|
3134 */ );
|
|
3135 Vload_path = Qnil;
|
|
3136
|
|
3137 /* xxxDEFVAR_LISP ("dump-load-path", &Vdump_load_path,
|
|
3138 "*Location of lisp files to be used when dumping ONLY."); */
|
|
3139
|
|
3140 DEFVAR_BOOL ("load-in-progress", &load_in_progress /*
|
|
3141 Non-nil iff inside of `load'.
|
|
3142 */ );
|
|
3143
|
|
3144 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist /*
|
|
3145 An alist of expressions to be evalled when particular files are loaded.
|
|
3146 Each element looks like (FILENAME FORMS...).
|
|
3147 When `load' is run and the file-name argument is FILENAME,
|
|
3148 the FORMS in the corresponding element are executed at the end of loading.
|
|
3149
|
|
3150 FILENAME must match exactly! Normally FILENAME is the name of a library,
|
|
3151 with no directory specified, since that is how `load' is normally called.
|
|
3152 An error in FORMS does not undo the load,
|
|
3153 but does prevent execution of the rest of the FORMS.
|
|
3154 */ );
|
|
3155 Vafter_load_alist = Qnil;
|
|
3156
|
|
3157 DEFVAR_BOOL ("load-warn-when-source-newer", &load_warn_when_source_newer /*
|
|
3158 *Whether `load' should check whether the source is newer than the binary.
|
|
3159 If this variable is true, then when a `.elc' file is being loaded and the
|
|
3160 corresponding `.el' is newer, a warning message will be printed.
|
|
3161 */ );
|
1261
|
3162 load_warn_when_source_newer = 1;
|
428
|
3163
|
|
3164 DEFVAR_BOOL ("load-warn-when-source-only", &load_warn_when_source_only /*
|
|
3165 *Whether `load' should warn when loading a `.el' file instead of an `.elc'.
|
|
3166 If this variable is true, then when `load' is called with a filename without
|
|
3167 an extension, and the `.elc' version doesn't exist but the `.el' version does,
|
|
3168 then a message will be printed. If an explicit extension is passed to `load',
|
|
3169 no warning will be printed.
|
|
3170 */ );
|
|
3171 load_warn_when_source_only = 0;
|
|
3172
|
|
3173 DEFVAR_BOOL ("load-ignore-elc-files", &load_ignore_elc_files /*
|
|
3174 *Whether `load' should ignore `.elc' files when a suffix is not given.
|
|
3175 This is normally used only to bootstrap the `.elc' files when building XEmacs.
|
|
3176 */ );
|
|
3177 load_ignore_elc_files = 0;
|
|
3178
|
1123
|
3179 DEFVAR_BOOL ("load-ignore-out-of-date-elc-files",
|
|
3180 &load_ignore_out_of_date_elc_files /*
|
|
3181 *Whether `load' should ignore out-of-date `.elc' files when no suffix is given.
|
|
3182 This is normally used when compiling packages of elisp files that may have
|
|
3183 complex dependencies. Ignoring all elc files with `load-ignore-elc-files'
|
|
3184 would also be safe, but much slower.
|
|
3185 */ );
|
|
3186 load_ignore_out_of_date_elc_files = 0;
|
|
3187
|
|
3188 DEFVAR_BOOL ("load-always-display-messages",
|
|
3189 &load_always_display_messages /*
|
|
3190 *Whether `load' should always display loading messages.
|
|
3191 If this is true, every file loaded will be shown, regardless of the setting
|
|
3192 of the NOMESSAGE parameter, and even when files are loaded indirectly, e.g.
|
|
3193 due to `requre'.
|
|
3194 */ );
|
|
3195 load_always_display_messages = 0;
|
|
3196
|
|
3197 DEFVAR_BOOL ("load-show-full-path-in-messages",
|
|
3198 &load_show_full_path_in_messages /*
|
|
3199 *Whether `load' should show the full path in all loading messages.
|
|
3200 */ );
|
|
3201 load_show_full_path_in_messages = 0;
|
|
3202
|
428
|
3203 #ifdef LOADHIST
|
|
3204 DEFVAR_LISP ("load-history", &Vload_history /*
|
|
3205 Alist mapping source file names to symbols and features.
|
|
3206 Each alist element is a list that starts with a file name,
|
|
3207 except for one element (optional) that starts with nil and describes
|
|
3208 definitions evaluated from buffers not visiting files.
|
|
3209 The remaining elements of each list are symbols defined as functions
|
|
3210 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.
|
|
3211 */ );
|
|
3212 Vload_history = Qnil;
|
|
3213
|
|
3214 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list /*
|
|
3215 Used for internal purposes by `load'.
|
|
3216 */ );
|
|
3217 Vcurrent_load_list = Qnil;
|
|
3218 #endif
|
|
3219
|
|
3220 DEFVAR_LISP ("load-file-name", &Vload_file_name /*
|
|
3221 Full name of file being loaded by `load'.
|
|
3222 */ );
|
|
3223 Vload_file_name = Qnil;
|
|
3224
|
|
3225 DEFVAR_LISP ("load-read-function", &Vload_read_function /*
|
|
3226 Function used by `load' and `eval-region' for reading expressions.
|
|
3227 The default is nil, which means use the function `read'.
|
|
3228 */ );
|
|
3229 Vload_read_function = Qnil;
|
|
3230
|
|
3231 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings /*
|
|
3232 Non-nil means `load' should force-load all dynamic doc strings.
|
|
3233 This is useful when the file being loaded is a temporary copy.
|
|
3234 */ );
|
|
3235 load_force_doc_strings = 0;
|
|
3236
|
|
3237 /* See read_escape(). */
|
|
3238 #if 0
|
|
3239 /* Used to be named `puke-on-fsf-keys' */
|
|
3240 DEFVAR_BOOL ("fail-on-bucky-bit-character-escapes",
|
|
3241 &fail_on_bucky_bit_character_escapes /*
|
|
3242 Whether `read' should signal an error when it encounters unsupported
|
|
3243 character escape syntaxes or just read them incorrectly.
|
|
3244 */ );
|
|
3245 fail_on_bucky_bit_character_escapes = 0;
|
|
3246 #endif
|
|
3247
|
|
3248 /* This must be initialized in init_lread otherwise it may start out
|
|
3249 with values saved when the image is dumped. */
|
|
3250 staticpro (&Vload_descriptor_list);
|
|
3251
|
|
3252 /* Initialized in init_lread. */
|
|
3253 staticpro (&Vload_force_doc_string_list);
|
|
3254
|
|
3255 Vload_file_name_internal = Qnil;
|
|
3256 staticpro (&Vload_file_name_internal);
|
|
3257
|
|
3258 Vload_file_name_internal_the_purecopy = Qnil;
|
|
3259 staticpro (&Vload_file_name_internal_the_purecopy);
|
|
3260
|
|
3261 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
3262 Vcurrent_compiled_function_annotation = Qnil;
|
|
3263 staticpro (&Vcurrent_compiled_function_annotation);
|
|
3264 #endif
|
|
3265
|
|
3266 /* So that early-early stuff will work */
|
1292
|
3267 Ffset (Qload, Qload_internal);
|
428
|
3268
|
|
3269 #ifdef FEATUREP_SYNTAX
|
563
|
3270 DEFSYMBOL (Qfeaturep);
|
771
|
3271 Fprovide (intern ("xemacs"));
|
428
|
3272 #ifdef INFODOCK
|
771
|
3273 Fprovide (intern ("infodock"));
|
428
|
3274 #endif /* INFODOCK */
|
|
3275 #endif /* FEATUREP_SYNTAX */
|
|
3276
|
|
3277 #ifdef LISP_BACKQUOTES
|
|
3278 old_backquote_flag = new_backquote_flag = 0;
|
|
3279 #endif
|
|
3280
|
|
3281 #ifdef I18N3
|
|
3282 Vfile_domain = Qnil;
|
|
3283 #endif
|
|
3284
|
|
3285 Vread_objects = Qnil;
|
|
3286 staticpro (&Vread_objects);
|
|
3287
|
|
3288 Vlocate_file_hash_table = make_lisp_hash_table (200,
|
|
3289 HASH_TABLE_NON_WEAK,
|
|
3290 HASH_TABLE_EQUAL);
|
|
3291 staticpro (&Vlocate_file_hash_table);
|
|
3292 #ifdef DEBUG_XEMACS
|
|
3293 symbol_value (XSYMBOL (intern ("Vlocate-file-hash-table")))
|
|
3294 = Vlocate_file_hash_table;
|
|
3295 #endif
|
|
3296 }
|