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