Mercurial > emacs
annotate src/lread.c @ 28069:bd586b823051
(lisp-font-lock-keywords-1): Highlight
`(defun (setf foo)' differently.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 09 Mar 2000 13:28:42 +0000 |
parents | 98f55bbdbbad |
children | 2e784b17f85a |
rev | line source |
---|---|
341 | 1 /* Lisp parsing and input streams. |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
2 Copyright (C) 1985, 86, 87, 88, 89, 93, 94, 95, 97, 98, 1999 |
18771
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3 Free Software Foundation, Inc. |
341 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
617 | 9 the Free Software Foundation; either version 2, or (at your option) |
341 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14130
diff
changeset
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14130
diff
changeset
|
20 Boston, MA 02111-1307, USA. */ |
341 | 21 |
22 | |
7898 | 23 #include <config.h> |
27763
70a9799a393e
Undef feature selection macros before defining.
Dave Love <fx@gnu.org>
parents:
27727
diff
changeset
|
24 /* The following feature selections should be in config.h, but that |
70a9799a393e
Undef feature selection macros before defining.
Dave Love <fx@gnu.org>
parents:
27727
diff
changeset
|
25 causes at best a host of warnings on some systems. */ |
70a9799a393e
Undef feature selection macros before defining.
Dave Love <fx@gnu.org>
parents:
27727
diff
changeset
|
26 #undef _XOPEN_SOURCE /* Avoid warnings about redefinition |
70a9799a393e
Undef feature selection macros before defining.
Dave Love <fx@gnu.org>
parents:
27727
diff
changeset
|
27 in some cases. */ |
27612
578e78aa0553
(_XOPEN_SOURCE): Declare (for ftello).
Dave Love <fx@gnu.org>
parents:
27364
diff
changeset
|
28 #define _XOPEN_SOURCE 500 /* for Unix 98 ftello on GNU */ |
27763
70a9799a393e
Undef feature selection macros before defining.
Dave Love <fx@gnu.org>
parents:
27727
diff
changeset
|
29 #undef __EXTENSIONS__ |
27645 | 30 #define __EXTENSIONS__ /* Keep Solaris 2.6 happy with the |
31 above, else things we need are hidden. */ | |
341 | 32 #include <stdio.h> |
33 #include <sys/types.h> | |
34 #include <sys/stat.h> | |
35 #include <sys/file.h> | |
8083
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
36 #include <errno.h> |
341 | 37 #include "lisp.h" |
25787
3d1138357287
(readchar): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
38 #include "intervals.h" |
341 | 39 #include "buffer.h" |
17038 | 40 #include "charset.h" |
24412
d11ac02f9d6a
Use epaths.h istead of paths.h.
Richard M. Stallman <rms@gnu.org>
parents:
23933
diff
changeset
|
41 #include <epaths.h> |
341 | 42 #include "commands.h" |
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
43 #include "keyboard.h" |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
44 #include "termhooks.h" |
341 | 45 |
46 #ifdef lint | |
47 #include <sys/inode.h> | |
48 #endif /* lint */ | |
49 | |
14972
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
50 #ifdef MSDOS |
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
51 #if __DJGPP__ < 2 |
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
52 #include <unistd.h> /* to get X_OK */ |
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
53 #endif |
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
54 #include "msdos.h" |
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
55 #endif |
a6889b33d21c
[MSDOS]: If DJGPP version 2, include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
14950
diff
changeset
|
56 |
21799 | 57 #ifdef HAVE_UNISTD_H |
58 #include <unistd.h> | |
59 #endif | |
60 | |
341 | 61 #ifndef X_OK |
62 #define X_OK 01 | |
63 #endif | |
64 | |
65 #include <math.h> | |
66 | |
14950 | 67 #ifdef HAVE_SETLOCALE |
68 #include <locale.h> | |
69 #endif /* HAVE_SETLOCALE */ | |
70 | |
8596 | 71 #ifndef O_RDONLY |
72 #define O_RDONLY 0 | |
73 #endif | |
74 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
75 #ifdef HAVE_FTELLO |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
76 #define file_offset off_t |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
77 #define file_tell ftello |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
78 #else |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
79 #define file_offset long |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
80 #define file_tell ftell |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
81 #endif |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
82 |
8083
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
83 extern int errno; |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
84 |
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
85 Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list; |
341 | 86 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
87 Lisp_Object Qascii_character, Qload, Qload_file_name; |
13235
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
88 Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
89 Lisp_Object Qinhibit_file_name_operation; |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
90 |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
91 extern Lisp_Object Qevent_symbol_element_mask; |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
92 extern Lisp_Object Qfile_exists_p; |
341 | 93 |
94 /* non-zero if inside `load' */ | |
95 int load_in_progress; | |
96 | |
13601
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
97 /* Directory in which the sources were found. */ |
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
98 Lisp_Object Vsource_directory; |
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
99 |
341 | 100 /* Search path for files to be loaded. */ |
101 Lisp_Object Vload_path; | |
102 | |
24817
3e8c8a06329b
(Vuser_init_file): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
24412
diff
changeset
|
103 /* File name of user's init file. */ |
3e8c8a06329b
(Vuser_init_file): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
24412
diff
changeset
|
104 Lisp_Object Vuser_init_file; |
3e8c8a06329b
(Vuser_init_file): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
24412
diff
changeset
|
105 |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
106 /* This is the user-visible association list that maps features to |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
107 lists of defs in their load files. */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
108 Lisp_Object Vload_history; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
109 |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
110 /* This is used to build the load history. */ |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
111 Lisp_Object Vcurrent_load_list; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
112 |
18665
6d7b8b35d878
(Vpreloaded_file_list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18530
diff
changeset
|
113 /* List of files that were preloaded. */ |
6d7b8b35d878
(Vpreloaded_file_list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18530
diff
changeset
|
114 Lisp_Object Vpreloaded_file_list; |
6d7b8b35d878
(Vpreloaded_file_list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18530
diff
changeset
|
115 |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
116 /* Name of file actually being read by `load'. */ |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
117 Lisp_Object Vload_file_name; |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
118 |
11079
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
119 /* Function to use for reading, in `load' and friends. */ |
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
120 Lisp_Object Vload_read_function; |
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
121 |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
122 /* The association list of objects read with the #n=object form. |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
123 Each member of the list has the form (n . object), and is used to |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
124 look up the object for the corresponding #n# construct. |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
125 It must be set to nil before all top-level calls to read0. */ |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
126 Lisp_Object read_objects; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
127 |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
128 /* Nonzero means load should forcibly load all dynamic doc strings. */ |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
129 static int load_force_doc_strings; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
130 |
21677
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
131 /* Nonzero means read should convert strings to unibyte. */ |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
132 static int load_convert_to_unibyte; |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
133 |
17038 | 134 /* Function to use for loading an Emacs lisp source file (not |
135 compiled) instead of readevalloop. */ | |
136 Lisp_Object Vload_source_file_function; | |
137 | |
25555
301ce7f0b398
(Vbyte_boolean_vars): New variable.
Dave Love <fx@gnu.org>
parents:
25251
diff
changeset
|
138 /* List of all DEFVAR_BOOL variables. Used by the byte optimizer. */ |
301ce7f0b398
(Vbyte_boolean_vars): New variable.
Dave Love <fx@gnu.org>
parents:
25251
diff
changeset
|
139 Lisp_Object Vbyte_boolean_vars; |
301ce7f0b398
(Vbyte_boolean_vars): New variable.
Dave Love <fx@gnu.org>
parents:
25251
diff
changeset
|
140 |
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
141 /* List of descriptors now open for Fload. */ |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
142 static Lisp_Object load_descriptor_list; |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
143 |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
144 /* File for get_file_char to read from. Use by load. */ |
341 | 145 static FILE *instream; |
146 | |
147 /* When nonzero, read conses in pure space */ | |
148 static int read_pure; | |
149 | |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
150 /* For use within read-from-string (this reader is non-reentrant!!) */ |
341 | 151 static int read_from_string_index; |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
152 static int read_from_string_index_byte; |
341 | 153 static int read_from_string_limit; |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
154 |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
155 /* Number of bytes left to read in the buffer character |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
156 that `readchar' has already advanced over. */ |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
157 static int readchar_backlog; |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
158 |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
159 /* This contains the last string skipped with #@. */ |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
160 static char *saved_doc_string; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
161 /* Length of buffer allocated in saved_doc_string. */ |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
162 static int saved_doc_string_size; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
163 /* Length of actual data in saved_doc_string. */ |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
164 static int saved_doc_string_length; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
165 /* This is the file position that string came from. */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
166 static file_offset saved_doc_string_position; |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
167 |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
168 /* This contains the previous string skipped with #@. |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
169 We copy it from saved_doc_string when a new string |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
170 is put in saved_doc_string. */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
171 static char *prev_saved_doc_string; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
172 /* Length of buffer allocated in prev_saved_doc_string. */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
173 static int prev_saved_doc_string_size; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
174 /* Length of actual data in prev_saved_doc_string. */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
175 static int prev_saved_doc_string_length; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
176 /* This is the file position that string came from. */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
177 static file_offset prev_saved_doc_string_position; |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
178 |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
179 /* Nonzero means inside a new-style backquote |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
180 with no surrounding parentheses. |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
181 Fread initializes this to zero, so we need not specbind it |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
182 or worry about what happens to it when there is an error. */ |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
183 static int new_backquote_flag; |
341 | 184 |
185 /* Handle unreading and rereading of characters. | |
186 Write READCHAR to read a character, | |
17038 | 187 UNREAD(c) to unread c to be read again. |
188 | |
189 These macros actually read/unread a byte code, multibyte characters | |
190 are not handled here. The caller should manage them if necessary. | |
191 */ | |
341 | 192 |
193 #define READCHAR readchar (readcharfun) | |
194 #define UNREAD(c) unreadchar (readcharfun, c) | |
195 | |
196 static int | |
197 readchar (readcharfun) | |
198 Lisp_Object readcharfun; | |
199 { | |
200 Lisp_Object tem; | |
25787
3d1138357287
(readchar): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
201 register int c; |
341 | 202 |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
203 if (BUFFERP (readcharfun)) |
341 | 204 { |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
205 register struct buffer *inbuffer = XBUFFER (readcharfun); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
206 |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
207 int pt_byte = BUF_PT_BYTE (inbuffer); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
208 int orig_pt_byte = pt_byte; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
209 |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
210 if (readchar_backlog > 0) |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
211 /* We get the address of the byte just passed, |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
212 which is the last byte of the character. |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
213 The other bytes in this character are consecutive with it, |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
214 because the gap can't be in the middle of a character. */ |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
215 return *(BUF_BYTE_ADDRESS (inbuffer, BUF_PT_BYTE (inbuffer) - 1) |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
216 - --readchar_backlog); |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
217 |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
218 if (pt_byte >= BUF_ZV_BYTE (inbuffer)) |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
219 return -1; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
220 |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
221 readchar_backlog = -1; |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
222 |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
223 if (! NILP (inbuffer->enable_multibyte_characters)) |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
224 { |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
225 /* Fetch the character code from the buffer. */ |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
226 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, pt_byte); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
227 BUF_INC_POS (inbuffer, pt_byte); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
228 c = STRING_CHAR (p, pt_byte - orig_pt_byte); |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
229 } |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
230 else |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
231 { |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
232 c = BUF_FETCH_BYTE (inbuffer, pt_byte); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
233 pt_byte++; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
234 } |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
235 SET_BUF_PT_BOTH (inbuffer, BUF_PT (inbuffer) + 1, pt_byte); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
236 |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
237 return c; |
341 | 238 } |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
239 if (MARKERP (readcharfun)) |
341 | 240 { |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
241 register struct buffer *inbuffer = XMARKER (readcharfun)->buffer; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
242 |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
243 int bytepos = marker_byte_position (readcharfun); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
244 int orig_bytepos = bytepos; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
245 |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
246 if (readchar_backlog > 0) |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
247 /* We get the address of the byte just passed, |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
248 which is the last byte of the character. |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
249 The other bytes in this character are consecutive with it, |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
250 because the gap can't be in the middle of a character. */ |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
251 return *(BUF_BYTE_ADDRESS (inbuffer, XMARKER (readcharfun)->bytepos - 1) |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
252 - --readchar_backlog); |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
253 |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
254 if (bytepos >= BUF_ZV_BYTE (inbuffer)) |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
255 return -1; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
256 |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
257 readchar_backlog = -1; |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
258 |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
259 if (! NILP (inbuffer->enable_multibyte_characters)) |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
260 { |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
261 /* Fetch the character code from the buffer. */ |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
262 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, bytepos); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
263 BUF_INC_POS (inbuffer, bytepos); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
264 c = STRING_CHAR (p, bytepos - orig_bytepos); |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
265 } |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
266 else |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
267 { |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
268 c = BUF_FETCH_BYTE (inbuffer, bytepos); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
269 bytepos++; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
270 } |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
271 |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
272 XMARKER (readcharfun)->bytepos = bytepos; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
273 XMARKER (readcharfun)->charpos++; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
274 |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
275 return c; |
341 | 276 } |
22691
ff0ed53342b3
(read_list): Pass new arg to get_doc_string.
Richard M. Stallman <rms@gnu.org>
parents:
22603
diff
changeset
|
277 |
ff0ed53342b3
(read_list): Pass new arg to get_doc_string.
Richard M. Stallman <rms@gnu.org>
parents:
22603
diff
changeset
|
278 if (EQ (readcharfun, Qlambda)) |
ff0ed53342b3
(read_list): Pass new arg to get_doc_string.
Richard M. Stallman <rms@gnu.org>
parents:
22603
diff
changeset
|
279 return read_bytecode_char (0); |
ff0ed53342b3
(read_list): Pass new arg to get_doc_string.
Richard M. Stallman <rms@gnu.org>
parents:
22603
diff
changeset
|
280 |
341 | 281 if (EQ (readcharfun, Qget_file_char)) |
8083
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
282 { |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
283 c = getc (instream); |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
284 #ifdef EINTR |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
285 /* Interrupted reads have been observed while reading over the network */ |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
286 while (c == EOF && ferror (instream) && errno == EINTR) |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
287 { |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
288 clearerr (instream); |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
289 c = getc (instream); |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
290 } |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
291 #endif |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
292 return c; |
dc62b2daf48e
(readchar): Restart interrupted I/O.
Karl Heuer <kwzh@gnu.org>
parents:
7898
diff
changeset
|
293 } |
341 | 294 |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
295 if (STRINGP (readcharfun)) |
341 | 296 { |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
297 if (read_from_string_index >= read_from_string_limit) |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
298 c = -1; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
299 else if (STRING_MULTIBYTE (readcharfun)) |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
300 FETCH_STRING_CHAR_ADVANCE (c, readcharfun, |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
301 read_from_string_index, |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
302 read_from_string_index_byte); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
303 else |
341 | 304 c = XSTRING (readcharfun)->data[read_from_string_index++]; |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
305 |
341 | 306 return c; |
307 } | |
308 | |
309 tem = call0 (readcharfun); | |
310 | |
485 | 311 if (NILP (tem)) |
341 | 312 return -1; |
313 return XINT (tem); | |
314 } | |
315 | |
316 /* Unread the character C in the way appropriate for the stream READCHARFUN. | |
317 If the stream is a user function, call it with the char as argument. */ | |
318 | |
319 static void | |
320 unreadchar (readcharfun, c) | |
321 Lisp_Object readcharfun; | |
322 int c; | |
323 { | |
6471
4e6b54b64d94
(unreadchar): Don't back up the pointer when unreading EOF.
Karl Heuer <kwzh@gnu.org>
parents:
6470
diff
changeset
|
324 if (c == -1) |
4e6b54b64d94
(unreadchar): Don't back up the pointer when unreading EOF.
Karl Heuer <kwzh@gnu.org>
parents:
6470
diff
changeset
|
325 /* Don't back up the pointer if we're unreading the end-of-input mark, |
4e6b54b64d94
(unreadchar): Don't back up the pointer when unreading EOF.
Karl Heuer <kwzh@gnu.org>
parents:
6470
diff
changeset
|
326 since readchar didn't advance it when we read it. */ |
4e6b54b64d94
(unreadchar): Don't back up the pointer when unreading EOF.
Karl Heuer <kwzh@gnu.org>
parents:
6470
diff
changeset
|
327 ; |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
328 else if (BUFFERP (readcharfun)) |
20691
cf1919e207ef
(unreadchar): For unreading an ASCII char
Richard M. Stallman <rms@gnu.org>
parents:
20669
diff
changeset
|
329 { |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
330 struct buffer *b = XBUFFER (readcharfun); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
331 int bytepos = BUF_PT_BYTE (b); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
332 |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
333 if (readchar_backlog >= 0) |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
334 readchar_backlog++; |
20691
cf1919e207ef
(unreadchar): For unreading an ASCII char
Richard M. Stallman <rms@gnu.org>
parents:
20669
diff
changeset
|
335 else |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
336 { |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
337 BUF_PT (b)--; |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
338 if (! NILP (b->enable_multibyte_characters)) |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
339 BUF_DEC_POS (b, bytepos); |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
340 else |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
341 bytepos--; |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
342 |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
343 BUF_PT_BYTE (b) = bytepos; |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
344 } |
20691
cf1919e207ef
(unreadchar): For unreading an ASCII char
Richard M. Stallman <rms@gnu.org>
parents:
20669
diff
changeset
|
345 } |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
346 else if (MARKERP (readcharfun)) |
20691
cf1919e207ef
(unreadchar): For unreading an ASCII char
Richard M. Stallman <rms@gnu.org>
parents:
20669
diff
changeset
|
347 { |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
348 struct buffer *b = XMARKER (readcharfun)->buffer; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
349 int bytepos = XMARKER (readcharfun)->bytepos; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
350 |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
351 if (readchar_backlog >= 0) |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
352 readchar_backlog++; |
20691
cf1919e207ef
(unreadchar): For unreading an ASCII char
Richard M. Stallman <rms@gnu.org>
parents:
20669
diff
changeset
|
353 else |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
354 { |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
355 XMARKER (readcharfun)->charpos--; |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
356 if (! NILP (b->enable_multibyte_characters)) |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
357 BUF_DEC_POS (b, bytepos); |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
358 else |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
359 bytepos--; |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
360 |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
361 XMARKER (readcharfun)->bytepos = bytepos; |
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
362 } |
20691
cf1919e207ef
(unreadchar): For unreading an ASCII char
Richard M. Stallman <rms@gnu.org>
parents:
20669
diff
changeset
|
363 } |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
364 else if (STRINGP (readcharfun)) |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
365 { |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
366 read_from_string_index--; |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
367 read_from_string_index_byte |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
368 = string_char_to_byte (readcharfun, read_from_string_index); |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
369 } |
22691
ff0ed53342b3
(read_list): Pass new arg to get_doc_string.
Richard M. Stallman <rms@gnu.org>
parents:
22603
diff
changeset
|
370 else if (EQ (readcharfun, Qlambda)) |
ff0ed53342b3
(read_list): Pass new arg to get_doc_string.
Richard M. Stallman <rms@gnu.org>
parents:
22603
diff
changeset
|
371 read_bytecode_char (1); |
341 | 372 else if (EQ (readcharfun, Qget_file_char)) |
373 ungetc (c, instream); | |
374 else | |
375 call1 (readcharfun, make_number (c)); | |
376 } | |
377 | |
378 static Lisp_Object read0 (), read1 (), read_list (), read_vector (); | |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
379 static int read_multibyte (); |
25165
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
380 static Lisp_Object substitute_object_recurse (); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
381 static void substitute_object_in_subtree (), substitute_in_interval (); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
382 |
341 | 383 |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
384 /* Get a character from the tty. */ |
341 | 385 |
1519
5d0837ebee9c
* lread.c (read_char): Add an extern declaration for this,
Jim Blandy <jimb@redhat.com>
parents:
1092
diff
changeset
|
386 extern Lisp_Object read_char (); |
5d0837ebee9c
* lread.c (read_char): Add an extern declaration for this,
Jim Blandy <jimb@redhat.com>
parents:
1092
diff
changeset
|
387 |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
388 /* Read input events until we get one that's acceptable for our purposes. |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
389 |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
390 If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
391 until we get a character we like, and then stuffed into |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
392 unread_switch_frame. |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
393 |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
394 If ASCII_REQUIRED is non-zero, we check function key events to see |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
395 if the unmodified version of the symbol has a Qascii_character |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
396 property, and use that character, if present. |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
397 |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
398 If ERROR_NONASCII is non-zero, we signal an error if the input we |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
399 get isn't an ASCII character with modifiers. If it's zero but |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
400 ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
401 character. |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
402 |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
403 If INPUT_METHOD is nonzero, we invoke the current input method |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
404 if the character warrants that. */ |
14483
7f49c41db1e8
(Fread_char_exclusive): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
14300
diff
changeset
|
405 |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
406 Lisp_Object |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
407 read_filtered_event (no_switch_frame, ascii_required, error_nonascii, |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
408 input_method) |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
409 int no_switch_frame, ascii_required, error_nonascii, input_method; |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
410 { |
6503
7c566d0e4b3d
(read_filtered_event, intern): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6471
diff
changeset
|
411 register Lisp_Object val, delayed_switch_frame; |
7c566d0e4b3d
(read_filtered_event, intern): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6471
diff
changeset
|
412 |
7c566d0e4b3d
(read_filtered_event, intern): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6471
diff
changeset
|
413 delayed_switch_frame = Qnil; |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
414 |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
415 /* Read until we get an acceptable event. */ |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
416 retry: |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
417 val = read_char (0, 0, 0, |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
418 (input_method ? Qnil : Qt), |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
419 0); |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
420 |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
421 if (BUFFERP (val)) |
5888
0d02ee7ee659
(read_filtered_event): Retry read_char after a buffer change.
Karl Heuer <kwzh@gnu.org>
parents:
5687
diff
changeset
|
422 goto retry; |
0d02ee7ee659
(read_filtered_event): Retry read_char after a buffer change.
Karl Heuer <kwzh@gnu.org>
parents:
5687
diff
changeset
|
423 |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
424 /* switch-frame events are put off until after the next ASCII |
14036 | 425 character. This is better than signaling an error just because |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
426 the last characters were typed to a separate minibuffer frame, |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
427 for example. Eventually, some code which can deal with |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
428 switch-frame events will read it and process it. */ |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
429 if (no_switch_frame |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
430 && EVENT_HAS_PARAMETERS (val) |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
431 && EQ (EVENT_HEAD (val), Qswitch_frame)) |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
432 { |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
433 delayed_switch_frame = val; |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
434 goto retry; |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
435 } |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
436 |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
437 if (ascii_required) |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
438 { |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
439 /* Convert certain symbols to their ASCII equivalents. */ |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
440 if (SYMBOLP (val)) |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
441 { |
25787
3d1138357287
(readchar): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
442 Lisp_Object tem, tem1; |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
443 tem = Fget (val, Qevent_symbol_element_mask); |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
444 if (!NILP (tem)) |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
445 { |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
446 tem1 = Fget (Fcar (tem), Qascii_character); |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
447 /* Merge this symbol's modifier bits |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
448 with the ASCII equivalent of its basic code. */ |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
449 if (!NILP (tem1)) |
9313
ed68c3822e4b
(read_filtered_event, init_obarray): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9274
diff
changeset
|
450 XSETFASTINT (val, XINT (tem1) | XINT (Fcar (Fcdr (tem)))); |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
451 } |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
452 } |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
453 |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
454 /* If we don't have a character now, deal with it appropriately. */ |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
455 if (!INTEGERP (val)) |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
456 { |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
457 if (error_nonascii) |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
458 { |
7106
06542cc6ddcd
(read_filtered_event): Use Vunread_command_events.
Richard M. Stallman <rms@gnu.org>
parents:
7028
diff
changeset
|
459 Vunread_command_events = Fcons (val, Qnil); |
2654
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
460 error ("Non-character input-event"); |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
461 } |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
462 else |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
463 goto retry; |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
464 } |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
465 } |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
466 |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
467 if (! NILP (delayed_switch_frame)) |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
468 unread_switch_frame = delayed_switch_frame; |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
469 |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
470 return val; |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
471 } |
ba685dcc3750
Arrange for Fy_or_n_p to put off switch-frame events.
Jim Blandy <jimb@redhat.com>
parents:
2545
diff
changeset
|
472 |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
473 DEFUN ("read-char", Fread_char, Sread_char, 0, 2, 0, |
341 | 474 "Read a character from the command input (keyboard or macro).\n\ |
851 | 475 It is returned as a number.\n\ |
476 If the user generates an event which is not a character (i.e. a mouse\n\ | |
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
477 click or function key event), `read-char' signals an error. As an\n\ |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
478 exception, switch-frame events are put off until non-ASCII events can\n\ |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
479 be read.\n\ |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
480 If you want to read non-character events, or ignore them, call\n\ |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
481 `read-event' or `read-char-exclusive' instead.\n\ |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
482 \n\ |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
483 If the optional argument PROMPT is non-nil, display that as a prompt.\n\ |
23933
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
484 If the optional argument INHERIT-INPUT-METHOD is non-nil and some\n\ |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
485 input method is turned on in the current buffer, that input method\n\ |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
486 is used for reading a character.") |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
487 (prompt, inherit_input_method) |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
488 Lisp_Object prompt, inherit_input_method; |
341 | 489 { |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
490 if (! NILP (prompt)) |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
491 message_with_string ("%s", prompt, 0); |
23933
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
492 return read_filtered_event (1, 1, 1, ! NILP (inherit_input_method)); |
341 | 493 } |
494 | |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
495 DEFUN ("read-event", Fread_event, Sread_event, 0, 2, 0, |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
496 "Read an event object from the input stream.\n\ |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
497 If the optional argument PROMPT is non-nil, display that as a prompt.\n\ |
23933
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
498 If the optional argument INHERIT-INPUT-METHOD is non-nil and some\n\ |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
499 input method is turned on in the current buffer, that input method\n\ |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
500 is used for reading a character.") |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
501 (prompt, inherit_input_method) |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
502 Lisp_Object prompt, inherit_input_method; |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
503 { |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
504 if (! NILP (prompt)) |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
505 message_with_string ("%s", prompt, 0); |
23933
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
506 return read_filtered_event (0, 0, 0, ! NILP (inherit_input_method)); |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
507 } |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
508 |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
509 DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 2, 0, |
341 | 510 "Read a character from the command input (keyboard or macro).\n\ |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
511 It is returned as a number. Non-character events are ignored.\n\ |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
512 \n\ |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
513 If the optional argument PROMPT is non-nil, display that as a prompt.\n\ |
23933
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
514 If the optional argument INHERIT-INPUT-METHOD is non-nil and some\n\ |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
515 input method is turned on in the current buffer, that input method\n\ |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
516 is used for reading a character.") |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
517 (prompt, inherit_input_method) |
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
518 Lisp_Object prompt, inherit_input_method; |
341 | 519 { |
23056
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
520 if (! NILP (prompt)) |
1b44597160c3
(read_filtered_event): New arg INPUT_METHOD. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
22889
diff
changeset
|
521 message_with_string ("%s", prompt, 0); |
23933
d993b7332153
(Fread_char): Change the meaning of the second argument.
Kenichi Handa <handa@m17n.org>
parents:
23284
diff
changeset
|
522 return read_filtered_event (1, 1, 0, ! NILP (inherit_input_method)); |
341 | 523 } |
524 | |
525 DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0, | |
526 "Don't use this yourself.") | |
527 () | |
528 { | |
529 register Lisp_Object val; | |
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
530 XSETINT (val, getc (instream)); |
341 | 531 return val; |
532 } | |
533 | |
534 static void readevalloop (); | |
535 static Lisp_Object load_unwind (); | |
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
536 static Lisp_Object load_descriptor_unwind (); |
341 | 537 |
19115
266915689f9e
(Fload): New optional arg MUST-SUFFIX.
Richard M. Stallman <rms@gnu.org>
parents:
19020
diff
changeset
|
538 DEFUN ("load", Fload, Sload, 1, 5, 0, |
341 | 539 "Execute a file of Lisp code named FILE.\n\ |
540 First try FILE with `.elc' appended, then try with `.el',\n\ | |
541 then try FILE unmodified.\n\ | |
542 This function searches the directories in `load-path'.\n\ | |
543 If optional second arg NOERROR is non-nil,\n\ | |
544 report no error if FILE doesn't exist.\n\ | |
545 Print messages at start and end of loading unless\n\ | |
546 optional third arg NOMESSAGE is non-nil.\n\ | |
547 If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\ | |
548 suffixes `.elc' or `.el' to the specified name FILE.\n\ | |
19622
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
549 If optional fifth arg MUST-SUFFIX is non-nil, insist on\n\ |
19626
a9f87afd5ac6
(Fload): Fix doc syntax.
Richard M. Stallman <rms@gnu.org>
parents:
19622
diff
changeset
|
550 the suffix `.elc' or `.el'; don't accept just FILE unless\n\ |
19622
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
551 it ends in one of those suffixes or includes a directory name.\n\ |
341 | 552 Return t if file exists.") |
19115
266915689f9e
(Fload): New optional arg MUST-SUFFIX.
Richard M. Stallman <rms@gnu.org>
parents:
19020
diff
changeset
|
553 (file, noerror, nomessage, nosuffix, must_suffix) |
266915689f9e
(Fload): New optional arg MUST-SUFFIX.
Richard M. Stallman <rms@gnu.org>
parents:
19020
diff
changeset
|
554 Lisp_Object file, noerror, nomessage, nosuffix, must_suffix; |
341 | 555 { |
556 register FILE *stream; | |
557 register int fd = -1; | |
558 register Lisp_Object lispstream; | |
559 int count = specpdl_ptr - specpdl; | |
560 Lisp_Object temp; | |
561 struct gcpro gcpro1; | |
562 Lisp_Object found; | |
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
563 /* 1 means we printed the ".el is newer" message. */ |
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
564 int newer = 0; |
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
565 /* 1 means we are loading a compiled file. */ |
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
566 int compiled = 0; |
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
567 Lisp_Object handler; |
21936
6635a9f225a9
(Fload): Rename dosmode to fmode and use it on all
Eli Zaretskii <eliz@gnu.org>
parents:
21935
diff
changeset
|
568 char *fmode = "r"; |
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
569 #ifdef DOS_NT |
21936
6635a9f225a9
(Fload): Rename dosmode to fmode and use it on all
Eli Zaretskii <eliz@gnu.org>
parents:
21935
diff
changeset
|
570 fmode = "rt"; |
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
571 #endif /* DOS_NT */ |
341 | 572 |
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
573 CHECK_STRING (file, 0); |
341 | 574 |
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
575 /* If file name is magic, call the handler. */ |
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
576 handler = Ffind_file_name_handler (file, Qload); |
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
577 if (!NILP (handler)) |
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
578 return call5 (handler, Qload, file, noerror, nomessage, nosuffix); |
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
579 |
10014
d149c4dc84f3
(Fload): Call Fsubstitute_in_file_name after trying handler.
Richard M. Stallman <rms@gnu.org>
parents:
9938
diff
changeset
|
580 /* Do this after the handler to avoid |
d149c4dc84f3
(Fload): Call Fsubstitute_in_file_name after trying handler.
Richard M. Stallman <rms@gnu.org>
parents:
9938
diff
changeset
|
581 the need to gcpro noerror, nomessage and nosuffix. |
d149c4dc84f3
(Fload): Call Fsubstitute_in_file_name after trying handler.
Richard M. Stallman <rms@gnu.org>
parents:
9938
diff
changeset
|
582 (Below here, we care only whether they are nil or not.) */ |
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
583 file = Fsubstitute_in_file_name (file); |
10014
d149c4dc84f3
(Fload): Call Fsubstitute_in_file_name after trying handler.
Richard M. Stallman <rms@gnu.org>
parents:
9938
diff
changeset
|
584 |
341 | 585 /* Avoid weird lossage with null string as arg, |
586 since it would try to load a directory as a Lisp file */ | |
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
587 if (XSTRING (file)->size > 0) |
341 | 588 { |
26072
1e8b099fba75
(Fload): Calculate bytes of filename correctly.
Kenichi Handa <handa@m17n.org>
parents:
25787
diff
changeset
|
589 int size = STRING_BYTES (XSTRING (file)); |
19622
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
590 |
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
591 GCPRO1 (file); |
19622
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
592 |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
593 if (! NILP (must_suffix)) |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
594 { |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
595 /* Don't insist on adding a suffix if FILE already ends with one. */ |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
596 if (size > 3 |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
597 && !strcmp (XSTRING (file)->data + size - 3, ".el")) |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
598 must_suffix = Qnil; |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
599 else if (size > 4 |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
600 && !strcmp (XSTRING (file)->data + size - 4, ".elc")) |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
601 must_suffix = Qnil; |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
602 /* Don't insist on adding a suffix |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
603 if the argument includes a directory name. */ |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
604 else if (! NILP (Ffile_name_directory (file))) |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
605 must_suffix = Qnil; |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
606 } |
be0876941b71
(Fload): If FILE arg ends in .el or .elc, don't insist on adding a suffix.
Richard M. Stallman <rms@gnu.org>
parents:
19240
diff
changeset
|
607 |
19115
266915689f9e
(Fload): New optional arg MUST-SUFFIX.
Richard M. Stallman <rms@gnu.org>
parents:
19020
diff
changeset
|
608 fd = openp (Vload_path, file, |
266915689f9e
(Fload): New optional arg MUST-SUFFIX.
Richard M. Stallman <rms@gnu.org>
parents:
19020
diff
changeset
|
609 (!NILP (nosuffix) ? "" |
27612
578e78aa0553
(_XOPEN_SOURCE): Declare (for ftello).
Dave Love <fx@gnu.org>
parents:
27364
diff
changeset
|
610 : ! NILP (must_suffix) ? ".elc.gz:.elc:.el.gz:.el" |
578e78aa0553
(_XOPEN_SOURCE): Declare (for ftello).
Dave Love <fx@gnu.org>
parents:
27364
diff
changeset
|
611 : ".elc:.elc.gz:.el.gz:.el:"), |
341 | 612 &found, 0); |
6392
58e075552627
(openp, Fload): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6072
diff
changeset
|
613 UNGCPRO; |
341 | 614 } |
615 | |
616 if (fd < 0) | |
617 { | |
485 | 618 if (NILP (noerror)) |
341 | 619 while (1) |
620 Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"), | |
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
621 Fcons (file, Qnil))); |
341 | 622 else |
623 return Qnil; | |
624 } | |
625 | |
24817
3e8c8a06329b
(Vuser_init_file): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
24412
diff
changeset
|
626 if (EQ (Qt, Vuser_init_file)) |
3e8c8a06329b
(Vuser_init_file): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
24412
diff
changeset
|
627 Vuser_init_file = found; |
3e8c8a06329b
(Vuser_init_file): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
24412
diff
changeset
|
628 |
23193
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
629 /* If FD is 0, that means openp found a magic file. */ |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
630 if (fd == 0) |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
631 { |
23193
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
632 if (NILP (Fequal (found, file))) |
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
633 /* If FOUND is a different file name from FILE, |
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
634 find its handler even if we have already inhibited |
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
635 the `load' operation on FILE. */ |
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
636 handler = Ffind_file_name_handler (found, Qt); |
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
637 else |
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
638 handler = Ffind_file_name_handler (found, Qload); |
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
639 if (! NILP (handler)) |
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
640 return call5 (handler, Qload, found, noerror, nomessage, Qt); |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
641 } |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
642 |
23193
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
643 /* Load .elc files directly, but not when they are |
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
644 remote and have no handler! */ |
26072
1e8b099fba75
(Fload): Calculate bytes of filename correctly.
Kenichi Handa <handa@m17n.org>
parents:
25787
diff
changeset
|
645 if (!bcmp (&(XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 4]), |
23193
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
646 ".elc", 4) |
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
647 && fd != 0) |
341 | 648 { |
649 struct stat s1, s2; | |
650 int result; | |
651 | |
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
652 compiled = 1; |
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
653 |
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
654 #ifdef DOS_NT |
21936
6635a9f225a9
(Fload): Rename dosmode to fmode and use it on all
Eli Zaretskii <eliz@gnu.org>
parents:
21935
diff
changeset
|
655 fmode = "rb"; |
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
656 #endif /* DOS_NT */ |
6072
8af8f6b469e1
(Fload): Cast the args to stat.
Richard M. Stallman <rms@gnu.org>
parents:
5888
diff
changeset
|
657 stat ((char *)XSTRING (found)->data, &s1); |
26072
1e8b099fba75
(Fload): Calculate bytes of filename correctly.
Kenichi Handa <handa@m17n.org>
parents:
25787
diff
changeset
|
658 XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 1] = 0; |
6072
8af8f6b469e1
(Fload): Cast the args to stat.
Richard M. Stallman <rms@gnu.org>
parents:
5888
diff
changeset
|
659 result = stat ((char *)XSTRING (found)->data, &s2); |
341 | 660 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) |
1758
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
661 { |
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
662 /* Make the progress messages mention that source is newer. */ |
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
663 newer = 1; |
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
664 |
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
665 /* If we won't print another message, mention this anyway. */ |
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
666 if (! NILP (nomessage)) |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
667 message_with_string ("Source file `%s' newer than byte-compiled file", |
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
668 found, 1); |
1758
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
669 } |
26072
1e8b099fba75
(Fload): Calculate bytes of filename correctly.
Kenichi Handa <handa@m17n.org>
parents:
25787
diff
changeset
|
670 XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 1] = 'c'; |
341 | 671 } |
17038 | 672 else |
673 { | |
674 /* We are loading a source file (*.el). */ | |
675 if (!NILP (Vload_source_file_function)) | |
676 { | |
23193
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
677 if (fd != 0) |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
678 emacs_close (fd); |
17125
4a6c43010388
(Fload): Call Vload_source_file_function with 4 args.
Erik Naggum <erik@naggum.no>
parents:
17038
diff
changeset
|
679 return call4 (Vload_source_file_function, found, file, |
17038 | 680 NILP (noerror) ? Qnil : Qt, |
681 NILP (nomessage) ? Qnil : Qt); | |
682 } | |
683 } | |
341 | 684 |
21936
6635a9f225a9
(Fload): Rename dosmode to fmode and use it on all
Eli Zaretskii <eliz@gnu.org>
parents:
21935
diff
changeset
|
685 #ifdef WINDOWSNT |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
686 emacs_close (fd); |
21936
6635a9f225a9
(Fload): Rename dosmode to fmode and use it on all
Eli Zaretskii <eliz@gnu.org>
parents:
21935
diff
changeset
|
687 stream = fopen ((char *) XSTRING (found)->data, fmode); |
6635a9f225a9
(Fload): Rename dosmode to fmode and use it on all
Eli Zaretskii <eliz@gnu.org>
parents:
21935
diff
changeset
|
688 #else /* not WINDOWSNT */ |
6635a9f225a9
(Fload): Rename dosmode to fmode and use it on all
Eli Zaretskii <eliz@gnu.org>
parents:
21935
diff
changeset
|
689 stream = fdopen (fd, fmode); |
6635a9f225a9
(Fload): Rename dosmode to fmode and use it on all
Eli Zaretskii <eliz@gnu.org>
parents:
21935
diff
changeset
|
690 #endif /* not WINDOWSNT */ |
341 | 691 if (stream == 0) |
692 { | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
693 emacs_close (fd); |
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
694 error ("Failure to create stdio stream for %s", XSTRING (file)->data); |
341 | 695 } |
696 | |
18665
6d7b8b35d878
(Vpreloaded_file_list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18530
diff
changeset
|
697 if (! NILP (Vpurify_flag)) |
6d7b8b35d878
(Vpreloaded_file_list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18530
diff
changeset
|
698 Vpreloaded_file_list = Fcons (file, Vpreloaded_file_list); |
6d7b8b35d878
(Vpreloaded_file_list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18530
diff
changeset
|
699 |
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
700 if (NILP (nomessage)) |
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
701 { |
20168
13074c25ab06
Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents:
20048
diff
changeset
|
702 if (!compiled) |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
703 message_with_string ("Loading %s (source)...", file, 1); |
20168
13074c25ab06
Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents:
20048
diff
changeset
|
704 else if (newer) |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
705 message_with_string ("Loading %s (compiled; note, source file is newer)...", |
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
706 file, 1); |
20168
13074c25ab06
Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents:
20048
diff
changeset
|
707 else /* The typical case; compiled file newer than source file. */ |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
708 message_with_string ("Loading %s...", file, 1); |
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
709 } |
341 | 710 |
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
711 GCPRO1 (file); |
9361
c11cc966dc6a
(Fload, load_unwind): Store stream pointer as a cons of two integers,
Karl Heuer <kwzh@gnu.org>
parents:
9358
diff
changeset
|
712 lispstream = Fcons (Qnil, Qnil); |
25663
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
713 XSETFASTINT (XCAR (lispstream), (EMACS_UINT)stream >> 16); |
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
714 XSETFASTINT (XCDR (lispstream), (EMACS_UINT)stream & 0xffff); |
341 | 715 record_unwind_protect (load_unwind, lispstream); |
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
716 record_unwind_protect (load_descriptor_unwind, load_descriptor_list); |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
717 specbind (Qload_file_name, found); |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
718 specbind (Qinhibit_file_name_operation, Qnil); |
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
719 load_descriptor_list |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
720 = Fcons (make_number (fileno (stream)), load_descriptor_list); |
341 | 721 load_in_progress++; |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
722 readevalloop (Qget_file_char, stream, file, Feval, 0, Qnil, Qnil); |
341 | 723 unbind_to (count, Qnil); |
724 | |
725 /* Run any load-hooks for this file. */ | |
13036
cd0e7903d0a9
(Fload): Rename arg STR to FILE.
Richard M. Stallman <rms@gnu.org>
parents:
12780
diff
changeset
|
726 temp = Fassoc (file, Vafter_load_alist); |
485 | 727 if (!NILP (temp)) |
341 | 728 Fprogn (Fcdr (temp)); |
729 UNGCPRO; | |
730 | |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
731 if (saved_doc_string) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
732 free (saved_doc_string); |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
733 saved_doc_string = 0; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
734 saved_doc_string_size = 0; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
735 |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
736 if (prev_saved_doc_string) |
27852
98f55bbdbbad
(Fload): Use `xfree' instead of `free'.
Gerd Moellmann <gerd@gnu.org>
parents:
27763
diff
changeset
|
737 xfree (prev_saved_doc_string); |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
738 prev_saved_doc_string = 0; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
739 prev_saved_doc_string_size = 0; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
740 |
485 | 741 if (!noninteractive && NILP (nomessage)) |
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
742 { |
20168
13074c25ab06
Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents:
20048
diff
changeset
|
743 if (!compiled) |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
744 message_with_string ("Loading %s (source)...done", file, 1); |
20168
13074c25ab06
Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents:
20048
diff
changeset
|
745 else if (newer) |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
746 message_with_string ("Loading %s (compiled; note, source file is newer)...done", |
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
747 file, 1); |
20168
13074c25ab06
Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents:
20048
diff
changeset
|
748 else /* The typical case; compiled file newer than source file. */ |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
749 message_with_string ("Loading %s...done", file, 1); |
16012
3b5ffd35defe
(Fload): Add "source is newer" info to the "loading" and "done" messages.
Richard M. Stallman <rms@gnu.org>
parents:
15283
diff
changeset
|
750 } |
341 | 751 return Qt; |
752 } | |
753 | |
754 static Lisp_Object | |
755 load_unwind (stream) /* used as unwind-protect function in load */ | |
756 Lisp_Object stream; | |
757 { | |
25663
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
758 fclose ((FILE *) (XFASTINT (XCAR (stream)) << 16 |
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
759 | XFASTINT (XCDR (stream)))); |
341 | 760 if (--load_in_progress < 0) load_in_progress = 0; |
761 return Qnil; | |
762 } | |
763 | |
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
764 static Lisp_Object |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
765 load_descriptor_unwind (oldlist) |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
766 Lisp_Object oldlist; |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
767 { |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
768 load_descriptor_list = oldlist; |
9361
c11cc966dc6a
(Fload, load_unwind): Store stream pointer as a cons of two integers,
Karl Heuer <kwzh@gnu.org>
parents:
9358
diff
changeset
|
769 return Qnil; |
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
770 } |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
771 |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
772 /* Close all descriptors in use for Floads. |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
773 This is used when starting a subprocess. */ |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
774 |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
775 void |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
776 close_load_descs () |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
777 { |
15091
e05dd165b889
(close_load_descs) [WINDOWS_NT]: Don't actually do anything.
Richard M. Stallman <rms@gnu.org>
parents:
14972
diff
changeset
|
778 #ifndef WINDOWSNT |
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
779 Lisp_Object tail; |
25663
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
780 for (tail = load_descriptor_list; !NILP (tail); tail = XCDR (tail)) |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
781 emacs_close (XFASTINT (XCAR (tail))); |
15091
e05dd165b889
(close_load_descs) [WINDOWS_NT]: Don't actually do anything.
Richard M. Stallman <rms@gnu.org>
parents:
14972
diff
changeset
|
782 #endif |
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
783 } |
341 | 784 |
785 static int | |
786 complete_filename_p (pathname) | |
787 Lisp_Object pathname; | |
788 { | |
789 register unsigned char *s = XSTRING (pathname)->data; | |
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
790 return (IS_DIRECTORY_SEP (s[0]) |
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
791 || (XSTRING (pathname)->size > 2 |
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
792 && IS_DEVICE_SEP (s[1]) && IS_DIRECTORY_SEP (s[2])) |
341 | 793 #ifdef ALTOS |
794 || *s == '@' | |
795 #endif | |
796 #ifdef VMS | |
797 || index (s, ':') | |
798 #endif /* VMS */ | |
799 ); | |
800 } | |
801 | |
802 /* Search for a file whose name is STR, looking in directories | |
803 in the Lisp list PATH, and trying suffixes from SUFFIX. | |
804 SUFFIX is a string containing possible suffixes separated by colons. | |
805 On success, returns a file descriptor. On failure, returns -1. | |
806 | |
807 EXEC_ONLY nonzero means don't open the files, | |
808 just look for one that is executable. In this case, | |
809 returns 1 on success. | |
810 | |
811 If STOREPTR is nonzero, it points to a slot where the name of | |
812 the file actually found should be stored as a Lisp string. | |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
813 nil is stored there on failure. |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
814 |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
815 If the file we find is remote, return 0 |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
816 but store the found remote file name in *STOREPTR. |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
817 We do not check for remote files if EXEC_ONLY is nonzero. */ |
341 | 818 |
819 int | |
820 openp (path, str, suffix, storeptr, exec_only) | |
821 Lisp_Object path, str; | |
822 char *suffix; | |
823 Lisp_Object *storeptr; | |
824 int exec_only; | |
825 { | |
826 register int fd; | |
827 int fn_size = 100; | |
828 char buf[100]; | |
829 register char *fn = buf; | |
830 int absolute = 0; | |
831 int want_size; | |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
832 Lisp_Object filename; |
341 | 833 struct stat st; |
6392
58e075552627
(openp, Fload): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6072
diff
changeset
|
834 struct gcpro gcpro1; |
341 | 835 |
6392
58e075552627
(openp, Fload): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6072
diff
changeset
|
836 GCPRO1 (str); |
341 | 837 if (storeptr) |
838 *storeptr = Qnil; | |
839 | |
840 if (complete_filename_p (str)) | |
841 absolute = 1; | |
842 | |
485 | 843 for (; !NILP (path); path = Fcdr (path)) |
341 | 844 { |
845 char *nsuffix; | |
846 | |
847 filename = Fexpand_file_name (str, Fcar (path)); | |
848 if (!complete_filename_p (filename)) | |
849 /* If there are non-absolute elts in PATH (eg ".") */ | |
850 /* Of course, this could conceivably lose if luser sets | |
851 default-directory to be something non-absolute... */ | |
852 { | |
853 filename = Fexpand_file_name (filename, current_buffer->directory); | |
854 if (!complete_filename_p (filename)) | |
855 /* Give up on this path element! */ | |
856 continue; | |
857 } | |
858 | |
859 /* Calculate maximum size of any filename made from | |
860 this path element/specified file name and any possible suffix. */ | |
26072
1e8b099fba75
(Fload): Calculate bytes of filename correctly.
Kenichi Handa <handa@m17n.org>
parents:
25787
diff
changeset
|
861 want_size = strlen (suffix) + STRING_BYTES (XSTRING (filename)) + 1; |
341 | 862 if (fn_size < want_size) |
863 fn = (char *) alloca (fn_size = 100 + want_size); | |
864 | |
865 nsuffix = suffix; | |
866 | |
867 /* Loop over suffixes. */ | |
868 while (1) | |
869 { | |
870 char *esuffix = (char *) index (nsuffix, ':'); | |
871 int lsuffix = esuffix ? esuffix - nsuffix : strlen (nsuffix); | |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
872 Lisp_Object handler; |
341 | 873 |
16383
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
874 /* Concatenate path element/specified name with the suffix. |
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
875 If the directory starts with /:, remove that. */ |
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
876 if (XSTRING (filename)->size > 2 |
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
877 && XSTRING (filename)->data[0] == '/' |
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
878 && XSTRING (filename)->data[1] == ':') |
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
879 { |
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
880 strncpy (fn, XSTRING (filename)->data + 2, |
26072
1e8b099fba75
(Fload): Calculate bytes of filename correctly.
Kenichi Handa <handa@m17n.org>
parents:
25787
diff
changeset
|
881 STRING_BYTES (XSTRING (filename)) - 2); |
1e8b099fba75
(Fload): Calculate bytes of filename correctly.
Kenichi Handa <handa@m17n.org>
parents:
25787
diff
changeset
|
882 fn[STRING_BYTES (XSTRING (filename)) - 2] = 0; |
16383
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
883 } |
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
884 else |
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
885 { |
26072
1e8b099fba75
(Fload): Calculate bytes of filename correctly.
Kenichi Handa <handa@m17n.org>
parents:
25787
diff
changeset
|
886 strncpy (fn, XSTRING (filename)->data, |
1e8b099fba75
(Fload): Calculate bytes of filename correctly.
Kenichi Handa <handa@m17n.org>
parents:
25787
diff
changeset
|
887 STRING_BYTES (XSTRING (filename))); |
1e8b099fba75
(Fload): Calculate bytes of filename correctly.
Kenichi Handa <handa@m17n.org>
parents:
25787
diff
changeset
|
888 fn[STRING_BYTES (XSTRING (filename))] = 0; |
16383
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
889 } |
497b37552adb
(openp): Omit /: from start of file name.
Richard M. Stallman <rms@gnu.org>
parents:
16342
diff
changeset
|
890 |
341 | 891 if (lsuffix != 0) /* Bug happens on CCI if lsuffix is 0. */ |
892 strncat (fn, nsuffix, lsuffix); | |
893 | |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
894 /* Check that the file exists and is not a directory. */ |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
895 if (absolute) |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
896 handler = Qnil; |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
897 else |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
898 handler = Ffind_file_name_handler (filename, Qfile_exists_p); |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
899 if (! NILP (handler) && ! exec_only) |
341 | 900 { |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
901 Lisp_Object string; |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
902 int exists; |
341 | 903 |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
904 string = build_string (fn); |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
905 exists = ! NILP (exec_only ? Ffile_executable_p (string) |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
906 : Ffile_readable_p (string)); |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
907 if (exists |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
908 && ! NILP (Ffile_directory_p (build_string (fn)))) |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
909 exists = 0; |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
910 |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
911 if (exists) |
341 | 912 { |
913 /* We succeeded; return this descriptor and filename. */ | |
914 if (storeptr) | |
915 *storeptr = build_string (fn); | |
8906
93f3d6f5753c
(openp): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8828
diff
changeset
|
916 UNGCPRO; |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
917 return 0; |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
918 } |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
919 } |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
920 else |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
921 { |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
922 int exists = (stat (fn, &st) >= 0 |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
923 && (st.st_mode & S_IFMT) != S_IFDIR); |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
924 if (exists) |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
925 { |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
926 /* Check that we can access or open it. */ |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
927 if (exec_only) |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
928 fd = (access (fn, X_OK) == 0) ? 1 : -1; |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
929 else |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
930 fd = emacs_open (fn, O_RDONLY, 0); |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
931 |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
932 if (fd >= 0) |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
933 { |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
934 /* We succeeded; return this descriptor and filename. */ |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
935 if (storeptr) |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
936 *storeptr = build_string (fn); |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
937 UNGCPRO; |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
938 return fd; |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
939 } |
341 | 940 } |
941 } | |
942 | |
943 /* Advance to next suffix. */ | |
944 if (esuffix == 0) | |
945 break; | |
946 nsuffix += lsuffix + 1; | |
947 } | |
6392
58e075552627
(openp, Fload): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6072
diff
changeset
|
948 if (absolute) |
8906
93f3d6f5753c
(openp): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8828
diff
changeset
|
949 break; |
341 | 950 } |
951 | |
8906
93f3d6f5753c
(openp): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8828
diff
changeset
|
952 UNGCPRO; |
93f3d6f5753c
(openp): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8828
diff
changeset
|
953 return -1; |
341 | 954 } |
955 | |
956 | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
957 /* Merge the list we've accumulated of globals from the current input source |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
958 into the load_history variable. The details depend on whether |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
959 the source has an associated file name or not. */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
960 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
961 static void |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
962 build_load_history (stream, source) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
963 FILE *stream; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
964 Lisp_Object source; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
965 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
966 register Lisp_Object tail, prev, newelt; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
967 register Lisp_Object tem, tem2; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
968 register int foundit, loading; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
969 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
970 loading = stream || !NARROWED; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
971 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
972 tail = Vload_history; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
973 prev = Qnil; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
974 foundit = 0; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
975 while (!NILP (tail)) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
976 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
977 tem = Fcar (tail); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
978 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
979 /* Find the feature's previous assoc list... */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
980 if (!NILP (Fequal (source, Fcar (tem)))) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
981 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
982 foundit = 1; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
983 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
984 /* If we're loading, remove it. */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
985 if (loading) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
986 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
987 if (NILP (prev)) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
988 Vload_history = Fcdr (tail); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
989 else |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
990 Fsetcdr (prev, Fcdr (tail)); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
991 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
992 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
993 /* Otherwise, cons on new symbols that are not already members. */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
994 else |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
995 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
996 tem2 = Vcurrent_load_list; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
997 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
998 while (CONSP (tem2)) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
999 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1000 newelt = Fcar (tem2); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1001 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1002 if (NILP (Fmemq (newelt, tem))) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1003 Fsetcar (tail, Fcons (Fcar (tem), |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1004 Fcons (newelt, Fcdr (tem)))); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1005 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1006 tem2 = Fcdr (tem2); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1007 QUIT; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1008 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1009 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1010 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1011 else |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1012 prev = tail; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1013 tail = Fcdr (tail); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1014 QUIT; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1015 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1016 |
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
1017 /* If we're loading, cons the new assoc onto the front of load-history, |
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
1018 the most-recently-loaded position. Also do this if we didn't find |
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
1019 an existing member for the current source. */ |
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
1020 if (loading || !foundit) |
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
1021 Vload_history = Fcons (Fnreverse (Vcurrent_load_list), |
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
1022 Vload_history); |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1023 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1024 |
341 | 1025 Lisp_Object |
1026 unreadpure () /* Used as unwind-protect function in readevalloop */ | |
1027 { | |
1028 read_pure = 0; | |
1029 return Qnil; | |
1030 } | |
1031 | |
21677
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1032 static Lisp_Object |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1033 readevalloop_1 (old) |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1034 Lisp_Object old; |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1035 { |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1036 load_convert_to_unibyte = ! NILP (old); |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1037 return Qnil; |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1038 } |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1039 |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1040 /* UNIBYTE specifies how to set load_convert_to_unibyte |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1041 for this invocation. |
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1042 READFUN, if non-nil, is used instead of `read'. */ |
21677
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1043 |
341 | 1044 static void |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1045 readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte, readfun) |
341 | 1046 Lisp_Object readcharfun; |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1047 FILE *stream; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1048 Lisp_Object sourcename; |
341 | 1049 Lisp_Object (*evalfun) (); |
1050 int printflag; | |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1051 Lisp_Object unibyte, readfun; |
341 | 1052 { |
1053 register int c; | |
1054 register Lisp_Object val; | |
1055 int count = specpdl_ptr - specpdl; | |
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
1056 struct gcpro gcpro1; |
5185
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
1057 struct buffer *b = 0; |
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
1058 |
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
1059 if (BUFFERP (readcharfun)) |
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
1060 b = XBUFFER (readcharfun); |
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
1061 else if (MARKERP (readcharfun)) |
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
1062 b = XMARKER (readcharfun)->buffer; |
341 | 1063 |
1064 specbind (Qstandard_input, readcharfun); | |
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
1065 specbind (Qcurrent_load_list, Qnil); |
21677
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1066 record_unwind_protect (readevalloop_1, load_convert_to_unibyte ? Qt : Qnil); |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1067 load_convert_to_unibyte = !NILP (unibyte); |
341 | 1068 |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
1069 readchar_backlog = -1; |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
1070 |
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
1071 GCPRO1 (sourcename); |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1072 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1073 LOADHIST_ATTACH (sourcename); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1074 |
341 | 1075 while (1) |
1076 { | |
5185
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
1077 if (b != 0 && NILP (b->name)) |
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
1078 error ("Reading from killed buffer"); |
52629d087993
(readevalloop): Get error if buffer being eval'd is killed.
Richard M. Stallman <rms@gnu.org>
parents:
5117
diff
changeset
|
1079 |
341 | 1080 instream = stream; |
1081 c = READCHAR; | |
1082 if (c == ';') | |
1083 { | |
1084 while ((c = READCHAR) != '\n' && c != -1); | |
1085 continue; | |
1086 } | |
1087 if (c < 0) break; | |
10163
70b04b218216
(readevalloop): Ignore ^M here.
Richard M. Stallman <rms@gnu.org>
parents:
10014
diff
changeset
|
1088 |
70b04b218216
(readevalloop): Ignore ^M here.
Richard M. Stallman <rms@gnu.org>
parents:
10014
diff
changeset
|
1089 /* Ignore whitespace here, so we can detect eof. */ |
70b04b218216
(readevalloop): Ignore ^M here.
Richard M. Stallman <rms@gnu.org>
parents:
10014
diff
changeset
|
1090 if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r') |
70b04b218216
(readevalloop): Ignore ^M here.
Richard M. Stallman <rms@gnu.org>
parents:
10014
diff
changeset
|
1091 continue; |
341 | 1092 |
485 | 1093 if (!NILP (Vpurify_flag) && c == '(') |
341 | 1094 { |
8182
94f524e0d5cd
(readevalloop): Correctly unbind the unwind protect.
Richard M. Stallman <rms@gnu.org>
parents:
8083
diff
changeset
|
1095 int count1 = specpdl_ptr - specpdl; |
341 | 1096 record_unwind_protect (unreadpure, Qnil); |
1097 val = read_list (-1, readcharfun); | |
8182
94f524e0d5cd
(readevalloop): Correctly unbind the unwind protect.
Richard M. Stallman <rms@gnu.org>
parents:
8083
diff
changeset
|
1098 unbind_to (count1, Qnil); |
341 | 1099 } |
1100 else | |
1101 { | |
1102 UNREAD (c); | |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1103 read_objects = Qnil; |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1104 if (! NILP (readfun)) |
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1105 val = call1 (readfun, readcharfun); |
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1106 else if (! NILP (Vload_read_function)) |
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1107 val = call1 (Vload_read_function, readcharfun); |
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1108 else |
11079
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
1109 val = read0 (readcharfun); |
341 | 1110 } |
1111 | |
1112 val = (*evalfun) (val); | |
1113 if (printflag) | |
1114 { | |
1115 Vvalues = Fcons (val, Vvalues); | |
1116 if (EQ (Vstandard_output, Qt)) | |
1117 Fprin1 (val, Qnil); | |
1118 else | |
1119 Fprint (val, Qnil); | |
1120 } | |
1121 } | |
1122 | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1123 build_load_history (stream, sourcename); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1124 UNGCPRO; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1125 |
341 | 1126 unbind_to (count, Qnil); |
1127 } | |
1128 | |
25206
f2c7d7fb6198
(Feval_buffer): New arg DO_ALLOW_PRINT.
Richard M. Stallman <rms@gnu.org>
parents:
25165
diff
changeset
|
1129 DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 5, "", |
675
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
1130 "Execute the current buffer as Lisp code.\n\ |
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
1131 Programs can pass two arguments, BUFFER and PRINTFLAG.\n\ |
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
1132 BUFFER is the buffer to evaluate (nil means use current buffer).\n\ |
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
1133 PRINTFLAG controls printing of output:\n\ |
672 | 1134 nil means discard it; anything else is stream for print.\n\ |
1135 \n\ | |
19803
7573e51f9c41
(Feval_buffer): New arg FILENAME.
Richard M. Stallman <rms@gnu.org>
parents:
19626
diff
changeset
|
1136 If the optional third argument FILENAME is non-nil,\n\ |
7573e51f9c41
(Feval_buffer): New arg FILENAME.
Richard M. Stallman <rms@gnu.org>
parents:
19626
diff
changeset
|
1137 it specifies the file name to use for `load-history'.\n\ |
25206
f2c7d7fb6198
(Feval_buffer): New arg DO_ALLOW_PRINT.
Richard M. Stallman <rms@gnu.org>
parents:
25165
diff
changeset
|
1138 The optional fourth argument UNIBYTE specifies `load-convert-to-unibyte'\n\ |
f2c7d7fb6198
(Feval_buffer): New arg DO_ALLOW_PRINT.
Richard M. Stallman <rms@gnu.org>
parents:
25165
diff
changeset
|
1139 for this invocation.\n\ |
f2c7d7fb6198
(Feval_buffer): New arg DO_ALLOW_PRINT.
Richard M. Stallman <rms@gnu.org>
parents:
25165
diff
changeset
|
1140 \n\ |
f2c7d7fb6198
(Feval_buffer): New arg DO_ALLOW_PRINT.
Richard M. Stallman <rms@gnu.org>
parents:
25165
diff
changeset
|
1141 The optional fifth argument DO-ALLOW-PRINT, if not-nil, specifies that\n\ |
f2c7d7fb6198
(Feval_buffer): New arg DO_ALLOW_PRINT.
Richard M. Stallman <rms@gnu.org>
parents:
25165
diff
changeset
|
1142 `print' and related functions should work normally even if PRINTFLAG is nil.\n\ |
19803
7573e51f9c41
(Feval_buffer): New arg FILENAME.
Richard M. Stallman <rms@gnu.org>
parents:
19626
diff
changeset
|
1143 \n\ |
16978
71aff157cff2
(Feval_buffer): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
16937
diff
changeset
|
1144 This function preserves the position of point.") |
25206
f2c7d7fb6198
(Feval_buffer): New arg DO_ALLOW_PRINT.
Richard M. Stallman <rms@gnu.org>
parents:
25165
diff
changeset
|
1145 (buffer, printflag, filename, unibyte, do_allow_print) |
f2c7d7fb6198
(Feval_buffer): New arg DO_ALLOW_PRINT.
Richard M. Stallman <rms@gnu.org>
parents:
25165
diff
changeset
|
1146 Lisp_Object buffer, printflag, filename, unibyte, do_allow_print; |
672 | 1147 { |
1148 int count = specpdl_ptr - specpdl; | |
1149 Lisp_Object tem, buf; | |
1150 | |
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
1151 if (NILP (buffer)) |
672 | 1152 buf = Fcurrent_buffer (); |
1153 else | |
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
1154 buf = Fget_buffer (buffer); |
673 | 1155 if (NILP (buf)) |
19803
7573e51f9c41
(Feval_buffer): New arg FILENAME.
Richard M. Stallman <rms@gnu.org>
parents:
19626
diff
changeset
|
1156 error ("No such buffer"); |
672 | 1157 |
25206
f2c7d7fb6198
(Feval_buffer): New arg DO_ALLOW_PRINT.
Richard M. Stallman <rms@gnu.org>
parents:
25165
diff
changeset
|
1158 if (NILP (printflag) && NILP (do_allow_print)) |
672 | 1159 tem = Qsymbolp; |
1160 else | |
1161 tem = printflag; | |
19803
7573e51f9c41
(Feval_buffer): New arg FILENAME.
Richard M. Stallman <rms@gnu.org>
parents:
19626
diff
changeset
|
1162 |
7573e51f9c41
(Feval_buffer): New arg FILENAME.
Richard M. Stallman <rms@gnu.org>
parents:
19626
diff
changeset
|
1163 if (NILP (filename)) |
7573e51f9c41
(Feval_buffer): New arg FILENAME.
Richard M. Stallman <rms@gnu.org>
parents:
19626
diff
changeset
|
1164 filename = XBUFFER (buf)->filename; |
7573e51f9c41
(Feval_buffer): New arg FILENAME.
Richard M. Stallman <rms@gnu.org>
parents:
19626
diff
changeset
|
1165 |
672 | 1166 specbind (Qstandard_output, tem); |
1167 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
1168 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); | |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1169 readevalloop (buf, 0, filename, Feval, !NILP (printflag), unibyte, Qnil); |
1924
21bd3a2189d3
* keyboard.c (recursive_edit_1, command_loop_1): Pass the proper
Jim Blandy <jimb@redhat.com>
parents:
1887
diff
changeset
|
1170 unbind_to (count, Qnil); |
672 | 1171 |
1172 return Qnil; | |
1173 } | |
1174 | |
1175 #if 0 | |
20024
b0626d6a3f13
Make sure that make-docfile does not see the doc string
Karl Heuer <kwzh@gnu.org>
parents:
19803
diff
changeset
|
1176 XDEFUN ("eval-current-buffer", Feval_current_buffer, Seval_current_buffer, 0, 1, "", |
341 | 1177 "Execute the current buffer as Lisp code.\n\ |
1178 Programs can pass argument PRINTFLAG which controls printing of output:\n\ | |
1179 nil means discard it; anything else is stream for print.\n\ | |
1180 \n\ | |
1181 If there is no error, point does not move. If there is an error,\n\ | |
1182 point remains at the end of the last character read from the buffer.") | |
1183 (printflag) | |
1184 Lisp_Object printflag; | |
1185 { | |
1186 int count = specpdl_ptr - specpdl; | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1187 Lisp_Object tem, cbuf; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1188 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1189 cbuf = Fcurrent_buffer () |
341 | 1190 |
485 | 1191 if (NILP (printflag)) |
341 | 1192 tem = Qsymbolp; |
1193 else | |
1194 tem = printflag; | |
1195 specbind (Qstandard_output, tem); | |
1196 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
1197 SET_PT (BEGV); | |
21677
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1198 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1199 !NILP (printflag), Qnil, Qnil); |
341 | 1200 return unbind_to (count, Qnil); |
1201 } | |
672 | 1202 #endif |
341 | 1203 |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1204 DEFUN ("eval-region", Feval_region, Seval_region, 2, 4, "r", |
341 | 1205 "Execute the region as Lisp code.\n\ |
1206 When called from programs, expects two arguments,\n\ | |
1207 giving starting and ending indices in the current buffer\n\ | |
1208 of the text to be executed.\n\ | |
1209 Programs can pass third argument PRINTFLAG which controls output:\n\ | |
1210 nil means discard it; anything else is stream for printing it.\n\ | |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1211 Also the fourth argument READ-FUNCTION, if non-nil, is used\n\ |
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1212 instead of `read' to read each expression. It gets one argument\n\ |
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1213 which is the input stream for reading characters.\n\ |
341 | 1214 \n\ |
20406
0f0a48a69b88
(Feval_region): Doc correction (point does not move).
Karl Heuer <kwzh@gnu.org>
parents:
20298
diff
changeset
|
1215 This function does not move point.") |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1216 (start, end, printflag, read_function) |
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1217 Lisp_Object start, end, printflag, read_function; |
341 | 1218 { |
1219 int count = specpdl_ptr - specpdl; | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1220 Lisp_Object tem, cbuf; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1221 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1222 cbuf = Fcurrent_buffer (); |
341 | 1223 |
485 | 1224 if (NILP (printflag)) |
341 | 1225 tem = Qsymbolp; |
1226 else | |
1227 tem = printflag; | |
1228 specbind (Qstandard_output, tem); | |
1229 | |
485 | 1230 if (NILP (printflag)) |
341 | 1231 record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
1232 record_unwind_protect (save_restriction_restore, save_restriction_save ()); | |
1233 | |
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
1234 /* This both uses start and checks its type. */ |
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
1235 Fgoto_char (start); |
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
1236 Fnarrow_to_region (make_number (BEGV), end); |
21677
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1237 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, |
22420
cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22321
diff
changeset
|
1238 !NILP (printflag), Qnil, read_function); |
341 | 1239 |
1240 return unbind_to (count, Qnil); | |
1241 } | |
1242 | |
1243 | |
1244 DEFUN ("read", Fread, Sread, 0, 1, 0, | |
1245 "Read one Lisp expression as text from STREAM, return as Lisp object.\n\ | |
1246 If STREAM is nil, use the value of `standard-input' (which see).\n\ | |
1247 STREAM or the value of `standard-input' may be:\n\ | |
1248 a buffer (read from point and advance it)\n\ | |
1249 a marker (read from where it points and advance it)\n\ | |
1250 a function (call it with no arguments for each character,\n\ | |
1251 call it with a char as argument to push a char back)\n\ | |
1252 a string (takes text from string, starting at the beginning)\n\ | |
1253 t (read text line using minibuffer and use it).") | |
12545
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1254 (stream) |
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1255 Lisp_Object stream; |
341 | 1256 { |
1257 extern Lisp_Object Fread_minibuffer (); | |
1258 | |
12545
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1259 if (NILP (stream)) |
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1260 stream = Vstandard_input; |
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1261 if (EQ (stream, Qt)) |
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1262 stream = Qread_char; |
341 | 1263 |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
1264 readchar_backlog = -1; |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1265 new_backquote_flag = 0; |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1266 read_objects = Qnil; |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1267 |
12545
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1268 if (EQ (stream, Qread_char)) |
341 | 1269 return Fread_minibuffer (build_string ("Lisp expression: "), Qnil); |
1270 | |
12545
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1271 if (STRINGP (stream)) |
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1272 return Fcar (Fread_from_string (stream, Qnil, Qnil)); |
341 | 1273 |
12545
ccc20d466150
(Fread): Rename arg READCHARFUN to STREAM.
Karl Heuer <kwzh@gnu.org>
parents:
11955
diff
changeset
|
1274 return read0 (stream); |
341 | 1275 } |
1276 | |
1277 DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0, | |
1278 "Read one Lisp expression which is represented as text by STRING.\n\ | |
1279 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\ | |
1280 START and END optionally delimit a substring of STRING from which to read;\n\ | |
1281 they default to 0 and (length STRING) respectively.") | |
1282 (string, start, end) | |
1283 Lisp_Object string, start, end; | |
1284 { | |
1285 int startval, endval; | |
1286 Lisp_Object tem; | |
1287 | |
1288 CHECK_STRING (string,0); | |
1289 | |
485 | 1290 if (NILP (end)) |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1291 endval = XSTRING (string)->size; |
341 | 1292 else |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
1293 { |
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
1294 CHECK_NUMBER (end, 2); |
21761
7c159e118cd4
(Fread_from_string): Initialize startval and endval.
Richard M. Stallman <rms@gnu.org>
parents:
21759
diff
changeset
|
1295 endval = XINT (end); |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1296 if (endval < 0 || endval > XSTRING (string)->size) |
341 | 1297 args_out_of_range (string, end); |
1298 } | |
1299 | |
485 | 1300 if (NILP (start)) |
341 | 1301 startval = 0; |
1302 else | |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
1303 { |
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
1304 CHECK_NUMBER (start, 1); |
21761
7c159e118cd4
(Fread_from_string): Initialize startval and endval.
Richard M. Stallman <rms@gnu.org>
parents:
21759
diff
changeset
|
1305 startval = XINT (start); |
341 | 1306 if (startval < 0 || startval > endval) |
1307 args_out_of_range (string, start); | |
1308 } | |
1309 | |
1310 read_from_string_index = startval; | |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1311 read_from_string_index_byte = string_char_to_byte (string, startval); |
341 | 1312 read_from_string_limit = endval; |
1313 | |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1314 new_backquote_flag = 0; |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1315 read_objects = Qnil; |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1316 |
341 | 1317 tem = read0 (string); |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1318 return Fcons (tem, make_number (read_from_string_index)); |
341 | 1319 } |
1320 | |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1321 /* Use this for recursive reads, in contexts where internal tokens |
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1322 are not allowed. */ |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
1323 |
341 | 1324 static Lisp_Object |
1325 read0 (readcharfun) | |
1326 Lisp_Object readcharfun; | |
1327 { | |
1328 register Lisp_Object val; | |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
1329 int c; |
341 | 1330 |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1331 val = read1 (readcharfun, &c, 0); |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1332 if (c) |
21211
293254dae80a
(read0): Swap args to Fmake_string.
Richard M. Stallman <rms@gnu.org>
parents:
20815
diff
changeset
|
1333 Fsignal (Qinvalid_read_syntax, Fcons (Fmake_string (make_number (1), |
293254dae80a
(read0): Swap args to Fmake_string.
Richard M. Stallman <rms@gnu.org>
parents:
20815
diff
changeset
|
1334 make_number (c)), |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
1335 Qnil)); |
341 | 1336 |
1337 return val; | |
1338 } | |
1339 | |
1340 static int read_buffer_size; | |
1341 static char *read_buffer; | |
1342 | |
17038 | 1343 /* Read multibyte form and return it as a character. C is a first |
1344 byte of multibyte form, and rest of them are read from | |
1345 READCHARFUN. */ | |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
1346 |
17038 | 1347 static int |
1348 read_multibyte (c, readcharfun) | |
1349 register int c; | |
1350 Lisp_Object readcharfun; | |
1351 { | |
1352 /* We need the actual character code of this multibyte | |
1353 characters. */ | |
26866
305531847450
(readchar): Adjusted for the change of CHAR_STRING.
Kenichi Handa <handa@m17n.org>
parents:
26755
diff
changeset
|
1354 unsigned char str[MAX_MULTIBYTE_LENGTH]; |
17038 | 1355 int len = 0; |
1356 | |
1357 str[len++] = c; | |
1358 while ((c = READCHAR) >= 0xA0 | |
26866
305531847450
(readchar): Adjusted for the change of CHAR_STRING.
Kenichi Handa <handa@m17n.org>
parents:
26755
diff
changeset
|
1359 && len < MAX_MULTIBYTE_LENGTH) |
17038 | 1360 str[len++] = c; |
1361 UNREAD (c); | |
1362 return STRING_CHAR (str, len); | |
1363 } | |
1364 | |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
1365 /* Read a \-escape sequence, assuming we already read the `\'. */ |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
1366 |
341 | 1367 static int |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1368 read_escape (readcharfun, stringp) |
341 | 1369 Lisp_Object readcharfun; |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1370 int stringp; |
341 | 1371 { |
1372 register int c = READCHAR; | |
1373 switch (c) | |
1374 { | |
15091
e05dd165b889
(close_load_descs) [WINDOWS_NT]: Don't actually do anything.
Richard M. Stallman <rms@gnu.org>
parents:
14972
diff
changeset
|
1375 case -1: |
e05dd165b889
(close_load_descs) [WINDOWS_NT]: Don't actually do anything.
Richard M. Stallman <rms@gnu.org>
parents:
14972
diff
changeset
|
1376 error ("End of file"); |
e05dd165b889
(close_load_descs) [WINDOWS_NT]: Don't actually do anything.
Richard M. Stallman <rms@gnu.org>
parents:
14972
diff
changeset
|
1377 |
341 | 1378 case 'a': |
485 | 1379 return '\007'; |
341 | 1380 case 'b': |
1381 return '\b'; | |
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1382 case 'd': |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1383 return 0177; |
341 | 1384 case 'e': |
1385 return 033; | |
1386 case 'f': | |
1387 return '\f'; | |
1388 case 'n': | |
1389 return '\n'; | |
1390 case 'r': | |
1391 return '\r'; | |
1392 case 't': | |
1393 return '\t'; | |
1394 case 'v': | |
1395 return '\v'; | |
1396 case '\n': | |
1397 return -1; | |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
1398 case ' ': |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1399 if (stringp) |
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1400 return -1; |
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1401 return ' '; |
341 | 1402 |
1403 case 'M': | |
1404 c = READCHAR; | |
1405 if (c != '-') | |
1406 error ("Invalid escape character syntax"); | |
1407 c = READCHAR; | |
1408 if (c == '\\') | |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1409 c = read_escape (readcharfun, 0); |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1410 return c | meta_modifier; |
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1411 |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1412 case 'S': |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1413 c = READCHAR; |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1414 if (c != '-') |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1415 error ("Invalid escape character syntax"); |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1416 c = READCHAR; |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1417 if (c == '\\') |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1418 c = read_escape (readcharfun, 0); |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1419 return c | shift_modifier; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1420 |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1421 case 'H': |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1422 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1423 if (c != '-') |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1424 error ("Invalid escape character syntax"); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1425 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1426 if (c == '\\') |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1427 c = read_escape (readcharfun, 0); |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1428 return c | hyper_modifier; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1429 |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1430 case 'A': |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1431 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1432 if (c != '-') |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1433 error ("Invalid escape character syntax"); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1434 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1435 if (c == '\\') |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1436 c = read_escape (readcharfun, 0); |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1437 return c | alt_modifier; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1438 |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1439 case 's': |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1440 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1441 if (c != '-') |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1442 error ("Invalid escape character syntax"); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1443 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1444 if (c == '\\') |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1445 c = read_escape (readcharfun, 0); |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1446 return c | super_modifier; |
341 | 1447 |
1448 case 'C': | |
1449 c = READCHAR; | |
1450 if (c != '-') | |
1451 error ("Invalid escape character syntax"); | |
1452 case '^': | |
1453 c = READCHAR; | |
1454 if (c == '\\') | |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1455 c = read_escape (readcharfun, 0); |
25251
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1456 if ((c & ~CHAR_MODIFIER_MASK) == '?') |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1457 return 0177 | (c & CHAR_MODIFIER_MASK); |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1458 else if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1459 return c | ctrl_modifier; |
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1460 /* ASCII control chars are made from letters (both cases), |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1461 as well as the non-letters within 0100...0137. */ |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1462 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132) |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1463 return (c & (037 | ~0177)); |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1464 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137) |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1465 return (c & (037 | ~0177)); |
341 | 1466 else |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1467 return c | ctrl_modifier; |
341 | 1468 |
1469 case '0': | |
1470 case '1': | |
1471 case '2': | |
1472 case '3': | |
1473 case '4': | |
1474 case '5': | |
1475 case '6': | |
1476 case '7': | |
1477 /* An octal escape, as in ANSI C. */ | |
1478 { | |
1479 register int i = c - '0'; | |
1480 register int count = 0; | |
1481 while (++count < 3) | |
1482 { | |
1483 if ((c = READCHAR) >= '0' && c <= '7') | |
1484 { | |
1485 i *= 8; | |
1486 i += c - '0'; | |
1487 } | |
1488 else | |
1489 { | |
1490 UNREAD (c); | |
1491 break; | |
1492 } | |
1493 } | |
1494 return i; | |
1495 } | |
1496 | |
1497 case 'x': | |
1498 /* A hex escape, as in ANSI C. */ | |
1499 { | |
1500 int i = 0; | |
1501 while (1) | |
1502 { | |
1503 c = READCHAR; | |
1504 if (c >= '0' && c <= '9') | |
1505 { | |
1506 i *= 16; | |
1507 i += c - '0'; | |
1508 } | |
1509 else if ((c >= 'a' && c <= 'f') | |
1510 || (c >= 'A' && c <= 'F')) | |
1511 { | |
1512 i *= 16; | |
1513 if (c >= 'a' && c <= 'f') | |
1514 i += c - 'a' + 10; | |
1515 else | |
1516 i += c - 'A' + 10; | |
1517 } | |
1518 else | |
1519 { | |
1520 UNREAD (c); | |
1521 break; | |
1522 } | |
1523 } | |
1524 return i; | |
1525 } | |
1526 | |
1527 default: | |
17038 | 1528 if (BASE_LEADING_CODE_P (c)) |
1529 c = read_multibyte (c, readcharfun); | |
341 | 1530 return c; |
1531 } | |
1532 } | |
1533 | |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1534 /* If the next token is ')' or ']' or '.', we store that character |
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1535 in *PCH and the return value is not interesting. Else, we store |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1536 zero in *PCH and we read and return one lisp object. |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1537 |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1538 FIRST_IN_LIST is nonzero if this is the first element of a list. */ |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1539 |
341 | 1540 static Lisp_Object |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1541 read1 (readcharfun, pch, first_in_list) |
341 | 1542 register Lisp_Object readcharfun; |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
1543 int *pch; |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1544 int first_in_list; |
341 | 1545 { |
1546 register int c; | |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1547 int uninterned_symbol = 0; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1548 |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1549 *pch = 0; |
341 | 1550 |
1551 retry: | |
1552 | |
1553 c = READCHAR; | |
1554 if (c < 0) return Fsignal (Qend_of_file, Qnil); | |
1555 | |
1556 switch (c) | |
1557 { | |
1558 case '(': | |
1559 return read_list (0, readcharfun); | |
1560 | |
1561 case '[': | |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1562 return read_vector (readcharfun, 0); |
341 | 1563 |
1564 case ')': | |
1565 case ']': | |
1566 { | |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1567 *pch = c; |
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1568 return Qnil; |
341 | 1569 } |
1570 | |
1571 case '#': | |
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1572 c = READCHAR; |
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1573 if (c == '^') |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1574 { |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1575 c = READCHAR; |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1576 if (c == '[') |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1577 { |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1578 Lisp_Object tmp; |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1579 tmp = read_vector (readcharfun, 0); |
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1580 if (XVECTOR (tmp)->size < CHAR_TABLE_STANDARD_SLOTS |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1581 || XVECTOR (tmp)->size > CHAR_TABLE_STANDARD_SLOTS + 10) |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1582 error ("Invalid size char-table"); |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1583 XSETCHAR_TABLE (tmp, XCHAR_TABLE (tmp)); |
17325
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1584 XCHAR_TABLE (tmp)->top = Qt; |
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1585 return tmp; |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1586 } |
17325
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1587 else if (c == '^') |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1588 { |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1589 c = READCHAR; |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1590 if (c == '[') |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1591 { |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1592 Lisp_Object tmp; |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1593 tmp = read_vector (readcharfun, 0); |
17325
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1594 if (XVECTOR (tmp)->size != SUB_CHAR_TABLE_STANDARD_SLOTS) |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1595 error ("Invalid size char-table"); |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1596 XSETCHAR_TABLE (tmp, XCHAR_TABLE (tmp)); |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1597 XCHAR_TABLE (tmp)->top = Qnil; |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1598 return tmp; |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1599 } |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1600 Fsignal (Qinvalid_read_syntax, |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1601 Fcons (make_string ("#^^", 3), Qnil)); |
c19c552c486f
(read1): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents:
17125
diff
changeset
|
1602 } |
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1603 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#^", 2), Qnil)); |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1604 } |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1605 if (c == '&') |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1606 { |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1607 Lisp_Object length; |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1608 length = read1 (readcharfun, pch, first_in_list); |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1609 c = READCHAR; |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1610 if (c == '"') |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1611 { |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1612 Lisp_Object tmp, val; |
16925
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1613 int size_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1) |
13363
941c37982f37
(BITS_PER_SHORT, BITS_PER_INT, BITS_PER_LONG):
Karl Heuer <kwzh@gnu.org>
parents:
13235
diff
changeset
|
1614 / BITS_PER_CHAR); |
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1615 |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1616 UNREAD (c); |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1617 tmp = read1 (readcharfun, pch, first_in_list); |
16925
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1618 if (size_in_chars != XSTRING (tmp)->size |
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1619 /* We used to print 1 char too many |
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1620 when the number of bits was a multiple of 8. |
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1621 Accept such input in case it came from an old version. */ |
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1622 && ! (XFASTINT (length) |
2b35e4ccbb32
(read1): Round size of bool-vector properly.
Richard M. Stallman <rms@gnu.org>
parents:
16856
diff
changeset
|
1623 == (XSTRING (tmp)->size - 1) * BITS_PER_CHAR)) |
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1624 Fsignal (Qinvalid_read_syntax, |
16856 | 1625 Fcons (make_string ("#&...", 5), Qnil)); |
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1626 |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1627 val = Fmake_bool_vector (length, Qnil); |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1628 bcopy (XSTRING (tmp)->data, XBOOL_VECTOR (val)->data, |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1629 size_in_chars); |
21935
8dad06385435
(read1): Clear out extraneous bits at end of bool-vector.
Eli Zaretskii <eliz@gnu.org>
parents:
21911
diff
changeset
|
1630 /* Clear the extraneous bits in the last byte. */ |
8dad06385435
(read1): Clear out extraneous bits at end of bool-vector.
Eli Zaretskii <eliz@gnu.org>
parents:
21911
diff
changeset
|
1631 if (XINT (length) != size_in_chars * BITS_PER_CHAR) |
8dad06385435
(read1): Clear out extraneous bits at end of bool-vector.
Eli Zaretskii <eliz@gnu.org>
parents:
21911
diff
changeset
|
1632 XBOOL_VECTOR (val)->data[size_in_chars - 1] |
8dad06385435
(read1): Clear out extraneous bits at end of bool-vector.
Eli Zaretskii <eliz@gnu.org>
parents:
21911
diff
changeset
|
1633 &= (1 << (XINT (length) % BITS_PER_CHAR)) - 1; |
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1634 return val; |
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1635 } |
16856 | 1636 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#&...", 5), |
16855
d10bb3a79eff
(read1): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
16487
diff
changeset
|
1637 Qnil)); |
13146
6182d95acd14
(read1): Handle chartables and boolvectors.
Richard M. Stallman <rms@gnu.org>
parents:
13036
diff
changeset
|
1638 } |
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1639 if (c == '[') |
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1640 { |
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1641 /* Accept compiled functions at read-time so that we don't have to |
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1642 build them using function calls. */ |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1643 Lisp_Object tmp; |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1644 tmp = read_vector (readcharfun, 1); |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1645 return Fmake_byte_code (XVECTOR (tmp)->size, |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1646 XVECTOR (tmp)->contents); |
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1647 } |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1648 if (c == '(') |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1649 { |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1650 Lisp_Object tmp; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1651 struct gcpro gcpro1; |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
1652 int ch; |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1653 |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1654 /* Read the string itself. */ |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1655 tmp = read1 (readcharfun, &ch, 0); |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1656 if (ch != 0 || !STRINGP (tmp)) |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1657 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1658 GCPRO1 (tmp); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1659 /* Read the intervals and their properties. */ |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1660 while (1) |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1661 { |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1662 Lisp_Object beg, end, plist; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1663 |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1664 beg = read1 (readcharfun, &ch, 0); |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1665 if (ch == ')') |
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1666 break; |
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1667 if (ch == 0) |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1668 end = read1 (readcharfun, &ch, 0); |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1669 if (ch == 0) |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1670 plist = read1 (readcharfun, &ch, 0); |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1671 if (ch) |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1672 Fsignal (Qinvalid_read_syntax, |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1673 Fcons (build_string ("invalid string property list"), |
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
1674 Qnil)); |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1675 Fset_text_properties (beg, end, plist, tmp); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1676 } |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1677 UNGCPRO; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1678 return tmp; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1679 } |
26404
c3c9cc1c2379
Remove USE_TEXT_PROPERTIES.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
1680 |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1681 /* #@NUMBER is used to skip NUMBER following characters. |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1682 That's used in .elc files to skip over doc strings |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1683 and function definitions. */ |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1684 if (c == '@') |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1685 { |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1686 int i, nskip = 0; |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1687 |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1688 /* Read a decimal integer. */ |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1689 while ((c = READCHAR) >= 0 |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1690 && c >= '0' && c <= '9') |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1691 { |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1692 nskip *= 10; |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1693 nskip += c - '0'; |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1694 } |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1695 if (c >= 0) |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1696 UNREAD (c); |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1697 |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1698 if (load_force_doc_strings && EQ (readcharfun, Qget_file_char)) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1699 { |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1700 /* If we are supposed to force doc strings into core right now, |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1701 record the last string that we skipped, |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1702 and record where in the file it comes from. */ |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1703 |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1704 /* But first exchange saved_doc_string |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1705 with prev_saved_doc_string, so we save two strings. */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1706 { |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1707 char *temp = saved_doc_string; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1708 int temp_size = saved_doc_string_size; |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
1709 file_offset temp_pos = saved_doc_string_position; |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1710 int temp_len = saved_doc_string_length; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1711 |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1712 saved_doc_string = prev_saved_doc_string; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1713 saved_doc_string_size = prev_saved_doc_string_size; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1714 saved_doc_string_position = prev_saved_doc_string_position; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1715 saved_doc_string_length = prev_saved_doc_string_length; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1716 |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1717 prev_saved_doc_string = temp; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1718 prev_saved_doc_string_size = temp_size; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1719 prev_saved_doc_string_position = temp_pos; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1720 prev_saved_doc_string_length = temp_len; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1721 } |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
1722 |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1723 if (saved_doc_string_size == 0) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1724 { |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1725 saved_doc_string_size = nskip + 100; |
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
1726 saved_doc_string = (char *) xmalloc (saved_doc_string_size); |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1727 } |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1728 if (nskip > saved_doc_string_size) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1729 { |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1730 saved_doc_string_size = nskip + 100; |
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
1731 saved_doc_string = (char *) xrealloc (saved_doc_string, |
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
1732 saved_doc_string_size); |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1733 } |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1734 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26072
diff
changeset
|
1735 saved_doc_string_position = file_tell (instream); |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1736 |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1737 /* Copy that many characters into saved_doc_string. */ |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1738 for (i = 0; i < nskip && c >= 0; i++) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1739 saved_doc_string[i] = c = READCHAR; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1740 |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1741 saved_doc_string_length = i; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1742 } |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1743 else |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1744 { |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1745 /* Skip that many characters. */ |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1746 for (i = 0; i < nskip && c >= 0; i++) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1747 c = READCHAR; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
1748 } |
20048
5324d8b2322b
(read_list): Don't recognize Vload_file_name
Karl Heuer <kwzh@gnu.org>
parents:
20024
diff
changeset
|
1749 |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1750 goto retry; |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1751 } |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1752 if (c == '$') |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1753 return Vload_file_name; |
13235
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
1754 if (c == '\'') |
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
1755 return Fcons (Qfunction, Fcons (read0 (readcharfun), Qnil)); |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1756 /* #:foo is the uninterned symbol named foo. */ |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1757 if (c == ':') |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1758 { |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1759 uninterned_symbol = 1; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1760 c = READCHAR; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1761 goto default_label; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1762 } |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1763 /* Reader forms that can reuse previously read objects. */ |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1764 if (c >= '0' && c <= '9') |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1765 { |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1766 int n = 0; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1767 Lisp_Object tem; |
13235
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
1768 |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1769 /* Read a non-negative integer. */ |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1770 while (c >= '0' && c <= '9') |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1771 { |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1772 n *= 10; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1773 n += c - '0'; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1774 c = READCHAR; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1775 } |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1776 /* #n=object returns object, but associates it with n for #n#. */ |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1777 if (c == '=') |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1778 { |
25165
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1779 /* Make a placeholder for #n# to use temporarily */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1780 Lisp_Object placeholder; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1781 Lisp_Object cell; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1782 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1783 placeholder = Fcons(Qnil, Qnil); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1784 cell = Fcons (make_number (n), placeholder); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1785 read_objects = Fcons (cell, read_objects); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1786 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1787 /* Read the object itself. */ |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1788 tem = read0 (readcharfun); |
25165
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1789 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1790 /* Now put it everywhere the placeholder was... */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1791 substitute_object_in_subtree (tem, placeholder); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1792 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1793 /* ...and #n# will use the real value from now on. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1794 Fsetcdr (cell, tem); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
1795 |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1796 return tem; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1797 } |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1798 /* #n# returns a previously read object. */ |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1799 if (c == '#') |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1800 { |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1801 tem = Fassq (make_number (n), read_objects); |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1802 if (CONSP (tem)) |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1803 return XCDR (tem); |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1804 /* Fall through to error message. */ |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1805 } |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1806 /* Fall through to error message. */ |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
1807 } |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
1808 |
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1809 UNREAD (c); |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1810 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); |
341 | 1811 |
1812 case ';': | |
1813 while ((c = READCHAR) >= 0 && c != '\n'); | |
1814 goto retry; | |
1815 | |
1816 case '\'': | |
1817 { | |
1818 return Fcons (Qquote, Fcons (read0 (readcharfun), Qnil)); | |
1819 } | |
1820 | |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1821 case '`': |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1822 if (first_in_list) |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1823 goto default_label; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1824 else |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1825 { |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1826 Lisp_Object value; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1827 |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1828 new_backquote_flag = 1; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1829 value = read0 (readcharfun); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1830 new_backquote_flag = 0; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1831 |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1832 return Fcons (Qbackquote, Fcons (value, Qnil)); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1833 } |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1834 |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1835 case ',': |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1836 if (new_backquote_flag) |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1837 { |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1838 Lisp_Object comma_type = Qnil; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1839 Lisp_Object value; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1840 int ch = READCHAR; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1841 |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1842 if (ch == '@') |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1843 comma_type = Qcomma_at; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1844 else if (ch == '.') |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1845 comma_type = Qcomma_dot; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1846 else |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1847 { |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1848 if (ch >= 0) UNREAD (ch); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1849 comma_type = Qcomma; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1850 } |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1851 |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1852 new_backquote_flag = 0; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1853 value = read0 (readcharfun); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1854 new_backquote_flag = 1; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1855 return Fcons (comma_type, Fcons (value, Qnil)); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1856 } |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1857 else |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1858 goto default_label; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
1859 |
341 | 1860 case '?': |
1861 { | |
1862 c = READCHAR; | |
1863 if (c < 0) return Fsignal (Qend_of_file, Qnil); | |
1864 | |
1865 if (c == '\\') | |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1866 c = read_escape (readcharfun, 0); |
17038 | 1867 else if (BASE_LEADING_CODE_P (c)) |
1868 c = read_multibyte (c, readcharfun); | |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
1869 |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
1870 return make_number (c); |
341 | 1871 } |
1872 | |
22103
cbec85828fad
(readchar): Use readchar_backlog again
Richard M. Stallman <rms@gnu.org>
parents:
21982
diff
changeset
|
1873 case '"': |
341 | 1874 { |
1875 register char *p = read_buffer; | |
1876 register char *end = read_buffer + read_buffer_size; | |
1877 register int c; | |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1878 /* Nonzero if we saw an escape sequence specifying |
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1879 a multibyte character. */ |
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1880 int force_multibyte = 0; |
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1881 /* Nonzero if we saw an escape sequence specifying |
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1882 a single-byte character. */ |
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1883 int force_singlebyte = 0; |
341 | 1884 int cancel = 0; |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1885 int nchars; |
341 | 1886 |
1887 while ((c = READCHAR) >= 0 | |
1888 && c != '\"') | |
1889 { | |
26866
305531847450
(readchar): Adjusted for the change of CHAR_STRING.
Kenichi Handa <handa@m17n.org>
parents:
26755
diff
changeset
|
1890 if (end - p < MAX_MULTIBYTE_LENGTH) |
341 | 1891 { |
1892 char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | |
1893 p += new - read_buffer; | |
1894 read_buffer += new - read_buffer; | |
1895 end = read_buffer + read_buffer_size; | |
1896 } | |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1897 |
341 | 1898 if (c == '\\') |
19240
c962562027d4
(read1): Handle read_escape making a multibyte character.
Richard M. Stallman <rms@gnu.org>
parents:
19115
diff
changeset
|
1899 { |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1900 c = read_escape (readcharfun, 1); |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1901 |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1902 /* C is -1 if \ newline has just been seen */ |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1903 if (c == -1) |
19240
c962562027d4
(read1): Handle read_escape making a multibyte character.
Richard M. Stallman <rms@gnu.org>
parents:
19115
diff
changeset
|
1904 { |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1905 if (p == read_buffer) |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1906 cancel = 1; |
19240
c962562027d4
(read1): Handle read_escape making a multibyte character.
Richard M. Stallman <rms@gnu.org>
parents:
19115
diff
changeset
|
1907 continue; |
c962562027d4
(read1): Handle read_escape making a multibyte character.
Richard M. Stallman <rms@gnu.org>
parents:
19115
diff
changeset
|
1908 } |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1909 |
21677
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1910 /* If an escape specifies a non-ASCII single-byte character, |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1911 this must be a unibyte string. */ |
25251
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1912 if (SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)) |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1913 && ! ASCII_BYTE_P ((c & ~CHAR_MODIFIER_MASK))) |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1914 force_singlebyte = 1; |
19240
c962562027d4
(read1): Handle read_escape making a multibyte character.
Richard M. Stallman <rms@gnu.org>
parents:
19115
diff
changeset
|
1915 } |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
1916 |
25251
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1917 if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) |
341 | 1918 { |
25251
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1919 /* Any modifiers for a multibyte character are invalid. */ |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1920 if (c & CHAR_MODIFIER_MASK) |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1921 error ("Invalid modifier in string"); |
26866
305531847450
(readchar): Adjusted for the change of CHAR_STRING.
Kenichi Handa <handa@m17n.org>
parents:
26755
diff
changeset
|
1922 p += CHAR_STRING (c, p); |
305531847450
(readchar): Adjusted for the change of CHAR_STRING.
Kenichi Handa <handa@m17n.org>
parents:
26755
diff
changeset
|
1923 force_multibyte = 1; |
341 | 1924 } |
1925 else | |
6470
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1926 { |
7144
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1927 /* Allow `\C- ' and `\C-?'. */ |
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1928 if (c == (CHAR_CTL | ' ')) |
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1929 c = 0; |
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1930 else if (c == (CHAR_CTL | '?')) |
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1931 c = 127; |
cf47c0c11bda
(read1): Allow `\C- ' and `\C-?'.
Richard M. Stallman <rms@gnu.org>
parents:
7106
diff
changeset
|
1932 |
25251
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1933 if (c & CHAR_SHIFT) |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1934 { |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1935 /* Shift modifier is valid only with [A-Za-z]. */ |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1936 if ((c & 0377) >= 'A' && (c & 0377) <= 'Z') |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1937 c &= ~CHAR_SHIFT; |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1938 else if ((c & 0377) >= 'a' && (c & 0377) <= 'z') |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1939 c = (c & ~CHAR_SHIFT) - ('a' - 'A'); |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1940 } |
1fb18e7e3f35
(read_escape): For Control modifier, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
25206
diff
changeset
|
1941 |
6470
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1942 if (c & CHAR_META) |
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1943 /* Move the meta bit to the right place for a string. */ |
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1944 c = (c & ~CHAR_META) | 0x80; |
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1945 if (c & ~0xff) |
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1946 error ("Invalid modifier in string"); |
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1947 *p++ = c; |
651b49e52c9e
(read1): Check for invalid modifier bits in a string.
Karl Heuer <kwzh@gnu.org>
parents:
6392
diff
changeset
|
1948 } |
341 | 1949 } |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
1950 if (c < 0) |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
1951 return Fsignal (Qend_of_file, Qnil); |
341 | 1952 |
1953 /* If purifying, and string starts with \ newline, | |
1954 return zero instead. This is for doc strings | |
604 | 1955 that we are really going to find in etc/DOC.nn.nn */ |
485 | 1956 if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel) |
341 | 1957 return make_number (0); |
1958 | |
21759
53f1e474e639
(read1): Allow multibyte and unibyte together in one string.
Richard M. Stallman <rms@gnu.org>
parents:
21736
diff
changeset
|
1959 if (force_multibyte) |
53f1e474e639
(read1): Allow multibyte and unibyte together in one string.
Richard M. Stallman <rms@gnu.org>
parents:
21736
diff
changeset
|
1960 nchars = multibyte_chars_in_text (read_buffer, p - read_buffer); |
53f1e474e639
(read1): Allow multibyte and unibyte together in one string.
Richard M. Stallman <rms@gnu.org>
parents:
21736
diff
changeset
|
1961 else if (force_singlebyte) |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1962 nchars = p - read_buffer; |
21677
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1963 else if (load_convert_to_unibyte) |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1964 { |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1965 Lisp_Object string; |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1966 nchars = multibyte_chars_in_text (read_buffer, p - read_buffer); |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1967 if (p - read_buffer != nchars) |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1968 { |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1969 string = make_multibyte_string (read_buffer, nchars, |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1970 p - read_buffer); |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1971 return Fstring_make_unibyte (string); |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1972 } |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
1973 } |
22889
beddbcd21407
(read1): In reading a string, treat Qlambda like Qget_file_char.
Richard M. Stallman <rms@gnu.org>
parents:
22691
diff
changeset
|
1974 else if (EQ (readcharfun, Qget_file_char) |
beddbcd21407
(read1): In reading a string, treat Qlambda like Qget_file_char.
Richard M. Stallman <rms@gnu.org>
parents:
22691
diff
changeset
|
1975 || EQ (readcharfun, Qlambda)) |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1976 /* Nowadays, reading directly from a file |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1977 is used only for compiled Emacs Lisp files, |
22889
beddbcd21407
(read1): In reading a string, treat Qlambda like Qget_file_char.
Richard M. Stallman <rms@gnu.org>
parents:
22691
diff
changeset
|
1978 and those always use the Emacs internal encoding. |
beddbcd21407
(read1): In reading a string, treat Qlambda like Qget_file_char.
Richard M. Stallman <rms@gnu.org>
parents:
22691
diff
changeset
|
1979 Meanwhile, Qlambda is used for reading dynamic byte code |
beddbcd21407
(read1): In reading a string, treat Qlambda like Qget_file_char.
Richard M. Stallman <rms@gnu.org>
parents:
22691
diff
changeset
|
1980 (compiled with byte-compile-dynamic = t). */ |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1981 nchars = multibyte_chars_in_text (read_buffer, p - read_buffer); |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1982 else |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1983 /* In all other cases, if we read these bytes as |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
1984 separate characters, treat them as separate characters now. */ |
20669
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1985 nchars = p - read_buffer; |
fa76057543dd
(read1): Escape codes can force multibyte or single-byte.
Karl Heuer <kwzh@gnu.org>
parents:
20609
diff
changeset
|
1986 |
341 | 1987 if (read_pure) |
21251
05fbf4f5b14f
(read1): Pass new arg to make_pure_string.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
1988 return make_pure_string (read_buffer, nchars, p - read_buffer, |
05fbf4f5b14f
(read1): Pass new arg to make_pure_string.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
1989 (force_multibyte |
05fbf4f5b14f
(read1): Pass new arg to make_pure_string.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
1990 || (p - read_buffer != nchars))); |
05fbf4f5b14f
(read1): Pass new arg to make_pure_string.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
1991 return make_specified_string (read_buffer, nchars, p - read_buffer, |
05fbf4f5b14f
(read1): Pass new arg to make_pure_string.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
1992 (force_multibyte |
05fbf4f5b14f
(read1): Pass new arg to make_pure_string.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
1993 || (p - read_buffer != nchars))); |
341 | 1994 } |
1995 | |
762 | 1996 case '.': |
1997 { | |
1998 /* If a period is followed by a number, then we should read it | |
1999 as a floating point number. Otherwise, it denotes a dotted | |
2000 pair. */ | |
2001 int next_char = READCHAR; | |
2002 UNREAD (next_char); | |
2003 | |
9871 | 2004 if (! (next_char >= '0' && next_char <= '9')) |
762 | 2005 { |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
2006 *pch = c; |
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
2007 return Qnil; |
762 | 2008 } |
2009 | |
2010 /* Otherwise, we fall through! Note that the atom-reading loop | |
2011 below will now loop at least once, assuring that we will not | |
2012 try to UNREAD two characters in a row. */ | |
2013 } | |
341 | 2014 default: |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2015 default_label: |
341 | 2016 if (c <= 040) goto retry; |
2017 { | |
2018 register char *p = read_buffer; | |
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2019 int quoted = 0; |
341 | 2020 |
2021 { | |
2022 register char *end = read_buffer + read_buffer_size; | |
2023 | |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
2024 while (c > 040 |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
2025 && !(c == '\"' || c == '\'' || c == ';' || c == '?' |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
2026 || c == '(' || c == ')' |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
2027 || c == '[' || c == ']' || c == '#' |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
2028 )) |
341 | 2029 { |
26866
305531847450
(readchar): Adjusted for the change of CHAR_STRING.
Kenichi Handa <handa@m17n.org>
parents:
26755
diff
changeset
|
2030 if (end - p < MAX_MULTIBYTE_LENGTH) |
341 | 2031 { |
2032 register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | |
2033 p += new - read_buffer; | |
2034 read_buffer += new - read_buffer; | |
2035 end = read_buffer + read_buffer_size; | |
2036 } | |
2037 if (c == '\\') | |
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2038 { |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2039 c = READCHAR; |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2040 quoted = 1; |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2041 } |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
2042 |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
2043 if (! SINGLE_BYTE_CHAR_P (c)) |
26866
305531847450
(readchar): Adjusted for the change of CHAR_STRING.
Kenichi Handa <handa@m17n.org>
parents:
26755
diff
changeset
|
2044 p += CHAR_STRING (c, p); |
21724
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
2045 else |
12a826a37249
(read_from_string_index_byte): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21677
diff
changeset
|
2046 *p++ = c; |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
2047 |
341 | 2048 c = READCHAR; |
2049 } | |
2050 | |
2051 if (p == end) | |
2052 { | |
2053 char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | |
2054 p += new - read_buffer; | |
2055 read_buffer += new - read_buffer; | |
2056 /* end = read_buffer + read_buffer_size; */ | |
2057 } | |
2058 *p = 0; | |
2059 if (c >= 0) | |
2060 UNREAD (c); | |
2061 } | |
2062 | |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2063 if (!quoted && !uninterned_symbol) |
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2064 { |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2065 register char *p1; |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2066 register Lisp_Object val; |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2067 p1 = read_buffer; |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2068 if (*p1 == '+' || *p1 == '-') p1++; |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2069 /* Is it an integer? */ |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2070 if (p1 != p) |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2071 { |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2072 while (p1 != p && (c = *p1) >= '0' && c <= '9') p1++; |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2073 /* Integers can have trailing decimal points. */ |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2074 if (p1 > read_buffer && p1 < p && *p1 == '.') p1++; |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2075 if (p1 == p) |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2076 /* It is an integer. */ |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2077 { |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2078 if (p1[-1] == '.') |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2079 p1[-1] = '\0'; |
11699
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
2080 if (sizeof (int) == sizeof (EMACS_INT)) |
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
2081 XSETINT (val, atoi (read_buffer)); |
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
2082 else if (sizeof (long) == sizeof (EMACS_INT)) |
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
2083 XSETINT (val, atol (read_buffer)); |
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
2084 else |
eb4b842ee557
(read1): Handle long EMACS_INT in atol.
Richard M. Stallman <rms@gnu.org>
parents:
11683
diff
changeset
|
2085 abort (); |
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2086 return val; |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2087 } |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2088 } |
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2089 if (isfloat_string (read_buffer)) |
20815
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2090 { |
23159
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2091 /* Compute NaN and infinities using 0.0 in a variable, |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2092 to cope with compilers that think they are smarter |
23193
c12a3c0be4ee
(Fload): Handle case where openp finds a magic file
Karl Heuer <kwzh@gnu.org>
parents:
23159
diff
changeset
|
2093 than we are. */ |
21636
10d8ced94467
(read1): Compute NaN and infinities using 0.0 in a
Richard M. Stallman <rms@gnu.org>
parents:
21635
diff
changeset
|
2094 double zero = 0.0; |
23159
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2095 |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2096 double value; |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2097 |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2098 /* Negate the value ourselves. This treats 0, NaNs, |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2099 and infinity properly on IEEE floating point hosts, |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2100 and works around a common bug where atof ("-0.0") |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2101 drops the sign. */ |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2102 int negative = read_buffer[0] == '-'; |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2103 |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2104 /* The only way p[-1] can be 'F' or 'N', after isfloat_string |
20815
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2105 returns 1, is if the input ends in e+INF or e+NaN. */ |
23159
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2106 switch (p[-1]) |
20815
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2107 { |
23159
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2108 case 'F': |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2109 value = 1.0 / zero; |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2110 break; |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2111 case 'N': |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2112 value = zero / zero; |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2113 break; |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2114 default: |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2115 value = atof (read_buffer + negative); |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2116 break; |
20815
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2117 } |
23159
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2118 |
b468525b44b8
(read1): Don't assume that atof ("-0.0") yields -0.0.
Paul Eggert <eggert@twinsun.com>
parents:
23056
diff
changeset
|
2119 return make_float (negative ? - value : value); |
20815
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2120 } |
5017
9c277d938ccd
(read1): If token has a \, don't treat it as a number.
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
2121 } |
341 | 2122 |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2123 if (uninterned_symbol) |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2124 return make_symbol (read_buffer); |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2125 else |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2126 return intern (read_buffer); |
341 | 2127 } |
2128 } | |
2129 } | |
2130 | |
25165
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2131 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2132 /* List of nodes we've seen during substitute_object_in_subtree. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2133 static Lisp_Object seen_list; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2134 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2135 static void |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2136 substitute_object_in_subtree (object, placeholder) |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2137 Lisp_Object object; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2138 Lisp_Object placeholder; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2139 { |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2140 Lisp_Object check_object; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2141 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2142 /* We haven't seen any objects when we start. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2143 seen_list = Qnil; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2144 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2145 /* Make all the substitutions. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2146 check_object |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2147 = substitute_object_recurse (object, placeholder, object); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2148 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2149 /* Clear seen_list because we're done with it. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2150 seen_list = Qnil; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2151 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2152 /* The returned object here is expected to always eq the |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2153 original. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2154 if (!EQ (check_object, object)) |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2155 error ("Unexpected mutation error in reader"); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2156 } |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2157 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2158 /* Feval doesn't get called from here, so no gc protection is needed. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2159 #define SUBSTITUTE(get_val, set_val) \ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2160 { \ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2161 Lisp_Object old_value = get_val; \ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2162 Lisp_Object true_value \ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2163 = substitute_object_recurse (object, placeholder,\ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2164 old_value); \ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2165 \ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2166 if (!EQ (old_value, true_value)) \ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2167 { \ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2168 set_val; \ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2169 } \ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2170 } |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2171 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2172 static Lisp_Object |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2173 substitute_object_recurse (object, placeholder, subtree) |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2174 Lisp_Object object; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2175 Lisp_Object placeholder; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2176 Lisp_Object subtree; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2177 { |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2178 /* If we find the placeholder, return the target object. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2179 if (EQ (placeholder, subtree)) |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2180 return object; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2181 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2182 /* If we've been to this node before, don't explore it again. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2183 if (!EQ (Qnil, Fmemq (subtree, seen_list))) |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2184 return subtree; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2185 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2186 /* If this node can be the entry point to a cycle, remember that |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2187 we've seen it. It can only be such an entry point if it was made |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2188 by #n=, which means that we can find it as a value in |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2189 read_objects. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2190 if (!EQ (Qnil, Frassq (subtree, read_objects))) |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2191 seen_list = Fcons (subtree, seen_list); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2192 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2193 /* Recurse according to subtree's type. |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2194 Every branch must return a Lisp_Object. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2195 switch (XTYPE (subtree)) |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2196 { |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2197 case Lisp_Vectorlike: |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2198 { |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2199 int i; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2200 int length = Flength(subtree); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2201 for (i = 0; i < length; i++) |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2202 { |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2203 Lisp_Object idx = make_number (i); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2204 SUBSTITUTE (Faref (subtree, idx), |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2205 Faset (subtree, idx, true_value)); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2206 } |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2207 return subtree; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2208 } |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2209 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2210 case Lisp_Cons: |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2211 { |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2212 SUBSTITUTE (Fcar_safe (subtree), |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2213 Fsetcar (subtree, true_value)); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2214 SUBSTITUTE (Fcdr_safe (subtree), |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2215 Fsetcdr (subtree, true_value)); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2216 return subtree; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2217 } |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2218 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2219 case Lisp_String: |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2220 { |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2221 /* Check for text properties in each interval. |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2222 substitute_in_interval contains part of the logic. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2223 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2224 INTERVAL root_interval = XSTRING (subtree)->intervals; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2225 Lisp_Object arg = Fcons (object, placeholder); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2226 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2227 traverse_intervals (root_interval, 1, 0, |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2228 &substitute_in_interval, arg); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2229 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2230 return subtree; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2231 } |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2232 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2233 /* Other types don't recurse any further. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2234 default: |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2235 return subtree; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2236 } |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2237 } |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2238 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2239 /* Helper function for substitute_object_recurse. */ |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2240 static void |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2241 substitute_in_interval (interval, arg) |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2242 INTERVAL interval; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2243 Lisp_Object arg; |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2244 { |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2245 Lisp_Object object = Fcar (arg); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2246 Lisp_Object placeholder = Fcdr (arg); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2247 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2248 SUBSTITUTE(interval->plist, interval->plist = true_value); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2249 } |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2250 |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
2251 |
341 | 2252 #define LEAD_INT 1 |
2253 #define DOT_CHAR 2 | |
2254 #define TRAIL_INT 4 | |
2255 #define E_CHAR 8 | |
2256 #define EXP_INT 16 | |
2257 | |
2258 int | |
2259 isfloat_string (cp) | |
2260 register char *cp; | |
2261 { | |
21799 | 2262 register int state; |
341 | 2263 |
21911
8087931b409e
(isfloat_string): Don't look at bytes before the string.
Richard M. Stallman <rms@gnu.org>
parents:
21799
diff
changeset
|
2264 char *start = cp; |
8087931b409e
(isfloat_string): Don't look at bytes before the string.
Richard M. Stallman <rms@gnu.org>
parents:
21799
diff
changeset
|
2265 |
341 | 2266 state = 0; |
2267 if (*cp == '+' || *cp == '-') | |
2268 cp++; | |
2269 | |
9871 | 2270 if (*cp >= '0' && *cp <= '9') |
341 | 2271 { |
2272 state |= LEAD_INT; | |
9871 | 2273 while (*cp >= '0' && *cp <= '9') |
2274 cp++; | |
341 | 2275 } |
2276 if (*cp == '.') | |
2277 { | |
2278 state |= DOT_CHAR; | |
2279 cp++; | |
2280 } | |
9871 | 2281 if (*cp >= '0' && *cp <= '9') |
341 | 2282 { |
2283 state |= TRAIL_INT; | |
9871 | 2284 while (*cp >= '0' && *cp <= '9') |
341 | 2285 cp++; |
2286 } | |
16342
b91af71f45f1
(isfloat_string): Accept E like e.
Richard M. Stallman <rms@gnu.org>
parents:
16228
diff
changeset
|
2287 if (*cp == 'e' || *cp == 'E') |
341 | 2288 { |
2289 state |= E_CHAR; | |
2290 cp++; | |
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2291 if (*cp == '+' || *cp == '-') |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
2292 cp++; |
341 | 2293 } |
2294 | |
9871 | 2295 if (*cp >= '0' && *cp <= '9') |
341 | 2296 { |
2297 state |= EXP_INT; | |
9871 | 2298 while (*cp >= '0' && *cp <= '9') |
341 | 2299 cp++; |
2300 } | |
21911
8087931b409e
(isfloat_string): Don't look at bytes before the string.
Richard M. Stallman <rms@gnu.org>
parents:
21799
diff
changeset
|
2301 else if (cp == start) |
8087931b409e
(isfloat_string): Don't look at bytes before the string.
Richard M. Stallman <rms@gnu.org>
parents:
21799
diff
changeset
|
2302 ; |
20815
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2303 else if (cp[-1] == '+' && cp[0] == 'I' && cp[1] == 'N' && cp[2] == 'F') |
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2304 { |
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2305 state |= EXP_INT; |
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2306 cp += 3; |
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2307 } |
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2308 else if (cp[-1] == '+' && cp[0] == 'N' && cp[1] == 'a' && cp[2] == 'N') |
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2309 { |
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2310 state |= EXP_INT; |
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2311 cp += 3; |
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2312 } |
d5ae7491d2b0
(read1): Handle infinities, NaN and -0.0 specially.
Richard M. Stallman <rms@gnu.org>
parents:
20773
diff
changeset
|
2313 |
11172
e1ca77e22c12
(isfloat_string): Permit trailing space.
Richard M. Stallman <rms@gnu.org>
parents:
11079
diff
changeset
|
2314 return (((*cp == 0) || (*cp == ' ') || (*cp == '\t') || (*cp == '\n') || (*cp == '\r') || (*cp == '\f')) |
341 | 2315 && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT) |
826 | 2316 || state == (DOT_CHAR|TRAIL_INT) |
341 | 2317 || state == (LEAD_INT|E_CHAR|EXP_INT) |
826 | 2318 || state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT) |
2319 || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT))); | |
341 | 2320 } |
27727
9400865ec7cf
Remove `LISP_FLOAT_TYPE' and `standalone'.
Gerd Moellmann <gerd@gnu.org>
parents:
27645
diff
changeset
|
2321 |
341 | 2322 |
2323 static Lisp_Object | |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2324 read_vector (readcharfun, bytecodeflag) |
341 | 2325 Lisp_Object readcharfun; |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2326 int bytecodeflag; |
341 | 2327 { |
2328 register int i; | |
2329 register int size; | |
2330 register Lisp_Object *ptr; | |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2331 register Lisp_Object tem, item, vector; |
341 | 2332 register struct Lisp_Cons *otem; |
2333 Lisp_Object len; | |
2334 | |
2335 tem = read_list (1, readcharfun); | |
2336 len = Flength (tem); | |
2337 vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil)); | |
2338 | |
2339 size = XVECTOR (vector)->size; | |
2340 ptr = XVECTOR (vector)->contents; | |
2341 for (i = 0; i < size; i++) | |
2342 { | |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2343 item = Fcar (tem); |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2344 /* If `load-force-doc-strings' is t when reading a lazily-loaded |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2345 bytecode object, the docstring containing the bytecode and |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2346 constants values must be treated as unibyte and passed to |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2347 Fread, to get the actual bytecode string and constants vector. */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2348 if (bytecodeflag && load_force_doc_strings) |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2349 { |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2350 if (i == COMPILED_BYTECODE) |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2351 { |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2352 if (!STRINGP (item)) |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2353 error ("invalid byte code"); |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2354 |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2355 /* Delay handling the bytecode slot until we know whether |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2356 it is lazily-loaded (we can tell by whether the |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2357 constants slot is nil). */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2358 ptr[COMPILED_CONSTANTS] = item; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2359 item = Qnil; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2360 } |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2361 else if (i == COMPILED_CONSTANTS) |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2362 { |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2363 Lisp_Object bytestr = ptr[COMPILED_CONSTANTS]; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2364 |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2365 if (NILP (item)) |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2366 { |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2367 /* Coerce string to unibyte (like string-as-unibyte, |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2368 but without generating extra garbage and |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2369 guaranteeing no change in the contents). */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2370 XSTRING (bytestr)->size = STRING_BYTES (XSTRING (bytestr)); |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2371 SET_STRING_BYTES (XSTRING (bytestr), -1); |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2372 |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2373 item = Fread (bytestr); |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2374 if (!CONSP (item)) |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2375 error ("invalid byte code"); |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2376 |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2377 otem = XCONS (item); |
25663
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
2378 bytestr = XCAR (item); |
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
2379 item = XCDR (item); |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2380 free_cons (otem); |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2381 } |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2382 |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2383 /* Now handle the bytecode slot. */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2384 ptr[COMPILED_BYTECODE] = read_pure ? Fpurecopy (bytestr) : bytestr; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2385 } |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2386 } |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2387 ptr[i] = read_pure ? Fpurecopy (item) : item; |
341 | 2388 otem = XCONS (tem); |
2389 tem = Fcdr (tem); | |
2390 free_cons (otem); | |
2391 } | |
2392 return vector; | |
2393 } | |
2394 | |
20548
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
2395 /* FLAG = 1 means check for ] to terminate rather than ) and . |
e9733cb049d9
(readchar_backlog): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20406
diff
changeset
|
2396 FLAG = -1 means check for starting with defun |
341 | 2397 and make structure pure. */ |
2398 | |
2399 static Lisp_Object | |
2400 read_list (flag, readcharfun) | |
2401 int flag; | |
2402 register Lisp_Object readcharfun; | |
2403 { | |
2404 /* -1 means check next element for defun, | |
2405 0 means don't check, | |
2406 1 means already checked and found defun. */ | |
2407 int defunflag = flag < 0 ? -1 : 0; | |
2408 Lisp_Object val, tail; | |
2409 register Lisp_Object elt, tem; | |
2410 struct gcpro gcpro1, gcpro2; | |
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2411 /* 0 is the normal case. |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2412 1 means this list is a doc reference; replace it with the number 0. |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2413 2 means this list is a doc reference; replace it with the doc string. */ |
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2414 int doc_reference = 0; |
341 | 2415 |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2416 /* Initialize this to 1 if we are reading a list. */ |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2417 int first_in_list = flag <= 0; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2418 |
341 | 2419 val = Qnil; |
2420 tail = Qnil; | |
2421 | |
2422 while (1) | |
2423 { | |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2424 int ch; |
341 | 2425 GCPRO2 (val, tail); |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2426 elt = read1 (readcharfun, &ch, first_in_list); |
341 | 2427 UNGCPRO; |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
2428 |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2429 first_in_list = 0; |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2430 |
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2431 /* While building, if the list starts with #$, treat it specially. */ |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
2432 if (EQ (elt, Vload_file_name) |
20048
5324d8b2322b
(read_list): Don't recognize Vload_file_name
Karl Heuer <kwzh@gnu.org>
parents:
20024
diff
changeset
|
2433 && ! NILP (elt) |
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2434 && !NILP (Vpurify_flag)) |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2435 { |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2436 if (NILP (Vdoc_file_name)) |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2437 /* We have not yet called Snarf-documentation, so assume |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2438 this file is described in the DOC-MM.NN file |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2439 and Snarf-documentation will fill in the right value later. |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2440 For now, replace the whole list with 0. */ |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2441 doc_reference = 1; |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2442 else |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2443 /* We have already called Snarf-documentation, so make a relative |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2444 file name for this file, so it can be found properly |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2445 in the installed Lisp directory. |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2446 We don't use Fexpand_file_name because that would make |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2447 the directory absolute now. */ |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2448 elt = concat2 (build_string ("../lisp/"), |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2449 Ffile_name_nondirectory (elt)); |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2450 } |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2451 else if (EQ (elt, Vload_file_name) |
20048
5324d8b2322b
(read_list): Don't recognize Vload_file_name
Karl Heuer <kwzh@gnu.org>
parents:
20024
diff
changeset
|
2452 && ! NILP (elt) |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2453 && load_force_doc_strings) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2454 doc_reference = 2; |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
2455 |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
2456 if (ch) |
341 | 2457 { |
2458 if (flag > 0) | |
2459 { | |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
2460 if (ch == ']') |
341 | 2461 return val; |
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2462 Fsignal (Qinvalid_read_syntax, |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2463 Fcons (make_string (") or . in a vector", 18), Qnil)); |
341 | 2464 } |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
2465 if (ch == ')') |
341 | 2466 return val; |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
2467 if (ch == '.') |
341 | 2468 { |
2469 GCPRO2 (val, tail); | |
485 | 2470 if (!NILP (tail)) |
25663
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
2471 XCDR (tail) = read0 (readcharfun); |
341 | 2472 else |
2473 val = read0 (readcharfun); | |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
2474 read1 (readcharfun, &ch, 0); |
341 | 2475 UNGCPRO; |
9358
361c6409e7c1
(read1): New argument for returning out-of-band data, obviating the need for
Karl Heuer <kwzh@gnu.org>
parents:
9313
diff
changeset
|
2476 if (ch == ')') |
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2477 { |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2478 if (doc_reference == 1) |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2479 return make_number (0); |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2480 if (doc_reference == 2) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2481 { |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2482 /* Get a doc string from the file we are loading. |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2483 If it's in saved_doc_string, get it from there. */ |
25663
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
2484 int pos = XINT (XCDR (val)); |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2485 /* Position is negative for user variables. */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2486 if (pos < 0) pos = -pos; |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2487 if (pos >= saved_doc_string_position |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2488 && pos < (saved_doc_string_position |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2489 + saved_doc_string_length)) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2490 { |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2491 int start = pos - saved_doc_string_position; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2492 int from, to; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2493 |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2494 /* Process quoting with ^A, |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2495 and find the end of the string, |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2496 which is marked with ^_ (037). */ |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2497 for (from = start, to = start; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2498 saved_doc_string[from] != 037;) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2499 { |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2500 int c = saved_doc_string[from++]; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2501 if (c == 1) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2502 { |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2503 c = saved_doc_string[from++]; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2504 if (c == 1) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2505 saved_doc_string[to++] = c; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2506 else if (c == '0') |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2507 saved_doc_string[to++] = 0; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2508 else if (c == '_') |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2509 saved_doc_string[to++] = 037; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2510 } |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2511 else |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2512 saved_doc_string[to++] = c; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2513 } |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2514 |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2515 return make_string (saved_doc_string + start, |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2516 to - start); |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2517 } |
22321
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2518 /* Look in prev_saved_doc_string the same way. */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2519 else if (pos >= prev_saved_doc_string_position |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2520 && pos < (prev_saved_doc_string_position |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2521 + prev_saved_doc_string_length)) |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2522 { |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2523 int start = pos - prev_saved_doc_string_position; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2524 int from, to; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2525 |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2526 /* Process quoting with ^A, |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2527 and find the end of the string, |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2528 which is marked with ^_ (037). */ |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2529 for (from = start, to = start; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2530 prev_saved_doc_string[from] != 037;) |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2531 { |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2532 int c = prev_saved_doc_string[from++]; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2533 if (c == 1) |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2534 { |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2535 c = prev_saved_doc_string[from++]; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2536 if (c == 1) |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2537 prev_saved_doc_string[to++] = c; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2538 else if (c == '0') |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2539 prev_saved_doc_string[to++] = 0; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2540 else if (c == '_') |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2541 prev_saved_doc_string[to++] = 037; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2542 } |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2543 else |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2544 prev_saved_doc_string[to++] = c; |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2545 } |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2546 |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2547 return make_string (prev_saved_doc_string + start, |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2548 to - start); |
2b81c3b8f0c8
Remember the last TWO strings skipped with #@.
Richard M. Stallman <rms@gnu.org>
parents:
22103
diff
changeset
|
2549 } |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2550 else |
22603
329fe9a2bdb8
(read_list): Pass new arg to get_doc_string.
Richard M. Stallman <rms@gnu.org>
parents:
22420
diff
changeset
|
2551 return get_doc_string (val, 0, 0); |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2552 } |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2553 |
12639
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2554 return val; |
1410ce7c4fab
(read_list): When a file loaded from site-init.el uses #$,
Richard M. Stallman <rms@gnu.org>
parents:
12545
diff
changeset
|
2555 } |
341 | 2556 return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil)); |
2557 } | |
2558 return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil)); | |
2559 } | |
2560 tem = (read_pure && flag <= 0 | |
2561 ? pure_cons (elt, Qnil) | |
2562 : Fcons (elt, Qnil)); | |
485 | 2563 if (!NILP (tail)) |
25663
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
2564 XCDR (tail) = tem; |
341 | 2565 else |
2566 val = tem; | |
2567 tail = tem; | |
2568 if (defunflag < 0) | |
2569 defunflag = EQ (elt, Qdefun); | |
2570 else if (defunflag > 0) | |
2571 read_pure = 1; | |
2572 } | |
2573 } | |
2574 | |
2575 Lisp_Object Vobarray; | |
2576 Lisp_Object initial_obarray; | |
2577 | |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2578 /* oblookup stores the bucket number here, for the sake of Funintern. */ |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2579 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2580 int oblookup_last_bucket_number; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2581 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2582 static int hash_string (); |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2583 Lisp_Object oblookup (); |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2584 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2585 /* Get an error if OBARRAY is not an obarray. |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2586 If it is one, return it. */ |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2587 |
341 | 2588 Lisp_Object |
2589 check_obarray (obarray) | |
2590 Lisp_Object obarray; | |
2591 { | |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2592 while (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) |
341 | 2593 { |
2594 /* If Vobarray is now invalid, force it to be valid. */ | |
2595 if (EQ (Vobarray, obarray)) Vobarray = initial_obarray; | |
2596 | |
2597 obarray = wrong_type_argument (Qvectorp, obarray); | |
2598 } | |
2599 return obarray; | |
2600 } | |
2601 | |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2602 /* Intern the C string STR: return a symbol with that name, |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2603 interned in the current obarray. */ |
341 | 2604 |
2605 Lisp_Object | |
2606 intern (str) | |
2607 char *str; | |
2608 { | |
2609 Lisp_Object tem; | |
2610 int len = strlen (str); | |
6503
7c566d0e4b3d
(read_filtered_event, intern): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6471
diff
changeset
|
2611 Lisp_Object obarray; |
341 | 2612 |
6503
7c566d0e4b3d
(read_filtered_event, intern): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6471
diff
changeset
|
2613 obarray = Vobarray; |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2614 if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) |
341 | 2615 obarray = check_obarray (obarray); |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2616 tem = oblookup (obarray, str, len, len); |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2617 if (SYMBOLP (tem)) |
341 | 2618 return tem; |
18051
b985b9739beb
(intern): Don't make a pure string here, since Fintern does that.
Richard M. Stallman <rms@gnu.org>
parents:
17918
diff
changeset
|
2619 return Fintern (make_string (str, len), obarray); |
341 | 2620 } |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2621 |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2622 /* Create an uninterned symbol with name STR. */ |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2623 |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2624 Lisp_Object |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2625 make_symbol (str) |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2626 char *str; |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2627 { |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2628 int len = strlen (str); |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2629 |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2630 return Fmake_symbol ((!NILP (Vpurify_flag) |
21251
05fbf4f5b14f
(read1): Pass new arg to make_pure_string.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
2631 ? make_pure_string (str, len, len, 0) |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2632 : make_string (str, len))); |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2633 } |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2634 |
341 | 2635 DEFUN ("intern", Fintern, Sintern, 1, 2, 0, |
2636 "Return the canonical symbol whose name is STRING.\n\ | |
2637 If there is none, one is created by this function and returned.\n\ | |
2638 A second optional argument specifies the obarray to use;\n\ | |
2639 it defaults to the value of `obarray'.") | |
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2640 (string, obarray) |
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2641 Lisp_Object string, obarray; |
341 | 2642 { |
2643 register Lisp_Object tem, sym, *ptr; | |
2644 | |
485 | 2645 if (NILP (obarray)) obarray = Vobarray; |
341 | 2646 obarray = check_obarray (obarray); |
2647 | |
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2648 CHECK_STRING (string, 0); |
341 | 2649 |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2650 tem = oblookup (obarray, XSTRING (string)->data, |
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2651 XSTRING (string)->size, |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21220
diff
changeset
|
2652 STRING_BYTES (XSTRING (string))); |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2653 if (!INTEGERP (tem)) |
341 | 2654 return tem; |
2655 | |
485 | 2656 if (!NILP (Vpurify_flag)) |
14092
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2657 string = Fpurecopy (string); |
279f5f3528a8
(Feval_buffer, Feval_region, Fintern, Fintern_soft): Harmonize arguments
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2658 sym = Fmake_symbol (string); |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2659 XSYMBOL (sym)->obarray = obarray; |
341 | 2660 |
21776
0b8510aab527
(Fintern): Initialize keywords only in initial obarray.
Richard M. Stallman <rms@gnu.org>
parents:
21761
diff
changeset
|
2661 if ((XSTRING (string)->data[0] == ':') |
21982
456f95c03285
(Fintern): Properly compare lisp objects.
Richard M. Stallman <rms@gnu.org>
parents:
21936
diff
changeset
|
2662 && EQ (obarray, initial_obarray)) |
17918
72aec83491a2
(Fintern): Give keywords a value when interned.
Richard M. Stallman <rms@gnu.org>
parents:
17605
diff
changeset
|
2663 XSYMBOL (sym)->value = sym; |
72aec83491a2
(Fintern): Give keywords a value when interned.
Richard M. Stallman <rms@gnu.org>
parents:
17605
diff
changeset
|
2664 |
341 | 2665 ptr = &XVECTOR (obarray)->contents[XINT (tem)]; |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2666 if (SYMBOLP (*ptr)) |
341 | 2667 XSYMBOL (sym)->next = XSYMBOL (*ptr); |
2668 else | |
2669 XSYMBOL (sym)->next = 0; | |
2670 *ptr = sym; | |
2671 return sym; | |
2672 } | |
2673 | |
2674 DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0, | |
26735
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2675 "Return the canonical symbol named NAME, or nil if none exists.\n\ |
26755
6bb3d25454a8
(Fintern_soft): Fix newlines in doc string.
Dave Love <fx@gnu.org>
parents:
26735
diff
changeset
|
2676 NAME may be a string or a symbol. If it is a symbol, that exact\n\ |
6bb3d25454a8
(Fintern_soft): Fix newlines in doc string.
Dave Love <fx@gnu.org>
parents:
26735
diff
changeset
|
2677 symbol is searched for.\n\ |
341 | 2678 A second optional argument specifies the obarray to use;\n\ |
2679 it defaults to the value of `obarray'.") | |
26735
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2680 (name, obarray) |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2681 Lisp_Object name, obarray; |
341 | 2682 { |
2683 register Lisp_Object tem; | |
26735
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2684 struct Lisp_String *string; |
341 | 2685 |
485 | 2686 if (NILP (obarray)) obarray = Vobarray; |
341 | 2687 obarray = check_obarray (obarray); |
2688 | |
26735
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2689 if (!SYMBOLP (name)) |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2690 { |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2691 CHECK_STRING (name, 0); |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2692 string = XSTRING (name); |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2693 } |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2694 else |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2695 string = XSYMBOL (name)->name; |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2696 |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2697 tem = oblookup (obarray, string->data, string->size, STRING_BYTES (string)); |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2698 if (INTEGERP (tem) || (SYMBOLP (name) && !EQ (name, tem))) |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2699 return Qnil; |
c13ab7bc6fdc
(Fintern_soft): Accept a symbol argument.
Gerd Moellmann <gerd@gnu.org>
parents:
26404
diff
changeset
|
2700 else |
341 | 2701 return tem; |
2702 } | |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2703 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2704 DEFUN ("unintern", Funintern, Sunintern, 1, 2, 0, |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2705 "Delete the symbol named NAME, if any, from OBARRAY.\n\ |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2706 The value is t if a symbol was found and deleted, nil otherwise.\n\ |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2707 NAME may be a string or a symbol. If it is a symbol, that symbol\n\ |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2708 is deleted, if it belongs to OBARRAY--no other symbol is deleted.\n\ |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2709 OBARRAY defaults to the value of the variable `obarray'.") |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2710 (name, obarray) |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2711 Lisp_Object name, obarray; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2712 { |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2713 register Lisp_Object string, tem; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2714 int hash; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2715 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2716 if (NILP (obarray)) obarray = Vobarray; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2717 obarray = check_obarray (obarray); |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2718 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2719 if (SYMBOLP (name)) |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2720 XSETSTRING (string, XSYMBOL (name)->name); |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2721 else |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2722 { |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2723 CHECK_STRING (name, 0); |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2724 string = name; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2725 } |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2726 |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2727 tem = oblookup (obarray, XSTRING (string)->data, |
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2728 XSTRING (string)->size, |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21220
diff
changeset
|
2729 STRING_BYTES (XSTRING (string))); |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2730 if (INTEGERP (tem)) |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2731 return Qnil; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2732 /* If arg was a symbol, don't delete anything but that symbol itself. */ |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2733 if (SYMBOLP (name) && !EQ (name, tem)) |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2734 return Qnil; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2735 |
20773
6c655dc99321
(Funintern): Clear the symbol's obarray field.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
2736 XSYMBOL (tem)->obarray = Qnil; |
6c655dc99321
(Funintern): Clear the symbol's obarray field.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
2737 |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2738 hash = oblookup_last_bucket_number; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2739 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2740 if (EQ (XVECTOR (obarray)->contents[hash], tem)) |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2741 { |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2742 if (XSYMBOL (tem)->next) |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2743 XSETSYMBOL (XVECTOR (obarray)->contents[hash], XSYMBOL (tem)->next); |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2744 else |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2745 XSETINT (XVECTOR (obarray)->contents[hash], 0); |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
2746 } |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2747 else |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2748 { |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2749 Lisp_Object tail, following; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2750 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2751 for (tail = XVECTOR (obarray)->contents[hash]; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2752 XSYMBOL (tail)->next; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2753 tail = following) |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2754 { |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2755 XSETSYMBOL (following, XSYMBOL (tail)->next); |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2756 if (EQ (following, tem)) |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2757 { |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2758 XSYMBOL (tail)->next = XSYMBOL (following)->next; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2759 break; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2760 } |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2761 } |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2762 } |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2763 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2764 return Qt; |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2765 } |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2766 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2767 /* Return the symbol in OBARRAY whose names matches the string |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2768 of SIZE characters (SIZE_BYTE bytes) at PTR. |
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2769 If there is no such symbol in OBARRAY, return nil. |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2770 |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2771 Also store the bucket number in oblookup_last_bucket_number. */ |
341 | 2772 |
2773 Lisp_Object | |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2774 oblookup (obarray, ptr, size, size_byte) |
341 | 2775 Lisp_Object obarray; |
2776 register char *ptr; | |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2777 int size, size_byte; |
341 | 2778 { |
8828 | 2779 int hash; |
2780 int obsize; | |
341 | 2781 register Lisp_Object tail; |
2782 Lisp_Object bucket, tem; | |
2783 | |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2784 if (!VECTORP (obarray) |
5243 | 2785 || (obsize = XVECTOR (obarray)->size) == 0) |
341 | 2786 { |
2787 obarray = check_obarray (obarray); | |
2788 obsize = XVECTOR (obarray)->size; | |
2789 } | |
13455
4f5a9ce67782
(oblookup): Clear ARRAY_MARK_FLAG in obsize.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
2790 /* This is sometimes needed in the middle of GC. */ |
4f5a9ce67782
(oblookup): Clear ARRAY_MARK_FLAG in obsize.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
2791 obsize &= ~ARRAY_MARK_FLAG; |
341 | 2792 /* Combining next two lines breaks VMS C 2.3. */ |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2793 hash = hash_string (ptr, size_byte); |
341 | 2794 hash %= obsize; |
2795 bucket = XVECTOR (obarray)->contents[hash]; | |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2796 oblookup_last_bucket_number = hash; |
341 | 2797 if (XFASTINT (bucket) == 0) |
2798 ; | |
9149
fe6b30db719d
(readchar, readchar, unreadchar, read_filtered_event, Fread, read0, read1,
Karl Heuer <kwzh@gnu.org>
parents:
8906
diff
changeset
|
2799 else if (!SYMBOLP (bucket)) |
341 | 2800 error ("Bad data in guts of obarray"); /* Like CADR error message */ |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2801 else |
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2802 for (tail = bucket; ; XSETSYMBOL (tail, XSYMBOL (tail)->next)) |
341 | 2803 { |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21220
diff
changeset
|
2804 if (STRING_BYTES (XSYMBOL (tail)->name) == size_byte |
20609
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2805 && XSYMBOL (tail)->name->size == size |
4bf29951648f
(read_escape): `\ ' stands for nothing at all.
Richard M. Stallman <rms@gnu.org>
parents:
20566
diff
changeset
|
2806 && !bcmp (XSYMBOL (tail)->name->data, ptr, size_byte)) |
341 | 2807 return tail; |
2808 else if (XSYMBOL (tail)->next == 0) | |
2809 break; | |
2810 } | |
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
2811 XSETINT (tem, hash); |
341 | 2812 return tem; |
2813 } | |
2814 | |
2815 static int | |
2816 hash_string (ptr, len) | |
2817 unsigned char *ptr; | |
2818 int len; | |
2819 { | |
2820 register unsigned char *p = ptr; | |
2821 register unsigned char *end = p + len; | |
2822 register unsigned char c; | |
2823 register int hash = 0; | |
2824 | |
2825 while (p != end) | |
2826 { | |
2827 c = *p++; | |
2828 if (c >= 0140) c -= 40; | |
2829 hash = ((hash<<3) + (hash>>28) + c); | |
2830 } | |
2831 return hash & 07777777777; | |
2832 } | |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
2833 |
341 | 2834 void |
2835 map_obarray (obarray, fn, arg) | |
2836 Lisp_Object obarray; | |
20298
b7d23d2eded1
(read1): Declare `workbuf' as unsigned char.
Andreas Schwab <schwab@suse.de>
parents:
20168
diff
changeset
|
2837 void (*fn) P_ ((Lisp_Object, Lisp_Object)); |
341 | 2838 Lisp_Object arg; |
2839 { | |
2840 register int i; | |
2841 register Lisp_Object tail; | |
2842 CHECK_VECTOR (obarray, 1); | |
2843 for (i = XVECTOR (obarray)->size - 1; i >= 0; i--) | |
2844 { | |
2845 tail = XVECTOR (obarray)->contents[i]; | |
19020
1ee295d0114a
(map_obarray): Don't crash if something strange is in the obarray.
Richard M. Stallman <rms@gnu.org>
parents:
18771
diff
changeset
|
2846 if (SYMBOLP (tail)) |
341 | 2847 while (1) |
2848 { | |
2849 (*fn) (tail, arg); | |
2850 if (XSYMBOL (tail)->next == 0) | |
2851 break; | |
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
2852 XSETSYMBOL (tail, XSYMBOL (tail)->next); |
341 | 2853 } |
2854 } | |
2855 } | |
2856 | |
20298
b7d23d2eded1
(read1): Declare `workbuf' as unsigned char.
Andreas Schwab <schwab@suse.de>
parents:
20168
diff
changeset
|
2857 void |
341 | 2858 mapatoms_1 (sym, function) |
2859 Lisp_Object sym, function; | |
2860 { | |
2861 call1 (function, sym); | |
2862 } | |
2863 | |
2864 DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0, | |
2865 "Call FUNCTION on every symbol in OBARRAY.\n\ | |
2866 OBARRAY defaults to the value of `obarray'.") | |
2867 (function, obarray) | |
2868 Lisp_Object function, obarray; | |
2869 { | |
485 | 2870 if (NILP (obarray)) obarray = Vobarray; |
341 | 2871 obarray = check_obarray (obarray); |
2872 | |
2873 map_obarray (obarray, mapatoms_1, function); | |
2874 return Qnil; | |
2875 } | |
2876 | |
5117
951396781a0e
(OBARRAY_SIZE): Increase from 509.
Richard M. Stallman <rms@gnu.org>
parents:
5017
diff
changeset
|
2877 #define OBARRAY_SIZE 1511 |
341 | 2878 |
2879 void | |
2880 init_obarray () | |
2881 { | |
2882 Lisp_Object oblength; | |
2883 int hash; | |
2884 Lisp_Object *tem; | |
2885 | |
9313
ed68c3822e4b
(read_filtered_event, init_obarray): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9274
diff
changeset
|
2886 XSETFASTINT (oblength, OBARRAY_SIZE); |
341 | 2887 |
21251
05fbf4f5b14f
(read1): Pass new arg to make_pure_string.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
2888 Qnil = Fmake_symbol (make_pure_string ("nil", 3, 3, 0)); |
341 | 2889 Vobarray = Fmake_vector (oblength, make_number (0)); |
2890 initial_obarray = Vobarray; | |
2891 staticpro (&initial_obarray); | |
2892 /* Intern nil in the obarray */ | |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
2893 XSYMBOL (Qnil)->obarray = Vobarray; |
341 | 2894 /* These locals are to kludge around a pyramid compiler bug. */ |
2895 hash = hash_string ("nil", 3); | |
2896 /* Separate statement here to avoid VAXC bug. */ | |
2897 hash %= OBARRAY_SIZE; | |
2898 tem = &XVECTOR (Vobarray)->contents[hash]; | |
2899 *tem = Qnil; | |
2900 | |
21251
05fbf4f5b14f
(read1): Pass new arg to make_pure_string.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
2901 Qunbound = Fmake_symbol (make_pure_string ("unbound", 7, 7, 0)); |
341 | 2902 XSYMBOL (Qnil)->function = Qunbound; |
2903 XSYMBOL (Qunbound)->value = Qunbound; | |
2904 XSYMBOL (Qunbound)->function = Qunbound; | |
2905 | |
2906 Qt = intern ("t"); | |
2907 XSYMBOL (Qnil)->value = Qnil; | |
2908 XSYMBOL (Qnil)->plist = Qnil; | |
2909 XSYMBOL (Qt)->value = Qt; | |
2910 | |
2911 /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */ | |
2912 Vpurify_flag = Qt; | |
2913 | |
2914 Qvariable_documentation = intern ("variable-documentation"); | |
16228
fa7a56c543df
(init_obarray): staticpro Qvariable_documentation.
Erik Naggum <erik@naggum.no>
parents:
16165
diff
changeset
|
2915 staticpro (&Qvariable_documentation); |
341 | 2916 |
26866
305531847450
(readchar): Adjusted for the change of CHAR_STRING.
Kenichi Handa <handa@m17n.org>
parents:
26755
diff
changeset
|
2917 read_buffer_size = 100 + MAX_MULTIBYTE_LENGTH; |
27852
98f55bbdbbad
(Fload): Use `xfree' instead of `free'.
Gerd Moellmann <gerd@gnu.org>
parents:
27763
diff
changeset
|
2918 read_buffer = (char *) xmalloc (read_buffer_size); |
341 | 2919 } |
2920 | |
2921 void | |
2922 defsubr (sname) | |
2923 struct Lisp_Subr *sname; | |
2924 { | |
2925 Lisp_Object sym; | |
2926 sym = intern (sname->symbol_name); | |
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
2927 XSETSUBR (XSYMBOL (sym)->function, sname); |
341 | 2928 } |
2929 | |
2930 #ifdef NOTDEF /* use fset in subr.el now */ | |
2931 void | |
2932 defalias (sname, string) | |
2933 struct Lisp_Subr *sname; | |
2934 char *string; | |
2935 { | |
2936 Lisp_Object sym; | |
2937 sym = intern (string); | |
9274
5c66d8b65a7c
(Fget_file_char, Fload, read1, oblookup, map_obarray, defsubr, defalias,
Karl Heuer <kwzh@gnu.org>
parents:
9149
diff
changeset
|
2938 XSETSUBR (XSYMBOL (sym)->function, sname); |
341 | 2939 } |
2940 #endif /* NOTDEF */ | |
2941 | |
2942 /* Define an "integer variable"; a symbol whose value is forwarded | |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2943 to a C variable of type int. Sample call: */ |
10606
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
2944 /* DEFVAR_INT ("indent-tabs-mode", &indent_tabs_mode, "Documentation"); */ |
341 | 2945 void |
7765
688637ba31c5
(defvar_bool, defvar_int, defvar_lisp, defvar_lisp_nopro):
Richard M. Stallman <rms@gnu.org>
parents:
7675
diff
changeset
|
2946 defvar_int (namestring, address) |
341 | 2947 char *namestring; |
2948 int *address; | |
2949 { | |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2950 Lisp_Object sym, val; |
341 | 2951 sym = intern (namestring); |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2952 val = allocate_misc (); |
11242
36e8e27c8625
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_kboard)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2953 XMISCTYPE (val) = Lisp_Misc_Intfwd; |
9913
c921977bb0ce
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_per_buffer): Use accessor
Karl Heuer <kwzh@gnu.org>
parents:
9871
diff
changeset
|
2954 XINTFWD (val)->intvar = address; |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2955 XSYMBOL (sym)->value = val; |
341 | 2956 } |
2957 | |
2958 /* Similar but define a variable whose value is T if address contains 1, | |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2959 NIL if address contains 0 */ |
341 | 2960 void |
7765
688637ba31c5
(defvar_bool, defvar_int, defvar_lisp, defvar_lisp_nopro):
Richard M. Stallman <rms@gnu.org>
parents:
7675
diff
changeset
|
2961 defvar_bool (namestring, address) |
341 | 2962 char *namestring; |
2963 int *address; | |
2964 { | |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2965 Lisp_Object sym, val; |
341 | 2966 sym = intern (namestring); |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2967 val = allocate_misc (); |
11242
36e8e27c8625
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_kboard)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2968 XMISCTYPE (val) = Lisp_Misc_Boolfwd; |
9913
c921977bb0ce
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_per_buffer): Use accessor
Karl Heuer <kwzh@gnu.org>
parents:
9871
diff
changeset
|
2969 XBOOLFWD (val)->boolvar = address; |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2970 XSYMBOL (sym)->value = val; |
25555
301ce7f0b398
(Vbyte_boolean_vars): New variable.
Dave Love <fx@gnu.org>
parents:
25251
diff
changeset
|
2971 Vbyte_boolean_vars = Fcons (sym, Vbyte_boolean_vars); |
341 | 2972 } |
2973 | |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2974 /* Similar but define a variable whose value is the Lisp Object stored |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2975 at address. Two versions: with and without gc-marking of the C |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2976 variable. The nopro version is used when that variable will be |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2977 gc-marked for some other reason, since marking the same slot twice |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2978 can cause trouble with strings. */ |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2979 void |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2980 defvar_lisp_nopro (namestring, address) |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2981 char *namestring; |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2982 Lisp_Object *address; |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2983 { |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2984 Lisp_Object sym, val; |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2985 sym = intern (namestring); |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2986 val = allocate_misc (); |
11242
36e8e27c8625
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_kboard)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2987 XMISCTYPE (val) = Lisp_Misc_Objfwd; |
9913
c921977bb0ce
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_per_buffer): Use accessor
Karl Heuer <kwzh@gnu.org>
parents:
9871
diff
changeset
|
2988 XOBJFWD (val)->objvar = address; |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2989 XSYMBOL (sym)->value = val; |
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2990 } |
341 | 2991 |
2992 void | |
7765
688637ba31c5
(defvar_bool, defvar_int, defvar_lisp, defvar_lisp_nopro):
Richard M. Stallman <rms@gnu.org>
parents:
7675
diff
changeset
|
2993 defvar_lisp (namestring, address) |
341 | 2994 char *namestring; |
2995 Lisp_Object *address; | |
2996 { | |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
2997 defvar_lisp_nopro (namestring, address); |
341 | 2998 staticpro (address); |
2999 } | |
3000 | |
3001 /* Similar but define a variable whose value is the Lisp Object stored in | |
9363
4ccd5f13788d
(defvar_per_buffer): Access buffer_local_flags as Lisp_Object, not int.
Karl Heuer <kwzh@gnu.org>
parents:
9361
diff
changeset
|
3002 the current buffer. address is the address of the slot in the buffer |
4ccd5f13788d
(defvar_per_buffer): Access buffer_local_flags as Lisp_Object, not int.
Karl Heuer <kwzh@gnu.org>
parents:
9361
diff
changeset
|
3003 that is current now. */ |
341 | 3004 |
3005 void | |
1009
bf78b5ea9b3a
* lread.c (defvar_per_buffer): Support new TYPE argument, by
Jim Blandy <jimb@redhat.com>
parents:
851
diff
changeset
|
3006 defvar_per_buffer (namestring, address, type, doc) |
341 | 3007 char *namestring; |
3008 Lisp_Object *address; | |
1009
bf78b5ea9b3a
* lread.c (defvar_per_buffer): Support new TYPE argument, by
Jim Blandy <jimb@redhat.com>
parents:
851
diff
changeset
|
3009 Lisp_Object type; |
341 | 3010 char *doc; |
3011 { | |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
3012 Lisp_Object sym, val; |
341 | 3013 int offset; |
3014 extern struct buffer buffer_local_symbols; | |
3015 | |
3016 sym = intern (namestring); | |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
3017 val = allocate_misc (); |
341 | 3018 offset = (char *)address - (char *)current_buffer; |
3019 | |
11242
36e8e27c8625
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_kboard)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
3020 XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd; |
9913
c921977bb0ce
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_per_buffer): Use accessor
Karl Heuer <kwzh@gnu.org>
parents:
9871
diff
changeset
|
3021 XBUFFER_OBJFWD (val)->offset = offset; |
9466
9052bf69f7de
(defvar_int, defvar_bool, defvar_lisp, defvar_lisp_nopro, defvar_per_buffer):
Karl Heuer <kwzh@gnu.org>
parents:
9363
diff
changeset
|
3022 XSYMBOL (sym)->value = val; |
341 | 3023 *(Lisp_Object *)(offset + (char *)&buffer_local_symbols) = sym; |
1009
bf78b5ea9b3a
* lread.c (defvar_per_buffer): Support new TYPE argument, by
Jim Blandy <jimb@redhat.com>
parents:
851
diff
changeset
|
3024 *(Lisp_Object *)(offset + (char *)&buffer_local_types) = type; |
9363
4ccd5f13788d
(defvar_per_buffer): Access buffer_local_flags as Lisp_Object, not int.
Karl Heuer <kwzh@gnu.org>
parents:
9361
diff
changeset
|
3025 if (XINT (*(Lisp_Object *)(offset + (char *)&buffer_local_flags)) == 0) |
341 | 3026 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding |
3027 slot of buffer_local_flags */ | |
3028 abort (); | |
3029 } | |
3030 | |
10606
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3031 |
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3032 /* Similar but define a variable whose value is the Lisp Object stored |
11020
0951bb12c8ee
(defvar_kboard): Renamed from defvar_display.
Karl Heuer <kwzh@gnu.org>
parents:
10650
diff
changeset
|
3033 at a particular offset in the current kboard object. */ |
10606
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3034 |
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3035 void |
11020
0951bb12c8ee
(defvar_kboard): Renamed from defvar_display.
Karl Heuer <kwzh@gnu.org>
parents:
10650
diff
changeset
|
3036 defvar_kboard (namestring, offset) |
10606
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3037 char *namestring; |
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3038 int offset; |
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3039 { |
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3040 Lisp_Object sym, val; |
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3041 sym = intern (namestring); |
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3042 val = allocate_misc (); |
11242
36e8e27c8625
(defvar_int, defvar_bool, defvar_lisp_nopro, defvar_kboard)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
3043 XMISCTYPE (val) = Lisp_Misc_Kboard_Objfwd; |
11020
0951bb12c8ee
(defvar_kboard): Renamed from defvar_display.
Karl Heuer <kwzh@gnu.org>
parents:
10650
diff
changeset
|
3044 XKBOARD_OBJFWD (val)->offset = offset; |
10606
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3045 XSYMBOL (sym)->value = val; |
97b210b19217
(defvar_display): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10200
diff
changeset
|
3046 } |
341 | 3047 |
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
3048 /* Record the value of load-path used at the start of dumping |
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
3049 so we can see if the site changed it later during dumping. */ |
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
3050 static Lisp_Object dump_path; |
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
3051 |
20298
b7d23d2eded1
(read1): Declare `workbuf' as unsigned char.
Andreas Schwab <schwab@suse.de>
parents:
20168
diff
changeset
|
3052 void |
364 | 3053 init_lread () |
341 | 3054 { |
617 | 3055 char *normal; |
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3056 int turn_off_warning = 0; |
341 | 3057 |
364 | 3058 /* Compute the default load-path. */ |
617 | 3059 #ifdef CANNOT_DUMP |
3060 normal = PATH_LOADSEARCH; | |
638 | 3061 Vload_path = decode_env_path (0, normal); |
617 | 3062 #else |
3063 if (NILP (Vpurify_flag)) | |
3064 normal = PATH_LOADSEARCH; | |
3065 else | |
3066 normal = PATH_DUMPLOADSEARCH; | |
3067 | |
3068 /* In a dumped Emacs, we normally have to reset the value of | |
3069 Vload_path from PATH_LOADSEARCH, since the value that was dumped | |
3070 uses ../lisp, instead of the path of the installed elisp | |
3071 libraries. However, if it appears that Vload_path was changed | |
3072 from the default before dumping, don't override that value. */ | |
621 | 3073 if (initialized) |
3074 { | |
3075 if (! NILP (Fequal (dump_path, Vload_path))) | |
4482
09d0f4b26641
(init_lread): Normally put Vinvocation_directory
Richard M. Stallman <rms@gnu.org>
parents:
3704
diff
changeset
|
3076 { |
09d0f4b26641
(init_lread): Normally put Vinvocation_directory
Richard M. Stallman <rms@gnu.org>
parents:
3704
diff
changeset
|
3077 Vload_path = decode_env_path (0, normal); |
5617
0b312b3fa24e
(init_lread): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5568
diff
changeset
|
3078 if (!NILP (Vinstallation_directory)) |
4482
09d0f4b26641
(init_lread): Normally put Vinvocation_directory
Richard M. Stallman <rms@gnu.org>
parents:
3704
diff
changeset
|
3079 { |
5617
0b312b3fa24e
(init_lread): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5568
diff
changeset
|
3080 /* Add to the path the lisp subdir of the |
7004
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3081 installation dir, if it exists. */ |
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3082 Lisp_Object tem, tem1; |
5617
0b312b3fa24e
(init_lread): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5568
diff
changeset
|
3083 tem = Fexpand_file_name (build_string ("lisp"), |
0b312b3fa24e
(init_lread): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5568
diff
changeset
|
3084 Vinstallation_directory); |
7004
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3085 tem1 = Ffile_exists_p (tem); |
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3086 if (!NILP (tem1)) |
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3087 { |
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3088 if (NILP (Fmember (tem, Vload_path))) |
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3089 { |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3090 turn_off_warning = 1; |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3091 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil)); |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3092 } |
7004
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3093 } |
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3094 else |
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3095 /* That dir doesn't exist, so add the build-time |
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3096 Lisp dirs instead. */ |
0c4d3481bb1b
(init_lread): Maybe put build-time Lisp dirs on load-path.
Richard M. Stallman <rms@gnu.org>
parents:
6503
diff
changeset
|
3097 Vload_path = nconc2 (Vload_path, dump_path); |
11311
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
3098 |
18530
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3099 /* Add leim under the installation dir, if it exists. */ |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3100 tem = Fexpand_file_name (build_string ("leim"), |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3101 Vinstallation_directory); |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3102 tem1 = Ffile_exists_p (tem); |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3103 if (!NILP (tem1)) |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3104 { |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3105 if (NILP (Fmember (tem, Vload_path))) |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3106 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil)); |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3107 } |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3108 |
11311
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
3109 /* Add site-list under the installation dir, if it exists. */ |
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
3110 tem = Fexpand_file_name (build_string ("site-lisp"), |
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
3111 Vinstallation_directory); |
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
3112 tem1 = Ffile_exists_p (tem); |
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
3113 if (!NILP (tem1)) |
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
3114 { |
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
3115 if (NILP (Fmember (tem, Vload_path))) |
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
3116 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil)); |
864c3dea8754
(read_escape): Undo Nov 15 change.
Richard M. Stallman <rms@gnu.org>
parents:
11242
diff
changeset
|
3117 } |
18084
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3118 |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3119 /* If Emacs was not built in the source directory, |
18530
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3120 and it is run from where it was built, add to load-path |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3121 the lisp, leim and site-lisp dirs under that directory. */ |
18084
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3122 |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3123 if (NILP (Fequal (Vinstallation_directory, Vsource_directory))) |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3124 { |
18771
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3125 Lisp_Object tem2; |
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3126 |
18084
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3127 tem = Fexpand_file_name (build_string ("src/Makefile"), |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3128 Vinstallation_directory); |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3129 tem1 = Ffile_exists_p (tem); |
18771
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3130 |
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3131 /* Don't be fooled if they moved the entire source tree |
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3132 AFTER dumping Emacs. If the build directory is indeed |
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3133 different from the source dir, src/Makefile.in and |
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3134 src/Makefile will not be found together. */ |
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3135 tem = Fexpand_file_name (build_string ("src/Makefile.in"), |
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3136 Vinstallation_directory); |
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3137 tem2 = Ffile_exists_p (tem); |
c0b6ecdf4a2b
(init_lread): Don't add to load-path lisp subdirectories
Richard M. Stallman <rms@gnu.org>
parents:
18665
diff
changeset
|
3138 if (!NILP (tem1) && NILP (tem2)) |
18084
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3139 { |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3140 tem = Fexpand_file_name (build_string ("lisp"), |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3141 Vsource_directory); |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3142 |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3143 if (NILP (Fmember (tem, Vload_path))) |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3144 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil)); |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3145 |
18530
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3146 tem = Fexpand_file_name (build_string ("leim"), |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3147 Vsource_directory); |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3148 |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3149 if (NILP (Fmember (tem, Vload_path))) |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3150 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil)); |
94c18a43de33
(init_lread): Add leim subdir, like lisp subdir.
Richard M. Stallman <rms@gnu.org>
parents:
18084
diff
changeset
|
3151 |
18084
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3152 tem = Fexpand_file_name (build_string ("site-lisp"), |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3153 Vsource_directory); |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3154 |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3155 if (NILP (Fmember (tem, Vload_path))) |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3156 Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil)); |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3157 } |
6f264bb70b49
(init_lread): Sometimes add to load-path
Richard M. Stallman <rms@gnu.org>
parents:
18051
diff
changeset
|
3158 } |
4482
09d0f4b26641
(init_lread): Normally put Vinvocation_directory
Richard M. Stallman <rms@gnu.org>
parents:
3704
diff
changeset
|
3159 } |
09d0f4b26641
(init_lread): Normally put Vinvocation_directory
Richard M. Stallman <rms@gnu.org>
parents:
3704
diff
changeset
|
3160 } |
621 | 3161 } |
3162 else | |
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
3163 { |
17605
83850481ae70
(init_lread): Don't add ../lisp to the dump-time load path.
Richard M. Stallman <rms@gnu.org>
parents:
17325
diff
changeset
|
3164 /* NORMAL refers to the lisp dir in the source directory. */ |
83850481ae70
(init_lread): Don't add ../lisp to the dump-time load path.
Richard M. Stallman <rms@gnu.org>
parents:
17325
diff
changeset
|
3165 /* We used to add ../lisp at the front here, but |
83850481ae70
(init_lread): Don't add ../lisp to the dump-time load path.
Richard M. Stallman <rms@gnu.org>
parents:
17325
diff
changeset
|
3166 that caused trouble because it was copied from dump_path |
83850481ae70
(init_lread): Don't add ../lisp to the dump-time load path.
Richard M. Stallman <rms@gnu.org>
parents:
17325
diff
changeset
|
3167 into Vload_path, aboe, when Vinstallation_directory was non-nil. |
83850481ae70
(init_lread): Don't add ../lisp to the dump-time load path.
Richard M. Stallman <rms@gnu.org>
parents:
17325
diff
changeset
|
3168 It should be unnecessary. */ |
83850481ae70
(init_lread): Don't add ../lisp to the dump-time load path.
Richard M. Stallman <rms@gnu.org>
parents:
17325
diff
changeset
|
3169 Vload_path = decode_env_path (0, normal); |
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
3170 dump_path = Vload_path; |
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
3171 } |
364 | 3172 #endif |
3173 | |
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
3174 #ifndef WINDOWSNT |
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
3175 /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is |
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
3176 almost never correct, thereby causing a warning to be printed out that |
14036 | 3177 confuses users. Since PATH_LOADSEARCH is always overridden by the |
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
3178 EMACSLOADPATH environment variable below, disable the warning on NT. */ |
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
3179 |
341 | 3180 /* Warn if dirs in the *standard* path don't exist. */ |
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3181 if (!turn_off_warning) |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3182 { |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3183 Lisp_Object path_tail; |
341 | 3184 |
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3185 for (path_tail = Vload_path; |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3186 !NILP (path_tail); |
25663
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
3187 path_tail = XCDR (path_tail)) |
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3188 { |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3189 Lisp_Object dirfile; |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3190 dirfile = Fcar (path_tail); |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3191 if (STRINGP (dirfile)) |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3192 { |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3193 dirfile = Fdirectory_file_name (dirfile); |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3194 if (access (XSTRING (dirfile)->data, 0) < 0) |
16487
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3195 dir_warning ("Warning: Lisp directory `%s' does not exist.\n", |
25663
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25555
diff
changeset
|
3196 XCAR (path_tail)); |
11735
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3197 } |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3198 } |
f2f0f3b55a7e
(isfloat_string): Reject strings like "0.5+".
Richard M. Stallman <rms@gnu.org>
parents:
11699
diff
changeset
|
3199 } |
9790
637b4664f7a5
Change explicit uses of the Unix directory separator
Richard M. Stallman <rms@gnu.org>
parents:
9552
diff
changeset
|
3200 #endif /* WINDOWSNT */ |
617 | 3201 |
3202 /* If the EMACSLOADPATH environment variable is set, use its value. | |
3203 This doesn't apply if we're dumping. */ | |
11955
d972c95e7577
(init_lread) [CANNOT_DUMP]: Set Vload_path to EMACSLOADPATH.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11868
diff
changeset
|
3204 #ifndef CANNOT_DUMP |
617 | 3205 if (NILP (Vpurify_flag) |
3206 && egetenv ("EMACSLOADPATH")) | |
11955
d972c95e7577
(init_lread) [CANNOT_DUMP]: Set Vload_path to EMACSLOADPATH.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11868
diff
changeset
|
3207 #endif |
364 | 3208 Vload_path = decode_env_path ("EMACSLOADPATH", normal); |
3209 | |
3210 Vvalues = Qnil; | |
3211 | |
341 | 3212 load_in_progress = 0; |
15283
b2be450a8da4
(init_lread): Init Vload_file_name to Qnil.
Karl Heuer <kwzh@gnu.org>
parents:
15091
diff
changeset
|
3213 Vload_file_name = Qnil; |
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
3214 |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
3215 load_descriptor_list = Qnil; |
21291
b039d32d8399
(init_lread): Init Vstandard_input.
Richard M. Stallman <rms@gnu.org>
parents:
21251
diff
changeset
|
3216 |
b039d32d8399
(init_lread): Init Vstandard_input.
Richard M. Stallman <rms@gnu.org>
parents:
21251
diff
changeset
|
3217 Vstandard_input = Qt; |
341 | 3218 } |
3219 | |
16487
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3220 /* Print a warning, using format string FORMAT, that directory DIRNAME |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3221 does not exist. Print it on stderr and put it in *Message*. */ |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3222 |
20298
b7d23d2eded1
(read1): Declare `workbuf' as unsigned char.
Andreas Schwab <schwab@suse.de>
parents:
20168
diff
changeset
|
3223 void |
16487
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3224 dir_warning (format, dirname) |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3225 char *format; |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3226 Lisp_Object dirname; |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3227 { |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3228 char *buffer |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3229 = (char *) alloca (XSTRING (dirname)->size + strlen (format) + 5); |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3230 |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3231 fprintf (stderr, format, XSTRING (dirname)->data); |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3232 sprintf (buffer, format, XSTRING (dirname)->data); |
21736
f654c3b16214
(dir_warning): Don't log a warning if Emacs hasn't
Geoff Voelker <voelker@cs.washington.edu>
parents:
21724
diff
changeset
|
3233 /* Don't log the warning before we've initialized!! */ |
f654c3b16214
(dir_warning): Don't log a warning if Emacs hasn't
Geoff Voelker <voelker@cs.washington.edu>
parents:
21724
diff
changeset
|
3234 if (initialized) |
f654c3b16214
(dir_warning): Don't log a warning if Emacs hasn't
Geoff Voelker <voelker@cs.washington.edu>
parents:
21724
diff
changeset
|
3235 message_dolog (buffer, strlen (buffer), 0, STRING_MULTIBYTE (dirname)); |
16487
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3236 } |
8e154ff6d4bf
(dir_warning): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16383
diff
changeset
|
3237 |
341 | 3238 void |
364 | 3239 syms_of_lread () |
341 | 3240 { |
3241 defsubr (&Sread); | |
3242 defsubr (&Sread_from_string); | |
3243 defsubr (&Sintern); | |
3244 defsubr (&Sintern_soft); | |
11188
d7f70df00bb0
(oblookup): Save bucket num in oblookup_last_bucket_number.
Richard M. Stallman <rms@gnu.org>
parents:
11172
diff
changeset
|
3245 defsubr (&Sunintern); |
341 | 3246 defsubr (&Sload); |
672 | 3247 defsubr (&Seval_buffer); |
341 | 3248 defsubr (&Seval_region); |
3249 defsubr (&Sread_char); | |
3250 defsubr (&Sread_char_exclusive); | |
3251 defsubr (&Sread_event); | |
3252 defsubr (&Sget_file_char); | |
3253 defsubr (&Smapatoms); | |
3254 | |
3255 DEFVAR_LISP ("obarray", &Vobarray, | |
3256 "Symbol table for use by `intern' and `read'.\n\ | |
3257 It is a vector whose length ought to be prime for best results.\n\ | |
3258 The vector's contents don't make sense if examined from Lisp programs;\n\ | |
3259 to find all the symbols in an obarray, use `mapatoms'."); | |
3260 | |
3261 DEFVAR_LISP ("values", &Vvalues, | |
3262 "List of values of all expressions which were read, evaluated and printed.\n\ | |
3263 Order is reverse chronological."); | |
3264 | |
3265 DEFVAR_LISP ("standard-input", &Vstandard_input, | |
3266 "Stream for read to get input from.\n\ | |
3267 See documentation of `read' for possible values."); | |
3268 Vstandard_input = Qt; | |
3269 | |
3270 DEFVAR_LISP ("load-path", &Vload_path, | |
3271 "*List of directories to search for files to load.\n\ | |
3272 Each element is a string (directory name) or nil (try default directory).\n\ | |
3273 Initialized based on EMACSLOADPATH environment variable, if any,\n\ | |
24412
d11ac02f9d6a
Use epaths.h istead of paths.h.
Richard M. Stallman <rms@gnu.org>
parents:
23933
diff
changeset
|
3274 otherwise to default specified by file `epaths.h' when Emacs was built."); |
341 | 3275 |
3276 DEFVAR_BOOL ("load-in-progress", &load_in_progress, | |
3277 "Non-nil iff inside of `load'."); | |
3278 | |
3279 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist, | |
3280 "An alist of expressions to be evalled when particular files are loaded.\n\ | |
3281 Each element looks like (FILENAME FORMS...).\n\ | |
3282 When `load' is run and the file-name argument is FILENAME,\n\ | |
3283 the FORMS in the corresponding element are executed at the end of loading.\n\n\ | |
3284 FILENAME must match exactly! Normally FILENAME is the name of a library,\n\ | |
3285 with no directory specified, since that is how `load' is normally called.\n\ | |
3286 An error in FORMS does not undo the load,\n\ | |
3287 but does prevent execution of the rest of the FORMS."); | |
3288 Vafter_load_alist = Qnil; | |
3289 | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3290 DEFVAR_LISP ("load-history", &Vload_history, |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3291 "Alist mapping source file names to symbols and features.\n\ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3292 Each alist element is a list that starts with a file name,\n\ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3293 except for one element (optional) that starts with nil and describes\n\ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3294 definitions evaluated from buffers not visiting files.\n\ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3295 The remaining elements of each list are symbols defined as functions\n\ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3296 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'."); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3297 Vload_history = Qnil; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3298 |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
3299 DEFVAR_LISP ("load-file-name", &Vload_file_name, |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
3300 "Full name of file being loaded by `load'."); |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
3301 Vload_file_name = Qnil; |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
3302 |
24817
3e8c8a06329b
(Vuser_init_file): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
24412
diff
changeset
|
3303 DEFVAR_LISP ("user-init-file", &Vuser_init_file, |
27628
2e9293b149dd
(syms_of_lread): Fix literal newlines.
Andrew Innes <andrewi@gnu.org>
parents:
27612
diff
changeset
|
3304 "File name, including directory, of user's initialization file.\n\ |
2e9293b149dd
(syms_of_lread): Fix literal newlines.
Andrew Innes <andrewi@gnu.org>
parents:
27612
diff
changeset
|
3305 If the file loaded had extension `.elc' and there was a corresponding `.el'\n\ |
2e9293b149dd
(syms_of_lread): Fix literal newlines.
Andrew Innes <andrewi@gnu.org>
parents:
27612
diff
changeset
|
3306 file, this variable contains the name of the .el file, suitable for use\n\ |
27364
0c0628ca5029
(syms_of_lread) [user-init-file]: Doc change.
Dave Love <fx@gnu.org>
parents:
26866
diff
changeset
|
3307 by functions like `custom-save-all' which edit the init file."); |
24817
3e8c8a06329b
(Vuser_init_file): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
24412
diff
changeset
|
3308 Vuser_init_file = Qnil; |
3e8c8a06329b
(Vuser_init_file): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
24412
diff
changeset
|
3309 |
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
3310 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list, |
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
3311 "Used for internal purposes by `load'."); |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3312 Vcurrent_load_list = Qnil; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
3313 |
11079
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
3314 DEFVAR_LISP ("load-read-function", &Vload_read_function, |
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
3315 "Function used by `load' and `eval-region' for reading expressions.\n\ |
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
3316 The default is nil, which means use the function `read'."); |
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
3317 Vload_read_function = Qnil; |
aeaaa579d967
(Vload_read_function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
11020
diff
changeset
|
3318 |
17038 | 3319 DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function, |
3320 "Function called in `load' for loading an Emacs lisp source file.\n\ | |
3321 This function is for doing code conversion before reading the source file.\n\ | |
3322 If nil, loading is done without any code conversion.\n\ | |
3323 Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where\n\ | |
3324 FULLNAME is the full name of FILE.\n\ | |
3325 See `load' for the meaning of the remaining arguments."); | |
3326 Vload_source_file_function = Qnil; | |
3327 | |
12780
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
3328 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings, |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
3329 "Non-nil means `load' should force-load all dynamic doc strings.\n\ |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
3330 This is useful when the file being loaded is a temporary copy."); |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
3331 load_force_doc_strings = 0; |
2c1f71512d5d
(saved_doc_string*): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
12639
diff
changeset
|
3332 |
21677
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
3333 DEFVAR_BOOL ("load-convert-to-unibyte", &load_convert_to_unibyte, |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
3334 "Non-nil means `load' converts strings to unibyte whenever possible.\n\ |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
3335 This is normally used in `load-with-code-conversion'\n\ |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
3336 for loading non-compiled files."); |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
3337 load_convert_to_unibyte = 0; |
f42b78e033db
(readevalloop): New arg UNIBYTE. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
21636
diff
changeset
|
3338 |
13601
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
3339 DEFVAR_LISP ("source-directory", &Vsource_directory, |
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
3340 "Directory in which Emacs sources were found when Emacs was built.\n\ |
0a091134e047
(Vsource_directory): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13455
diff
changeset
|
3341 You cannot count on them to still be there!"); |
14300
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
3342 Vsource_directory |
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
3343 = Fexpand_file_name (build_string ("../"), |
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
3344 Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH))); |
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
3345 |
18665
6d7b8b35d878
(Vpreloaded_file_list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18530
diff
changeset
|
3346 DEFVAR_LISP ("preloaded-file-list", &Vpreloaded_file_list, |
6d7b8b35d878
(Vpreloaded_file_list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18530
diff
changeset
|
3347 "List of files that were preloaded (when dumping Emacs)."); |
6d7b8b35d878
(Vpreloaded_file_list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18530
diff
changeset
|
3348 Vpreloaded_file_list = Qnil; |
6d7b8b35d878
(Vpreloaded_file_list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18530
diff
changeset
|
3349 |
25555
301ce7f0b398
(Vbyte_boolean_vars): New variable.
Dave Love <fx@gnu.org>
parents:
25251
diff
changeset
|
3350 DEFVAR_LISP ("byte-boolean-vars", &Vbyte_boolean_vars, |
301ce7f0b398
(Vbyte_boolean_vars): New variable.
Dave Love <fx@gnu.org>
parents:
25251
diff
changeset
|
3351 "List of all DEFVAR_BOOL variables, used by the byte code optimizer."); |
301ce7f0b398
(Vbyte_boolean_vars): New variable.
Dave Love <fx@gnu.org>
parents:
25251
diff
changeset
|
3352 Vbyte_boolean_vars = Qnil; |
301ce7f0b398
(Vbyte_boolean_vars): New variable.
Dave Love <fx@gnu.org>
parents:
25251
diff
changeset
|
3353 |
14300
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
3354 /* Vsource_directory was initialized in init_lread. */ |
f777822a5d81
(syms_of_lread): Set Vsource_directory here.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
3355 |
5568
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
3356 load_descriptor_list = Qnil; |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
3357 staticpro (&load_descriptor_list); |
1af95f18f709
(Fload): Record descriptor numbers on load_descriptor_list.
Richard M. Stallman <rms@gnu.org>
parents:
5496
diff
changeset
|
3358 |
2901
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
3359 Qcurrent_load_list = intern ("current-load-list"); |
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
3360 staticpro (&Qcurrent_load_list); |
510a7ebce564
(syms_of_lread): Make Vcurrent_load_list ordinary Lisp var.
Richard M. Stallman <rms@gnu.org>
parents:
2781
diff
changeset
|
3361 |
341 | 3362 Qstandard_input = intern ("standard-input"); |
3363 staticpro (&Qstandard_input); | |
3364 | |
3365 Qread_char = intern ("read-char"); | |
3366 staticpro (&Qread_char); | |
3367 | |
3368 Qget_file_char = intern ("get-file-char"); | |
3369 staticpro (&Qget_file_char); | |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
3370 |
11683
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
3371 Qbackquote = intern ("`"); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
3372 staticpro (&Qbackquote); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
3373 Qcomma = intern (","); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
3374 staticpro (&Qcomma); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
3375 Qcomma_at = intern (",@"); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
3376 staticpro (&Qcomma_at); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
3377 Qcomma_dot = intern (",."); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
3378 staticpro (&Qcomma_dot); |
355d0b23a080
(read1): New arg FIRST_IN_LIST; all callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
11311
diff
changeset
|
3379 |
16937
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
3380 Qinhibit_file_name_operation = intern ("inhibit-file-name-operation"); |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
3381 staticpro (&Qinhibit_file_name_operation); |
c46111ba348b
(openp): Handle remote file names in path.
Richard M. Stallman <rms@gnu.org>
parents:
16925
diff
changeset
|
3382 |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
3383 Qascii_character = intern ("ascii-character"); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
3384 staticpro (&Qascii_character); |
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
3385 |
13235
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
3386 Qfunction = intern ("function"); |
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
3387 staticpro (&Qfunction); |
0f83b9eb5478
(read1): Handle #' as prefix.
Richard M. Stallman <rms@gnu.org>
parents:
13146
diff
changeset
|
3388 |
3625
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
3389 Qload = intern ("load"); |
57174f9b1870
(Fload): Forward all 4 args to magic-name handler.
Richard M. Stallman <rms@gnu.org>
parents:
3041
diff
changeset
|
3390 staticpro (&Qload); |
10200
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
3391 |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
3392 Qload_file_name = intern ("load-file-name"); |
899f5bd94bbb
(Qload_file_name, Vload_file_name): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
10163
diff
changeset
|
3393 staticpro (&Qload_file_name); |
14130
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
3394 |
99ab26698ab0
(read1): Use xmalloc and xrealloc, not malloc and realloc.
Karl Heuer <kwzh@gnu.org>
parents:
14092
diff
changeset
|
3395 staticpro (&dump_path); |
16141
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
3396 |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
3397 staticpro (&read_objects); |
9cbc74969e46
Add #n=object, #n#, and #:symbol constructs to reader.
Erik Naggum <erik@naggum.no>
parents:
16039
diff
changeset
|
3398 read_objects = Qnil; |
25165
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
3399 staticpro (&seen_list); |
8b9110694bfa
(read1): Added circular reading code to #N=.
Richard M. Stallman <rms@gnu.org>
parents:
24817
diff
changeset
|
3400 |
341 | 3401 } |