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