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