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
|
867
|
567 foundstr = (Ibyte *) ALLOCA (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 Lisp_Object tail;
|
|
803 int mask = 0;
|
|
804 EXTERNAL_LIST_LOOP (tail, mode)
|
|
805 mask |= decode_mode_1 (XCAR (tail));
|
|
806 return mask;
|
|
807 }
|
|
808 else
|
|
809 return decode_mode_1 (mode);
|
|
810 }
|
|
811
|
|
812 DEFUN ("locate-file", Flocate_file, 2, 4, 0, /*
|
|
813 Search for FILENAME through PATH-LIST.
|
|
814
|
|
815 If SUFFIXES is non-nil, it should be a list of suffixes to append to
|
|
816 file name when searching.
|
|
817
|
|
818 If MODE is non-nil, it should be a symbol or a list of symbol representing
|
|
819 requirements. Allowed symbols are `exists', `executable', `writable', and
|
|
820 `readable'. If MODE is nil, it defaults to `readable'.
|
|
821
|
|
822 `locate-file' keeps hash tables of the directories it searches through,
|
|
823 in order to speed things up. It tries valiantly to not get confused in
|
|
824 the face of a changing and unpredictable environment, but can occasionally
|
|
825 get tripped up. In this case, you will have to call
|
|
826 `locate-file-clear-hashing' to get it back on track. See that function
|
|
827 for details.
|
|
828 */
|
|
829 (filename, path_list, suffixes, mode))
|
|
830 {
|
|
831 /* This function can GC */
|
|
832 Lisp_Object tp;
|
|
833
|
|
834 CHECK_STRING (filename);
|
|
835
|
|
836 if (LISTP (suffixes))
|
|
837 {
|
|
838 Lisp_Object tail;
|
|
839 EXTERNAL_LIST_LOOP (tail, suffixes)
|
|
840 CHECK_STRING (XCAR (tail));
|
|
841 }
|
|
842 else
|
|
843 CHECK_STRING (suffixes);
|
|
844
|
|
845 locate_file (path_list, filename, suffixes, &tp, decode_mode (mode));
|
|
846 return tp;
|
|
847 }
|
|
848
|
|
849 /* Recalculate the hash table for the given string. DIRECTORY should
|
|
850 better have been through Fexpand_file_name() by now. */
|
|
851
|
|
852 static Lisp_Object
|
|
853 locate_file_refresh_hashing (Lisp_Object directory)
|
|
854 {
|
|
855 Lisp_Object hash =
|
771
|
856 make_directory_hash_table (XSTRING_DATA (directory));
|
428
|
857
|
|
858 if (!NILP (hash))
|
|
859 Fputhash (directory, hash, Vlocate_file_hash_table);
|
|
860 return hash;
|
|
861 }
|
|
862
|
|
863 /* find the hash table for the given directory, recalculating if necessary */
|
|
864
|
|
865 static Lisp_Object
|
|
866 locate_file_find_directory_hash_table (Lisp_Object directory)
|
|
867 {
|
|
868 Lisp_Object hash = Fgethash (directory, Vlocate_file_hash_table, Qnil);
|
|
869 if (NILP (hash))
|
|
870 return locate_file_refresh_hashing (directory);
|
|
871 else
|
|
872 return hash;
|
|
873 }
|
|
874
|
|
875 /* The SUFFIXES argument in any of the locate_file* functions can be
|
|
876 nil, a list, or a string (for backward compatibility), with the
|
|
877 following semantics:
|
|
878
|
|
879 a) nil - no suffix, just search for file name intact
|
|
880 (semantically different from "empty suffix list", which
|
|
881 would be meaningless.)
|
|
882 b) list - list of suffixes to append to file name. Each of these
|
|
883 must be a string.
|
|
884 c) string - colon-separated suffixes to append to file name (backward
|
|
885 compatibility).
|
|
886
|
|
887 All of this got hairy, so I decided to use a mapper. Calling a
|
|
888 function for each suffix shouldn't slow things down, since
|
|
889 locate_file is rarely called with enough suffixes for funcalls to
|
|
890 make any difference. */
|
|
891
|
|
892 /* Map FUN over SUFFIXES, as described above. FUN will be called with a
|
|
893 char * containing the current file name, and ARG. Mapping stops when
|
|
894 FUN returns non-zero. */
|
|
895 static void
|
|
896 locate_file_map_suffixes (Lisp_Object filename, Lisp_Object suffixes,
|
867
|
897 int (*fun) (Ibyte *, void *),
|
428
|
898 void *arg)
|
|
899 {
|
|
900 /* This function can GC */
|
867
|
901 Ibyte *fn;
|
428
|
902 int fn_len, max;
|
|
903
|
|
904 /* Calculate maximum size of any filename made from
|
|
905 this path element/specified file name and any possible suffix. */
|
|
906 if (CONSP (suffixes))
|
|
907 {
|
|
908 /* We must traverse the list, so why not do it right. */
|
|
909 Lisp_Object tail;
|
|
910 max = 0;
|
|
911 LIST_LOOP (tail, suffixes)
|
|
912 {
|
|
913 if (XSTRING_LENGTH (XCAR (tail)) > max)
|
|
914 max = XSTRING_LENGTH (XCAR (tail));
|
|
915 }
|
|
916 }
|
|
917 else if (NILP (suffixes))
|
|
918 max = 0;
|
|
919 else
|
|
920 /* Just take the easy way out */
|
|
921 max = XSTRING_LENGTH (suffixes);
|
|
922
|
|
923 fn_len = XSTRING_LENGTH (filename);
|
867
|
924 fn = (Ibyte *) ALLOCA (max + fn_len + 1);
|
771
|
925 memcpy (fn, XSTRING_DATA (filename), fn_len);
|
428
|
926
|
|
927 /* Loop over suffixes. */
|
|
928 if (!STRINGP (suffixes))
|
|
929 {
|
|
930 if (NILP (suffixes))
|
|
931 {
|
|
932 /* Case a) discussed in the comment above. */
|
|
933 fn[fn_len] = 0;
|
|
934 if ((*fun) (fn, arg))
|
|
935 return;
|
|
936 }
|
|
937 else
|
|
938 {
|
|
939 /* Case b) */
|
|
940 Lisp_Object tail;
|
|
941 LIST_LOOP (tail, suffixes)
|
|
942 {
|
|
943 memcpy (fn + fn_len, XSTRING_DATA (XCAR (tail)),
|
|
944 XSTRING_LENGTH (XCAR (tail)));
|
|
945 fn[fn_len + XSTRING_LENGTH (XCAR (tail))] = 0;
|
|
946 if ((*fun) (fn, arg))
|
|
947 return;
|
|
948 }
|
|
949 }
|
|
950 }
|
|
951 else
|
|
952 {
|
|
953 /* Case c) */
|
867
|
954 const Ibyte *nsuffix = XSTRING_DATA (suffixes);
|
428
|
955
|
|
956 while (1)
|
|
957 {
|
867
|
958 Ibyte *esuffix = qxestrchr (nsuffix, ':');
|
771
|
959 Bytecount lsuffix = esuffix ? esuffix - nsuffix :
|
|
960 qxestrlen (nsuffix);
|
428
|
961
|
|
962 /* Concatenate path element/specified name with the suffix. */
|
771
|
963 qxestrncpy (fn + fn_len, nsuffix, lsuffix);
|
428
|
964 fn[fn_len + lsuffix] = 0;
|
|
965
|
|
966 if ((*fun) (fn, arg))
|
|
967 return;
|
|
968
|
|
969 /* Advance to next suffix. */
|
|
970 if (esuffix == 0)
|
|
971 break;
|
|
972 nsuffix += lsuffix + 1;
|
|
973 }
|
|
974 }
|
|
975 }
|
|
976
|
771
|
977 struct locate_file_in_directory_mapper_closure
|
|
978 {
|
428
|
979 int fd;
|
|
980 Lisp_Object *storeptr;
|
|
981 int mode;
|
|
982 };
|
|
983
|
1123
|
984 /* open() or access() a file to be returned by locate_file(). if
|
|
985 ACCESS_MODE >= 0, do an access() with that mode, else open(). Does
|
|
986 various magic, e.g. opening the file read-only and binary and setting
|
|
987 the close-on-exec flag on the file. */
|
|
988
|
|
989 static int
|
|
990 locate_file_open_or_access_file (Ibyte *fn, int access_mode)
|
|
991 {
|
|
992 int val;
|
|
993
|
|
994 /* Check that we can access or open it. */
|
|
995 if (access_mode >= 0)
|
|
996 val = qxe_access (fn, access_mode);
|
|
997 else
|
|
998 {
|
|
999 val = qxe_open (fn, O_RDONLY | OPEN_BINARY, 0);
|
|
1000
|
|
1001 #ifndef WIN32_NATIVE
|
|
1002 if (val >= 0)
|
|
1003 /* If we actually opened the file, set close-on-exec flag
|
|
1004 on the new descriptor so that subprocesses can't whack
|
|
1005 at it. */
|
|
1006 (void) fcntl (val, F_SETFD, FD_CLOEXEC);
|
|
1007 #endif
|
|
1008 }
|
|
1009
|
|
1010 return val;
|
|
1011 }
|
|
1012
|
428
|
1013 static int
|
867
|
1014 locate_file_in_directory_mapper (Ibyte *fn, void *arg)
|
428
|
1015 {
|
|
1016 struct locate_file_in_directory_mapper_closure *closure =
|
771
|
1017 (struct locate_file_in_directory_mapper_closure *) arg;
|
428
|
1018 struct stat st;
|
|
1019
|
|
1020 /* Ignore file if it's a directory. */
|
771
|
1021 if (qxe_stat (fn, &st) >= 0
|
428
|
1022 && (st.st_mode & S_IFMT) != S_IFDIR)
|
|
1023 {
|
|
1024 /* Check that we can access or open it. */
|
1123
|
1025 closure->fd = locate_file_open_or_access_file (fn, closure->mode);
|
428
|
1026
|
|
1027 if (closure->fd >= 0)
|
|
1028 {
|
|
1029 /* We succeeded; return this descriptor and filename. */
|
|
1030 if (closure->storeptr)
|
771
|
1031 *closure->storeptr = build_intstring (fn);
|
428
|
1032
|
|
1033 return 1;
|
|
1034 }
|
|
1035 }
|
|
1036 /* Keep mapping. */
|
|
1037 return 0;
|
|
1038 }
|
|
1039
|
|
1040
|
|
1041 /* look for STR in PATH, optionally adding SUFFIXES. DIRECTORY need
|
|
1042 not have been expanded. */
|
|
1043
|
|
1044 static int
|
|
1045 locate_file_in_directory (Lisp_Object directory, Lisp_Object str,
|
|
1046 Lisp_Object suffixes, Lisp_Object *storeptr,
|
|
1047 int mode)
|
|
1048 {
|
|
1049 /* This function can GC */
|
|
1050 struct locate_file_in_directory_mapper_closure closure;
|
|
1051 Lisp_Object filename = Qnil;
|
|
1052 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1053
|
|
1054 GCPRO3 (directory, str, filename);
|
|
1055
|
|
1056 filename = Fexpand_file_name (str, directory);
|
|
1057 if (NILP (filename) || NILP (Ffile_name_absolute_p (filename)))
|
|
1058 /* If there are non-absolute elts in PATH (eg ".") */
|
|
1059 /* Of course, this could conceivably lose if luser sets
|
|
1060 default-directory to be something non-absolute ... */
|
|
1061 {
|
|
1062 if (NILP (filename))
|
|
1063 /* NIL means current directory */
|
|
1064 filename = current_buffer->directory;
|
|
1065 else
|
|
1066 filename = Fexpand_file_name (filename,
|
|
1067 current_buffer->directory);
|
|
1068 if (NILP (Ffile_name_absolute_p (filename)))
|
|
1069 {
|
|
1070 /* Give up on this directory! */
|
|
1071 UNGCPRO;
|
|
1072 return -1;
|
|
1073 }
|
|
1074 }
|
|
1075
|
|
1076 closure.fd = -1;
|
|
1077 closure.storeptr = storeptr;
|
|
1078 closure.mode = mode;
|
|
1079
|
771
|
1080 locate_file_map_suffixes (filename, suffixes,
|
|
1081 locate_file_in_directory_mapper,
|
428
|
1082 &closure);
|
|
1083
|
|
1084 UNGCPRO;
|
|
1085 return closure.fd;
|
|
1086 }
|
|
1087
|
|
1088 /* do the same as locate_file() but don't use any hash tables. */
|
|
1089
|
|
1090 static int
|
|
1091 locate_file_without_hash (Lisp_Object path, Lisp_Object str,
|
|
1092 Lisp_Object suffixes, Lisp_Object *storeptr,
|
|
1093 int mode)
|
|
1094 {
|
|
1095 /* This function can GC */
|
|
1096 int absolute = !NILP (Ffile_name_absolute_p (str));
|
|
1097
|
|
1098 EXTERNAL_LIST_LOOP (path, path)
|
|
1099 {
|
|
1100 int val = locate_file_in_directory (XCAR (path), str, suffixes, storeptr,
|
|
1101 mode);
|
|
1102 if (val >= 0)
|
|
1103 return val;
|
|
1104 if (absolute)
|
|
1105 break;
|
|
1106 }
|
|
1107 return -1;
|
|
1108 }
|
|
1109
|
|
1110 static int
|
867
|
1111 locate_file_construct_suffixed_files_mapper (Ibyte *fn, void *arg)
|
428
|
1112 {
|
771
|
1113 Lisp_Object *tail = (Lisp_Object *) arg;
|
|
1114 *tail = Fcons (build_intstring (fn), *tail);
|
428
|
1115 return 0;
|
|
1116 }
|
|
1117
|
|
1118 /* Construct a list of all files to search for.
|
|
1119 It makes sense to have this despite locate_file_map_suffixes()
|
|
1120 because we need Lisp strings to access the hash-table, and it would
|
|
1121 be inefficient to create them on the fly, again and again for each
|
|
1122 path component. See locate_file(). */
|
|
1123
|
|
1124 static Lisp_Object
|
|
1125 locate_file_construct_suffixed_files (Lisp_Object filename,
|
|
1126 Lisp_Object suffixes)
|
|
1127 {
|
|
1128 Lisp_Object tail = Qnil;
|
|
1129 struct gcpro gcpro1;
|
|
1130 GCPRO1 (tail);
|
|
1131
|
|
1132 locate_file_map_suffixes (filename, suffixes,
|
|
1133 locate_file_construct_suffixed_files_mapper,
|
|
1134 &tail);
|
|
1135
|
|
1136 UNGCPRO;
|
|
1137 return Fnreverse (tail);
|
|
1138 }
|
|
1139
|
|
1140 DEFUN ("locate-file-clear-hashing", Flocate_file_clear_hashing, 1, 1, 0, /*
|
|
1141 Clear the hash records for the specified list of directories.
|
|
1142 `locate-file' uses a hashing scheme to speed lookup, and will correctly
|
|
1143 track the following environmental changes:
|
|
1144
|
|
1145 -- changes of any sort to the list of directories to be searched.
|
|
1146 -- addition and deletion of non-shadowing files (see below) from the
|
|
1147 directories in the list.
|
|
1148 -- byte-compilation of a .el file into a .elc file.
|
|
1149
|
|
1150 `locate-file' will primarily get confused if you add a file that shadows
|
|
1151 \(i.e. has the same name as) another file further down in the directory list.
|
|
1152 In this case, you must call `locate-file-clear-hashing'.
|
|
1153
|
|
1154 If PATH is t, it means to fully clear all the accumulated hashes. This
|
|
1155 can be used if the internal tables grow too large, or when dumping.
|
|
1156 */
|
|
1157 (path))
|
|
1158 {
|
|
1159 if (EQ (path, Qt))
|
|
1160 Fclrhash (Vlocate_file_hash_table);
|
|
1161 else
|
|
1162 {
|
|
1163 Lisp_Object pathtail;
|
|
1164 EXTERNAL_LIST_LOOP (pathtail, path)
|
|
1165 {
|
|
1166 Lisp_Object pathel = Fexpand_file_name (XCAR (pathtail), Qnil);
|
|
1167 Fremhash (pathel, Vlocate_file_hash_table);
|
|
1168 }
|
|
1169 }
|
|
1170 return Qnil;
|
|
1171 }
|
|
1172
|
|
1173 /* Search for a file whose name is STR, looking in directories
|
|
1174 in the Lisp list PATH, and trying suffixes from SUFFIXES.
|
|
1175 SUFFIXES is a list of possible suffixes, or (for backward
|
|
1176 compatibility) a string containing possible suffixes separated by
|
|
1177 colons.
|
|
1178 On success, returns a file descriptor. On failure, returns -1.
|
|
1179
|
|
1180 MODE nonnegative means don't open the files,
|
|
1181 just look for one for which access(file,MODE) succeeds. In this case,
|
951
|
1182 returns a nonnegative value on success. On failure, returns -1.
|
428
|
1183
|
|
1184 If STOREPTR is nonzero, it points to a slot where the name of
|
|
1185 the file actually found should be stored as a Lisp string.
|
|
1186 Nil is stored there on failure.
|
|
1187
|
|
1188 Called openp() in FSFmacs. */
|
|
1189
|
|
1190 int
|
|
1191 locate_file (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
|
|
1192 Lisp_Object *storeptr, int mode)
|
|
1193 {
|
|
1194 /* This function can GC */
|
|
1195 Lisp_Object suffixtab = Qnil;
|
|
1196 Lisp_Object pathtail, pathel_expanded;
|
|
1197 int val;
|
|
1198 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
|
|
1199
|
|
1200 if (storeptr)
|
|
1201 *storeptr = Qnil;
|
|
1202
|
|
1203 /* Is it really necessary to gcpro path and str? It shouldn't be
|
|
1204 unless some caller has fucked up. There are known instances that
|
|
1205 call us with build_string("foo:bar") as SUFFIXES, though. */
|
|
1206 GCPRO4 (path, str, suffixes, suffixtab);
|
|
1207
|
|
1208 /* if this filename has directory components, it's too complicated
|
|
1209 to try and use the hash tables. */
|
|
1210 if (!NILP (Ffile_name_directory (str)))
|
|
1211 {
|
|
1212 val = locate_file_without_hash (path, str, suffixes, storeptr, mode);
|
|
1213 UNGCPRO;
|
|
1214 return val;
|
|
1215 }
|
|
1216
|
|
1217 suffixtab = locate_file_construct_suffixed_files (str, suffixes);
|
|
1218
|
|
1219 EXTERNAL_LIST_LOOP (pathtail, path)
|
|
1220 {
|
|
1221 Lisp_Object pathel = XCAR (pathtail);
|
|
1222 Lisp_Object hash_table;
|
|
1223 Lisp_Object tail;
|
|
1224 int found = 0;
|
|
1225
|
|
1226 /* If this path element is relative, we have to look by hand. */
|
442
|
1227 if (NILP (pathel) || NILP (Ffile_name_absolute_p (pathel)))
|
428
|
1228 {
|
|
1229 val = locate_file_in_directory (pathel, str, suffixes, storeptr,
|
|
1230 mode);
|
|
1231 if (val >= 0)
|
|
1232 {
|
|
1233 UNGCPRO;
|
|
1234 return val;
|
|
1235 }
|
|
1236 continue;
|
|
1237 }
|
|
1238
|
|
1239 pathel_expanded = Fexpand_file_name (pathel, Qnil);
|
|
1240 hash_table = locate_file_find_directory_hash_table (pathel_expanded);
|
|
1241
|
|
1242 if (!NILP (hash_table))
|
|
1243 {
|
|
1244 /* Loop over suffixes. */
|
|
1245 LIST_LOOP (tail, suffixtab)
|
|
1246 if (!NILP (Fgethash (XCAR (tail), hash_table, Qnil)))
|
|
1247 {
|
|
1248 found = 1;
|
|
1249 break;
|
|
1250 }
|
|
1251 }
|
|
1252
|
|
1253 if (found)
|
|
1254 {
|
|
1255 /* This is a likely candidate. Look by hand in this directory
|
|
1256 so we don't get thrown off if someone byte-compiles a file. */
|
|
1257 val = locate_file_in_directory (pathel, str, suffixes, storeptr,
|
|
1258 mode);
|
|
1259 if (val >= 0)
|
|
1260 {
|
|
1261 UNGCPRO;
|
|
1262 return val;
|
|
1263 }
|
|
1264
|
|
1265 /* Hmm ... the file isn't actually there. (Or possibly it's
|
|
1266 a directory ...) So refresh our hashing. */
|
|
1267 locate_file_refresh_hashing (pathel_expanded);
|
|
1268 }
|
|
1269 }
|
|
1270
|
|
1271 /* File is probably not there, but check the hard way just in case. */
|
|
1272 val = locate_file_without_hash (path, str, suffixes, storeptr, mode);
|
|
1273 if (val >= 0)
|
|
1274 {
|
|
1275 /* Sneaky user added a file without telling us. */
|
|
1276 Flocate_file_clear_hashing (path);
|
|
1277 }
|
|
1278
|
|
1279 UNGCPRO;
|
|
1280 return val;
|
|
1281 }
|
|
1282
|
|
1283
|
|
1284 #ifdef LOADHIST
|
|
1285
|
|
1286 /* Merge the list we've accumulated of globals from the current input source
|
|
1287 into the load_history variable. The details depend on whether
|
|
1288 the source has an associated file name or not. */
|
|
1289
|
|
1290 static void
|
|
1291 build_load_history (int loading, Lisp_Object source)
|
|
1292 {
|
|
1293 REGISTER Lisp_Object tail, prev, newelt;
|
|
1294 REGISTER Lisp_Object tem, tem2;
|
|
1295 int foundit;
|
|
1296
|
|
1297 #if !defined(LOADHIST_DUMPED)
|
|
1298 /* Don't bother recording anything for preloaded files. */
|
|
1299 if (purify_flag)
|
|
1300 return;
|
|
1301 #endif
|
|
1302
|
|
1303 tail = Vload_history;
|
|
1304 prev = Qnil;
|
|
1305 foundit = 0;
|
|
1306 while (!NILP (tail))
|
|
1307 {
|
|
1308 tem = Fcar (tail);
|
|
1309
|
|
1310 /* Find the feature's previous assoc list... */
|
|
1311 if (internal_equal (source, Fcar (tem), 0))
|
|
1312 {
|
|
1313 foundit = 1;
|
|
1314
|
|
1315 /* If we're loading, remove it. */
|
|
1316 if (loading)
|
|
1317 {
|
|
1318 if (NILP (prev))
|
|
1319 Vload_history = Fcdr (tail);
|
|
1320 else
|
|
1321 Fsetcdr (prev, Fcdr (tail));
|
|
1322 }
|
|
1323
|
|
1324 /* Otherwise, cons on new symbols that are not already members. */
|
|
1325 else
|
|
1326 {
|
|
1327 tem2 = Vcurrent_load_list;
|
|
1328
|
|
1329 while (CONSP (tem2))
|
|
1330 {
|
|
1331 newelt = XCAR (tem2);
|
|
1332
|
|
1333 if (NILP (Fmemq (newelt, tem)))
|
|
1334 Fsetcar (tail, Fcons (Fcar (tem),
|
|
1335 Fcons (newelt, Fcdr (tem))));
|
|
1336
|
|
1337 tem2 = XCDR (tem2);
|
|
1338 QUIT;
|
|
1339 }
|
|
1340 }
|
|
1341 }
|
|
1342 else
|
|
1343 prev = tail;
|
|
1344 tail = Fcdr (tail);
|
|
1345 QUIT;
|
|
1346 }
|
|
1347
|
|
1348 /* If we're loading, cons the new assoc onto the front of load-history,
|
|
1349 the most-recently-loaded position. Also do this if we didn't find
|
|
1350 an existing member for the current source. */
|
|
1351 if (loading || !foundit)
|
|
1352 Vload_history = Fcons (Fnreverse (Vcurrent_load_list),
|
|
1353 Vload_history);
|
|
1354 }
|
|
1355
|
|
1356 #else /* !LOADHIST */
|
|
1357 #define build_load_history(x,y)
|
|
1358 #endif /* !LOADHIST */
|
|
1359
|
|
1360
|
|
1361 static void
|
|
1362 readevalloop (Lisp_Object readcharfun,
|
|
1363 Lisp_Object sourcename,
|
|
1364 Lisp_Object (*evalfun) (Lisp_Object),
|
|
1365 int printflag)
|
|
1366 {
|
|
1367 /* This function can GC */
|
867
|
1368 REGISTER Ichar c;
|
1849
|
1369 Lisp_Object val = Qnil;
|
428
|
1370 int speccount = specpdl_depth ();
|
|
1371 struct gcpro gcpro1, gcpro2;
|
|
1372 struct buffer *b = 0;
|
|
1373
|
|
1374 if (BUFFERP (readcharfun))
|
|
1375 b = XBUFFER (readcharfun);
|
|
1376 else if (MARKERP (readcharfun))
|
|
1377 b = XMARKER (readcharfun)->buffer;
|
|
1378
|
|
1379 /* Don't do this. It is not necessary, and it needlessly exposes
|
|
1380 READCHARFUN (which can be a stream) to Lisp. --hniksic */
|
|
1381 /*specbind (Qstandard_input, readcharfun);*/
|
|
1382
|
|
1383 specbind (Qcurrent_load_list, Qnil);
|
|
1384
|
|
1385 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
1386 Vcurrent_compiled_function_annotation = Qnil;
|
|
1387 #endif
|
|
1388 GCPRO2 (val, sourcename);
|
|
1389
|
|
1390 LOADHIST_ATTACH (sourcename);
|
|
1391
|
|
1392 while (1)
|
|
1393 {
|
|
1394 QUIT;
|
|
1395
|
|
1396 if (b != 0 && !BUFFER_LIVE_P (b))
|
563
|
1397 invalid_operation ("Reading from killed buffer", Qunbound);
|
428
|
1398
|
|
1399 c = readchar (readcharfun);
|
|
1400 if (c == ';')
|
|
1401 {
|
|
1402 /* Skip comment */
|
|
1403 while ((c = readchar (readcharfun)) != '\n' && c != -1)
|
|
1404 QUIT;
|
|
1405 continue;
|
|
1406 }
|
|
1407 if (c < 0)
|
|
1408 break;
|
|
1409
|
|
1410 /* Ignore whitespace here, so we can detect eof. */
|
|
1411 if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r')
|
|
1412 continue;
|
|
1413
|
814
|
1414 unreadchar (readcharfun, c);
|
|
1415 Vread_objects = Qnil;
|
|
1416 if (NILP (Vload_read_function))
|
|
1417 val = read0 (readcharfun);
|
428
|
1418 else
|
814
|
1419 val = call1 (Vload_read_function, readcharfun);
|
428
|
1420 val = (*evalfun) (val);
|
|
1421 if (printflag)
|
|
1422 {
|
|
1423 Vvalues = Fcons (val, Vvalues);
|
|
1424 if (EQ (Vstandard_output, Qt))
|
|
1425 Fprin1 (val, Qnil);
|
|
1426 else
|
|
1427 Fprint (val, Qnil);
|
|
1428 }
|
|
1429 }
|
|
1430
|
|
1431 build_load_history (LSTREAMP (readcharfun) ||
|
|
1432 /* This looks weird, but it's what's in FSFmacs */
|
|
1433 (b ? BUF_NARROWED (b) : BUF_NARROWED (current_buffer)),
|
|
1434 sourcename);
|
|
1435 UNGCPRO;
|
|
1436
|
771
|
1437 unbind_to (speccount);
|
428
|
1438 }
|
|
1439
|
|
1440 DEFUN ("eval-buffer", Feval_buffer, 0, 2, "bBuffer: ", /*
|
|
1441 Execute BUFFER as Lisp code.
|
|
1442 Programs can pass two arguments, BUFFER and PRINTFLAG.
|
|
1443 BUFFER is the buffer to evaluate (nil means use current buffer).
|
|
1444 PRINTFLAG controls printing of output:
|
444
|
1445 nil means discard it; anything else is a stream for printing.
|
428
|
1446
|
|
1447 If there is no error, point does not move. If there is an error,
|
|
1448 point remains at the end of the last character read from the buffer.
|
|
1449 */
|
444
|
1450 (buffer, printflag))
|
428
|
1451 {
|
|
1452 /* This function can GC */
|
|
1453 int speccount = specpdl_depth ();
|
|
1454 Lisp_Object tem, buf;
|
|
1455
|
444
|
1456 if (NILP (buffer))
|
428
|
1457 buf = Fcurrent_buffer ();
|
|
1458 else
|
444
|
1459 buf = Fget_buffer (buffer);
|
428
|
1460 if (NILP (buf))
|
563
|
1461 invalid_argument ("No such buffer", Qunbound);
|
428
|
1462
|
|
1463 if (NILP (printflag))
|
|
1464 tem = Qsymbolp; /* #### #@[]*&$#*[& SI:NULL-STREAM */
|
|
1465 else
|
|
1466 tem = printflag;
|
|
1467 specbind (Qstandard_output, tem);
|
|
1468 record_unwind_protect (save_excursion_restore, save_excursion_save ());
|
|
1469 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
|
|
1470 readevalloop (buf, XBUFFER (buf)->filename, Feval,
|
|
1471 !NILP (printflag));
|
|
1472
|
771
|
1473 return unbind_to (speccount);
|
428
|
1474 }
|
|
1475
|
|
1476 #if 0
|
826
|
1477 DEFUN ("eval-current-buffer", Feval_current_buffer, 0, 1, "", /*
|
428
|
1478 Execute the current buffer as Lisp code.
|
|
1479 Programs can pass argument PRINTFLAG which controls printing of output:
|
|
1480 nil means discard it; anything else is stream for print.
|
|
1481
|
|
1482 If there is no error, point does not move. If there is an error,
|
|
1483 point remains at the end of the last character read from the buffer.
|
|
1484 */
|
|
1485 (printflag))
|
|
1486 {
|
|
1487 code omitted;
|
|
1488 }
|
|
1489 #endif /* 0 */
|
|
1490
|
|
1491 DEFUN ("eval-region", Feval_region, 2, 3, "r", /*
|
|
1492 Execute the region as Lisp code.
|
444
|
1493 When called from programs, expects two arguments START and END
|
428
|
1494 giving starting and ending indices in the current buffer
|
|
1495 of the text to be executed.
|
444
|
1496 Programs can pass third optional argument STREAM which controls output:
|
428
|
1497 nil means discard it; anything else is stream for printing it.
|
|
1498
|
|
1499 If there is no error, point does not move. If there is an error,
|
|
1500 point remains at the end of the last character read from the buffer.
|
|
1501
|
|
1502 Note: Before evaling the region, this function narrows the buffer to it.
|
|
1503 If the code being eval'd should happen to trigger a redisplay you may
|
|
1504 see some text temporarily disappear because of this.
|
|
1505 */
|
444
|
1506 (start, end, stream))
|
428
|
1507 {
|
|
1508 /* This function can GC */
|
|
1509 int speccount = specpdl_depth ();
|
|
1510 Lisp_Object tem;
|
|
1511 Lisp_Object cbuf = Fcurrent_buffer ();
|
|
1512
|
444
|
1513 if (NILP (stream))
|
428
|
1514 tem = Qsymbolp; /* #### #@[]*&$#*[& SI:NULL-STREAM */
|
|
1515 else
|
444
|
1516 tem = stream;
|
428
|
1517 specbind (Qstandard_output, tem);
|
|
1518
|
444
|
1519 if (NILP (stream))
|
428
|
1520 record_unwind_protect (save_excursion_restore, save_excursion_save ());
|
844
|
1521 record_unwind_protect (save_restriction_restore,
|
|
1522 save_restriction_save (current_buffer));
|
428
|
1523
|
444
|
1524 /* This both uses start and checks its type. */
|
|
1525 Fgoto_char (start, cbuf);
|
|
1526 Fnarrow_to_region (make_int (BUF_BEGV (current_buffer)), end, cbuf);
|
428
|
1527 readevalloop (cbuf, XBUFFER (cbuf)->filename, Feval,
|
444
|
1528 !NILP (stream));
|
428
|
1529
|
771
|
1530 return unbind_to (speccount);
|
428
|
1531 }
|
|
1532
|
|
1533 DEFUN ("read", Fread, 0, 1, 0, /*
|
|
1534 Read one Lisp expression as text from STREAM, return as Lisp object.
|
|
1535 If STREAM is nil, use the value of `standard-input' (which see).
|
|
1536 STREAM or the value of `standard-input' may be:
|
|
1537 a buffer (read from point and advance it)
|
|
1538 a marker (read from where it points and advance it)
|
|
1539 a function (call it with no arguments for each character,
|
|
1540 call it with a char as argument to push a char back)
|
|
1541 a string (takes text from string, starting at the beginning)
|
|
1542 t (read text line using minibuffer and use it).
|
|
1543 */
|
|
1544 (stream))
|
|
1545 {
|
|
1546 if (NILP (stream))
|
|
1547 stream = Vstandard_input;
|
|
1548 if (EQ (stream, Qt))
|
|
1549 stream = Qread_char;
|
|
1550
|
|
1551 Vread_objects = Qnil;
|
|
1552
|
|
1553 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
1554 Vcurrent_compiled_function_annotation = Qnil;
|
|
1555 #endif
|
|
1556 if (EQ (stream, Qread_char))
|
|
1557 {
|
|
1558 Lisp_Object val = call1 (Qread_from_minibuffer,
|
771
|
1559 build_msg_string ("Lisp expression: "));
|
428
|
1560 return Fcar (Fread_from_string (val, Qnil, Qnil));
|
|
1561 }
|
|
1562
|
|
1563 if (STRINGP (stream))
|
|
1564 return Fcar (Fread_from_string (stream, Qnil, Qnil));
|
|
1565
|
|
1566 return read0 (stream);
|
|
1567 }
|
|
1568
|
|
1569 DEFUN ("read-from-string", Fread_from_string, 1, 3, 0, /*
|
|
1570 Read one Lisp expression which is represented as text by STRING.
|
|
1571 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).
|
|
1572 START and END optionally delimit a substring of STRING from which to read;
|
|
1573 they default to 0 and (length STRING) respectively.
|
|
1574 */
|
|
1575 (string, start, end))
|
|
1576 {
|
|
1577 Bytecount startval, endval;
|
|
1578 Lisp_Object tem;
|
|
1579 Lisp_Object lispstream = Qnil;
|
|
1580 struct gcpro gcpro1;
|
|
1581
|
|
1582 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
1583 Vcurrent_compiled_function_annotation = Qnil;
|
|
1584 #endif
|
|
1585 GCPRO1 (lispstream);
|
|
1586 CHECK_STRING (string);
|
|
1587 get_string_range_byte (string, start, end, &startval, &endval,
|
|
1588 GB_HISTORICAL_STRING_BEHAVIOR);
|
|
1589 lispstream = make_lisp_string_input_stream (string, startval,
|
|
1590 endval - startval);
|
|
1591
|
|
1592 Vread_objects = Qnil;
|
|
1593
|
|
1594 tem = read0 (lispstream);
|
|
1595 /* Yeah, it's ugly. Gonna make something of it?
|
|
1596 At least our reader is reentrant ... */
|
|
1597 tem =
|
|
1598 (Fcons (tem, make_int
|
793
|
1599 (string_index_byte_to_char
|
771
|
1600 (string,
|
428
|
1601 startval + Lstream_byte_count (XLSTREAM (lispstream))))));
|
|
1602 Lstream_delete (XLSTREAM (lispstream));
|
|
1603 UNGCPRO;
|
|
1604 return tem;
|
|
1605 }
|
|
1606
|
|
1607
|
|
1608
|
|
1609 /* Use this for recursive reads, in contexts where internal tokens
|
|
1610 are not allowed. See also read1(). */
|
|
1611 static Lisp_Object
|
|
1612 read0 (Lisp_Object readcharfun)
|
|
1613 {
|
|
1614 Lisp_Object val = read1 (readcharfun);
|
|
1615
|
|
1616 if (CONSP (val) && UNBOUNDP (XCAR (val)))
|
|
1617 {
|
867
|
1618 Ichar c = XCHAR (XCDR (val));
|
853
|
1619 free_cons (val);
|
428
|
1620 return Fsignal (Qinvalid_read_syntax,
|
|
1621 list1 (Fchar_to_string (make_char (c))));
|
|
1622 }
|
|
1623
|
|
1624 return val;
|
|
1625 }
|
|
1626
|
867
|
1627 static Ichar
|
428
|
1628 read_escape (Lisp_Object readcharfun)
|
|
1629 {
|
|
1630 /* This function can GC */
|
867
|
1631 Ichar c = readchar (readcharfun);
|
428
|
1632
|
|
1633 if (c < 0)
|
563
|
1634 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1635
|
|
1636 switch (c)
|
|
1637 {
|
|
1638 case 'a': return '\007';
|
|
1639 case 'b': return '\b';
|
|
1640 case 'd': return 0177;
|
|
1641 case 'e': return 033;
|
|
1642 case 'f': return '\f';
|
|
1643 case 'n': return '\n';
|
|
1644 case 'r': return '\r';
|
|
1645 case 't': return '\t';
|
|
1646 case 'v': return '\v';
|
|
1647 case '\n': return -1;
|
|
1648
|
|
1649 case 'M':
|
|
1650 c = readchar (readcharfun);
|
|
1651 if (c < 0)
|
563
|
1652 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1653 if (c != '-')
|
563
|
1654 syntax_error ("Invalid escape character syntax", Qunbound);
|
428
|
1655 c = readchar (readcharfun);
|
|
1656 if (c < 0)
|
563
|
1657 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1658 if (c == '\\')
|
|
1659 c = read_escape (readcharfun);
|
|
1660 return c | 0200;
|
|
1661
|
|
1662 /* Originally, FSF_KEYS provided a degree of FSF Emacs
|
|
1663 compatibility by defining character "modifiers" alt, super,
|
|
1664 hyper and shift to infest the characters (i.e. integers).
|
|
1665
|
|
1666 However, this doesn't cut it for XEmacs 20, which
|
|
1667 distinguishes characters from integers. Without Mule, ?\H-a
|
|
1668 simply returns ?a because every character is clipped into
|
|
1669 0-255. Under Mule it is much worse -- ?\H-a with FSF_KEYS
|
|
1670 produces an illegal character, and moves us to crash-land.
|
|
1671
|
|
1672 For these reasons, FSF_KEYS hack is useless and without hope
|
|
1673 of ever working under XEmacs 20. */
|
|
1674 #ifdef FSF_KEYS
|
831
|
1675 /* Deleted */
|
|
1676 #endif
|
428
|
1677
|
|
1678 case 'C':
|
|
1679 c = readchar (readcharfun);
|
|
1680 if (c < 0)
|
563
|
1681 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1682 if (c != '-')
|
563
|
1683 syntax_error ("Invalid escape character syntax", Qunbound);
|
428
|
1684 case '^':
|
|
1685 c = readchar (readcharfun);
|
|
1686 if (c < 0)
|
563
|
1687 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1688 if (c == '\\')
|
|
1689 c = read_escape (readcharfun);
|
|
1690 /* FSFmacs junk for non-ASCII controls.
|
|
1691 Not used here. */
|
|
1692 if (c == '?')
|
|
1693 return 0177;
|
|
1694 else
|
|
1695 return c & (0200 | 037);
|
|
1696
|
|
1697 case '0':
|
|
1698 case '1':
|
|
1699 case '2':
|
|
1700 case '3':
|
|
1701 case '4':
|
|
1702 case '5':
|
|
1703 case '6':
|
|
1704 case '7':
|
|
1705 /* An octal escape, as in ANSI C. */
|
|
1706 {
|
867
|
1707 REGISTER Ichar i = c - '0';
|
428
|
1708 REGISTER int count = 0;
|
|
1709 while (++count < 3)
|
|
1710 {
|
|
1711 if ((c = readchar (readcharfun)) >= '0' && c <= '7')
|
|
1712 i = (i << 3) + (c - '0');
|
|
1713 else
|
|
1714 {
|
|
1715 unreadchar (readcharfun, c);
|
|
1716 break;
|
|
1717 }
|
|
1718 }
|
831
|
1719 if (i >= 0400)
|
|
1720 syntax_error ("Attempt to create non-ASCII/ISO-8859-1 character",
|
|
1721 make_int (i));
|
428
|
1722 return i;
|
|
1723 }
|
|
1724
|
|
1725 case 'x':
|
|
1726 /* A hex escape, as in ANSI C, except that we only allow latin-1
|
|
1727 characters to be read this way. What is "\x4e03" supposed to
|
|
1728 mean, anyways, if the internal representation is hidden?
|
|
1729 This is also consistent with the treatment of octal escapes. */
|
|
1730 {
|
867
|
1731 REGISTER Ichar i = 0;
|
428
|
1732 REGISTER int count = 0;
|
|
1733 while (++count <= 2)
|
|
1734 {
|
|
1735 c = readchar (readcharfun);
|
867
|
1736 /* Remember, can't use isdigit(), isalpha() etc. on Ichars */
|
428
|
1737 if (c >= '0' && c <= '9') i = (i << 4) + (c - '0');
|
|
1738 else if (c >= 'a' && c <= 'f') i = (i << 4) + (c - 'a') + 10;
|
|
1739 else if (c >= 'A' && c <= 'F') i = (i << 4) + (c - 'A') + 10;
|
|
1740 else
|
|
1741 {
|
|
1742 unreadchar (readcharfun, c);
|
|
1743 break;
|
|
1744 }
|
|
1745 }
|
|
1746 return i;
|
|
1747 }
|
|
1748
|
|
1749 #ifdef MULE
|
|
1750 /* #### need some way of reading an extended character with
|
|
1751 an escape sequence. */
|
|
1752 #endif
|
|
1753
|
|
1754 default:
|
|
1755 return c;
|
|
1756 }
|
|
1757 }
|
|
1758
|
|
1759
|
|
1760
|
|
1761 /* read symbol-constituent stuff into `Vread_buffer_stream'. */
|
|
1762 static Bytecount
|
867
|
1763 read_atom_0 (Lisp_Object readcharfun, Ichar firstchar, int *saw_a_backslash)
|
428
|
1764 {
|
|
1765 /* This function can GC */
|
867
|
1766 Ichar c = ((firstchar) >= 0 ? firstchar : readchar (readcharfun));
|
428
|
1767 Lstream_rewind (XLSTREAM (Vread_buffer_stream));
|
|
1768
|
|
1769 *saw_a_backslash = 0;
|
|
1770
|
|
1771 while (c > 040 /* #### - comma should be here as should backquote */
|
|
1772 && !(c == '\"' || c == '\'' || c == ';'
|
|
1773 || c == '(' || c == ')'
|
|
1774 || c == '[' || c == ']' || c == '#'
|
|
1775 ))
|
|
1776 {
|
|
1777 if (c == '\\')
|
|
1778 {
|
|
1779 c = readchar (readcharfun);
|
|
1780 if (c < 0)
|
563
|
1781 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
1782 *saw_a_backslash = 1;
|
|
1783 }
|
867
|
1784 Lstream_put_ichar (XLSTREAM (Vread_buffer_stream), c);
|
428
|
1785 QUIT;
|
|
1786 c = readchar (readcharfun);
|
|
1787 }
|
|
1788
|
|
1789 if (c >= 0)
|
|
1790 unreadchar (readcharfun, c);
|
|
1791 /* blasted terminating 0 */
|
867
|
1792 Lstream_put_ichar (XLSTREAM (Vread_buffer_stream), 0);
|
428
|
1793 Lstream_flush (XLSTREAM (Vread_buffer_stream));
|
|
1794
|
|
1795 return Lstream_byte_count (XLSTREAM (Vread_buffer_stream)) - 1;
|
|
1796 }
|
|
1797
|
867
|
1798 static Lisp_Object parse_integer (const Ibyte *buf, Bytecount len, int base);
|
428
|
1799
|
|
1800 static Lisp_Object
|
|
1801 read_atom (Lisp_Object readcharfun,
|
867
|
1802 Ichar firstchar,
|
428
|
1803 int uninterned_symbol)
|
|
1804 {
|
|
1805 /* This function can GC */
|
|
1806 int saw_a_backslash;
|
|
1807 Bytecount len = read_atom_0 (readcharfun, firstchar, &saw_a_backslash);
|
|
1808 char *read_ptr = (char *)
|
|
1809 resizing_buffer_stream_ptr (XLSTREAM (Vread_buffer_stream));
|
|
1810
|
|
1811 /* Is it an integer? */
|
|
1812 if (! (saw_a_backslash || uninterned_symbol))
|
|
1813 {
|
|
1814 /* If a token had any backslashes in it, it is disqualified from
|
|
1815 being an integer or a float. This means that 123\456 is a
|
|
1816 symbol, as is \123 (which is the way (intern "123") prints).
|
|
1817 Also, if token was preceded by #:, it's always a symbol.
|
|
1818 */
|
|
1819 char *p = read_ptr + len;
|
|
1820 char *p1 = read_ptr;
|
|
1821
|
|
1822 if (*p1 == '+' || *p1 == '-') p1++;
|
|
1823 if (p1 != p)
|
|
1824 {
|
|
1825 int c;
|
|
1826
|
|
1827 while (p1 != p && (c = *p1) >= '0' && c <= '9')
|
|
1828 p1++;
|
|
1829 /* Integers can have trailing decimal points. */
|
|
1830 if (p1 > read_ptr && p1 < p && *p1 == '.')
|
|
1831 p1++;
|
|
1832 if (p1 == p)
|
|
1833 {
|
|
1834 /* It is an integer. */
|
|
1835 if (p1[-1] == '.')
|
|
1836 p1[-1] = '\0';
|
|
1837 #if 0
|
|
1838 {
|
|
1839 int number = 0;
|
|
1840 if (sizeof (int) == sizeof (EMACS_INT))
|
|
1841 number = atoi (read_buffer);
|
|
1842 else if (sizeof (long) == sizeof (EMACS_INT))
|
|
1843 number = atol (read_buffer);
|
|
1844 else
|
|
1845 abort ();
|
|
1846 return make_int (number);
|
|
1847 }
|
|
1848 #else
|
867
|
1849 return parse_integer ((Ibyte *) read_ptr, len, 10);
|
428
|
1850 #endif
|
|
1851 }
|
|
1852 }
|
1983
|
1853 #ifdef HAVE_RATIO
|
|
1854 if (isratio_string (read_ptr))
|
|
1855 {
|
2013
|
1856 /* GMP ratio_set_string has no effect with initial + sign */
|
2010
|
1857 if (*read_ptr == '+')
|
|
1858 read_ptr++;
|
1983
|
1859 ratio_set_string (scratch_ratio, read_ptr, 0);
|
|
1860 ratio_canonicalize (scratch_ratio);
|
|
1861 return Fcanonicalize_number (make_ratio_rt (scratch_ratio));
|
|
1862 }
|
|
1863 #endif
|
428
|
1864 if (isfloat_string (read_ptr))
|
|
1865 return make_float (atof (read_ptr));
|
|
1866 }
|
|
1867
|
|
1868 {
|
|
1869 Lisp_Object sym;
|
|
1870 if (uninterned_symbol)
|
867
|
1871 sym = Fmake_symbol ( make_string ((Ibyte *) read_ptr, len));
|
428
|
1872 else
|
|
1873 {
|
867
|
1874 Lisp_Object name = make_string ((Ibyte *) read_ptr, len);
|
428
|
1875 sym = Fintern (name, Qnil);
|
|
1876 }
|
|
1877 return sym;
|
|
1878 }
|
|
1879 }
|
|
1880
|
|
1881
|
|
1882 static Lisp_Object
|
867
|
1883 parse_integer (const Ibyte *buf, Bytecount len, int base)
|
428
|
1884 {
|
867
|
1885 const Ibyte *lim = buf + len;
|
|
1886 const Ibyte *p = buf;
|
428
|
1887 EMACS_UINT num = 0;
|
|
1888 int negativland = 0;
|
|
1889
|
|
1890 if (*p == '-')
|
|
1891 {
|
|
1892 negativland = 1;
|
|
1893 p++;
|
|
1894 }
|
|
1895 else if (*p == '+')
|
|
1896 {
|
|
1897 p++;
|
|
1898 }
|
|
1899
|
|
1900 if (p == lim)
|
|
1901 goto loser;
|
|
1902
|
|
1903 for (; (p < lim) && (*p != '\0'); p++)
|
|
1904 {
|
|
1905 int c = *p;
|
|
1906 EMACS_UINT onum;
|
|
1907
|
|
1908 if (isdigit (c))
|
|
1909 c = c - '0';
|
|
1910 else if (isupper (c))
|
|
1911 c = c - 'A' + 10;
|
|
1912 else if (islower (c))
|
|
1913 c = c - 'a' + 10;
|
|
1914 else
|
|
1915 goto loser;
|
|
1916
|
|
1917 if (c < 0 || c >= base)
|
|
1918 goto loser;
|
|
1919
|
|
1920 onum = num;
|
|
1921 num = num * base + c;
|
|
1922 if (num < onum)
|
|
1923 goto overflow;
|
|
1924 }
|
|
1925
|
|
1926 {
|
|
1927 EMACS_INT int_result = negativland ? - (EMACS_INT) num : (EMACS_INT) num;
|
|
1928 Lisp_Object result = make_int (int_result);
|
|
1929 if (num && ((XINT (result) < 0) != negativland))
|
|
1930 goto overflow;
|
|
1931 if (XINT (result) != int_result)
|
|
1932 goto overflow;
|
|
1933 return result;
|
|
1934 }
|
|
1935 overflow:
|
1983
|
1936 #ifdef HAVE_BIGNUM
|
|
1937 {
|
1995
|
1938 bignum_set_string (scratch_bignum, (const char *) buf, 0);
|
1983
|
1939 return make_bignum_bg (scratch_bignum);
|
|
1940 }
|
|
1941 #else
|
428
|
1942 return Fsignal (Qinvalid_read_syntax,
|
771
|
1943 list3 (build_msg_string
|
428
|
1944 ("Integer constant overflow in reader"),
|
|
1945 make_string (buf, len),
|
|
1946 make_int (base)));
|
1983
|
1947 #endif /* HAVE_BIGNUM */
|
428
|
1948 loser:
|
|
1949 return Fsignal (Qinvalid_read_syntax,
|
771
|
1950 list3 (build_msg_string
|
428
|
1951 ("Invalid integer constant in reader"),
|
|
1952 make_string (buf, len),
|
|
1953 make_int (base)));
|
|
1954 }
|
|
1955
|
|
1956
|
|
1957 static Lisp_Object
|
|
1958 read_integer (Lisp_Object readcharfun, int base)
|
|
1959 {
|
|
1960 /* This function can GC */
|
|
1961 int saw_a_backslash;
|
|
1962 Bytecount len = read_atom_0 (readcharfun, -1, &saw_a_backslash);
|
|
1963 return (parse_integer
|
|
1964 (resizing_buffer_stream_ptr (XLSTREAM (Vread_buffer_stream)),
|
|
1965 ((saw_a_backslash)
|
|
1966 ? 0 /* make parse_integer signal error */
|
|
1967 : len),
|
|
1968 base));
|
|
1969 }
|
|
1970
|
|
1971 static Lisp_Object
|
|
1972 read_bit_vector (Lisp_Object readcharfun)
|
|
1973 {
|
|
1974 unsigned_char_dynarr *dyn = Dynarr_new (unsigned_char);
|
440
|
1975 Lisp_Object val;
|
428
|
1976
|
|
1977 while (1)
|
|
1978 {
|
444
|
1979 unsigned char bit;
|
867
|
1980 Ichar c = readchar (readcharfun);
|
444
|
1981 if (c == '0')
|
|
1982 bit = 0;
|
|
1983 else if (c == '1')
|
|
1984 bit = 1;
|
|
1985 else
|
|
1986 {
|
|
1987 if (c >= 0)
|
|
1988 unreadchar (readcharfun, c);
|
|
1989 break;
|
|
1990 }
|
|
1991 Dynarr_add (dyn, bit);
|
428
|
1992 }
|
|
1993
|
440
|
1994 val = make_bit_vector_from_byte_vector (Dynarr_atp (dyn, 0),
|
|
1995 Dynarr_length (dyn));
|
|
1996 Dynarr_free (dyn);
|
|
1997
|
|
1998 return val;
|
428
|
1999 }
|
|
2000
|
|
2001
|
|
2002
|
|
2003 /* structures */
|
|
2004
|
|
2005 struct structure_type *
|
|
2006 define_structure_type (Lisp_Object type,
|
|
2007 int (*validate) (Lisp_Object data,
|
578
|
2008 Error_Behavior errb),
|
428
|
2009 Lisp_Object (*instantiate) (Lisp_Object data))
|
|
2010 {
|
|
2011 struct structure_type st;
|
|
2012
|
|
2013 st.type = type;
|
|
2014 st.keywords = Dynarr_new (structure_keyword_entry);
|
|
2015 st.validate = validate;
|
|
2016 st.instantiate = instantiate;
|
|
2017 Dynarr_add (the_structure_type_dynarr, st);
|
|
2018
|
|
2019 return Dynarr_atp (the_structure_type_dynarr,
|
|
2020 Dynarr_length (the_structure_type_dynarr) - 1);
|
|
2021 }
|
|
2022
|
|
2023 void
|
|
2024 define_structure_type_keyword (struct structure_type *st, Lisp_Object keyword,
|
|
2025 int (*validate) (Lisp_Object keyword,
|
|
2026 Lisp_Object value,
|
578
|
2027 Error_Behavior errb))
|
428
|
2028 {
|
|
2029 struct structure_keyword_entry en;
|
|
2030
|
|
2031 en.keyword = keyword;
|
|
2032 en.validate = validate;
|
|
2033 Dynarr_add (st->keywords, en);
|
|
2034 }
|
|
2035
|
|
2036 static struct structure_type *
|
|
2037 recognized_structure_type (Lisp_Object type)
|
|
2038 {
|
|
2039 int i;
|
|
2040
|
|
2041 for (i = 0; i < Dynarr_length (the_structure_type_dynarr); i++)
|
|
2042 {
|
|
2043 struct structure_type *st = Dynarr_atp (the_structure_type_dynarr, i);
|
|
2044 if (EQ (st->type, type))
|
|
2045 return st;
|
|
2046 }
|
|
2047
|
|
2048 return 0;
|
|
2049 }
|
|
2050
|
|
2051 static Lisp_Object
|
|
2052 read_structure (Lisp_Object readcharfun)
|
|
2053 {
|
867
|
2054 Ichar c = readchar (readcharfun);
|
428
|
2055 Lisp_Object list = Qnil;
|
|
2056 Lisp_Object orig_list = Qnil;
|
|
2057 Lisp_Object already_seen = Qnil;
|
|
2058 int keyword_count;
|
|
2059 struct structure_type *st;
|
|
2060 struct gcpro gcpro1, gcpro2;
|
|
2061
|
|
2062 GCPRO2 (orig_list, already_seen);
|
|
2063 if (c != '(')
|
442
|
2064 RETURN_UNGCPRO (continuable_read_syntax_error ("#s not followed by paren"));
|
428
|
2065 list = read_list (readcharfun, ')', 0, 0);
|
|
2066 orig_list = list;
|
|
2067 {
|
|
2068 int len = XINT (Flength (list));
|
|
2069 if (len == 0)
|
442
|
2070 RETURN_UNGCPRO (continuable_read_syntax_error
|
428
|
2071 ("structure type not specified"));
|
|
2072 if (!(len & 1))
|
|
2073 RETURN_UNGCPRO
|
442
|
2074 (continuable_read_syntax_error
|
428
|
2075 ("structures must have alternating keyword/value pairs"));
|
|
2076 }
|
|
2077
|
|
2078 st = recognized_structure_type (XCAR (list));
|
|
2079 if (!st)
|
|
2080 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax,
|
771
|
2081 list2 (build_msg_string
|
428
|
2082 ("unrecognized structure type"),
|
|
2083 XCAR (list))));
|
|
2084
|
|
2085 list = Fcdr (list);
|
|
2086 keyword_count = Dynarr_length (st->keywords);
|
|
2087 while (!NILP (list))
|
|
2088 {
|
|
2089 Lisp_Object keyword, value;
|
|
2090 int i;
|
|
2091 struct structure_keyword_entry *en = NULL;
|
|
2092
|
|
2093 keyword = Fcar (list);
|
|
2094 list = Fcdr (list);
|
|
2095 value = Fcar (list);
|
|
2096 list = Fcdr (list);
|
|
2097
|
|
2098 if (!NILP (memq_no_quit (keyword, already_seen)))
|
|
2099 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax,
|
771
|
2100 list2 (build_msg_string
|
428
|
2101 ("structure keyword already seen"),
|
|
2102 keyword)));
|
|
2103
|
|
2104 for (i = 0; i < keyword_count; i++)
|
|
2105 {
|
|
2106 en = Dynarr_atp (st->keywords, i);
|
|
2107 if (EQ (keyword, en->keyword))
|
|
2108 break;
|
|
2109 }
|
|
2110
|
|
2111 if (i == keyword_count)
|
|
2112 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax,
|
771
|
2113 list2 (build_msg_string
|
428
|
2114 ("unrecognized structure keyword"),
|
|
2115 keyword)));
|
|
2116
|
|
2117 if (en->validate && ! (en->validate) (keyword, value, ERROR_ME))
|
|
2118 RETURN_UNGCPRO
|
|
2119 (Fsignal (Qinvalid_read_syntax,
|
771
|
2120 list3 (build_msg_string
|
428
|
2121 ("invalid value for structure keyword"),
|
|
2122 keyword, value)));
|
|
2123
|
|
2124 already_seen = Fcons (keyword, already_seen);
|
|
2125 }
|
|
2126
|
|
2127 if (st->validate && ! (st->validate) (orig_list, ERROR_ME))
|
|
2128 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax,
|
771
|
2129 list2 (build_msg_string
|
428
|
2130 ("invalid structure initializer"),
|
|
2131 orig_list)));
|
|
2132
|
|
2133 RETURN_UNGCPRO ((st->instantiate) (XCDR (orig_list)));
|
|
2134 }
|
|
2135
|
|
2136
|
|
2137 static Lisp_Object read_compiled_function (Lisp_Object readcharfun,
|
|
2138 int terminator);
|
|
2139 static Lisp_Object read_vector (Lisp_Object readcharfun, int terminator);
|
|
2140
|
|
2141 /* Get the next character; filter out whitespace and comments */
|
|
2142
|
867
|
2143 static Ichar
|
428
|
2144 reader_nextchar (Lisp_Object readcharfun)
|
|
2145 {
|
|
2146 /* This function can GC */
|
867
|
2147 Ichar c;
|
428
|
2148
|
|
2149 retry:
|
|
2150 QUIT;
|
|
2151 c = readchar (readcharfun);
|
|
2152 if (c < 0)
|
563
|
2153 signal_error (Qend_of_file, 0, READCHARFUN_MAYBE (readcharfun));
|
428
|
2154
|
|
2155 switch (c)
|
|
2156 {
|
|
2157 default:
|
|
2158 {
|
|
2159 /* Ignore whitespace and control characters */
|
|
2160 if (c <= 040)
|
|
2161 goto retry;
|
|
2162 return c;
|
|
2163 }
|
|
2164
|
|
2165 case ';':
|
|
2166 {
|
|
2167 /* Comment */
|
|
2168 while ((c = readchar (readcharfun)) >= 0 && c != '\n')
|
|
2169 QUIT;
|
|
2170 goto retry;
|
|
2171 }
|
|
2172 }
|
|
2173 }
|
|
2174
|
|
2175 #if 0
|
|
2176 static Lisp_Object
|
|
2177 list2_pure (int pure, Lisp_Object a, Lisp_Object b)
|
|
2178 {
|
|
2179 return pure ? pure_cons (a, pure_cons (b, Qnil)) : list2 (a, b);
|
|
2180 }
|
|
2181 #endif
|
|
2182
|
|
2183 /* Read the next Lisp object from the stream READCHARFUN and return it.
|
|
2184 If the return value is a cons whose car is Qunbound, then read1()
|
|
2185 encountered a misplaced token (e.g. a right bracket, right paren,
|
|
2186 or dot followed by a non-number). To filter this stuff out,
|
|
2187 use read0(). */
|
|
2188
|
|
2189 static Lisp_Object
|
|
2190 read1 (Lisp_Object readcharfun)
|
|
2191 {
|
867
|
2192 Ichar c;
|
428
|
2193
|
|
2194 retry:
|
|
2195 c = reader_nextchar (readcharfun);
|
|
2196
|
|
2197 switch (c)
|
|
2198 {
|
|
2199 case '(':
|
|
2200 {
|
|
2201 #ifdef LISP_BACKQUOTES /* old backquote compatibility in lisp reader */
|
|
2202 /* if this is disabled, then other code in eval.c must be enabled */
|
867
|
2203 Ichar ch = reader_nextchar (readcharfun);
|
428
|
2204 switch (ch)
|
|
2205 {
|
|
2206 case '`':
|
|
2207 {
|
|
2208 Lisp_Object tem;
|
853
|
2209 int speccount = internal_bind_int (&old_backquote_flag,
|
|
2210 1 + old_backquote_flag);
|
428
|
2211 tem = read0 (readcharfun);
|
771
|
2212 unbind_to (speccount);
|
428
|
2213 ch = reader_nextchar (readcharfun);
|
|
2214 if (ch != ')')
|
|
2215 {
|
|
2216 unreadchar (readcharfun, ch);
|
|
2217 return Fsignal (Qinvalid_read_syntax,
|
771
|
2218 list1 (build_msg_string
|
428
|
2219 ("Weird old-backquote syntax")));
|
|
2220 }
|
|
2221 return list2 (Qbacktick, tem);
|
|
2222 }
|
|
2223 case ',':
|
|
2224 {
|
|
2225 if (old_backquote_flag)
|
|
2226 {
|
|
2227 Lisp_Object tem, comma_type;
|
|
2228 ch = readchar (readcharfun);
|
|
2229 if (ch == '@')
|
|
2230 comma_type = Qcomma_at;
|
|
2231 else
|
|
2232 {
|
|
2233 if (ch >= 0)
|
|
2234 unreadchar (readcharfun, ch);
|
|
2235 comma_type = Qcomma;
|
|
2236 }
|
|
2237 tem = read0 (readcharfun);
|
|
2238 ch = reader_nextchar (readcharfun);
|
|
2239 if (ch != ')')
|
|
2240 {
|
|
2241 unreadchar (readcharfun, ch);
|
|
2242 return Fsignal (Qinvalid_read_syntax,
|
771
|
2243 list1 (build_msg_string
|
428
|
2244 ("Weird old-backquote syntax")));
|
|
2245 }
|
|
2246 return list2 (comma_type, tem);
|
|
2247 }
|
|
2248 else
|
|
2249 {
|
|
2250 unreadchar (readcharfun, ch);
|
|
2251 #if 0
|
|
2252 return Fsignal (Qinvalid_read_syntax,
|
771
|
2253 list1 (build_msg_string ("Comma outside of backquote")));
|
428
|
2254 #else
|
|
2255 /* #### - yuck....but this is reverse compatible. */
|
|
2256 /* mostly this is required by edebug, which does its own
|
|
2257 annotated reading. We need to have an annotated_read
|
|
2258 function that records (with markers) the buffer
|
|
2259 positions of the elements that make up lists, then that
|
|
2260 can be used in edebug and bytecomp and the check above
|
|
2261 can go back in. --Stig */
|
|
2262 break;
|
|
2263 #endif
|
|
2264 }
|
|
2265 }
|
|
2266 default:
|
|
2267 unreadchar (readcharfun, ch);
|
|
2268 } /* switch(ch) */
|
|
2269 #endif /* old backquote crap... */
|
|
2270 return read_list (readcharfun, ')', 1, 1);
|
|
2271 }
|
|
2272 case '[':
|
|
2273 return read_vector (readcharfun, ']');
|
|
2274
|
|
2275 case ')':
|
|
2276 case ']':
|
|
2277 /* #### - huh? these don't do what they seem... */
|
|
2278 return noseeum_cons (Qunbound, make_char (c));
|
|
2279 case '.':
|
|
2280 {
|
|
2281 /* If a period is followed by a number, then we should read it
|
|
2282 as a floating point number. Otherwise, it denotes a dotted
|
|
2283 pair.
|
|
2284 */
|
|
2285 c = readchar (readcharfun);
|
|
2286 unreadchar (readcharfun, c);
|
|
2287
|
867
|
2288 /* Can't use isdigit on Ichars */
|
428
|
2289 if (c < '0' || c > '9')
|
|
2290 return noseeum_cons (Qunbound, make_char ('.'));
|
|
2291
|
|
2292 /* Note that read_atom will loop
|
|
2293 at least once, assuring that we will not try to UNREAD
|
|
2294 two characters in a row.
|
|
2295 (I think this doesn't matter anymore because there should
|
|
2296 be no more danger in unreading multiple characters) */
|
|
2297 return read_atom (readcharfun, '.', 0);
|
|
2298 }
|
|
2299
|
|
2300 case '#':
|
|
2301 {
|
|
2302 c = readchar (readcharfun);
|
|
2303 switch (c)
|
|
2304 {
|
|
2305 #if 0 /* FSFmacs silly char-table syntax */
|
|
2306 case '^':
|
|
2307 #endif
|
|
2308 #if 0 /* FSFmacs silly bool-vector syntax */
|
|
2309 case '&':
|
|
2310 #endif
|
|
2311 /* "#["-- byte-code constant syntax */
|
|
2312 /* purecons #[...] syntax */
|
|
2313 case '[': return read_compiled_function (readcharfun, ']'
|
|
2314 /*, purify_flag */ );
|
|
2315 /* "#:"-- gensym syntax */
|
|
2316 case ':': return read_atom (readcharfun, -1, 1);
|
|
2317 /* #'x => (function x) */
|
|
2318 case '\'': return list2 (Qfunction, read0 (readcharfun));
|
|
2319 #if 0
|
|
2320 /* RMS uses this syntax for fat-strings.
|
|
2321 If we use it for vectors, then obscure bugs happen.
|
|
2322 */
|
|
2323 /* "#(" -- Scheme/CL vector syntax */
|
|
2324 case '(': return read_vector (readcharfun, ')');
|
|
2325 #endif
|
|
2326 #if 0 /* FSFmacs */
|
|
2327 case '(':
|
|
2328 {
|
|
2329 Lisp_Object tmp;
|
|
2330 struct gcpro gcpro1;
|
|
2331
|
|
2332 /* Read the string itself. */
|
|
2333 tmp = read1 (readcharfun);
|
|
2334 if (!STRINGP (tmp))
|
|
2335 {
|
|
2336 if (CONSP (tmp) && UNBOUNDP (XCAR (tmp)))
|
853
|
2337 free_cons (tmp);
|
428
|
2338 return Fsignal (Qinvalid_read_syntax,
|
|
2339 list1 (build_string ("#")));
|
|
2340 }
|
|
2341 GCPRO1 (tmp);
|
|
2342 /* Read the intervals and their properties. */
|
|
2343 while (1)
|
|
2344 {
|
|
2345 Lisp_Object beg, end, plist;
|
867
|
2346 Ichar ch;
|
428
|
2347 int invalid = 0;
|
|
2348
|
|
2349 beg = read1 (readcharfun);
|
|
2350 if (CONSP (beg) && UNBOUNDP (XCAR (beg)))
|
|
2351 {
|
|
2352 ch = XCHAR (XCDR (beg));
|
853
|
2353 free_cons (beg);
|
428
|
2354 if (ch == ')')
|
|
2355 break;
|
|
2356 else
|
|
2357 invalid = 1;
|
|
2358 }
|
|
2359 if (!invalid)
|
|
2360 {
|
|
2361 end = read1 (readcharfun);
|
|
2362 if (CONSP (end) && UNBOUNDP (XCAR (end)))
|
|
2363 {
|
853
|
2364 free_cons (end);
|
428
|
2365 invalid = 1;
|
|
2366 }
|
|
2367 }
|
|
2368 if (!invalid)
|
|
2369 {
|
|
2370 plist = read1 (readcharfun);
|
|
2371 if (CONSP (plist) && UNBOUNDP (XCAR (plist)))
|
|
2372 {
|
853
|
2373 free_cons (plist);
|
428
|
2374 invalid = 1;
|
|
2375 }
|
|
2376 }
|
|
2377 if (invalid)
|
|
2378 RETURN_UNGCPRO
|
|
2379 (Fsignal (Qinvalid_read_syntax,
|
|
2380 list2
|
771
|
2381 (build_msg_string ("invalid string property list"),
|
428
|
2382 XCDR (plist))));
|
|
2383 Fset_text_properties (beg, end, plist, tmp);
|
|
2384 }
|
|
2385 UNGCPRO;
|
|
2386 return tmp;
|
|
2387 }
|
|
2388 #endif /* 0 */
|
|
2389 case '@':
|
|
2390 {
|
|
2391 /* #@NUMBER is used to skip NUMBER following characters.
|
|
2392 That's used in .elc files to skip over doc strings
|
|
2393 and function definitions. */
|
|
2394 int i, nskip = 0;
|
|
2395
|
|
2396 /* Read a decimal integer. */
|
|
2397 while ((c = readchar (readcharfun)) >= 0
|
|
2398 && c >= '0' && c <= '9')
|
|
2399 nskip = (10 * nskip) + (c - '0');
|
|
2400 if (c >= 0)
|
|
2401 unreadchar (readcharfun, c);
|
|
2402
|
|
2403 /* FSF has code here that maybe caches the skipped
|
|
2404 string. See above for why this is totally
|
|
2405 losing. We handle this differently. */
|
|
2406
|
|
2407 /* Skip that many characters. */
|
|
2408 for (i = 0; i < nskip && c >= 0; i++)
|
|
2409 c = readchar (readcharfun);
|
|
2410
|
|
2411 goto retry;
|
|
2412 }
|
|
2413 case '$': return Vload_file_name_internal;
|
|
2414 /* bit vectors */
|
|
2415 case '*': return read_bit_vector (readcharfun);
|
|
2416 /* #o10 => 8 -- octal constant syntax */
|
|
2417 case 'o': return read_integer (readcharfun, 8);
|
|
2418 /* #xdead => 57005 -- hex constant syntax */
|
|
2419 case 'x': return read_integer (readcharfun, 16);
|
|
2420 /* #b010 => 2 -- binary constant syntax */
|
|
2421 case 'b': return read_integer (readcharfun, 2);
|
|
2422 /* #s(foobar key1 val1 key2 val2) -- structure syntax */
|
|
2423 case 's': return read_structure (readcharfun);
|
|
2424 case '<':
|
|
2425 {
|
|
2426 unreadchar (readcharfun, c);
|
|
2427 return Fsignal (Qinvalid_read_syntax,
|
771
|
2428 list1 (build_msg_string ("Cannot read unreadable object")));
|
428
|
2429 }
|
|
2430 #ifdef FEATUREP_SYNTAX
|
|
2431 case '+':
|
|
2432 case '-':
|
|
2433 {
|
456
|
2434 Lisp_Object feature_exp, obj, tem;
|
428
|
2435 struct gcpro gcpro1, gcpro2;
|
|
2436
|
456
|
2437 feature_exp = read0(readcharfun);
|
428
|
2438 obj = read0(readcharfun);
|
|
2439
|
|
2440 /* the call to `featurep' may GC. */
|
456
|
2441 GCPRO2 (feature_exp, obj);
|
|
2442 tem = call1 (Qfeaturep, feature_exp);
|
428
|
2443 UNGCPRO;
|
|
2444
|
|
2445 if (c == '+' && NILP(tem)) goto retry;
|
|
2446 if (c == '-' && !NILP(tem)) goto retry;
|
|
2447 return obj;
|
|
2448 }
|
|
2449 #endif
|
|
2450 case '0': case '1': case '2': case '3': case '4':
|
|
2451 case '5': case '6': case '7': case '8': case '9':
|
|
2452 /* Reader forms that can reuse previously read objects. */
|
|
2453 {
|
|
2454 int n = 0;
|
|
2455 Lisp_Object found;
|
|
2456
|
|
2457 /* Using read_integer() here is impossible, because it
|
|
2458 chokes on `='. Using parse_integer() is too hard.
|
|
2459 So we simply read it in, and ignore overflows, which
|
|
2460 is safe. */
|
|
2461 while (c >= '0' && c <= '9')
|
|
2462 {
|
|
2463 n *= 10;
|
|
2464 n += c - '0';
|
|
2465 c = readchar (readcharfun);
|
|
2466 }
|
|
2467 found = assq_no_quit (make_int (n), Vread_objects);
|
|
2468 if (c == '=')
|
|
2469 {
|
|
2470 /* #n=object returns object, but associates it with
|
|
2471 n for #n#. */
|
|
2472 Lisp_Object obj;
|
|
2473 if (CONSP (found))
|
|
2474 return Fsignal (Qinvalid_read_syntax,
|
771
|
2475 list2 (build_msg_string
|
428
|
2476 ("Multiply defined symbol label"),
|
|
2477 make_int (n)));
|
|
2478 obj = read0 (readcharfun);
|
|
2479 Vread_objects = Fcons (Fcons (make_int (n), obj),
|
|
2480 Vread_objects);
|
|
2481 return obj;
|
|
2482 }
|
|
2483 else if (c == '#')
|
|
2484 {
|
|
2485 /* #n# returns a previously read object. */
|
|
2486 if (CONSP (found))
|
|
2487 return XCDR (found);
|
|
2488 else
|
|
2489 return Fsignal (Qinvalid_read_syntax,
|
771
|
2490 list2 (build_msg_string
|
428
|
2491 ("Undefined symbol label"),
|
|
2492 make_int (n)));
|
|
2493 }
|
|
2494 return Fsignal (Qinvalid_read_syntax,
|
|
2495 list1 (build_string ("#")));
|
|
2496 }
|
|
2497 default:
|
|
2498 {
|
|
2499 unreadchar (readcharfun, c);
|
|
2500 return Fsignal (Qinvalid_read_syntax,
|
|
2501 list1 (build_string ("#")));
|
|
2502 }
|
|
2503 }
|
|
2504 }
|
|
2505
|
|
2506 /* Quote */
|
|
2507 case '\'': return list2 (Qquote, read0 (readcharfun));
|
|
2508
|
|
2509 #ifdef LISP_BACKQUOTES
|
|
2510 case '`':
|
|
2511 {
|
|
2512 Lisp_Object tem;
|
853
|
2513 int speccount = internal_bind_int (&new_backquote_flag,
|
|
2514 1 + new_backquote_flag);
|
428
|
2515 tem = read0 (readcharfun);
|
771
|
2516 unbind_to (speccount);
|
428
|
2517 return list2 (Qbackquote, tem);
|
|
2518 }
|
|
2519
|
|
2520 case ',':
|
|
2521 {
|
|
2522 if (new_backquote_flag)
|
|
2523 {
|
|
2524 Lisp_Object comma_type = Qnil;
|
|
2525 int ch = readchar (readcharfun);
|
|
2526
|
|
2527 if (ch == '@')
|
|
2528 comma_type = Qcomma_at;
|
|
2529 else if (ch == '.')
|
|
2530 comma_type = Qcomma_dot;
|
|
2531 else
|
|
2532 {
|
|
2533 if (ch >= 0)
|
|
2534 unreadchar (readcharfun, ch);
|
|
2535 comma_type = Qcomma;
|
|
2536 }
|
|
2537 return list2 (comma_type, read0 (readcharfun));
|
|
2538 }
|
|
2539 else
|
|
2540 {
|
|
2541 /* YUCK. 99.999% backwards compatibility. The Right
|
|
2542 Thing(tm) is to signal an error here, because it's
|
|
2543 really invalid read syntax. Instead, this permits
|
|
2544 commas to begin symbols (unless they're inside
|
|
2545 backquotes). If an error is signalled here in the
|
|
2546 future, then commas should be invalid read syntax
|
|
2547 outside of backquotes anywhere they're found (i.e.
|
|
2548 they must be quoted in symbols) -- Stig */
|
|
2549 return read_atom (readcharfun, c, 0);
|
|
2550 }
|
|
2551 }
|
|
2552 #endif
|
|
2553
|
|
2554 case '?':
|
|
2555 {
|
|
2556 /* Evil GNU Emacs "character" (ie integer) syntax */
|
|
2557 c = readchar (readcharfun);
|
|
2558 if (c < 0)
|
|
2559 return Fsignal (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun)));
|
|
2560
|
|
2561 if (c == '\\')
|
|
2562 c = read_escape (readcharfun);
|
|
2563 return make_char (c);
|
|
2564 }
|
|
2565
|
|
2566 case '\"':
|
|
2567 {
|
|
2568 /* String */
|
|
2569 #ifdef I18N3
|
|
2570 /* #### If the input stream is translating, then the string
|
|
2571 should be marked as translatable by setting its
|
|
2572 `string-translatable' property to t. .el and .elc files
|
|
2573 normally are translating input streams. See Fgettext()
|
|
2574 and print_internal(). */
|
|
2575 #endif
|
|
2576 int cancel = 0;
|
|
2577
|
|
2578 Lstream_rewind (XLSTREAM (Vread_buffer_stream));
|
|
2579 while ((c = readchar (readcharfun)) >= 0
|
|
2580 && c != '\"')
|
|
2581 {
|
|
2582 if (c == '\\')
|
|
2583 c = read_escape (readcharfun);
|
|
2584 /* c is -1 if \ newline has just been seen */
|
|
2585 if (c == -1)
|
|
2586 {
|
|
2587 if (Lstream_byte_count (XLSTREAM (Vread_buffer_stream)) == 0)
|
|
2588 cancel = 1;
|
|
2589 }
|
|
2590 else
|
867
|
2591 Lstream_put_ichar (XLSTREAM (Vread_buffer_stream), c);
|
428
|
2592 QUIT;
|
|
2593 }
|
|
2594 if (c < 0)
|
|
2595 return Fsignal (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun)));
|
|
2596
|
|
2597 /* If purifying, and string starts with \ newline,
|
|
2598 return zero instead. This is for doc strings
|
|
2599 that we are really going to find in lib-src/DOC.nn.nn */
|
|
2600 if (purify_flag && NILP (Vinternal_doc_file_name) && cancel)
|
|
2601 return Qzero;
|
|
2602
|
|
2603 Lstream_flush (XLSTREAM (Vread_buffer_stream));
|
|
2604 return
|
|
2605 make_string
|
|
2606 (resizing_buffer_stream_ptr (XLSTREAM (Vread_buffer_stream)),
|
|
2607 Lstream_byte_count (XLSTREAM (Vread_buffer_stream)));
|
|
2608 }
|
|
2609
|
|
2610 default:
|
|
2611 {
|
|
2612 /* Ignore whitespace and control characters */
|
|
2613 if (c <= 040)
|
|
2614 goto retry;
|
|
2615 return read_atom (readcharfun, c, 0);
|
|
2616 }
|
|
2617 }
|
|
2618 }
|
|
2619
|
|
2620
|
|
2621
|
|
2622 #define LEAD_INT 1
|
|
2623 #define DOT_CHAR 2
|
|
2624 #define TRAIL_INT 4
|
|
2625 #define E_CHAR 8
|
|
2626 #define EXP_INT 16
|
|
2627
|
|
2628 int
|
442
|
2629 isfloat_string (const char *cp)
|
428
|
2630 {
|
|
2631 int state = 0;
|
867
|
2632 const Ibyte *ucp = (const Ibyte *) cp;
|
428
|
2633
|
|
2634 if (*ucp == '+' || *ucp == '-')
|
|
2635 ucp++;
|
|
2636
|
|
2637 if (*ucp >= '0' && *ucp <= '9')
|
|
2638 {
|
|
2639 state |= LEAD_INT;
|
|
2640 while (*ucp >= '0' && *ucp <= '9')
|
|
2641 ucp++;
|
|
2642 }
|
|
2643 if (*ucp == '.')
|
|
2644 {
|
|
2645 state |= DOT_CHAR;
|
|
2646 ucp++;
|
|
2647 }
|
|
2648 if (*ucp >= '0' && *ucp <= '9')
|
|
2649 {
|
|
2650 state |= TRAIL_INT;
|
|
2651 while (*ucp >= '0' && *ucp <= '9')
|
|
2652 ucp++;
|
|
2653 }
|
|
2654 if (*ucp == 'e' || *ucp == 'E')
|
|
2655 {
|
|
2656 state |= E_CHAR;
|
|
2657 ucp++;
|
|
2658 if ((*ucp == '+') || (*ucp == '-'))
|
|
2659 ucp++;
|
|
2660 }
|
|
2661
|
|
2662 if (*ucp >= '0' && *ucp <= '9')
|
|
2663 {
|
|
2664 state |= EXP_INT;
|
|
2665 while (*ucp >= '0' && *ucp <= '9')
|
|
2666 ucp++;
|
|
2667 }
|
|
2668 return (((*ucp == 0) || (*ucp == ' ') || (*ucp == '\t') || (*ucp == '\n')
|
|
2669 || (*ucp == '\r') || (*ucp == '\f'))
|
|
2670 && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT)
|
|
2671 || state == (DOT_CHAR|TRAIL_INT)
|
|
2672 || state == (LEAD_INT|E_CHAR|EXP_INT)
|
|
2673 || state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)
|
|
2674 || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)));
|
|
2675 }
|
1983
|
2676
|
|
2677 #ifdef HAVE_RATIO
|
|
2678 int
|
|
2679 isratio_string (const char *cp)
|
|
2680 {
|
2010
|
2681 /* Possible minus/plus sign */
|
|
2682 if (*cp == '-' || *cp == '+')
|
1983
|
2683 cp++;
|
|
2684
|
|
2685 /* Numerator */
|
|
2686 if (*cp < '0' || *cp > '9')
|
|
2687 return 0;
|
|
2688
|
|
2689 do {
|
|
2690 cp++;
|
|
2691 } while (*cp >= '0' && *cp <= '9');
|
|
2692
|
|
2693 /* Slash */
|
|
2694 if (*cp++ != '/')
|
|
2695 return 0;
|
|
2696
|
|
2697 /* Denominator */
|
|
2698 if (*cp < '0' || *cp > '9')
|
|
2699 return 0;
|
|
2700
|
|
2701 do {
|
|
2702 cp++;
|
|
2703 } while (*cp >= '0' && *cp <= '9');
|
|
2704
|
|
2705 return *cp == '\0' || *cp == ' ' || *cp =='\t' || *cp == '\n' ||
|
|
2706 *cp == '\r' || *cp == '\f';
|
|
2707 }
|
|
2708 #endif
|
428
|
2709
|
|
2710 static void *
|
|
2711 sequence_reader (Lisp_Object readcharfun,
|
867
|
2712 Ichar terminator,
|
428
|
2713 void *state,
|
|
2714 void * (*conser) (Lisp_Object readcharfun,
|
|
2715 void *state, Charcount len))
|
|
2716 {
|
|
2717 Charcount len;
|
|
2718
|
|
2719 for (len = 0; ; len++)
|
|
2720 {
|
867
|
2721 Ichar ch;
|
428
|
2722
|
|
2723 QUIT;
|
|
2724 ch = reader_nextchar (readcharfun);
|
|
2725
|
|
2726 if (ch == terminator)
|
|
2727 return state;
|
|
2728 else
|
|
2729 unreadchar (readcharfun, ch);
|
|
2730 #ifdef FEATUREP_SYNTAX
|
|
2731 if (ch == ']')
|
442
|
2732 read_syntax_error ("\"]\" in a list");
|
428
|
2733 else if (ch == ')')
|
442
|
2734 read_syntax_error ("\")\" in a vector");
|
428
|
2735 #endif
|
|
2736 state = ((conser) (readcharfun, state, len));
|
|
2737 }
|
|
2738 }
|
|
2739
|
|
2740
|
|
2741 struct read_list_state
|
|
2742 {
|
|
2743 Lisp_Object head;
|
|
2744 Lisp_Object tail;
|
|
2745 int length;
|
|
2746 int allow_dotted_lists;
|
867
|
2747 Ichar terminator;
|
428
|
2748 };
|
|
2749
|
|
2750 static void *
|
|
2751 read_list_conser (Lisp_Object readcharfun, void *state, Charcount len)
|
|
2752 {
|
|
2753 struct read_list_state *s = (struct read_list_state *) state;
|
|
2754 Lisp_Object elt;
|
|
2755
|
|
2756 elt = read1 (readcharfun);
|
|
2757
|
|
2758 if (CONSP (elt) && UNBOUNDP (XCAR (elt)))
|
|
2759 {
|
|
2760 Lisp_Object tem = elt;
|
867
|
2761 Ichar ch;
|
428
|
2762
|
|
2763 elt = XCDR (elt);
|
853
|
2764 free_cons (tem);
|
428
|
2765 tem = Qnil;
|
|
2766 ch = XCHAR (elt);
|
|
2767 #ifdef FEATUREP_SYNTAX
|
|
2768 if (ch == s->terminator) /* deal with #+, #- reader macros */
|
|
2769 {
|
|
2770 unreadchar (readcharfun, s->terminator);
|
|
2771 goto done;
|
|
2772 }
|
|
2773 else if (ch == ']')
|
442
|
2774 read_syntax_error ("']' in a list");
|
428
|
2775 else if (ch == ')')
|
442
|
2776 read_syntax_error ("')' in a vector");
|
428
|
2777 else
|
|
2778 #endif
|
|
2779 if (ch != '.')
|
563
|
2780 signal_error (Qinternal_error, "BUG! Internal reader error", elt);
|
428
|
2781 else if (!s->allow_dotted_lists)
|
442
|
2782 read_syntax_error ("\".\" in a vector");
|
428
|
2783 else
|
|
2784 {
|
|
2785 if (!NILP (s->tail))
|
|
2786 XCDR (s->tail) = read0 (readcharfun);
|
|
2787 else
|
|
2788 s->head = read0 (readcharfun);
|
|
2789 elt = read1 (readcharfun);
|
|
2790 if (CONSP (elt) && UNBOUNDP (XCAR (elt)))
|
|
2791 {
|
|
2792 ch = XCHAR (XCDR (elt));
|
853
|
2793 free_cons (elt);
|
428
|
2794 if (ch == s->terminator)
|
|
2795 {
|
|
2796 unreadchar (readcharfun, s->terminator);
|
|
2797 goto done;
|
|
2798 }
|
|
2799 }
|
442
|
2800 read_syntax_error (". in wrong context");
|
428
|
2801 }
|
|
2802 }
|
|
2803
|
|
2804 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
2805 if (s->length == 1 && s->allow_dotted_lists && EQ (XCAR (s->head), Qfset))
|
|
2806 {
|
|
2807 if (CONSP (elt) && EQ (XCAR (elt), Qquote) && CONSP (XCDR (elt)))
|
|
2808 Vcurrent_compiled_function_annotation = XCAR (XCDR (elt));
|
|
2809 else
|
|
2810 Vcurrent_compiled_function_annotation = elt;
|
|
2811 }
|
|
2812 #endif
|
|
2813
|
|
2814 elt = Fcons (elt, Qnil);
|
|
2815 if (!NILP (s->tail))
|
|
2816 XCDR (s->tail) = elt;
|
|
2817 else
|
|
2818 s->head = elt;
|
|
2819 s->tail = elt;
|
|
2820 done:
|
|
2821 s->length++;
|
|
2822 return s;
|
|
2823 }
|
|
2824
|
|
2825
|
814
|
2826 /* allow_dotted_lists means that something like (foo bar . baz)
|
|
2827 is acceptable. If -1, means check for starting with defun
|
|
2828 and make structure pure. (not implemented, probably for very
|
|
2829 good reasons)
|
|
2830
|
|
2831 If check_for_doc_references, look for (#$ . INT) doc references
|
|
2832 in the list and record if load_force_doc_strings is non-zero.
|
|
2833 (Such doc references will be destroyed during the loadup phase
|
|
2834 by replacing with Qzero, because Snarf-documentation will fill
|
|
2835 them in again.)
|
|
2836
|
|
2837 WARNING: If you set this, you sure as hell better not call
|
|
2838 free_list() on the returned list here.
|
|
2839 */
|
428
|
2840
|
|
2841 static Lisp_Object
|
|
2842 read_list (Lisp_Object readcharfun,
|
867
|
2843 Ichar terminator,
|
428
|
2844 int allow_dotted_lists,
|
|
2845 int check_for_doc_references)
|
|
2846 {
|
|
2847 struct read_list_state s;
|
|
2848 struct gcpro gcpro1, gcpro2;
|
|
2849 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
2850 Lisp_Object old_compiled_function_annotation =
|
|
2851 Vcurrent_compiled_function_annotation;
|
|
2852 #endif
|
|
2853
|
|
2854 s.head = Qnil;
|
|
2855 s.tail = Qnil;
|
|
2856 s.length = 0;
|
|
2857 s.allow_dotted_lists = allow_dotted_lists;
|
|
2858 s.terminator = terminator;
|
|
2859 GCPRO2 (s.head, s.tail);
|
|
2860
|
|
2861 sequence_reader (readcharfun, terminator, &s, read_list_conser);
|
|
2862 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
2863 Vcurrent_compiled_function_annotation = old_compiled_function_annotation;
|
|
2864 #endif
|
|
2865
|
|
2866 if ((purify_flag || load_force_doc_strings) && check_for_doc_references)
|
|
2867 {
|
|
2868 /* check now for any doc string references and record them
|
|
2869 for later. */
|
|
2870 Lisp_Object tail;
|
|
2871
|
|
2872 /* We might be dealing with an imperfect list so don't
|
|
2873 use LIST_LOOP */
|
|
2874 for (tail = s.head; CONSP (tail); tail = XCDR (tail))
|
|
2875 {
|
|
2876 Lisp_Object holding_cons = Qnil;
|
|
2877
|
|
2878 {
|
|
2879 Lisp_Object elem = XCAR (tail);
|
|
2880 /* elem might be (#$ . INT) ... */
|
|
2881 if (CONSP (elem) && EQ (XCAR (elem), Vload_file_name_internal))
|
|
2882 holding_cons = tail;
|
|
2883 /* or it might be (quote (#$ . INT)) i.e.
|
|
2884 (quote . ((#$ . INT) . nil)) in the case of
|
|
2885 `autoload' (autoload evaluates its arguments, while
|
|
2886 `defvar', `defun', etc. don't). */
|
|
2887 if (CONSP (elem) && EQ (XCAR (elem), Qquote)
|
|
2888 && CONSP (XCDR (elem)))
|
|
2889 {
|
|
2890 elem = XCAR (XCDR (elem));
|
|
2891 if (CONSP (elem) && EQ (XCAR (elem), Vload_file_name_internal))
|
|
2892 holding_cons = XCDR (XCAR (tail));
|
|
2893 }
|
|
2894 }
|
|
2895
|
|
2896 if (CONSP (holding_cons))
|
|
2897 {
|
|
2898 if (purify_flag)
|
|
2899 {
|
|
2900 if (NILP (Vinternal_doc_file_name))
|
|
2901 /* We have not yet called Snarf-documentation, so
|
|
2902 assume this file is described in the DOC file
|
|
2903 and Snarf-documentation will fill in the right
|
|
2904 value later. For now, replace the whole list
|
|
2905 with 0. */
|
|
2906 XCAR (holding_cons) = Qzero;
|
|
2907 else
|
|
2908 /* We have already called Snarf-documentation, so
|
|
2909 make a relative file name for this file, so it
|
|
2910 can be found properly in the installed Lisp
|
|
2911 directory. We don't use Fexpand_file_name
|
|
2912 because that would make the directory absolute
|
|
2913 now. */
|
|
2914 XCAR (XCAR (holding_cons)) =
|
|
2915 concat2 (build_string ("../lisp/"),
|
|
2916 Ffile_name_nondirectory
|
|
2917 (Vload_file_name_internal));
|
|
2918 }
|
|
2919 else
|
|
2920 /* Not pure. Just add to Vload_force_doc_string_list,
|
|
2921 and the string will be filled in properly in
|
|
2922 load_force_doc_string_unwind(). */
|
|
2923 Vload_force_doc_string_list =
|
|
2924 /* We pass the cons that holds the (#$ . INT) so we
|
|
2925 can modify it in-place. */
|
|
2926 Fcons (holding_cons, Vload_force_doc_string_list);
|
|
2927 }
|
|
2928 }
|
|
2929 }
|
|
2930
|
|
2931 UNGCPRO;
|
|
2932 return s.head;
|
|
2933 }
|
|
2934
|
|
2935 static Lisp_Object
|
|
2936 read_vector (Lisp_Object readcharfun,
|
867
|
2937 Ichar terminator)
|
428
|
2938 {
|
|
2939 Lisp_Object tem;
|
|
2940 Lisp_Object *p;
|
|
2941 int len;
|
|
2942 int i;
|
|
2943 struct read_list_state s;
|
|
2944 struct gcpro gcpro1, gcpro2;
|
|
2945
|
|
2946 s.head = Qnil;
|
|
2947 s.tail = Qnil;
|
|
2948 s.length = 0;
|
|
2949 s.allow_dotted_lists = 0;
|
|
2950 GCPRO2 (s.head, s.tail);
|
|
2951
|
|
2952 sequence_reader (readcharfun, terminator, &s, read_list_conser);
|
|
2953
|
|
2954 UNGCPRO;
|
|
2955 tem = s.head;
|
|
2956 len = XINT (Flength (tem));
|
|
2957
|
814
|
2958 s.head = make_vector (len, Qnil);
|
428
|
2959
|
|
2960 for (i = 0, p = &(XVECTOR_DATA (s.head)[0]);
|
|
2961 i < len;
|
|
2962 i++, p++)
|
|
2963 {
|
853
|
2964 Lisp_Object otem = tem;
|
428
|
2965 tem = Fcar (tem);
|
|
2966 *p = tem;
|
853
|
2967 tem = XCDR (otem);
|
428
|
2968 free_cons (otem);
|
|
2969 }
|
|
2970 return s.head;
|
|
2971 }
|
|
2972
|
|
2973 static Lisp_Object
|
867
|
2974 read_compiled_function (Lisp_Object readcharfun, Ichar terminator)
|
428
|
2975 {
|
|
2976 /* Accept compiled functions at read-time so that we don't
|
|
2977 have to build them at load-time. */
|
|
2978 Lisp_Object stuff;
|
|
2979 Lisp_Object make_byte_code_args[COMPILED_DOMAIN + 1];
|
|
2980 struct gcpro gcpro1;
|
|
2981 int len;
|
|
2982 int iii;
|
|
2983 int saw_a_doc_ref = 0;
|
|
2984
|
|
2985 /* Note: we tell read_list not to search for doc references
|
|
2986 because we need to handle the "doc reference" for the
|
|
2987 instructions and constants differently. */
|
|
2988 stuff = read_list (readcharfun, terminator, 0, 0);
|
|
2989 len = XINT (Flength (stuff));
|
|
2990 if (len < COMPILED_STACK_DEPTH + 1 || len > COMPILED_DOMAIN + 1)
|
|
2991 return
|
442
|
2992 continuable_read_syntax_error ("#[...] used with wrong number of elements");
|
428
|
2993
|
|
2994 for (iii = 0; CONSP (stuff); iii++)
|
|
2995 {
|
853
|
2996 Lisp_Object victim = stuff;
|
428
|
2997 make_byte_code_args[iii] = Fcar (stuff);
|
|
2998 if ((purify_flag || load_force_doc_strings)
|
|
2999 && CONSP (make_byte_code_args[iii])
|
|
3000 && EQ (XCAR (make_byte_code_args[iii]), Vload_file_name_internal))
|
|
3001 {
|
|
3002 if (purify_flag && iii == COMPILED_DOC_STRING)
|
|
3003 {
|
|
3004 /* same as in read_list(). */
|
|
3005 if (NILP (Vinternal_doc_file_name))
|
|
3006 make_byte_code_args[iii] = Qzero;
|
|
3007 else
|
|
3008 XCAR (make_byte_code_args[iii]) =
|
|
3009 concat2 (build_string ("../lisp/"),
|
|
3010 Ffile_name_nondirectory
|
|
3011 (Vload_file_name_internal));
|
|
3012 }
|
|
3013 else
|
|
3014 saw_a_doc_ref = 1;
|
|
3015 }
|
|
3016 stuff = Fcdr (stuff);
|
|
3017 free_cons (victim);
|
|
3018 }
|
|
3019 GCPRO1 (make_byte_code_args[0]);
|
|
3020 gcpro1.nvars = len;
|
|
3021
|
|
3022 /* v18 or v19 bytecode file. Need to Ebolify. */
|
|
3023 if (load_byte_code_version < 20 && VECTORP (make_byte_code_args[2]))
|
|
3024 ebolify_bytecode_constants (make_byte_code_args[2]);
|
|
3025
|
|
3026 /* make-byte-code looks at purify_flag, which should have the same
|
|
3027 * value as our "read-pure" argument */
|
|
3028 stuff = Fmake_byte_code (len, make_byte_code_args);
|
|
3029 XCOMPILED_FUNCTION (stuff)->flags.ebolified = (load_byte_code_version < 20);
|
|
3030 if (saw_a_doc_ref)
|
|
3031 Vload_force_doc_string_list = Fcons (stuff, Vload_force_doc_string_list);
|
|
3032 UNGCPRO;
|
|
3033 return stuff;
|
|
3034 }
|
|
3035
|
|
3036
|
|
3037
|
|
3038 void
|
|
3039 init_lread (void)
|
|
3040 {
|
|
3041 Vvalues = Qnil;
|
|
3042
|
|
3043 load_in_progress = 0;
|
|
3044
|
|
3045 Vload_descriptor_list = Qnil;
|
|
3046
|
|
3047 /* kludge: locate-file does not work for a null load-path, even if
|
|
3048 the file name is absolute. */
|
|
3049
|
|
3050 Vload_path = Fcons (build_string (""), Qnil);
|
|
3051
|
|
3052 /* This used to get initialized in init_lread because all streams
|
|
3053 got closed when dumping occurs. This is no longer true --
|
|
3054 Vread_buffer_stream is a resizing output stream, and there is no
|
|
3055 reason to close it at dump-time.
|
|
3056
|
|
3057 Vread_buffer_stream is set to Qnil in vars_of_lread, and this
|
|
3058 will initialize it only once, at dump-time. */
|
|
3059 if (NILP (Vread_buffer_stream))
|
|
3060 Vread_buffer_stream = make_resizing_buffer_output_stream ();
|
|
3061
|
|
3062 Vload_force_doc_string_list = Qnil;
|
|
3063 }
|
|
3064
|
|
3065 void
|
|
3066 syms_of_lread (void)
|
|
3067 {
|
|
3068 DEFSUBR (Fread);
|
|
3069 DEFSUBR (Fread_from_string);
|
|
3070 DEFSUBR (Fload_internal);
|
|
3071 DEFSUBR (Flocate_file);
|
|
3072 DEFSUBR (Flocate_file_clear_hashing);
|
|
3073 DEFSUBR (Feval_buffer);
|
|
3074 DEFSUBR (Feval_region);
|
|
3075
|
563
|
3076 DEFSYMBOL (Qstandard_input);
|
|
3077 DEFSYMBOL (Qread_char);
|
|
3078 DEFSYMBOL (Qcurrent_load_list);
|
|
3079 DEFSYMBOL (Qload);
|
|
3080 DEFSYMBOL (Qload_file_name);
|
1292
|
3081 DEFSYMBOL (Qload_internal);
|
563
|
3082 DEFSYMBOL (Qfset);
|
428
|
3083
|
|
3084 #ifdef LISP_BACKQUOTES
|
563
|
3085 DEFSYMBOL (Qbackquote);
|
428
|
3086 defsymbol (&Qbacktick, "`");
|
|
3087 defsymbol (&Qcomma, ",");
|
|
3088 defsymbol (&Qcomma_at, ",@");
|
|
3089 defsymbol (&Qcomma_dot, ",.");
|
|
3090 #endif
|
|
3091
|
563
|
3092 DEFSYMBOL (Qexists);
|
|
3093 DEFSYMBOL (Qreadable);
|
|
3094 DEFSYMBOL (Qwritable);
|
|
3095 DEFSYMBOL (Qexecutable);
|
428
|
3096 }
|
|
3097
|
|
3098 void
|
|
3099 structure_type_create (void)
|
|
3100 {
|
|
3101 the_structure_type_dynarr = Dynarr_new (structure_type);
|
|
3102 }
|
|
3103
|
|
3104 void
|
|
3105 reinit_vars_of_lread (void)
|
|
3106 {
|
|
3107 Vread_buffer_stream = Qnil;
|
|
3108 staticpro_nodump (&Vread_buffer_stream);
|
|
3109 }
|
|
3110
|
|
3111 void
|
|
3112 vars_of_lread (void)
|
|
3113 {
|
|
3114 reinit_vars_of_lread ();
|
|
3115
|
|
3116 DEFVAR_LISP ("values", &Vvalues /*
|
|
3117 List of values of all expressions which were read, evaluated and printed.
|
|
3118 Order is reverse chronological.
|
|
3119 */ );
|
|
3120
|
|
3121 DEFVAR_LISP ("standard-input", &Vstandard_input /*
|
|
3122 Stream for read to get input from.
|
|
3123 See documentation of `read' for possible values.
|
|
3124 */ );
|
|
3125 Vstandard_input = Qt;
|
|
3126
|
|
3127 DEFVAR_LISP ("load-path", &Vload_path /*
|
|
3128 *List of directories to search for files to load.
|
|
3129 Each element is a string (directory name) or nil (try default directory).
|
|
3130
|
|
3131 Note that the elements of this list *may not* begin with "~", so you must
|
|
3132 call `expand-file-name' on them before adding them to this list.
|
|
3133
|
|
3134 Initialized based on EMACSLOADPATH environment variable, if any,
|
|
3135 otherwise to default specified in by file `paths.h' when XEmacs was built.
|
|
3136 If there were no paths specified in `paths.h', then XEmacs chooses a default
|
|
3137 value for this variable by looking around in the file-system near the
|
|
3138 directory in which the XEmacs executable resides.
|
|
3139 */ );
|
|
3140 Vload_path = Qnil;
|
|
3141
|
|
3142 /* xxxDEFVAR_LISP ("dump-load-path", &Vdump_load_path,
|
|
3143 "*Location of lisp files to be used when dumping ONLY."); */
|
|
3144
|
|
3145 DEFVAR_BOOL ("load-in-progress", &load_in_progress /*
|
|
3146 Non-nil iff inside of `load'.
|
|
3147 */ );
|
|
3148
|
|
3149 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist /*
|
|
3150 An alist of expressions to be evalled when particular files are loaded.
|
|
3151 Each element looks like (FILENAME FORMS...).
|
|
3152 When `load' is run and the file-name argument is FILENAME,
|
|
3153 the FORMS in the corresponding element are executed at the end of loading.
|
|
3154
|
|
3155 FILENAME must match exactly! Normally FILENAME is the name of a library,
|
|
3156 with no directory specified, since that is how `load' is normally called.
|
|
3157 An error in FORMS does not undo the load,
|
|
3158 but does prevent execution of the rest of the FORMS.
|
|
3159 */ );
|
|
3160 Vafter_load_alist = Qnil;
|
|
3161
|
|
3162 DEFVAR_BOOL ("load-warn-when-source-newer", &load_warn_when_source_newer /*
|
|
3163 *Whether `load' should check whether the source is newer than the binary.
|
|
3164 If this variable is true, then when a `.elc' file is being loaded and the
|
|
3165 corresponding `.el' is newer, a warning message will be printed.
|
|
3166 */ );
|
1261
|
3167 load_warn_when_source_newer = 1;
|
428
|
3168
|
|
3169 DEFVAR_BOOL ("load-warn-when-source-only", &load_warn_when_source_only /*
|
|
3170 *Whether `load' should warn when loading a `.el' file instead of an `.elc'.
|
|
3171 If this variable is true, then when `load' is called with a filename without
|
|
3172 an extension, and the `.elc' version doesn't exist but the `.el' version does,
|
|
3173 then a message will be printed. If an explicit extension is passed to `load',
|
|
3174 no warning will be printed.
|
|
3175 */ );
|
|
3176 load_warn_when_source_only = 0;
|
|
3177
|
|
3178 DEFVAR_BOOL ("load-ignore-elc-files", &load_ignore_elc_files /*
|
|
3179 *Whether `load' should ignore `.elc' files when a suffix is not given.
|
|
3180 This is normally used only to bootstrap the `.elc' files when building XEmacs.
|
|
3181 */ );
|
|
3182 load_ignore_elc_files = 0;
|
|
3183
|
1123
|
3184 DEFVAR_BOOL ("load-ignore-out-of-date-elc-files",
|
|
3185 &load_ignore_out_of_date_elc_files /*
|
|
3186 *Whether `load' should ignore out-of-date `.elc' files when no suffix is given.
|
|
3187 This is normally used when compiling packages of elisp files that may have
|
|
3188 complex dependencies. Ignoring all elc files with `load-ignore-elc-files'
|
|
3189 would also be safe, but much slower.
|
|
3190 */ );
|
|
3191 load_ignore_out_of_date_elc_files = 0;
|
|
3192
|
|
3193 DEFVAR_BOOL ("load-always-display-messages",
|
|
3194 &load_always_display_messages /*
|
|
3195 *Whether `load' should always display loading messages.
|
|
3196 If this is true, every file loaded will be shown, regardless of the setting
|
|
3197 of the NOMESSAGE parameter, and even when files are loaded indirectly, e.g.
|
|
3198 due to `requre'.
|
|
3199 */ );
|
|
3200 load_always_display_messages = 0;
|
|
3201
|
|
3202 DEFVAR_BOOL ("load-show-full-path-in-messages",
|
|
3203 &load_show_full_path_in_messages /*
|
|
3204 *Whether `load' should show the full path in all loading messages.
|
|
3205 */ );
|
|
3206 load_show_full_path_in_messages = 0;
|
|
3207
|
428
|
3208 #ifdef LOADHIST
|
|
3209 DEFVAR_LISP ("load-history", &Vload_history /*
|
|
3210 Alist mapping source file names to symbols and features.
|
|
3211 Each alist element is a list that starts with a file name,
|
|
3212 except for one element (optional) that starts with nil and describes
|
|
3213 definitions evaluated from buffers not visiting files.
|
|
3214 The remaining elements of each list are symbols defined as functions
|
|
3215 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.
|
|
3216 */ );
|
|
3217 Vload_history = Qnil;
|
|
3218
|
|
3219 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list /*
|
|
3220 Used for internal purposes by `load'.
|
|
3221 */ );
|
|
3222 Vcurrent_load_list = Qnil;
|
|
3223 #endif
|
|
3224
|
|
3225 DEFVAR_LISP ("load-file-name", &Vload_file_name /*
|
|
3226 Full name of file being loaded by `load'.
|
|
3227 */ );
|
|
3228 Vload_file_name = Qnil;
|
|
3229
|
|
3230 DEFVAR_LISP ("load-read-function", &Vload_read_function /*
|
|
3231 Function used by `load' and `eval-region' for reading expressions.
|
|
3232 The default is nil, which means use the function `read'.
|
|
3233 */ );
|
|
3234 Vload_read_function = Qnil;
|
|
3235
|
|
3236 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings /*
|
|
3237 Non-nil means `load' should force-load all dynamic doc strings.
|
|
3238 This is useful when the file being loaded is a temporary copy.
|
|
3239 */ );
|
|
3240 load_force_doc_strings = 0;
|
|
3241
|
|
3242 /* See read_escape(). */
|
|
3243 #if 0
|
|
3244 /* Used to be named `puke-on-fsf-keys' */
|
|
3245 DEFVAR_BOOL ("fail-on-bucky-bit-character-escapes",
|
|
3246 &fail_on_bucky_bit_character_escapes /*
|
|
3247 Whether `read' should signal an error when it encounters unsupported
|
|
3248 character escape syntaxes or just read them incorrectly.
|
|
3249 */ );
|
|
3250 fail_on_bucky_bit_character_escapes = 0;
|
|
3251 #endif
|
|
3252
|
|
3253 /* This must be initialized in init_lread otherwise it may start out
|
|
3254 with values saved when the image is dumped. */
|
|
3255 staticpro (&Vload_descriptor_list);
|
|
3256
|
|
3257 /* Initialized in init_lread. */
|
|
3258 staticpro (&Vload_force_doc_string_list);
|
|
3259
|
|
3260 Vload_file_name_internal = Qnil;
|
|
3261 staticpro (&Vload_file_name_internal);
|
|
3262
|
|
3263 Vload_file_name_internal_the_purecopy = Qnil;
|
|
3264 staticpro (&Vload_file_name_internal_the_purecopy);
|
|
3265
|
|
3266 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
3267 Vcurrent_compiled_function_annotation = Qnil;
|
|
3268 staticpro (&Vcurrent_compiled_function_annotation);
|
|
3269 #endif
|
|
3270
|
|
3271 /* So that early-early stuff will work */
|
1292
|
3272 Ffset (Qload, Qload_internal);
|
428
|
3273
|
|
3274 #ifdef FEATUREP_SYNTAX
|
563
|
3275 DEFSYMBOL (Qfeaturep);
|
771
|
3276 Fprovide (intern ("xemacs"));
|
428
|
3277 #ifdef INFODOCK
|
771
|
3278 Fprovide (intern ("infodock"));
|
428
|
3279 #endif /* INFODOCK */
|
|
3280 #endif /* FEATUREP_SYNTAX */
|
|
3281
|
|
3282 #ifdef LISP_BACKQUOTES
|
|
3283 old_backquote_flag = new_backquote_flag = 0;
|
|
3284 #endif
|
|
3285
|
|
3286 #ifdef I18N3
|
|
3287 Vfile_domain = Qnil;
|
|
3288 #endif
|
|
3289
|
|
3290 Vread_objects = Qnil;
|
|
3291 staticpro (&Vread_objects);
|
|
3292
|
|
3293 Vlocate_file_hash_table = make_lisp_hash_table (200,
|
|
3294 HASH_TABLE_NON_WEAK,
|
|
3295 HASH_TABLE_EQUAL);
|
|
3296 staticpro (&Vlocate_file_hash_table);
|
|
3297 #ifdef DEBUG_XEMACS
|
|
3298 symbol_value (XSYMBOL (intern ("Vlocate-file-hash-table")))
|
|
3299 = Vlocate_file_hash_table;
|
|
3300 #endif
|
|
3301 }
|