diff options
| author | Karoly Lorentey | 2006-06-12 07:27:12 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2006-06-12 07:27:12 +0000 |
| commit | 476e9367ec1f440aa23904b7bc482ea4a3b8041c (patch) | |
| tree | 4f7f5a5e9a6668f908834bb6e216c8fa3727d4b3 /src/lread.c | |
| parent | a13f8f50d4cc544d3bbfa78568e82ce09e68bded (diff) | |
| parent | 6b519504c3297595101628e823e72c91e562ab45 (diff) | |
| download | emacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.tar.gz emacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.zip | |
Merged from emacs@sv.gnu.org.
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-294
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-295
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-296
Update from CVS: admin/FOR-RELEASE: Update refcard section.
* emacs@sv.gnu.org/emacs--devo--0--patch-297
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-298
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-299
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-300
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-301
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-302
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-303
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-304
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-103
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-104
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-570
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 119 |
1 files changed, 97 insertions, 22 deletions
diff --git a/src/lread.c b/src/lread.c index 8d0d6b098c0..797ae1078fb 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -89,6 +89,7 @@ Lisp_Object Qascii_character, Qload, Qload_file_name; | |||
| 89 | Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; | 89 | Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; |
| 90 | Lisp_Object Qinhibit_file_name_operation; | 90 | Lisp_Object Qinhibit_file_name_operation; |
| 91 | Lisp_Object Qeval_buffer_list, Veval_buffer_list; | 91 | Lisp_Object Qeval_buffer_list, Veval_buffer_list; |
| 92 | Lisp_Object Qfile_truename, Qdo_after_load_evaluation; /* ACM 2006/5/16 */ | ||
| 92 | 93 | ||
| 93 | extern Lisp_Object Qevent_symbol_element_mask; | 94 | extern Lisp_Object Qevent_symbol_element_mask; |
| 94 | extern Lisp_Object Qfile_exists_p; | 95 | extern Lisp_Object Qfile_exists_p; |
| @@ -720,8 +721,8 @@ Return t if the file exists and loads successfully. */) | |||
| 720 | register int fd = -1; | 721 | register int fd = -1; |
| 721 | int count = SPECPDL_INDEX (); | 722 | int count = SPECPDL_INDEX (); |
| 722 | Lisp_Object temp; | 723 | Lisp_Object temp; |
| 723 | struct gcpro gcpro1, gcpro2; | 724 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 724 | Lisp_Object found, efound; | 725 | Lisp_Object found, efound, hist_file_name; |
| 725 | /* 1 means we printed the ".el is newer" message. */ | 726 | /* 1 means we printed the ".el is newer" message. */ |
| 726 | int newer = 0; | 727 | int newer = 0; |
| 727 | /* 1 means we are loading a compiled file. */ | 728 | /* 1 means we are loading a compiled file. */ |
| @@ -729,6 +730,7 @@ Return t if the file exists and loads successfully. */) | |||
| 729 | Lisp_Object handler; | 730 | Lisp_Object handler; |
| 730 | int safe_p = 1; | 731 | int safe_p = 1; |
| 731 | char *fmode = "r"; | 732 | char *fmode = "r"; |
| 733 | Lisp_Object tmp[2]; | ||
| 732 | #ifdef DOS_NT | 734 | #ifdef DOS_NT |
| 733 | fmode = "rt"; | 735 | fmode = "rt"; |
| 734 | #endif /* DOS_NT */ | 736 | #endif /* DOS_NT */ |
| @@ -745,7 +747,7 @@ Return t if the file exists and loads successfully. */) | |||
| 745 | the need to gcpro noerror, nomessage and nosuffix. | 747 | the need to gcpro noerror, nomessage and nosuffix. |
| 746 | (Below here, we care only whether they are nil or not.) | 748 | (Below here, we care only whether they are nil or not.) |
| 747 | The presence of this call is the result of a historical accident: | 749 | The presence of this call is the result of a historical accident: |
| 748 | it used to be in every file-operations and when it got removed | 750 | it used to be in every file-operation and when it got removed |
| 749 | everywhere, it accidentally stayed here. Since then, enough people | 751 | everywhere, it accidentally stayed here. Since then, enough people |
| 750 | supposedly have things like (load "$PROJECT/foo.el") in their .emacs | 752 | supposedly have things like (load "$PROJECT/foo.el") in their .emacs |
| 751 | that it seemed risky to remove. */ | 753 | that it seemed risky to remove. */ |
| @@ -765,7 +767,6 @@ Return t if the file exists and loads successfully. */) | |||
| 765 | if (SCHARS (file) > 0) | 767 | if (SCHARS (file) > 0) |
| 766 | { | 768 | { |
| 767 | int size = SBYTES (file); | 769 | int size = SBYTES (file); |
| 768 | Lisp_Object tmp[2]; | ||
| 769 | 770 | ||
| 770 | found = Qnil; | 771 | found = Qnil; |
| 771 | GCPRO2 (file, found); | 772 | GCPRO2 (file, found); |
| @@ -849,6 +850,13 @@ Return t if the file exists and loads successfully. */) | |||
| 849 | Vloads_in_progress = Fcons (found, Vloads_in_progress); | 850 | Vloads_in_progress = Fcons (found, Vloads_in_progress); |
| 850 | } | 851 | } |
| 851 | 852 | ||
| 853 | /* Get the name for load-history. */ | ||
| 854 | hist_file_name = (! NILP (Vpurify_flag) | ||
| 855 | ? Fconcat (2, (tmp[0] = Ffile_name_directory (file), | ||
| 856 | tmp[1] = Ffile_name_nondirectory (found), | ||
| 857 | tmp)) | ||
| 858 | : found) ; | ||
| 859 | |||
| 852 | if (!bcmp (SDATA (found) + SBYTES (found) - 4, | 860 | if (!bcmp (SDATA (found) + SBYTES (found) - 4, |
| 853 | ".elc", 4)) | 861 | ".elc", 4)) |
| 854 | /* Load .elc files directly, but not when they are | 862 | /* Load .elc files directly, but not when they are |
| @@ -859,7 +867,7 @@ Return t if the file exists and loads successfully. */) | |||
| 859 | struct stat s1, s2; | 867 | struct stat s1, s2; |
| 860 | int result; | 868 | int result; |
| 861 | 869 | ||
| 862 | GCPRO2 (file, found); | 870 | GCPRO3 (file, found, hist_file_name); |
| 863 | 871 | ||
| 864 | if (!safe_to_load_p (fd)) | 872 | if (!safe_to_load_p (fd)) |
| 865 | { | 873 | { |
| @@ -913,14 +921,14 @@ Return t if the file exists and loads successfully. */) | |||
| 913 | 921 | ||
| 914 | if (fd >= 0) | 922 | if (fd >= 0) |
| 915 | emacs_close (fd); | 923 | emacs_close (fd); |
| 916 | val = call4 (Vload_source_file_function, found, file, | 924 | val = call4 (Vload_source_file_function, found, hist_file_name, |
| 917 | NILP (noerror) ? Qnil : Qt, | 925 | NILP (noerror) ? Qnil : Qt, |
| 918 | NILP (nomessage) ? Qnil : Qt); | 926 | NILP (nomessage) ? Qnil : Qt); |
| 919 | return unbind_to (count, val); | 927 | return unbind_to (count, val); |
| 920 | } | 928 | } |
| 921 | } | 929 | } |
| 922 | 930 | ||
| 923 | GCPRO2 (file, found); | 931 | GCPRO3 (file, found, hist_file_name); |
| 924 | 932 | ||
| 925 | #ifdef WINDOWSNT | 933 | #ifdef WINDOWSNT |
| 926 | emacs_close (fd); | 934 | emacs_close (fd); |
| @@ -959,14 +967,15 @@ Return t if the file exists and loads successfully. */) | |||
| 959 | load_descriptor_list | 967 | load_descriptor_list |
| 960 | = Fcons (make_number (fileno (stream)), load_descriptor_list); | 968 | = Fcons (make_number (fileno (stream)), load_descriptor_list); |
| 961 | load_in_progress++; | 969 | load_in_progress++; |
| 962 | readevalloop (Qget_file_char, stream, (! NILP (Vpurify_flag) ? file : found), | 970 | readevalloop (Qget_file_char, stream, hist_file_name, |
| 963 | Feval, 0, Qnil, Qnil, Qnil, Qnil); | 971 | Feval, 0, Qnil, Qnil, Qnil, Qnil); |
| 964 | unbind_to (count, Qnil); | 972 | unbind_to (count, Qnil); |
| 965 | 973 | ||
| 966 | /* Run any load-hooks for this file. */ | 974 | /* Run any eval-after-load forms for this file */ |
| 967 | temp = Fassoc (file, Vafter_load_alist); | 975 | if (NILP (Vpurify_flag) |
| 968 | if (!NILP (temp)) | 976 | && (!NILP (Ffboundp (Qdo_after_load_evaluation)))) |
| 969 | Fprogn (Fcdr (temp)); | 977 | call1 (Qdo_after_load_evaluation, hist_file_name) ; |
| 978 | |||
| 970 | UNGCPRO; | 979 | UNGCPRO; |
| 971 | 980 | ||
| 972 | if (saved_doc_string) | 981 | if (saved_doc_string) |
| @@ -1393,6 +1402,12 @@ readevalloop (readcharfun, stream, sourcename, evalfun, | |||
| 1393 | 1402 | ||
| 1394 | GCPRO4 (sourcename, readfun, start, end); | 1403 | GCPRO4 (sourcename, readfun, start, end); |
| 1395 | 1404 | ||
| 1405 | /* Try to ensure sourcename is a truename, except whilst preloading. */ | ||
| 1406 | if (NILP (Vpurify_flag) | ||
| 1407 | && !NILP (sourcename) && Ffile_name_absolute_p (sourcename) | ||
| 1408 | && (!NILP (Ffboundp (Qfile_truename)))) | ||
| 1409 | sourcename = call1 (Qfile_truename, sourcename) ; | ||
| 1410 | |||
| 1396 | LOADHIST_ATTACH (sourcename); | 1411 | LOADHIST_ATTACH (sourcename); |
| 1397 | 1412 | ||
| 1398 | continue_reading_p = 1; | 1413 | continue_reading_p = 1; |
| @@ -1751,6 +1766,9 @@ read_escape (readcharfun, stringp, byterep) | |||
| 1751 | int *byterep; | 1766 | int *byterep; |
| 1752 | { | 1767 | { |
| 1753 | register int c = READCHAR; | 1768 | register int c = READCHAR; |
| 1769 | /* \u allows up to four hex digits, \U up to eight. Default to the | ||
| 1770 | behaviour for \u, and change this value in the case that \U is seen. */ | ||
| 1771 | int unicode_hex_count = 4; | ||
| 1754 | 1772 | ||
| 1755 | *byterep = 0; | 1773 | *byterep = 0; |
| 1756 | 1774 | ||
| @@ -1915,6 +1933,52 @@ read_escape (readcharfun, stringp, byterep) | |||
| 1915 | return i; | 1933 | return i; |
| 1916 | } | 1934 | } |
| 1917 | 1935 | ||
| 1936 | case 'U': | ||
| 1937 | /* Post-Unicode-2.0: Up to eight hex chars. */ | ||
| 1938 | unicode_hex_count = 8; | ||
| 1939 | case 'u': | ||
| 1940 | |||
| 1941 | /* A Unicode escape. We only permit them in strings and characters, | ||
| 1942 | not arbitrarily in the source code, as in some other languages. */ | ||
| 1943 | { | ||
| 1944 | int i = 0; | ||
| 1945 | int count = 0; | ||
| 1946 | Lisp_Object lisp_char; | ||
| 1947 | struct gcpro gcpro1; | ||
| 1948 | |||
| 1949 | while (++count <= unicode_hex_count) | ||
| 1950 | { | ||
| 1951 | c = READCHAR; | ||
| 1952 | /* isdigit(), isalpha() may be locale-specific, which we don't | ||
| 1953 | want. */ | ||
| 1954 | if (c >= '0' && c <= '9') i = (i << 4) + (c - '0'); | ||
| 1955 | else if (c >= 'a' && c <= 'f') i = (i << 4) + (c - 'a') + 10; | ||
| 1956 | else if (c >= 'A' && c <= 'F') i = (i << 4) + (c - 'A') + 10; | ||
| 1957 | else | ||
| 1958 | { | ||
| 1959 | error ("Non-hex digit used for Unicode escape"); | ||
| 1960 | break; | ||
| 1961 | } | ||
| 1962 | } | ||
| 1963 | |||
| 1964 | GCPRO1 (readcharfun); | ||
| 1965 | lisp_char = call2(intern("decode-char"), intern("ucs"), | ||
| 1966 | make_number(i)); | ||
| 1967 | UNGCPRO; | ||
| 1968 | |||
| 1969 | if (EQ(Qnil, lisp_char)) | ||
| 1970 | { | ||
| 1971 | /* This is ugly and horrible and trashes the user's data. */ | ||
| 1972 | XSETFASTINT (i, MAKE_CHAR (charset_katakana_jisx0201, | ||
| 1973 | 34 + 128, 46 + 128)); | ||
| 1974 | return i; | ||
| 1975 | } | ||
| 1976 | else | ||
| 1977 | { | ||
| 1978 | return XFASTINT (lisp_char); | ||
| 1979 | } | ||
| 1980 | } | ||
| 1981 | |||
| 1918 | default: | 1982 | default: |
| 1919 | if (BASE_LEADING_CODE_P (c)) | 1983 | if (BASE_LEADING_CODE_P (c)) |
| 1920 | c = read_multibyte (c, readcharfun); | 1984 | c = read_multibyte (c, readcharfun); |
| @@ -3973,16 +4037,17 @@ customize `jka-compr-load-suffixes' rather than the present variable. */); | |||
| 3973 | 4037 | ||
| 3974 | DEFVAR_LISP ("after-load-alist", &Vafter_load_alist, | 4038 | DEFVAR_LISP ("after-load-alist", &Vafter_load_alist, |
| 3975 | doc: /* An alist of expressions to be evalled when particular files are loaded. | 4039 | doc: /* An alist of expressions to be evalled when particular files are loaded. |
| 3976 | Each element looks like (FILENAME FORMS...). | 4040 | Each element looks like (REGEXP-OR-FEATURE FORMS...). |
| 3977 | When `load' is run and the file-name argument is FILENAME, | 4041 | |
| 3978 | the FORMS in the corresponding element are executed at the end of loading. | 4042 | REGEXP-OR-FEATURE is either a regular expression to match file names, or |
| 3979 | 4043 | a symbol \(a feature name). | |
| 3980 | FILENAME must match exactly! Normally FILENAME is the name of a library, | 4044 | |
| 3981 | with no directory specified, since that is how `load' is normally called. | 4045 | When `load' is run and the file-name argument matches an element's |
| 3982 | An error in FORMS does not undo the load, | 4046 | REGEXP-OR-FEATURE, or when `provide' is run and provides the symbol |
| 3983 | but does prevent execution of the rest of the FORMS. | 4047 | REGEXP-OR-FEATURE, the FORMS in the element are executed. |
| 3984 | FILENAME can also be a symbol (a feature) and FORMS are then executed | 4048 | |
| 3985 | when the corresponding call to `provide' is made. */); | 4049 | An error in FORMS does not undo the load, but does prevent execution of |
| 4050 | the rest of the FORMS. */); | ||
| 3986 | Vafter_load_alist = Qnil; | 4051 | Vafter_load_alist = Qnil; |
| 3987 | 4052 | ||
| 3988 | DEFVAR_LISP ("load-history", &Vload_history, | 4053 | DEFVAR_LISP ("load-history", &Vload_history, |
| @@ -3990,6 +4055,10 @@ when the corresponding call to `provide' is made. */); | |||
| 3990 | Each alist element is a list that starts with a file name, | 4055 | Each alist element is a list that starts with a file name, |
| 3991 | except for one element (optional) that starts with nil and describes | 4056 | except for one element (optional) that starts with nil and describes |
| 3992 | definitions evaluated from buffers not visiting files. | 4057 | definitions evaluated from buffers not visiting files. |
| 4058 | |||
| 4059 | The file name is absolute and is the true file name (i.e. it doesn't | ||
| 4060 | contain symbolic links) of the loaded file. | ||
| 4061 | |||
| 3993 | The remaining elements of each list are symbols defined as variables | 4062 | The remaining elements of each list are symbols defined as variables |
| 3994 | and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)', | 4063 | and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)', |
| 3995 | `(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'. | 4064 | `(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'. |
| @@ -4120,6 +4189,12 @@ to load. See also `load-dangerous-libraries'. */); | |||
| 4120 | Qeval_buffer_list = intern ("eval-buffer-list"); | 4189 | Qeval_buffer_list = intern ("eval-buffer-list"); |
| 4121 | staticpro (&Qeval_buffer_list); | 4190 | staticpro (&Qeval_buffer_list); |
| 4122 | 4191 | ||
| 4192 | Qfile_truename = intern ("file-truename"); | ||
| 4193 | staticpro (&Qfile_truename) ; | ||
| 4194 | |||
| 4195 | Qdo_after_load_evaluation = intern ("do-after-load-evaluation"); | ||
| 4196 | staticpro (&Qdo_after_load_evaluation) ; | ||
| 4197 | |||
| 4123 | staticpro (&dump_path); | 4198 | staticpro (&dump_path); |
| 4124 | 4199 | ||
| 4125 | staticpro (&read_objects); | 4200 | staticpro (&read_objects); |