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