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