Mercurial > hg > xemacs-beta
comparison src/lread.c @ 771:943eaba38521
[xemacs-hg @ 2002-03-13 08:51:24 by ben]
The big ben-mule-21-5 check-in!
Various files were added and deleted. See CHANGES-ben-mule.
There are still some test suite failures. No crashes, though.
Many of the failures have to do with problems in the test suite itself
rather than in the actual code. I'll be addressing these in the next
day or so -- none of the test suite failures are at all critical.
Meanwhile I'll be trying to address the biggest issues -- i.e. build
or run failures, which will almost certainly happen on various platforms.
All comments should be sent to ben@xemacs.org -- use a Cc: if necessary
when sending to mailing lists. There will be pre- and post- tags,
something like
pre-ben-mule-21-5-merge-in, and
post-ben-mule-21-5-merge-in.
author | ben |
---|---|
date | Wed, 13 Mar 2002 08:54:06 +0000 |
parents | fdefd0186b75 |
children | 578cb2932d72 |
comparison
equal
deleted
inserted
replaced
770:336a418893b5 | 771:943eaba38521 |
---|---|
1 /* Lisp parsing and input streams. | 1 /* Lisp parsing and input streams. |
2 Copyright (C) 1985-1989, 1992-1995 Free Software Foundation, Inc. | 2 Copyright (C) 1985-1989, 1992-1995 Free Software Foundation, Inc. |
3 Copyright (C) 1995 Tinker Systems. | 3 Copyright (C) 1995 Tinker Systems. |
4 Copyright (C) 1996 Ben Wing. | 4 Copyright (C) 1996, 2001 Ben Wing. |
5 | 5 |
6 This file is part of XEmacs. | 6 This file is part of XEmacs. |
7 | 7 |
8 XEmacs is free software; you can redistribute it and/or modify it | 8 XEmacs is free software; you can redistribute it and/or modify it |
9 under the terms of the GNU General Public License as published by the | 9 under the terms of the GNU General Public License as published by the |
30 #include "buffer.h" | 30 #include "buffer.h" |
31 #include "bytecode.h" | 31 #include "bytecode.h" |
32 #include "elhash.h" | 32 #include "elhash.h" |
33 #include "lstream.h" | 33 #include "lstream.h" |
34 #include "opaque.h" | 34 #include "opaque.h" |
35 #ifdef FILE_CODING | |
36 #include "file-coding.h" | 35 #include "file-coding.h" |
37 #endif | |
38 | 36 |
39 #include "sysfile.h" | 37 #include "sysfile.h" |
40 | |
41 #ifdef LISP_FLOAT_TYPE | |
42 #define THIS_FILENAME lread | |
43 #include "sysfloat.h" | 38 #include "sysfloat.h" |
44 #endif /* LISP_FLOAT_TYPE */ | 39 #ifdef WIN32_NATIVE |
40 #include "syswindows.h" | |
41 #endif | |
45 | 42 |
46 Lisp_Object Qread_char, Qstandard_input; | 43 Lisp_Object Qread_char, Qstandard_input; |
47 Lisp_Object Qvariable_documentation; | 44 Lisp_Object Qvariable_documentation; |
48 #define LISP_BACKQUOTES | 45 #define LISP_BACKQUOTES |
49 #ifdef LISP_BACKQUOTES | 46 #ifdef LISP_BACKQUOTES |
211 | 208 |
212 /* When errors are signaled, the actual readcharfun should not be used | 209 /* When errors are signaled, the actual readcharfun should not be used |
213 as an argument if it is an lstream, so that lstreams don't escape | 210 as an argument if it is an lstream, so that lstreams don't escape |
214 to the Lisp level. */ | 211 to the Lisp level. */ |
215 #define READCHARFUN_MAYBE(x) (LSTREAMP (x) \ | 212 #define READCHARFUN_MAYBE(x) (LSTREAMP (x) \ |
216 ? (build_string ("internal input stream")) \ | 213 ? (build_msg_string ("internal input stream")) \ |
217 : (x)) | 214 : (x)) |
218 | 215 |
219 | 216 |
220 static DOESNT_RETURN | 217 static DOESNT_RETURN |
221 read_syntax_error (const char *string) | 218 read_syntax_error (const char *string) |
505 void | 502 void |
506 close_load_descs (void) | 503 close_load_descs (void) |
507 { | 504 { |
508 Lisp_Object tail; | 505 Lisp_Object tail; |
509 LIST_LOOP (tail, Vload_descriptor_list) | 506 LIST_LOOP (tail, Vload_descriptor_list) |
510 close (XINT (XCAR (tail))); | 507 retry_close (XINT (XCAR (tail))); |
511 } | 508 } |
512 | 509 |
513 #ifdef I18N3 | 510 #ifdef I18N3 |
514 Lisp_Object Vfile_domain; | 511 Lisp_Object Vfile_domain; |
515 | 512 |
571 | 568 |
572 /* Do this after the handler to avoid | 569 /* Do this after the handler to avoid |
573 the need to gcpro noerror, nomessage and nosuffix. | 570 the need to gcpro noerror, nomessage and nosuffix. |
574 (Below here, we care only whether they are nil or not.) */ | 571 (Below here, we care only whether they are nil or not.) */ |
575 file = Fsubstitute_in_file_name (file); | 572 file = Fsubstitute_in_file_name (file); |
576 #ifdef FILE_CODING | |
577 if (!NILP (used_codesys)) | 573 if (!NILP (used_codesys)) |
578 CHECK_SYMBOL (used_codesys); | 574 CHECK_SYMBOL (used_codesys); |
579 #endif | |
580 | 575 |
581 /* Avoid weird lossage with null string as arg, | 576 /* Avoid weird lossage with null string as arg, |
582 since it would try to load a directory as a Lisp file. | 577 since it would try to load a directory as a Lisp file. |
583 Unix truly sucks. */ | 578 Unix truly sucks. */ |
584 if (XSTRING_LENGTH (file) > 0) | 579 if (XSTRING_LENGTH (file) > 0) |
585 { | 580 { |
586 char *foundstr; | 581 Intbyte *foundstr; |
587 int foundlen; | 582 int foundlen; |
588 | 583 |
589 fd = locate_file (Vload_path, file, | 584 fd = locate_file (Vload_path, file, |
590 ((!NILP (nosuffix)) ? Qnil : | 585 ((!NILP (nosuffix)) ? Qnil : |
591 build_string (load_ignore_elc_files ? ".el:" : | 586 build_string (load_ignore_elc_files ? ".el:" : |
602 UNGCPRO; | 597 UNGCPRO; |
603 return Qnil; | 598 return Qnil; |
604 } | 599 } |
605 } | 600 } |
606 | 601 |
607 foundstr = (char *) alloca (XSTRING_LENGTH (found) + 1); | 602 foundstr = (Intbyte *) alloca (XSTRING_LENGTH (found) + 1); |
608 strcpy (foundstr, (char *) XSTRING_DATA (found)); | 603 qxestrcpy (foundstr, XSTRING_DATA (found)); |
609 foundlen = strlen (foundstr); | 604 foundlen = qxestrlen (foundstr); |
610 | 605 |
611 /* The omniscient JWZ thinks this is worthless, but I beg to | 606 /* The omniscient JWZ thinks this is worthless, but I beg to |
612 differ. --ben */ | 607 differ. --ben */ |
613 if (load_ignore_elc_files) | 608 if (load_ignore_elc_files) |
614 { | 609 { |
615 newer = Ffile_name_nondirectory (found); | 610 newer = Ffile_name_nondirectory (found); |
616 } | 611 } |
617 else if (load_warn_when_source_newer && | 612 else if (load_warn_when_source_newer && |
618 !memcmp (".elc", foundstr + foundlen - 4, 4)) | 613 !memcmp (".elc", foundstr + foundlen - 4, 4)) |
619 { | 614 { |
620 if (! fstat (fd, &s1)) /* can't fail, right? */ | 615 if (! qxe_fstat (fd, &s1)) /* can't fail, right? */ |
621 { | 616 { |
622 int result; | 617 int result; |
623 /* temporarily hack the 'c' off the end of the filename */ | 618 /* temporarily hack the 'c' off the end of the filename */ |
624 foundstr[foundlen - 1] = '\0'; | 619 foundstr[foundlen - 1] = '\0'; |
625 result = xemacs_stat (foundstr, &s2); | 620 result = qxe_stat (foundstr, &s2); |
626 if (result >= 0 && | 621 if (result >= 0 && |
627 (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) | 622 (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) |
628 { | 623 { |
629 Lisp_Object newer_name = make_string ((Intbyte *) foundstr, | 624 Lisp_Object newer_name = make_string (foundstr, |
630 foundlen - 1); | 625 foundlen - 1); |
631 struct gcpro nngcpro1; | 626 struct gcpro nngcpro1; |
632 NNGCPRO1 (newer_name); | 627 NNGCPRO1 (newer_name); |
633 newer = Ffile_name_nondirectory (newer_name); | 628 newer = Ffile_name_nondirectory (newer_name); |
634 NNUNGCPRO; | 629 NNUNGCPRO; |
682 lispstream = make_filedesc_input_stream (fd, 0, -1, LSTR_CLOSING); | 677 lispstream = make_filedesc_input_stream (fd, 0, -1, LSTR_CLOSING); |
683 /* 64K is used for normal files; 8K should be OK here because Lisp | 678 /* 64K is used for normal files; 8K should be OK here because Lisp |
684 files aren't really all that big. */ | 679 files aren't really all that big. */ |
685 Lstream_set_buffering (XLSTREAM (lispstream), LSTREAM_BLOCKN_BUFFERED, | 680 Lstream_set_buffering (XLSTREAM (lispstream), LSTREAM_BLOCKN_BUFFERED, |
686 block_size); | 681 block_size); |
687 #ifdef FILE_CODING | 682 lispstream = make_coding_input_stream |
688 lispstream = make_decoding_input_stream | 683 (XLSTREAM (lispstream), get_coding_system_for_text_file (codesys, 1), |
689 (XLSTREAM (lispstream), Fget_coding_system (codesys)); | 684 CODING_DECODE); |
690 Lstream_set_buffering (XLSTREAM (lispstream), LSTREAM_BLOCKN_BUFFERED, | 685 Lstream_set_buffering (XLSTREAM (lispstream), LSTREAM_BLOCKN_BUFFERED, |
691 block_size); | 686 block_size); |
692 #endif | |
693 /* NOTE: Order of these is very important. Don't rearrange them. */ | 687 /* NOTE: Order of these is very important. Don't rearrange them. */ |
694 record_unwind_protect (load_unwind, lispstream); | 688 record_unwind_protect (load_unwind, lispstream); |
695 record_unwind_protect (load_descriptor_unwind, Vload_descriptor_list); | 689 record_unwind_protect (load_descriptor_unwind, Vload_descriptor_list); |
696 record_unwind_protect (load_file_name_internal_unwind, | 690 record_unwind_protect (load_file_name_internal_unwind, |
697 Vload_file_name_internal); | 691 Vload_file_name_internal); |
731 } | 725 } |
732 else | 726 else |
733 load_byte_code_version = 100; /* no Ebolification needed */ | 727 load_byte_code_version = 100; /* no Ebolification needed */ |
734 | 728 |
735 readevalloop (lispstream, file, Feval, 0); | 729 readevalloop (lispstream, file, Feval, 0); |
736 #ifdef FILE_CODING | |
737 if (!NILP (used_codesys)) | 730 if (!NILP (used_codesys)) |
738 Fset (used_codesys, | 731 Fset (used_codesys, |
739 XCODING_SYSTEM_NAME | 732 XCODING_SYSTEM_NAME |
740 (decoding_stream_coding_system (XLSTREAM (lispstream)))); | 733 (coding_stream_detected_coding_system (XLSTREAM (lispstream)))); |
741 #endif | 734 unbind_to (speccount); |
742 unbind_to (speccount, Qnil); | |
743 | 735 |
744 NUNGCPRO; | 736 NUNGCPRO; |
745 } | 737 } |
746 | 738 |
747 { | 739 { |
877 | 869 |
878 static Lisp_Object | 870 static Lisp_Object |
879 locate_file_refresh_hashing (Lisp_Object directory) | 871 locate_file_refresh_hashing (Lisp_Object directory) |
880 { | 872 { |
881 Lisp_Object hash = | 873 Lisp_Object hash = |
882 make_directory_hash_table ((char *) XSTRING_DATA (directory)); | 874 make_directory_hash_table (XSTRING_DATA (directory)); |
883 | 875 |
884 if (!NILP (hash)) | 876 if (!NILP (hash)) |
885 Fputhash (directory, hash, Vlocate_file_hash_table); | 877 Fputhash (directory, hash, Vlocate_file_hash_table); |
886 return hash; | 878 return hash; |
887 } | 879 } |
918 /* Map FUN over SUFFIXES, as described above. FUN will be called with a | 910 /* Map FUN over SUFFIXES, as described above. FUN will be called with a |
919 char * containing the current file name, and ARG. Mapping stops when | 911 char * containing the current file name, and ARG. Mapping stops when |
920 FUN returns non-zero. */ | 912 FUN returns non-zero. */ |
921 static void | 913 static void |
922 locate_file_map_suffixes (Lisp_Object filename, Lisp_Object suffixes, | 914 locate_file_map_suffixes (Lisp_Object filename, Lisp_Object suffixes, |
923 int (*fun) (char *, void *), | 915 int (*fun) (Intbyte *, void *), |
924 void *arg) | 916 void *arg) |
925 { | 917 { |
926 /* This function can GC */ | 918 /* This function can GC */ |
927 char *fn; | 919 Intbyte *fn; |
928 int fn_len, max; | 920 int fn_len, max; |
929 | 921 |
930 /* Calculate maximum size of any filename made from | 922 /* Calculate maximum size of any filename made from |
931 this path element/specified file name and any possible suffix. */ | 923 this path element/specified file name and any possible suffix. */ |
932 if (CONSP (suffixes)) | 924 if (CONSP (suffixes)) |
945 else | 937 else |
946 /* Just take the easy way out */ | 938 /* Just take the easy way out */ |
947 max = XSTRING_LENGTH (suffixes); | 939 max = XSTRING_LENGTH (suffixes); |
948 | 940 |
949 fn_len = XSTRING_LENGTH (filename); | 941 fn_len = XSTRING_LENGTH (filename); |
950 fn = (char *) alloca (max + fn_len + 1); | 942 fn = (Intbyte *) alloca (max + fn_len + 1); |
951 memcpy (fn, (char *) XSTRING_DATA (filename), fn_len); | 943 memcpy (fn, XSTRING_DATA (filename), fn_len); |
952 | 944 |
953 /* Loop over suffixes. */ | 945 /* Loop over suffixes. */ |
954 if (!STRINGP (suffixes)) | 946 if (!STRINGP (suffixes)) |
955 { | 947 { |
956 if (NILP (suffixes)) | 948 if (NILP (suffixes)) |
975 } | 967 } |
976 } | 968 } |
977 else | 969 else |
978 { | 970 { |
979 /* Case c) */ | 971 /* Case c) */ |
980 const char *nsuffix = (const char *) XSTRING_DATA (suffixes); | 972 const Intbyte *nsuffix = XSTRING_DATA (suffixes); |
981 | 973 |
982 while (1) | 974 while (1) |
983 { | 975 { |
984 char *esuffix = (char *) strchr (nsuffix, ':'); | 976 Intbyte *esuffix = qxestrchr (nsuffix, ':'); |
985 int lsuffix = esuffix ? esuffix - nsuffix : (int) strlen (nsuffix); | 977 Bytecount lsuffix = esuffix ? esuffix - nsuffix : |
978 qxestrlen (nsuffix); | |
986 | 979 |
987 /* Concatenate path element/specified name with the suffix. */ | 980 /* Concatenate path element/specified name with the suffix. */ |
988 strncpy (fn + fn_len, nsuffix, lsuffix); | 981 qxestrncpy (fn + fn_len, nsuffix, lsuffix); |
989 fn[fn_len + lsuffix] = 0; | 982 fn[fn_len + lsuffix] = 0; |
990 | 983 |
991 if ((*fun) (fn, arg)) | 984 if ((*fun) (fn, arg)) |
992 return; | 985 return; |
993 | 986 |
997 nsuffix += lsuffix + 1; | 990 nsuffix += lsuffix + 1; |
998 } | 991 } |
999 } | 992 } |
1000 } | 993 } |
1001 | 994 |
1002 struct locate_file_in_directory_mapper_closure { | 995 struct locate_file_in_directory_mapper_closure |
996 { | |
1003 int fd; | 997 int fd; |
1004 Lisp_Object *storeptr; | 998 Lisp_Object *storeptr; |
1005 int mode; | 999 int mode; |
1006 }; | 1000 }; |
1007 | 1001 |
1008 static int | 1002 static int |
1009 locate_file_in_directory_mapper (char *fn, void *arg) | 1003 locate_file_in_directory_mapper (Intbyte *fn, void *arg) |
1010 { | 1004 { |
1011 struct locate_file_in_directory_mapper_closure *closure = | 1005 struct locate_file_in_directory_mapper_closure *closure = |
1012 (struct locate_file_in_directory_mapper_closure *)arg; | 1006 (struct locate_file_in_directory_mapper_closure *) arg; |
1013 struct stat st; | 1007 struct stat st; |
1014 | 1008 |
1015 /* Ignore file if it's a directory. */ | 1009 /* Ignore file if it's a directory. */ |
1016 if (xemacs_stat (fn, &st) >= 0 | 1010 if (qxe_stat (fn, &st) >= 0 |
1017 && (st.st_mode & S_IFMT) != S_IFDIR) | 1011 && (st.st_mode & S_IFMT) != S_IFDIR) |
1018 { | 1012 { |
1019 /* Check that we can access or open it. */ | 1013 /* Check that we can access or open it. */ |
1020 if (closure->mode >= 0) | 1014 if (closure->mode >= 0) |
1021 closure->fd = access (fn, closure->mode); | 1015 closure->fd = qxe_access (fn, closure->mode); |
1022 else | 1016 else |
1023 closure->fd = open (fn, O_RDONLY | OPEN_BINARY, 0); | 1017 closure->fd = qxe_open (fn, O_RDONLY | OPEN_BINARY, 0); |
1024 | 1018 |
1025 if (closure->fd >= 0) | 1019 if (closure->fd >= 0) |
1026 { | 1020 { |
1027 /* We succeeded; return this descriptor and filename. */ | 1021 /* We succeeded; return this descriptor and filename. */ |
1028 if (closure->storeptr) | 1022 if (closure->storeptr) |
1029 *closure->storeptr = build_string (fn); | 1023 *closure->storeptr = build_intstring (fn); |
1030 | 1024 |
1031 #ifndef WIN32_NATIVE | 1025 #ifndef WIN32_NATIVE |
1032 /* If we actually opened the file, set close-on-exec flag | 1026 /* If we actually opened the file, set close-on-exec flag |
1033 on the new descriptor so that subprocesses can't whack | 1027 on the new descriptor so that subprocesses can't whack |
1034 at it. */ | 1028 at it. */ |
1081 | 1075 |
1082 closure.fd = -1; | 1076 closure.fd = -1; |
1083 closure.storeptr = storeptr; | 1077 closure.storeptr = storeptr; |
1084 closure.mode = mode; | 1078 closure.mode = mode; |
1085 | 1079 |
1086 locate_file_map_suffixes (filename, suffixes, locate_file_in_directory_mapper, | 1080 locate_file_map_suffixes (filename, suffixes, |
1081 locate_file_in_directory_mapper, | |
1087 &closure); | 1082 &closure); |
1088 | 1083 |
1089 UNGCPRO; | 1084 UNGCPRO; |
1090 return closure.fd; | 1085 return closure.fd; |
1091 } | 1086 } |
1111 } | 1106 } |
1112 return -1; | 1107 return -1; |
1113 } | 1108 } |
1114 | 1109 |
1115 static int | 1110 static int |
1116 locate_file_construct_suffixed_files_mapper (char *fn, void *arg) | 1111 locate_file_construct_suffixed_files_mapper (Intbyte *fn, void *arg) |
1117 { | 1112 { |
1118 Lisp_Object *tail = (Lisp_Object *)arg; | 1113 Lisp_Object *tail = (Lisp_Object *) arg; |
1119 *tail = Fcons (build_string (fn), *tail); | 1114 *tail = Fcons (build_intstring (fn), *tail); |
1120 return 0; | 1115 return 0; |
1121 } | 1116 } |
1122 | 1117 |
1123 /* Construct a list of all files to search for. | 1118 /* Construct a list of all files to search for. |
1124 It makes sense to have this despite locate_file_map_suffixes() | 1119 It makes sense to have this despite locate_file_map_suffixes() |
1429 if (purify_flag && c == '(') | 1424 if (purify_flag && c == '(') |
1430 { | 1425 { |
1431 int count1 = specpdl_depth (); | 1426 int count1 = specpdl_depth (); |
1432 record_unwind_protect (unreadpure, Qnil); | 1427 record_unwind_protect (unreadpure, Qnil); |
1433 val = read_list (readcharfun, ')', -1, 1); | 1428 val = read_list (readcharfun, ')', -1, 1); |
1434 unbind_to (count1, Qnil); | 1429 unbind_to (count1); |
1435 } | 1430 } |
1436 else | 1431 else |
1437 #else /* No "defun hack" -- Emacs 19 uses read-time syntax for bytecodes */ | 1432 #else /* No "defun hack" -- Emacs 19 uses read-time syntax for bytecodes */ |
1438 { | 1433 { |
1439 unreadchar (readcharfun, c); | 1434 unreadchar (readcharfun, c); |
1459 /* This looks weird, but it's what's in FSFmacs */ | 1454 /* This looks weird, but it's what's in FSFmacs */ |
1460 (b ? BUF_NARROWED (b) : BUF_NARROWED (current_buffer)), | 1455 (b ? BUF_NARROWED (b) : BUF_NARROWED (current_buffer)), |
1461 sourcename); | 1456 sourcename); |
1462 UNGCPRO; | 1457 UNGCPRO; |
1463 | 1458 |
1464 unbind_to (speccount, Qnil); | 1459 unbind_to (speccount); |
1465 } | 1460 } |
1466 | 1461 |
1467 DEFUN ("eval-buffer", Feval_buffer, 0, 2, "bBuffer: ", /* | 1462 DEFUN ("eval-buffer", Feval_buffer, 0, 2, "bBuffer: ", /* |
1468 Execute BUFFER as Lisp code. | 1463 Execute BUFFER as Lisp code. |
1469 Programs can pass two arguments, BUFFER and PRINTFLAG. | 1464 Programs can pass two arguments, BUFFER and PRINTFLAG. |
1495 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 1490 record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
1496 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); | 1491 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); |
1497 readevalloop (buf, XBUFFER (buf)->filename, Feval, | 1492 readevalloop (buf, XBUFFER (buf)->filename, Feval, |
1498 !NILP (printflag)); | 1493 !NILP (printflag)); |
1499 | 1494 |
1500 return unbind_to (speccount, Qnil); | 1495 return unbind_to (speccount); |
1501 } | 1496 } |
1502 | 1497 |
1503 #if 0 | 1498 #if 0 |
1504 xxDEFUN ("eval-current-buffer", Feval_current_buffer, 0, 1, "", /* | 1499 xxDEFUN ("eval-current-buffer", Feval_current_buffer, 0, 1, "", /* |
1505 Execute the current buffer as Lisp code. | 1500 Execute the current buffer as Lisp code. |
1551 Fgoto_char (start, cbuf); | 1546 Fgoto_char (start, cbuf); |
1552 Fnarrow_to_region (make_int (BUF_BEGV (current_buffer)), end, cbuf); | 1547 Fnarrow_to_region (make_int (BUF_BEGV (current_buffer)), end, cbuf); |
1553 readevalloop (cbuf, XBUFFER (cbuf)->filename, Feval, | 1548 readevalloop (cbuf, XBUFFER (cbuf)->filename, Feval, |
1554 !NILP (stream)); | 1549 !NILP (stream)); |
1555 | 1550 |
1556 return unbind_to (speccount, Qnil); | 1551 return unbind_to (speccount); |
1557 } | 1552 } |
1558 | 1553 |
1559 DEFUN ("read", Fread, 0, 1, 0, /* | 1554 DEFUN ("read", Fread, 0, 1, 0, /* |
1560 Read one Lisp expression as text from STREAM, return as Lisp object. | 1555 Read one Lisp expression as text from STREAM, return as Lisp object. |
1561 If STREAM is nil, use the value of `standard-input' (which see). | 1556 If STREAM is nil, use the value of `standard-input' (which see). |
1580 Vcurrent_compiled_function_annotation = Qnil; | 1575 Vcurrent_compiled_function_annotation = Qnil; |
1581 #endif | 1576 #endif |
1582 if (EQ (stream, Qread_char)) | 1577 if (EQ (stream, Qread_char)) |
1583 { | 1578 { |
1584 Lisp_Object val = call1 (Qread_from_minibuffer, | 1579 Lisp_Object val = call1 (Qread_from_minibuffer, |
1585 build_translated_string ("Lisp expression: ")); | 1580 build_msg_string ("Lisp expression: ")); |
1586 return Fcar (Fread_from_string (val, Qnil, Qnil)); | 1581 return Fcar (Fread_from_string (val, Qnil, Qnil)); |
1587 } | 1582 } |
1588 | 1583 |
1589 if (STRINGP (stream)) | 1584 if (STRINGP (stream)) |
1590 return Fcar (Fread_from_string (stream, Qnil, Qnil)); | 1585 return Fcar (Fread_from_string (stream, Qnil, Qnil)); |
1620 tem = read0 (lispstream); | 1615 tem = read0 (lispstream); |
1621 /* Yeah, it's ugly. Gonna make something of it? | 1616 /* Yeah, it's ugly. Gonna make something of it? |
1622 At least our reader is reentrant ... */ | 1617 At least our reader is reentrant ... */ |
1623 tem = | 1618 tem = |
1624 (Fcons (tem, make_int | 1619 (Fcons (tem, make_int |
1625 (bytecount_to_charcount | 1620 (XSTRING_INDEX_BYTE_TO_CHAR |
1626 (XSTRING_DATA (string), | 1621 (string, |
1627 startval + Lstream_byte_count (XLSTREAM (lispstream)))))); | 1622 startval + Lstream_byte_count (XLSTREAM (lispstream)))))); |
1628 Lstream_delete (XLSTREAM (lispstream)); | 1623 Lstream_delete (XLSTREAM (lispstream)); |
1629 UNGCPRO; | 1624 UNGCPRO; |
1630 return tem; | 1625 return tem; |
1631 } | 1626 } |
2000 goto overflow; | 1995 goto overflow; |
2001 return result; | 1996 return result; |
2002 } | 1997 } |
2003 overflow: | 1998 overflow: |
2004 return Fsignal (Qinvalid_read_syntax, | 1999 return Fsignal (Qinvalid_read_syntax, |
2005 list3 (build_translated_string | 2000 list3 (build_msg_string |
2006 ("Integer constant overflow in reader"), | 2001 ("Integer constant overflow in reader"), |
2007 make_string (buf, len), | 2002 make_string (buf, len), |
2008 make_int (base))); | 2003 make_int (base))); |
2009 loser: | 2004 loser: |
2010 return Fsignal (Qinvalid_read_syntax, | 2005 return Fsignal (Qinvalid_read_syntax, |
2011 list3 (build_translated_string | 2006 list3 (build_msg_string |
2012 ("Invalid integer constant in reader"), | 2007 ("Invalid integer constant in reader"), |
2013 make_string (buf, len), | 2008 make_string (buf, len), |
2014 make_int (base))); | 2009 make_int (base))); |
2015 } | 2010 } |
2016 | 2011 |
2137 } | 2132 } |
2138 | 2133 |
2139 st = recognized_structure_type (XCAR (list)); | 2134 st = recognized_structure_type (XCAR (list)); |
2140 if (!st) | 2135 if (!st) |
2141 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax, | 2136 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax, |
2142 list2 (build_translated_string | 2137 list2 (build_msg_string |
2143 ("unrecognized structure type"), | 2138 ("unrecognized structure type"), |
2144 XCAR (list)))); | 2139 XCAR (list)))); |
2145 | 2140 |
2146 list = Fcdr (list); | 2141 list = Fcdr (list); |
2147 keyword_count = Dynarr_length (st->keywords); | 2142 keyword_count = Dynarr_length (st->keywords); |
2156 value = Fcar (list); | 2151 value = Fcar (list); |
2157 list = Fcdr (list); | 2152 list = Fcdr (list); |
2158 | 2153 |
2159 if (!NILP (memq_no_quit (keyword, already_seen))) | 2154 if (!NILP (memq_no_quit (keyword, already_seen))) |
2160 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax, | 2155 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax, |
2161 list2 (build_translated_string | 2156 list2 (build_msg_string |
2162 ("structure keyword already seen"), | 2157 ("structure keyword already seen"), |
2163 keyword))); | 2158 keyword))); |
2164 | 2159 |
2165 for (i = 0; i < keyword_count; i++) | 2160 for (i = 0; i < keyword_count; i++) |
2166 { | 2161 { |
2169 break; | 2164 break; |
2170 } | 2165 } |
2171 | 2166 |
2172 if (i == keyword_count) | 2167 if (i == keyword_count) |
2173 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax, | 2168 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax, |
2174 list2 (build_translated_string | 2169 list2 (build_msg_string |
2175 ("unrecognized structure keyword"), | 2170 ("unrecognized structure keyword"), |
2176 keyword))); | 2171 keyword))); |
2177 | 2172 |
2178 if (en->validate && ! (en->validate) (keyword, value, ERROR_ME)) | 2173 if (en->validate && ! (en->validate) (keyword, value, ERROR_ME)) |
2179 RETURN_UNGCPRO | 2174 RETURN_UNGCPRO |
2180 (Fsignal (Qinvalid_read_syntax, | 2175 (Fsignal (Qinvalid_read_syntax, |
2181 list3 (build_translated_string | 2176 list3 (build_msg_string |
2182 ("invalid value for structure keyword"), | 2177 ("invalid value for structure keyword"), |
2183 keyword, value))); | 2178 keyword, value))); |
2184 | 2179 |
2185 already_seen = Fcons (keyword, already_seen); | 2180 already_seen = Fcons (keyword, already_seen); |
2186 } | 2181 } |
2187 | 2182 |
2188 if (st->validate && ! (st->validate) (orig_list, ERROR_ME)) | 2183 if (st->validate && ! (st->validate) (orig_list, ERROR_ME)) |
2189 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax, | 2184 RETURN_UNGCPRO (Fsignal (Qinvalid_read_syntax, |
2190 list2 (build_translated_string | 2185 list2 (build_msg_string |
2191 ("invalid structure initializer"), | 2186 ("invalid structure initializer"), |
2192 orig_list))); | 2187 orig_list))); |
2193 | 2188 |
2194 RETURN_UNGCPRO ((st->instantiate) (XCDR (orig_list))); | 2189 RETURN_UNGCPRO ((st->instantiate) (XCDR (orig_list))); |
2195 } | 2190 } |
2270 int speccount = specpdl_depth (); | 2265 int speccount = specpdl_depth (); |
2271 ++old_backquote_flag; | 2266 ++old_backquote_flag; |
2272 record_unwind_protect (backquote_unwind, | 2267 record_unwind_protect (backquote_unwind, |
2273 make_opaque_ptr (&old_backquote_flag)); | 2268 make_opaque_ptr (&old_backquote_flag)); |
2274 tem = read0 (readcharfun); | 2269 tem = read0 (readcharfun); |
2275 unbind_to (speccount, Qnil); | 2270 unbind_to (speccount); |
2276 ch = reader_nextchar (readcharfun); | 2271 ch = reader_nextchar (readcharfun); |
2277 if (ch != ')') | 2272 if (ch != ')') |
2278 { | 2273 { |
2279 unreadchar (readcharfun, ch); | 2274 unreadchar (readcharfun, ch); |
2280 return Fsignal (Qinvalid_read_syntax, | 2275 return Fsignal (Qinvalid_read_syntax, |
2281 list1 (build_string | 2276 list1 (build_msg_string |
2282 ("Weird old-backquote syntax"))); | 2277 ("Weird old-backquote syntax"))); |
2283 } | 2278 } |
2284 return list2 (Qbacktick, tem); | 2279 return list2 (Qbacktick, tem); |
2285 } | 2280 } |
2286 case ',': | 2281 case ',': |
2301 ch = reader_nextchar (readcharfun); | 2296 ch = reader_nextchar (readcharfun); |
2302 if (ch != ')') | 2297 if (ch != ')') |
2303 { | 2298 { |
2304 unreadchar (readcharfun, ch); | 2299 unreadchar (readcharfun, ch); |
2305 return Fsignal (Qinvalid_read_syntax, | 2300 return Fsignal (Qinvalid_read_syntax, |
2306 list1 (build_string | 2301 list1 (build_msg_string |
2307 ("Weird old-backquote syntax"))); | 2302 ("Weird old-backquote syntax"))); |
2308 } | 2303 } |
2309 return list2 (comma_type, tem); | 2304 return list2 (comma_type, tem); |
2310 } | 2305 } |
2311 else | 2306 else |
2312 { | 2307 { |
2313 unreadchar (readcharfun, ch); | 2308 unreadchar (readcharfun, ch); |
2314 #if 0 | 2309 #if 0 |
2315 return Fsignal (Qinvalid_read_syntax, | 2310 return Fsignal (Qinvalid_read_syntax, |
2316 list1 (build_string ("Comma outside of backquote"))); | 2311 list1 (build_msg_string ("Comma outside of backquote"))); |
2317 #else | 2312 #else |
2318 /* #### - yuck....but this is reverse compatible. */ | 2313 /* #### - yuck....but this is reverse compatible. */ |
2319 /* mostly this is required by edebug, which does its own | 2314 /* mostly this is required by edebug, which does its own |
2320 annotated reading. We need to have an annotated_read | 2315 annotated reading. We need to have an annotated_read |
2321 function that records (with markers) the buffer | 2316 function that records (with markers) the buffer |
2444 } | 2439 } |
2445 if (invalid) | 2440 if (invalid) |
2446 RETURN_UNGCPRO | 2441 RETURN_UNGCPRO |
2447 (Fsignal (Qinvalid_read_syntax, | 2442 (Fsignal (Qinvalid_read_syntax, |
2448 list2 | 2443 list2 |
2449 (build_string ("invalid string property list"), | 2444 (build_msg_string ("invalid string property list"), |
2450 XCDR (plist)))); | 2445 XCDR (plist)))); |
2451 Fset_text_properties (beg, end, plist, tmp); | 2446 Fset_text_properties (beg, end, plist, tmp); |
2452 } | 2447 } |
2453 UNGCPRO; | 2448 UNGCPRO; |
2454 return tmp; | 2449 return tmp; |
2491 case 's': return read_structure (readcharfun); | 2486 case 's': return read_structure (readcharfun); |
2492 case '<': | 2487 case '<': |
2493 { | 2488 { |
2494 unreadchar (readcharfun, c); | 2489 unreadchar (readcharfun, c); |
2495 return Fsignal (Qinvalid_read_syntax, | 2490 return Fsignal (Qinvalid_read_syntax, |
2496 list1 (build_string ("Cannot read unreadable object"))); | 2491 list1 (build_msg_string ("Cannot read unreadable object"))); |
2497 } | 2492 } |
2498 #ifdef FEATUREP_SYNTAX | 2493 #ifdef FEATUREP_SYNTAX |
2499 case '+': | 2494 case '+': |
2500 case '-': | 2495 case '-': |
2501 { | 2496 { |
2538 /* #n=object returns object, but associates it with | 2533 /* #n=object returns object, but associates it with |
2539 n for #n#. */ | 2534 n for #n#. */ |
2540 Lisp_Object obj; | 2535 Lisp_Object obj; |
2541 if (CONSP (found)) | 2536 if (CONSP (found)) |
2542 return Fsignal (Qinvalid_read_syntax, | 2537 return Fsignal (Qinvalid_read_syntax, |
2543 list2 (build_translated_string | 2538 list2 (build_msg_string |
2544 ("Multiply defined symbol label"), | 2539 ("Multiply defined symbol label"), |
2545 make_int (n))); | 2540 make_int (n))); |
2546 obj = read0 (readcharfun); | 2541 obj = read0 (readcharfun); |
2547 Vread_objects = Fcons (Fcons (make_int (n), obj), | 2542 Vread_objects = Fcons (Fcons (make_int (n), obj), |
2548 Vread_objects); | 2543 Vread_objects); |
2553 /* #n# returns a previously read object. */ | 2548 /* #n# returns a previously read object. */ |
2554 if (CONSP (found)) | 2549 if (CONSP (found)) |
2555 return XCDR (found); | 2550 return XCDR (found); |
2556 else | 2551 else |
2557 return Fsignal (Qinvalid_read_syntax, | 2552 return Fsignal (Qinvalid_read_syntax, |
2558 list2 (build_translated_string | 2553 list2 (build_msg_string |
2559 ("Undefined symbol label"), | 2554 ("Undefined symbol label"), |
2560 make_int (n))); | 2555 make_int (n))); |
2561 } | 2556 } |
2562 return Fsignal (Qinvalid_read_syntax, | 2557 return Fsignal (Qinvalid_read_syntax, |
2563 list1 (build_string ("#"))); | 2558 list1 (build_string ("#"))); |
2581 int speccount = specpdl_depth (); | 2576 int speccount = specpdl_depth (); |
2582 ++new_backquote_flag; | 2577 ++new_backquote_flag; |
2583 record_unwind_protect (backquote_unwind, | 2578 record_unwind_protect (backquote_unwind, |
2584 make_opaque_ptr (&new_backquote_flag)); | 2579 make_opaque_ptr (&new_backquote_flag)); |
2585 tem = read0 (readcharfun); | 2580 tem = read0 (readcharfun); |
2586 unbind_to (speccount, Qnil); | 2581 unbind_to (speccount); |
2587 return list2 (Qbackquote, tem); | 2582 return list2 (Qbackquote, tem); |
2588 } | 2583 } |
2589 | 2584 |
2590 case ',': | 2585 case ',': |
2591 { | 2586 { |
3289 /* So that early-early stuff will work */ | 3284 /* So that early-early stuff will work */ |
3290 Ffset (Qload, intern ("load-internal")); | 3285 Ffset (Qload, intern ("load-internal")); |
3291 | 3286 |
3292 #ifdef FEATUREP_SYNTAX | 3287 #ifdef FEATUREP_SYNTAX |
3293 DEFSYMBOL (Qfeaturep); | 3288 DEFSYMBOL (Qfeaturep); |
3294 Fprovide(intern("xemacs")); | 3289 Fprovide (intern ("xemacs")); |
3295 #ifdef INFODOCK | 3290 #ifdef INFODOCK |
3296 Fprovide(intern("infodock")); | 3291 Fprovide (intern ("infodock")); |
3297 #endif /* INFODOCK */ | 3292 #endif /* INFODOCK */ |
3298 #endif /* FEATUREP_SYNTAX */ | 3293 #endif /* FEATUREP_SYNTAX */ |
3299 | 3294 |
3300 #ifdef LISP_BACKQUOTES | 3295 #ifdef LISP_BACKQUOTES |
3301 old_backquote_flag = new_backquote_flag = 0; | 3296 old_backquote_flag = new_backquote_flag = 0; |