comparison src/lread.c @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents 966663fcf606
children 90d73dddcdc4
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
68 Lisp_Object Qcurrent_load_list; 68 Lisp_Object Qcurrent_load_list;
69 Lisp_Object Qload, Qload_file_name; 69 Lisp_Object Qload, Qload_file_name;
70 Lisp_Object Qlocate_file_hash_table; 70 Lisp_Object Qlocate_file_hash_table;
71 Lisp_Object Qfset; 71 Lisp_Object Qfset;
72 72
73 int puke_on_fsf_keys; 73 int fail_on_bucky_bit_character_escapes;
74 74
75 /* This symbol is also used in fns.c */ 75 /* This symbol is also used in fns.c */
76 #define FEATUREP_SYNTAX 76 #define FEATUREP_SYNTAX
77 77
78 #ifdef FEATUREP_SYNTAX 78 #ifdef FEATUREP_SYNTAX
204 /* Length of actual data in saved_doc_string. */ 204 /* Length of actual data in saved_doc_string. */
205 static int saved_doc_string_length; 205 static int saved_doc_string_length;
206 /* This is the file position that string came from. */ 206 /* This is the file position that string came from. */
207 static int saved_doc_string_position; 207 static int saved_doc_string_position;
208 #endif 208 #endif
209
210 EXFUN (Fread_from_string, 3);
209 211
210 /* When errors are signaled, the actual readcharfun should not be used 212 /* When errors are signaled, the actual readcharfun should not be used
211 as an argument if it is an lstream, so that lstreams don't escape 213 as an argument if it is an lstream, so that lstreams don't escape
212 to the Lisp level. */ 214 to the Lisp level. */
213 #define READCHARFUN_MAYBE(x) (LSTREAMP (x) \ 215 #define READCHARFUN_MAYBE(x) (LSTREAMP (x) \
571 struct gcpro gcpro1, gcpro2, gcpro3; 573 struct gcpro gcpro1, gcpro2, gcpro3;
572 int reading_elc = 0; 574 int reading_elc = 0;
573 int message_p = NILP (nomessage); 575 int message_p = NILP (nomessage);
574 /*#ifdef DEBUG_XEMACS*/ 576 /*#ifdef DEBUG_XEMACS*/
575 static Lisp_Object last_file_loaded; 577 static Lisp_Object last_file_loaded;
576 int pure_usage = 0; 578 size_t pure_usage = 0;
577 /*#endif*/ 579 /*#endif*/
578 struct stat s1, s2; 580 struct stat s1, s2;
579 GCPRO3 (file, newer, found); 581 GCPRO3 (file, newer, found);
580 582
581 CHECK_STRING (file); 583 CHECK_STRING (file);
855 /* This function can GC */ 857 /* This function can GC */
856 Lisp_Object tp; 858 Lisp_Object tp;
857 859
858 CHECK_STRING (filename); 860 CHECK_STRING (filename);
859 if (!NILP (suffixes)) 861 if (!NILP (suffixes))
860 { 862 CHECK_STRING (suffixes);
861 CHECK_STRING (suffixes); 863 if (!NILP (mode))
862 } 864 CHECK_NATNUM (mode);
863 if (!(NILP (mode) || (INTP (mode) && XINT (mode) >= 0))) 865
864 mode = wrong_type_argument (Qnatnump, mode);
865 locate_file (path_list, filename, 866 locate_file (path_list, filename,
866 ((NILP (suffixes)) ? "" : 867 ((NILP (suffixes)) ? "" :
867 (char *) (XSTRING_DATA (suffixes))), 868 (char *) (XSTRING_DATA (suffixes))),
868 &tp, (NILP (mode) ? R_OK : XINT (mode))); 869 &tp, (NILP (mode) ? R_OK : XINT (mode)));
869 return tp; 870 return tp;
1059 if (esuffix == 0) 1060 if (esuffix == 0)
1060 break; 1061 break;
1061 nsuffix += lsuffix + 1; 1062 nsuffix += lsuffix + 1;
1062 } 1063 }
1063 return Fnreverse (suffixtab); 1064 return Fnreverse (suffixtab);
1065 }
1066
1067 DEFUN ("locate-file-clear-hashing", Flocate_file_clear_hashing, 1, 1, 0, /*
1068 Clear the hash records for the specified list of directories.
1069 `locate-file' uses a hashing scheme to speed lookup, and will correctly
1070 track the following environmental changes:
1071
1072 -- changes of any sort to the list of directories to be searched.
1073 -- addition and deletion of non-shadowing files (see below) from the
1074 directories in the list.
1075 -- byte-compilation of a .el file into a .elc file.
1076
1077 `locate-file' will primarily get confused if you add a file that shadows
1078 \(i.e. has the same name as) another file further down in the directory list.
1079 In this case, you must call `locate-file-clear-hashing'.
1080 */
1081 (path))
1082 {
1083 Lisp_Object pathtail;
1084
1085 for (pathtail = path; !NILP (pathtail); pathtail = Fcdr (pathtail))
1086 {
1087 Lisp_Object pathel = Fcar (pathtail);
1088 if (!purified (pathel))
1089 Fput (pathel, Qlocate_file_hash_table, Qnil);
1090 }
1091 return Qnil;
1064 } 1092 }
1065 1093
1066 /* Search for a file whose name is STR, looking in directories 1094 /* Search for a file whose name is STR, looking in directories
1067 in the Lisp list PATH, and trying suffixes from SUFFIX. 1095 in the Lisp list PATH, and trying suffixes from SUFFIX.
1068 SUFFIX is a string containing possible suffixes separated by colons. 1096 SUFFIX is a string containing possible suffixes separated by colons.
1164 1192
1165 UNGCPRO; 1193 UNGCPRO;
1166 return val; 1194 return val;
1167 } 1195 }
1168 1196
1169 DEFUN ("locate-file-clear-hashing", Flocate_file_clear_hashing, 1, 1, 0, /*
1170 Clear the hash records for the specified list of directories.
1171 `locate-file' uses a hashing scheme to speed lookup, and will correctly
1172 track the following environmental changes:
1173
1174 -- changes of any sort to the list of directories to be searched.
1175 -- addition and deletion of non-shadowing files (see below) from the
1176 directories in the list.
1177 -- byte-compilation of a .el file into a .elc file.
1178
1179 `locate-file' will primarily get confused if you add a file that shadows
1180 \(i.e. has the same name as) another file further down in the directory list.
1181 In this case, you must call `locate-file-clear-hashing'.
1182 */
1183 (path))
1184 {
1185 Lisp_Object pathtail;
1186
1187 for (pathtail = path; !NILP (pathtail); pathtail = Fcdr (pathtail))
1188 {
1189 Lisp_Object pathel = Fcar (pathtail);
1190 if (!purified (pathel))
1191 Fput (pathel, Qlocate_file_hash_table, Qnil);
1192 }
1193 return Qnil;
1194 }
1195 1197
1196 #ifdef LOADHIST 1198 #ifdef LOADHIST
1197 1199
1198 /* Merge the list we've accumulated of globals from the current input source 1200 /* Merge the list we've accumulated of globals from the current input source
1199 into the load_history variable. The details depend on whether 1201 into the load_history variable. The details depend on whether
1625 1627
1626 #define ctl_modifier (0x400000) 1628 #define ctl_modifier (0x400000)
1627 #define meta_modifier (0x800000) 1629 #define meta_modifier (0x800000)
1628 */ 1630 */
1629 #define FSF_LOSSAGE(mask) \ 1631 #define FSF_LOSSAGE(mask) \
1630 if (puke_on_fsf_keys || ((c = readchar (readcharfun)) != '-')) \ 1632 if (fail_on_bucky_bit_character_escapes || \
1633 ((c = readchar (readcharfun)) != '-')) \
1631 error ("Invalid escape character syntax"); \ 1634 error ("Invalid escape character syntax"); \
1632 c = readchar (readcharfun); \ 1635 c = readchar (readcharfun); \
1633 if (c < 0) \ 1636 if (c < 0) \
1634 signal_error (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun))); \ 1637 signal_error (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun))); \
1635 if (c == '\\') \ 1638 if (c == '\\') \
1860 static Lisp_Object 1863 static Lisp_Object
1861 parse_integer (CONST Bufbyte *buf, Bytecount len, int base) 1864 parse_integer (CONST Bufbyte *buf, Bytecount len, int base)
1862 { 1865 {
1863 CONST Bufbyte *lim = buf + len; 1866 CONST Bufbyte *lim = buf + len;
1864 CONST Bufbyte *p = buf; 1867 CONST Bufbyte *p = buf;
1865 unsigned EMACS_INT num = 0; 1868 EMACS_UINT num = 0;
1866 int negativland = 0; 1869 int negativland = 0;
1867 1870
1868 if (*p == '-') 1871 if (*p == '-')
1869 { 1872 {
1870 negativland = 1; 1873 negativland = 1;
1879 goto loser; 1882 goto loser;
1880 1883
1881 for (; (p < lim) && (*p != '\0'); p++) 1884 for (; (p < lim) && (*p != '\0'); p++)
1882 { 1885 {
1883 int c = *p; 1886 int c = *p;
1884 unsigned EMACS_INT onum; 1887 EMACS_UINT onum;
1885 1888
1886 if (isdigit (c)) 1889 if (isdigit (c))
1887 c = c - '0'; 1890 c = c - '0';
1888 else if (isupper (c)) 1891 else if (isupper (c))
1889 c = c - 'A' + 10; 1892 c = c - 'A' + 10;
1900 if (num < onum) 1903 if (num < onum)
1901 goto overflow; 1904 goto overflow;
1902 } 1905 }
1903 1906
1904 { 1907 {
1905 int int_result = negativland ? -(int)num : (int)num; 1908 EMACS_INT int_result = negativland ? -num : num;
1906 Lisp_Object result = make_int (int_result); 1909 Lisp_Object result = make_int (int_result);
1907 if (num && ((XINT (result) < 0) != negativland)) 1910 if (num && ((XINT (result) < 0) != negativland))
1908 goto overflow; 1911 goto overflow;
1909 if (XINT (result) != int_result) 1912 if (XINT (result) != int_result)
1910 goto overflow; 1913 goto overflow;
2215 #if 0 2218 #if 0
2216 return Fsignal (Qinvalid_read_syntax, 2219 return Fsignal (Qinvalid_read_syntax,
2217 list1 (build_string ("Comma outside of backquote"))); 2220 list1 (build_string ("Comma outside of backquote")));
2218 #else 2221 #else
2219 /* #### - yuck....but this is reverse compatible. */ 2222 /* #### - yuck....but this is reverse compatible. */
2220 /* mostly this is required by edebug, which does it's own 2223 /* mostly this is required by edebug, which does its own
2221 annotated reading. We need to have an annotated_read 2224 annotated reading. We need to have an annotated_read
2222 function that records (with markers) the buffer 2225 function that records (with markers) the buffer
2223 positions of the elements that make up lists, then that 2226 positions of the elements that make up lists, then that
2224 can be used in edebug and bytecomp and the check above 2227 can be used in edebug and bytecomp and the check above
2225 can go back in. --Stig */ 2228 can go back in. --Stig */
2565 return Fsignal (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun))); 2568 return Fsignal (Qend_of_file, list1 (READCHARFUN_MAYBE (readcharfun)));
2566 2569
2567 /* If purifying, and string starts with \ newline, 2570 /* If purifying, and string starts with \ newline,
2568 return zero instead. This is for doc strings 2571 return zero instead. This is for doc strings
2569 that we are really going to find in lib-src/DOC.nn.nn */ 2572 that we are really going to find in lib-src/DOC.nn.nn */
2570 if (purify_flag && NILP (Vdoc_file_name) && cancel) 2573 if (purify_flag && NILP (Vinternal_doc_file_name) && cancel)
2571 return Qzero; 2574 return Qzero;
2572 2575
2573 Lstream_flush (XLSTREAM (Vread_buffer_stream)); 2576 Lstream_flush (XLSTREAM (Vread_buffer_stream));
2574 #if 0 /* FSFmacs defun hack */ 2577 #if 0 /* FSFmacs defun hack */
2575 if (read_pure) 2578 if (read_pure)
2841 2844
2842 if (CONSP (holding_cons)) 2845 if (CONSP (holding_cons))
2843 { 2846 {
2844 if (purify_flag) 2847 if (purify_flag)
2845 { 2848 {
2846 if (NILP (Vdoc_file_name)) 2849 if (NILP (Vinternal_doc_file_name))
2847 /* We have not yet called Snarf-documentation, so 2850 /* We have not yet called Snarf-documentation, so
2848 assume this file is described in the DOC file 2851 assume this file is described in the DOC file
2849 and Snarf-documentation will fill in the right 2852 and Snarf-documentation will fill in the right
2850 value later. For now, replace the whole list 2853 value later. For now, replace the whole list
2851 with 0. */ 2854 with 0. */
2956 && EQ (XCAR (make_byte_code_args[iii]), Vload_file_name_internal)) 2959 && EQ (XCAR (make_byte_code_args[iii]), Vload_file_name_internal))
2957 { 2960 {
2958 if (purify_flag && iii == COMPILED_DOC_STRING) 2961 if (purify_flag && iii == COMPILED_DOC_STRING)
2959 { 2962 {
2960 /* same as in read_list(). */ 2963 /* same as in read_list(). */
2961 if (NILP (Vdoc_file_name)) 2964 if (NILP (Vinternal_doc_file_name))
2962 make_byte_code_args[iii] = Qzero; 2965 make_byte_code_args[iii] = Qzero;
2963 else 2966 else
2964 XCAR (make_byte_code_args[iii]) = 2967 XCAR (make_byte_code_args[iii]) =
2965 concat2 (build_string ("../lisp/"), 2968 concat2 (build_string ("../lisp/"),
2966 Ffile_name_nondirectory 2969 Ffile_name_nondirectory
3164 Directory in which XEmacs sources were found when XEmacs was built. 3167 Directory in which XEmacs sources were found when XEmacs was built.
3165 You cannot count on them to still be there! 3168 You cannot count on them to still be there!
3166 */ ); 3169 */ );
3167 Vsource_directory = Qnil; 3170 Vsource_directory = Qnil;
3168 3171
3169 DEFVAR_BOOL ("fail-on-bucky-bit-character-escapes", &puke_on_fsf_keys /* 3172 /* Used to be named `puke-on-fsf-keys' */
3173 DEFVAR_BOOL ("fail-on-bucky-bit-character-escapes",
3174 &fail_on_bucky_bit_character_escapes /*
3170 Whether `read' should signal an error when it encounters unsupported 3175 Whether `read' should signal an error when it encounters unsupported
3171 character escape syntaxes or just read them incorrectly. 3176 character escape syntaxes or just read them incorrectly.
3172 */ ); 3177 */ );
3173 puke_on_fsf_keys = 0; 3178 fail_on_bucky_bit_character_escapes = 0;
3174 3179
3175 /* This must be initialized in init_lread otherwise it may start out 3180 /* This must be initialized in init_lread otherwise it may start out
3176 with values saved when the image is dumped. */ 3181 with values saved when the image is dumped. */
3177 staticpro (&Vload_descriptor_list); 3182 staticpro (&Vload_descriptor_list);
3178 3183