Mercurial > emacs
comparison src/lread.c @ 109126:aec1143e8d85
Convert (most) functions in src to standard C.
* src/alloc.c: Convert function definitions to standard C.
* src/atimer.c:
* src/bidi.c:
* src/bytecode.c:
* src/callint.c:
* src/callproc.c:
* src/casefiddle.c:
* src/casetab.c:
* src/category.c:
* src/ccl.c:
* src/character.c:
* src/charset.c:
* src/chartab.c:
* src/cmds.c:
* src/coding.c:
* src/composite.c:
* src/data.c:
* src/dbusbind.c:
* src/dired.c:
* src/dispnew.c:
* src/doc.c:
* src/doprnt.c:
* src/ecrt0.c:
* src/editfns.c:
* src/fileio.c:
* src/filelock.c:
* src/filemode.c:
* src/fns.c:
* src/font.c:
* src/fontset.c:
* src/frame.c:
* src/fringe.c:
* src/ftfont.c:
* src/ftxfont.c:
* src/gtkutil.c:
* src/indent.c:
* src/insdel.c:
* src/intervals.c:
* src/keymap.c:
* src/lread.c:
* src/macros.c:
* src/marker.c:
* src/md5.c:
* src/menu.c:
* src/minibuf.c:
* src/prefix-args.c:
* src/print.c:
* src/ralloc.c:
* src/regex.c:
* src/region-cache.c:
* src/scroll.c:
* src/search.c:
* src/sound.c:
* src/strftime.c:
* src/syntax.c:
* src/sysdep.c:
* src/termcap.c:
* src/terminal.c:
* src/terminfo.c:
* src/textprop.c:
* src/tparam.c:
* src/undo.c:
* src/unexelf.c:
* src/window.c:
* src/xfaces.c:
* src/xfns.c:
* src/xfont.c:
* src/xftfont.c:
* src/xgselect.c:
* src/xmenu.c:
* src/xrdb.c:
* src/xselect.c:
* src/xsettings.c:
* src/xsmfns.c:
* src/xterm.c: Likewise.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sun, 04 Jul 2010 00:50:25 -0700 |
parents | 2bc9a0c04c87 |
children | 18f8e88d3829 |
comparison
equal
deleted
inserted
replaced
109125:12b02558bf51 | 109126:aec1143e8d85 |
---|---|
228 Lisp_Object, Lisp_Object); | 228 Lisp_Object, Lisp_Object); |
229 static Lisp_Object load_unwind (Lisp_Object); | 229 static Lisp_Object load_unwind (Lisp_Object); |
230 static Lisp_Object load_descriptor_unwind (Lisp_Object); | 230 static Lisp_Object load_descriptor_unwind (Lisp_Object); |
231 | 231 |
232 static void invalid_syntax (const char *, int) NO_RETURN; | 232 static void invalid_syntax (const char *, int) NO_RETURN; |
233 static void end_of_file_error () NO_RETURN; | 233 static void end_of_file_error (void) NO_RETURN; |
234 | 234 |
235 | 235 |
236 /* Functions that read one byte from the current source READCHARFUN | 236 /* Functions that read one byte from the current source READCHARFUN |
237 or unreads one byte. If the integer argument C is -1, it returns | 237 or unreads one byte. If the integer argument C is -1, it returns |
238 one read byte, or -1 when there's no more byte in the source. If C | 238 one read byte, or -1 when there's no more byte in the source. If C |
260 a file stream can't handle multibyte-char unreading. The value -1 | 260 a file stream can't handle multibyte-char unreading. The value -1 |
261 means that there's no unread character. */ | 261 means that there's no unread character. */ |
262 static int unread_char; | 262 static int unread_char; |
263 | 263 |
264 static int | 264 static int |
265 readchar (readcharfun, multibyte) | 265 readchar (Lisp_Object readcharfun, int *multibyte) |
266 Lisp_Object readcharfun; | |
267 int *multibyte; | |
268 { | 266 { |
269 Lisp_Object tem; | 267 Lisp_Object tem; |
270 register int c; | 268 register int c; |
271 int (*readbyte) (int, Lisp_Object); | 269 int (*readbyte) (int, Lisp_Object); |
272 unsigned char buf[MAX_MULTIBYTE_LENGTH]; | 270 unsigned char buf[MAX_MULTIBYTE_LENGTH]; |
433 | 431 |
434 /* Unread the character C in the way appropriate for the stream READCHARFUN. | 432 /* Unread the character C in the way appropriate for the stream READCHARFUN. |
435 If the stream is a user function, call it with the char as argument. */ | 433 If the stream is a user function, call it with the char as argument. */ |
436 | 434 |
437 static void | 435 static void |
438 unreadchar (readcharfun, c) | 436 unreadchar (Lisp_Object readcharfun, int c) |
439 Lisp_Object readcharfun; | |
440 int c; | |
441 { | 437 { |
442 readchar_count--; | 438 readchar_count--; |
443 if (c == -1) | 439 if (c == -1) |
444 /* Don't back up the pointer if we're unreading the end-of-input mark, | 440 /* Don't back up the pointer if we're unreading the end-of-input mark, |
445 since readchar didn't advance it when we read it. */ | 441 since readchar didn't advance it when we read it. */ |
499 else | 495 else |
500 call1 (readcharfun, make_number (c)); | 496 call1 (readcharfun, make_number (c)); |
501 } | 497 } |
502 | 498 |
503 static int | 499 static int |
504 readbyte_for_lambda (c, readcharfun) | 500 readbyte_for_lambda (int c, Lisp_Object readcharfun) |
505 int c; | |
506 Lisp_Object readcharfun; | |
507 { | 501 { |
508 return read_bytecode_char (c >= 0); | 502 return read_bytecode_char (c >= 0); |
509 } | 503 } |
510 | 504 |
511 | 505 |
512 static int | 506 static int |
513 readbyte_from_file (c, readcharfun) | 507 readbyte_from_file (int c, Lisp_Object readcharfun) |
514 int c; | |
515 Lisp_Object readcharfun; | |
516 { | 508 { |
517 if (c >= 0) | 509 if (c >= 0) |
518 { | 510 { |
519 BLOCK_INPUT; | 511 BLOCK_INPUT; |
520 ungetc (c, instream); | 512 ungetc (c, instream); |
541 | 533 |
542 return (c == EOF ? -1 : c); | 534 return (c == EOF ? -1 : c); |
543 } | 535 } |
544 | 536 |
545 static int | 537 static int |
546 readbyte_from_string (c, readcharfun) | 538 readbyte_from_string (int c, Lisp_Object readcharfun) |
547 int c; | |
548 Lisp_Object readcharfun; | |
549 { | 539 { |
550 Lisp_Object string = XCAR (readcharfun); | 540 Lisp_Object string = XCAR (readcharfun); |
551 | 541 |
552 if (c >= 0) | 542 if (c >= 0) |
553 { | 543 { |
571 C. */ | 561 C. */ |
572 | 562 |
573 extern char emacs_mule_bytes[256]; | 563 extern char emacs_mule_bytes[256]; |
574 | 564 |
575 static int | 565 static int |
576 read_emacs_mule_char (c, readbyte, readcharfun) | 566 read_emacs_mule_char (int c, int (*readbyte) (int, Lisp_Object), Lisp_Object readcharfun) |
577 int c; | |
578 int (*readbyte) (int, Lisp_Object); | |
579 Lisp_Object readcharfun; | |
580 { | 567 { |
581 /* Emacs-mule coding uses at most 4-byte for one character. */ | 568 /* Emacs-mule coding uses at most 4-byte for one character. */ |
582 unsigned char buf[4]; | 569 unsigned char buf[4]; |
583 int len = emacs_mule_bytes[c]; | 570 int len = emacs_mule_bytes[c]; |
584 struct charset *charset; | 571 struct charset *charset; |
869 safe to load. Only files compiled with Emacs are safe to load. | 856 safe to load. Only files compiled with Emacs are safe to load. |
870 Files compiled with XEmacs can lead to a crash in Fbyte_code | 857 Files compiled with XEmacs can lead to a crash in Fbyte_code |
871 because of an incompatible change in the byte compiler. */ | 858 because of an incompatible change in the byte compiler. */ |
872 | 859 |
873 static int | 860 static int |
874 safe_to_load_p (fd) | 861 safe_to_load_p (int fd) |
875 int fd; | |
876 { | 862 { |
877 char buf[512]; | 863 char buf[512]; |
878 int nbytes, i; | 864 int nbytes, i; |
879 int safe_p = 1; | 865 int safe_p = 1; |
880 int version = 1; | 866 int version = 1; |
907 | 893 |
908 /* Callback for record_unwind_protect. Restore the old load list OLD, | 894 /* Callback for record_unwind_protect. Restore the old load list OLD, |
909 after loading a file successfully. */ | 895 after loading a file successfully. */ |
910 | 896 |
911 static Lisp_Object | 897 static Lisp_Object |
912 record_load_unwind (old) | 898 record_load_unwind (Lisp_Object old) |
913 Lisp_Object old; | |
914 { | 899 { |
915 return Vloads_in_progress = old; | 900 return Vloads_in_progress = old; |
916 } | 901 } |
917 | 902 |
918 /* This handler function is used via internal_condition_case_1. */ | 903 /* This handler function is used via internal_condition_case_1. */ |
919 | 904 |
920 static Lisp_Object | 905 static Lisp_Object |
921 load_error_handler (data) | 906 load_error_handler (Lisp_Object data) |
922 Lisp_Object data; | |
923 { | 907 { |
924 return Qnil; | 908 return Qnil; |
925 } | 909 } |
926 | 910 |
927 static Lisp_Object | 911 static Lisp_Object |
928 load_warn_old_style_backquotes (file) | 912 load_warn_old_style_backquotes (Lisp_Object file) |
929 Lisp_Object file; | |
930 { | 913 { |
931 if (!NILP (Vold_style_backquotes)) | 914 if (!NILP (Vold_style_backquotes)) |
932 { | 915 { |
933 Lisp_Object args[2]; | 916 Lisp_Object args[2]; |
934 args[0] = build_string ("Loading `%s': old-style backquotes detected!"); | 917 args[0] = build_string ("Loading `%s': old-style backquotes detected!"); |
1297 | 1280 |
1298 return Qt; | 1281 return Qt; |
1299 } | 1282 } |
1300 | 1283 |
1301 static Lisp_Object | 1284 static Lisp_Object |
1302 load_unwind (arg) /* used as unwind-protect function in load */ | 1285 load_unwind (Lisp_Object arg) /* used as unwind-protect function in load */ |
1303 Lisp_Object arg; | 1286 |
1304 { | 1287 { |
1305 FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer; | 1288 FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer; |
1306 if (stream != NULL) | 1289 if (stream != NULL) |
1307 { | 1290 { |
1308 BLOCK_INPUT; | 1291 BLOCK_INPUT; |
1311 } | 1294 } |
1312 return Qnil; | 1295 return Qnil; |
1313 } | 1296 } |
1314 | 1297 |
1315 static Lisp_Object | 1298 static Lisp_Object |
1316 load_descriptor_unwind (oldlist) | 1299 load_descriptor_unwind (Lisp_Object oldlist) |
1317 Lisp_Object oldlist; | |
1318 { | 1300 { |
1319 load_descriptor_list = oldlist; | 1301 load_descriptor_list = oldlist; |
1320 return Qnil; | 1302 return Qnil; |
1321 } | 1303 } |
1322 | 1304 |
1323 /* Close all descriptors in use for Floads. | 1305 /* Close all descriptors in use for Floads. |
1324 This is used when starting a subprocess. */ | 1306 This is used when starting a subprocess. */ |
1325 | 1307 |
1326 void | 1308 void |
1327 close_load_descs () | 1309 close_load_descs (void) |
1328 { | 1310 { |
1329 #ifndef WINDOWSNT | 1311 #ifndef WINDOWSNT |
1330 Lisp_Object tail; | 1312 Lisp_Object tail; |
1331 for (tail = load_descriptor_list; CONSP (tail); tail = XCDR (tail)) | 1313 for (tail = load_descriptor_list; CONSP (tail); tail = XCDR (tail)) |
1332 emacs_close (XFASTINT (XCAR (tail))); | 1314 emacs_close (XFASTINT (XCAR (tail))); |
1333 #endif | 1315 #endif |
1334 } | 1316 } |
1335 | 1317 |
1336 static int | 1318 static int |
1337 complete_filename_p (pathname) | 1319 complete_filename_p (Lisp_Object pathname) |
1338 Lisp_Object pathname; | |
1339 { | 1320 { |
1340 register const unsigned char *s = SDATA (pathname); | 1321 register const unsigned char *s = SDATA (pathname); |
1341 return (IS_DIRECTORY_SEP (s[0]) | 1322 return (IS_DIRECTORY_SEP (s[0]) |
1342 || (SCHARS (pathname) > 2 | 1323 || (SCHARS (pathname) > 2 |
1343 && IS_DEVICE_SEP (s[1]) && IS_DIRECTORY_SEP (s[2]))); | 1324 && IS_DEVICE_SEP (s[1]) && IS_DIRECTORY_SEP (s[2]))); |
1381 | 1362 |
1382 If the file we find is remote, return -2 | 1363 If the file we find is remote, return -2 |
1383 but store the found remote file name in *STOREPTR. */ | 1364 but store the found remote file name in *STOREPTR. */ |
1384 | 1365 |
1385 int | 1366 int |
1386 openp (path, str, suffixes, storeptr, predicate) | 1367 openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) |
1387 Lisp_Object path, str; | |
1388 Lisp_Object suffixes; | |
1389 Lisp_Object *storeptr; | |
1390 Lisp_Object predicate; | |
1391 { | 1368 { |
1392 register int fd; | 1369 register int fd; |
1393 int fn_size = 100; | 1370 int fn_size = 100; |
1394 char buf[100]; | 1371 char buf[100]; |
1395 register char *fn = buf; | 1372 register char *fn = buf; |
1537 | 1514 |
1538 FILENAME is the file name that we are loading from. | 1515 FILENAME is the file name that we are loading from. |
1539 ENTIRE is 1 if loading that entire file, 0 if evaluating part of it. */ | 1516 ENTIRE is 1 if loading that entire file, 0 if evaluating part of it. */ |
1540 | 1517 |
1541 static void | 1518 static void |
1542 build_load_history (filename, entire) | 1519 build_load_history (Lisp_Object filename, int entire) |
1543 Lisp_Object filename; | |
1544 int entire; | |
1545 { | 1520 { |
1546 register Lisp_Object tail, prev, newelt; | 1521 register Lisp_Object tail, prev, newelt; |
1547 register Lisp_Object tem, tem2; | 1522 register Lisp_Object tem, tem2; |
1548 register int foundit = 0; | 1523 register int foundit = 0; |
1549 | 1524 |
1599 Vload_history = Fcons (Fnreverse (Vcurrent_load_list), | 1574 Vload_history = Fcons (Fnreverse (Vcurrent_load_list), |
1600 Vload_history); | 1575 Vload_history); |
1601 } | 1576 } |
1602 | 1577 |
1603 Lisp_Object | 1578 Lisp_Object |
1604 unreadpure (junk) /* Used as unwind-protect function in readevalloop */ | 1579 unreadpure (Lisp_Object junk) /* Used as unwind-protect function in readevalloop */ |
1605 Lisp_Object junk; | 1580 |
1606 { | 1581 { |
1607 read_pure = 0; | 1582 read_pure = 0; |
1608 return Qnil; | 1583 return Qnil; |
1609 } | 1584 } |
1610 | 1585 |
1611 static Lisp_Object | 1586 static Lisp_Object |
1612 readevalloop_1 (old) | 1587 readevalloop_1 (Lisp_Object old) |
1613 Lisp_Object old; | |
1614 { | 1588 { |
1615 load_convert_to_unibyte = ! NILP (old); | 1589 load_convert_to_unibyte = ! NILP (old); |
1616 return Qnil; | 1590 return Qnil; |
1617 } | 1591 } |
1618 | 1592 |
1619 /* Signal an `end-of-file' error, if possible with file name | 1593 /* Signal an `end-of-file' error, if possible with file name |
1620 information. */ | 1594 information. */ |
1621 | 1595 |
1622 static void | 1596 static void |
1623 end_of_file_error () | 1597 end_of_file_error (void) |
1624 { | 1598 { |
1625 if (STRINGP (Vload_file_name)) | 1599 if (STRINGP (Vload_file_name)) |
1626 xsignal1 (Qend_of_file, Vload_file_name); | 1600 xsignal1 (Qend_of_file, Vload_file_name); |
1627 | 1601 |
1628 xsignal0 (Qend_of_file); | 1602 xsignal0 (Qend_of_file); |
1922 } | 1896 } |
1923 | 1897 |
1924 /* Function to set up the global context we need in toplevel read | 1898 /* Function to set up the global context we need in toplevel read |
1925 calls. */ | 1899 calls. */ |
1926 static Lisp_Object | 1900 static Lisp_Object |
1927 read_internal_start (stream, start, end) | 1901 read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) |
1928 Lisp_Object stream; | 1902 |
1929 Lisp_Object start; /* Only used when stream is a string. */ | 1903 /* Only used when stream is a string. */ |
1930 Lisp_Object end; /* Only used when stream is a string. */ | 1904 /* Only used when stream is a string. */ |
1931 { | 1905 { |
1932 Lisp_Object retval; | 1906 Lisp_Object retval; |
1933 | 1907 |
1934 readchar_count = 0; | 1908 readchar_count = 0; |
1935 new_backquote_flag = 0; | 1909 new_backquote_flag = 0; |
1983 | 1957 |
1984 /* Signal Qinvalid_read_syntax error. | 1958 /* Signal Qinvalid_read_syntax error. |
1985 S is error string of length N (if > 0) */ | 1959 S is error string of length N (if > 0) */ |
1986 | 1960 |
1987 static void | 1961 static void |
1988 invalid_syntax (s, n) | 1962 invalid_syntax (const char *s, int n) |
1989 const char *s; | |
1990 int n; | |
1991 { | 1963 { |
1992 if (!n) | 1964 if (!n) |
1993 n = strlen (s); | 1965 n = strlen (s); |
1994 xsignal1 (Qinvalid_read_syntax, make_string (s, n)); | 1966 xsignal1 (Qinvalid_read_syntax, make_string (s, n)); |
1995 } | 1967 } |
1997 | 1969 |
1998 /* Use this for recursive reads, in contexts where internal tokens | 1970 /* Use this for recursive reads, in contexts where internal tokens |
1999 are not allowed. */ | 1971 are not allowed. */ |
2000 | 1972 |
2001 static Lisp_Object | 1973 static Lisp_Object |
2002 read0 (readcharfun) | 1974 read0 (Lisp_Object readcharfun) |
2003 Lisp_Object readcharfun; | |
2004 { | 1975 { |
2005 register Lisp_Object val; | 1976 register Lisp_Object val; |
2006 int c; | 1977 int c; |
2007 | 1978 |
2008 val = read1 (readcharfun, &c, 0); | 1979 val = read1 (readcharfun, &c, 0); |
2018 | 1989 |
2019 /* Read a \-escape sequence, assuming we already read the `\'. | 1990 /* Read a \-escape sequence, assuming we already read the `\'. |
2020 If the escape sequence forces unibyte, return eight-bit char. */ | 1991 If the escape sequence forces unibyte, return eight-bit char. */ |
2021 | 1992 |
2022 static int | 1993 static int |
2023 read_escape (readcharfun, stringp) | 1994 read_escape (Lisp_Object readcharfun, int stringp) |
2024 Lisp_Object readcharfun; | |
2025 int stringp; | |
2026 { | 1995 { |
2027 register int c = READCHAR; | 1996 register int c = READCHAR; |
2028 /* \u allows up to four hex digits, \U up to eight. Default to the | 1997 /* \u allows up to four hex digits, \U up to eight. Default to the |
2029 behavior for \u, and change this value in the case that \U is seen. */ | 1998 behavior for \u, and change this value in the case that \U is seen. */ |
2030 int unicode_hex_count = 4; | 1999 int unicode_hex_count = 4; |
2234 read error is signaled . Value is the integer read. Signals an | 2203 read error is signaled . Value is the integer read. Signals an |
2235 error if encountering invalid read syntax or if RADIX is out of | 2204 error if encountering invalid read syntax or if RADIX is out of |
2236 range. */ | 2205 range. */ |
2237 | 2206 |
2238 static Lisp_Object | 2207 static Lisp_Object |
2239 read_integer (readcharfun, radix) | 2208 read_integer (Lisp_Object readcharfun, int radix) |
2240 Lisp_Object readcharfun; | |
2241 int radix; | |
2242 { | 2209 { |
2243 int ndigits = 0, invalid_p, c, sign = 0; | 2210 int ndigits = 0, invalid_p, c, sign = 0; |
2244 /* We use a floating point number because */ | 2211 /* We use a floating point number because */ |
2245 double number = 0; | 2212 double number = 0; |
2246 | 2213 |
2301 zero in *PCH and we read and return one lisp object. | 2268 zero in *PCH and we read and return one lisp object. |
2302 | 2269 |
2303 FIRST_IN_LIST is nonzero if this is the first element of a list. */ | 2270 FIRST_IN_LIST is nonzero if this is the first element of a list. */ |
2304 | 2271 |
2305 static Lisp_Object | 2272 static Lisp_Object |
2306 read1 (readcharfun, pch, first_in_list) | 2273 read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) |
2307 register Lisp_Object readcharfun; | |
2308 int *pch; | |
2309 int first_in_list; | |
2310 { | 2274 { |
2311 register int c; | 2275 register int c; |
2312 int uninterned_symbol = 0; | 2276 int uninterned_symbol = 0; |
2313 int multibyte; | 2277 int multibyte; |
2314 | 2278 |
3108 | 3072 |
3109 /* List of nodes we've seen during substitute_object_in_subtree. */ | 3073 /* List of nodes we've seen during substitute_object_in_subtree. */ |
3110 static Lisp_Object seen_list; | 3074 static Lisp_Object seen_list; |
3111 | 3075 |
3112 static void | 3076 static void |
3113 substitute_object_in_subtree (object, placeholder) | 3077 substitute_object_in_subtree (Lisp_Object object, Lisp_Object placeholder) |
3114 Lisp_Object object; | |
3115 Lisp_Object placeholder; | |
3116 { | 3078 { |
3117 Lisp_Object check_object; | 3079 Lisp_Object check_object; |
3118 | 3080 |
3119 /* We haven't seen any objects when we start. */ | 3081 /* We haven't seen any objects when we start. */ |
3120 seen_list = Qnil; | 3082 seen_list = Qnil; |
3145 set_val; \ | 3107 set_val; \ |
3146 } \ | 3108 } \ |
3147 } while (0) | 3109 } while (0) |
3148 | 3110 |
3149 static Lisp_Object | 3111 static Lisp_Object |
3150 substitute_object_recurse (object, placeholder, subtree) | 3112 substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Object subtree) |
3151 Lisp_Object object; | |
3152 Lisp_Object placeholder; | |
3153 Lisp_Object subtree; | |
3154 { | 3113 { |
3155 /* If we find the placeholder, return the target object. */ | 3114 /* If we find the placeholder, return the target object. */ |
3156 if (EQ (placeholder, subtree)) | 3115 if (EQ (placeholder, subtree)) |
3157 return object; | 3116 return object; |
3158 | 3117 |
3223 } | 3182 } |
3224 } | 3183 } |
3225 | 3184 |
3226 /* Helper function for substitute_object_recurse. */ | 3185 /* Helper function for substitute_object_recurse. */ |
3227 static void | 3186 static void |
3228 substitute_in_interval (interval, arg) | 3187 substitute_in_interval (INTERVAL interval, Lisp_Object arg) |
3229 INTERVAL interval; | |
3230 Lisp_Object arg; | |
3231 { | 3188 { |
3232 Lisp_Object object = Fcar (arg); | 3189 Lisp_Object object = Fcar (arg); |
3233 Lisp_Object placeholder = Fcdr (arg); | 3190 Lisp_Object placeholder = Fcdr (arg); |
3234 | 3191 |
3235 SUBSTITUTE (interval->plist, interval->plist = true_value); | 3192 SUBSTITUTE (interval->plist, interval->plist = true_value); |
3241 #define TRAIL_INT 4 | 3198 #define TRAIL_INT 4 |
3242 #define E_CHAR 8 | 3199 #define E_CHAR 8 |
3243 #define EXP_INT 16 | 3200 #define EXP_INT 16 |
3244 | 3201 |
3245 int | 3202 int |
3246 isfloat_string (cp, ignore_trailing) | 3203 isfloat_string (register char *cp, int ignore_trailing) |
3247 register char *cp; | |
3248 int ignore_trailing; | |
3249 { | 3204 { |
3250 register int state; | 3205 register int state; |
3251 | 3206 |
3252 char *start = cp; | 3207 char *start = cp; |
3253 | 3208 |
3308 || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT))); | 3263 || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT))); |
3309 } | 3264 } |
3310 | 3265 |
3311 | 3266 |
3312 static Lisp_Object | 3267 static Lisp_Object |
3313 read_vector (readcharfun, bytecodeflag) | 3268 read_vector (Lisp_Object readcharfun, int bytecodeflag) |
3314 Lisp_Object readcharfun; | |
3315 int bytecodeflag; | |
3316 { | 3269 { |
3317 register int i; | 3270 register int i; |
3318 register int size; | 3271 register int size; |
3319 register Lisp_Object *ptr; | 3272 register Lisp_Object *ptr; |
3320 register Lisp_Object tem, item, vector; | 3273 register Lisp_Object tem, item, vector; |
3393 /* FLAG = 1 means check for ] to terminate rather than ) and . | 3346 /* FLAG = 1 means check for ] to terminate rather than ) and . |
3394 FLAG = -1 means check for starting with defun | 3347 FLAG = -1 means check for starting with defun |
3395 and make structure pure. */ | 3348 and make structure pure. */ |
3396 | 3349 |
3397 static Lisp_Object | 3350 static Lisp_Object |
3398 read_list (flag, readcharfun) | 3351 read_list (int flag, register Lisp_Object readcharfun) |
3399 int flag; | |
3400 register Lisp_Object readcharfun; | |
3401 { | 3352 { |
3402 /* -1 means check next element for defun, | 3353 /* -1 means check next element for defun, |
3403 0 means don't check, | 3354 0 means don't check, |
3404 1 means already checked and found defun. */ | 3355 1 means already checked and found defun. */ |
3405 int defunflag = flag < 0 ? -1 : 0; | 3356 int defunflag = flag < 0 ? -1 : 0; |
3583 | 3534 |
3584 /* oblookup stores the bucket number here, for the sake of Funintern. */ | 3535 /* oblookup stores the bucket number here, for the sake of Funintern. */ |
3585 | 3536 |
3586 int oblookup_last_bucket_number; | 3537 int oblookup_last_bucket_number; |
3587 | 3538 |
3588 static int hash_string (); | 3539 static int hash_string (const unsigned char *ptr, int len); |
3589 | 3540 |
3590 /* Get an error if OBARRAY is not an obarray. | 3541 /* Get an error if OBARRAY is not an obarray. |
3591 If it is one, return it. */ | 3542 If it is one, return it. */ |
3592 | 3543 |
3593 Lisp_Object | 3544 Lisp_Object |
3594 check_obarray (obarray) | 3545 check_obarray (Lisp_Object obarray) |
3595 Lisp_Object obarray; | |
3596 { | 3546 { |
3597 if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) | 3547 if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) |
3598 { | 3548 { |
3599 /* If Vobarray is now invalid, force it to be valid. */ | 3549 /* If Vobarray is now invalid, force it to be valid. */ |
3600 if (EQ (Vobarray, obarray)) Vobarray = initial_obarray; | 3550 if (EQ (Vobarray, obarray)) Vobarray = initial_obarray; |
3605 | 3555 |
3606 /* Intern the C string STR: return a symbol with that name, | 3556 /* Intern the C string STR: return a symbol with that name, |
3607 interned in the current obarray. */ | 3557 interned in the current obarray. */ |
3608 | 3558 |
3609 Lisp_Object | 3559 Lisp_Object |
3610 intern (str) | 3560 intern (const char *str) |
3611 const char *str; | |
3612 { | 3561 { |
3613 Lisp_Object tem; | 3562 Lisp_Object tem; |
3614 int len = strlen (str); | 3563 int len = strlen (str); |
3615 Lisp_Object obarray; | 3564 Lisp_Object obarray; |
3616 | 3565 |
3647 } | 3596 } |
3648 | 3597 |
3649 /* Create an uninterned symbol with name STR. */ | 3598 /* Create an uninterned symbol with name STR. */ |
3650 | 3599 |
3651 Lisp_Object | 3600 Lisp_Object |
3652 make_symbol (str) | 3601 make_symbol (char *str) |
3653 char *str; | |
3654 { | 3602 { |
3655 int len = strlen (str); | 3603 int len = strlen (str); |
3656 | 3604 |
3657 return Fmake_symbol ((!NILP (Vpurify_flag) | 3605 return Fmake_symbol ((!NILP (Vpurify_flag) |
3658 ? make_pure_string (str, len, len, 0) | 3606 ? make_pure_string (str, len, len, 0) |
3810 If there is no such symbol in OBARRAY, return nil. | 3758 If there is no such symbol in OBARRAY, return nil. |
3811 | 3759 |
3812 Also store the bucket number in oblookup_last_bucket_number. */ | 3760 Also store the bucket number in oblookup_last_bucket_number. */ |
3813 | 3761 |
3814 Lisp_Object | 3762 Lisp_Object |
3815 oblookup (obarray, ptr, size, size_byte) | 3763 oblookup (Lisp_Object obarray, register const char *ptr, int size, int size_byte) |
3816 Lisp_Object obarray; | |
3817 register const char *ptr; | |
3818 int size, size_byte; | |
3819 { | 3764 { |
3820 int hash; | 3765 int hash; |
3821 int obsize; | 3766 int obsize; |
3822 register Lisp_Object tail; | 3767 register Lisp_Object tail; |
3823 Lisp_Object bucket, tem; | 3768 Lisp_Object bucket, tem; |
3850 XSETINT (tem, hash); | 3795 XSETINT (tem, hash); |
3851 return tem; | 3796 return tem; |
3852 } | 3797 } |
3853 | 3798 |
3854 static int | 3799 static int |
3855 hash_string (ptr, len) | 3800 hash_string (const unsigned char *ptr, int len) |
3856 const unsigned char *ptr; | |
3857 int len; | |
3858 { | 3801 { |
3859 register const unsigned char *p = ptr; | 3802 register const unsigned char *p = ptr; |
3860 register const unsigned char *end = p + len; | 3803 register const unsigned char *end = p + len; |
3861 register unsigned char c; | 3804 register unsigned char c; |
3862 register int hash = 0; | 3805 register int hash = 0; |
3869 } | 3812 } |
3870 return hash & 07777777777; | 3813 return hash & 07777777777; |
3871 } | 3814 } |
3872 | 3815 |
3873 void | 3816 void |
3874 map_obarray (obarray, fn, arg) | 3817 map_obarray (Lisp_Object obarray, void (*fn) (Lisp_Object, Lisp_Object), Lisp_Object arg) |
3875 Lisp_Object obarray; | |
3876 void (*fn) (Lisp_Object, Lisp_Object); | |
3877 Lisp_Object arg; | |
3878 { | 3818 { |
3879 register int i; | 3819 register int i; |
3880 register Lisp_Object tail; | 3820 register Lisp_Object tail; |
3881 CHECK_VECTOR (obarray); | 3821 CHECK_VECTOR (obarray); |
3882 for (i = XVECTOR (obarray)->size - 1; i >= 0; i--) | 3822 for (i = XVECTOR (obarray)->size - 1; i >= 0; i--) |
3892 } | 3832 } |
3893 } | 3833 } |
3894 } | 3834 } |
3895 | 3835 |
3896 void | 3836 void |
3897 mapatoms_1 (sym, function) | 3837 mapatoms_1 (Lisp_Object sym, Lisp_Object function) |
3898 Lisp_Object sym, function; | |
3899 { | 3838 { |
3900 call1 (function, sym); | 3839 call1 (function, sym); |
3901 } | 3840 } |
3902 | 3841 |
3903 DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0, | 3842 DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0, |
3914 } | 3853 } |
3915 | 3854 |
3916 #define OBARRAY_SIZE 1511 | 3855 #define OBARRAY_SIZE 1511 |
3917 | 3856 |
3918 void | 3857 void |
3919 init_obarray () | 3858 init_obarray (void) |
3920 { | 3859 { |
3921 Lisp_Object oblength; | 3860 Lisp_Object oblength; |
3922 | 3861 |
3923 XSETFASTINT (oblength, OBARRAY_SIZE); | 3862 XSETFASTINT (oblength, OBARRAY_SIZE); |
3924 | 3863 |
3955 read_buffer_size = 100 + MAX_MULTIBYTE_LENGTH; | 3894 read_buffer_size = 100 + MAX_MULTIBYTE_LENGTH; |
3956 read_buffer = (char *) xmalloc (read_buffer_size); | 3895 read_buffer = (char *) xmalloc (read_buffer_size); |
3957 } | 3896 } |
3958 | 3897 |
3959 void | 3898 void |
3960 defsubr (sname) | 3899 defsubr (struct Lisp_Subr *sname) |
3961 struct Lisp_Subr *sname; | |
3962 { | 3900 { |
3963 Lisp_Object sym; | 3901 Lisp_Object sym; |
3964 sym = intern_c_string (sname->symbol_name); | 3902 sym = intern_c_string (sname->symbol_name); |
3965 XSETPVECTYPE (sname, PVEC_SUBR); | 3903 XSETPVECTYPE (sname, PVEC_SUBR); |
3966 XSETSUBR (XSYMBOL (sym)->function, sname); | 3904 XSETSUBR (XSYMBOL (sym)->function, sname); |
4051 /* Record the value of load-path used at the start of dumping | 3989 /* Record the value of load-path used at the start of dumping |
4052 so we can see if the site changed it later during dumping. */ | 3990 so we can see if the site changed it later during dumping. */ |
4053 static Lisp_Object dump_path; | 3991 static Lisp_Object dump_path; |
4054 | 3992 |
4055 void | 3993 void |
4056 init_lread () | 3994 init_lread (void) |
4057 { | 3995 { |
4058 char *normal; | 3996 char *normal; |
4059 int turn_off_warning = 0; | 3997 int turn_off_warning = 0; |
4060 | 3998 |
4061 /* Compute the default load-path. */ | 3999 /* Compute the default load-path. */ |
4244 | 4182 |
4245 /* Print a warning, using format string FORMAT, that directory DIRNAME | 4183 /* Print a warning, using format string FORMAT, that directory DIRNAME |
4246 does not exist. Print it on stderr and put it in *Messages*. */ | 4184 does not exist. Print it on stderr and put it in *Messages*. */ |
4247 | 4185 |
4248 void | 4186 void |
4249 dir_warning (format, dirname) | 4187 dir_warning (char *format, Lisp_Object dirname) |
4250 char *format; | |
4251 Lisp_Object dirname; | |
4252 { | 4188 { |
4253 char *buffer | 4189 char *buffer |
4254 = (char *) alloca (SCHARS (dirname) + strlen (format) + 5); | 4190 = (char *) alloca (SCHARS (dirname) + strlen (format) + 5); |
4255 | 4191 |
4256 fprintf (stderr, format, SDATA (dirname)); | 4192 fprintf (stderr, format, SDATA (dirname)); |
4259 if (initialized) | 4195 if (initialized) |
4260 message_dolog (buffer, strlen (buffer), 0, STRING_MULTIBYTE (dirname)); | 4196 message_dolog (buffer, strlen (buffer), 0, STRING_MULTIBYTE (dirname)); |
4261 } | 4197 } |
4262 | 4198 |
4263 void | 4199 void |
4264 syms_of_lread () | 4200 syms_of_lread (void) |
4265 { | 4201 { |
4266 defsubr (&Sread); | 4202 defsubr (&Sread); |
4267 defsubr (&Sread_from_string); | 4203 defsubr (&Sread_from_string); |
4268 defsubr (&Sintern); | 4204 defsubr (&Sintern); |
4269 defsubr (&Sintern_soft); | 4205 defsubr (&Sintern_soft); |