diff options
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 157 |
1 files changed, 72 insertions, 85 deletions
diff --git a/src/lread.c b/src/lread.c index 639d574ac6b..171a51acb3f 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -970,10 +970,8 @@ load_warn_old_style_backquotes (Lisp_Object file) | |||
| 970 | { | 970 | { |
| 971 | if (!NILP (Vold_style_backquotes)) | 971 | if (!NILP (Vold_style_backquotes)) |
| 972 | { | 972 | { |
| 973 | Lisp_Object args[2]; | 973 | AUTO_STRING (format, "Loading `%s': old-style backquotes detected!"); |
| 974 | args[0] = build_string ("Loading `%s': old-style backquotes detected!"); | 974 | Fmessage (2, (Lisp_Object []) {format, file}); |
| 975 | args[1] = file; | ||
| 976 | Fmessage (2, args); | ||
| 977 | } | 975 | } |
| 978 | } | 976 | } |
| 979 | 977 | ||
| @@ -1473,6 +1471,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, | |||
| 1473 | ptrdiff_t max_suffix_len = 0; | 1471 | ptrdiff_t max_suffix_len = 0; |
| 1474 | int last_errno = ENOENT; | 1472 | int last_errno = ENOENT; |
| 1475 | int save_fd = -1; | 1473 | int save_fd = -1; |
| 1474 | USE_SAFE_ALLOCA; | ||
| 1476 | 1475 | ||
| 1477 | /* The last-modified time of the newest matching file found. | 1476 | /* The last-modified time of the newest matching file found. |
| 1478 | Initialize it to something less than all valid timestamps. */ | 1477 | Initialize it to something less than all valid timestamps. */ |
| @@ -1513,7 +1512,10 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, | |||
| 1513 | this path element/specified file name and any possible suffix. */ | 1512 | this path element/specified file name and any possible suffix. */ |
| 1514 | want_length = max_suffix_len + SBYTES (filename); | 1513 | want_length = max_suffix_len + SBYTES (filename); |
| 1515 | if (fn_size <= want_length) | 1514 | if (fn_size <= want_length) |
| 1516 | fn = alloca (fn_size = 100 + want_length); | 1515 | { |
| 1516 | fn_size = 100 + want_length; | ||
| 1517 | fn = SAFE_ALLOCA (fn_size); | ||
| 1518 | } | ||
| 1517 | 1519 | ||
| 1518 | /* Loop over suffixes. */ | 1520 | /* Loop over suffixes. */ |
| 1519 | for (tail = NILP (suffixes) ? list1 (empty_unibyte_string) : suffixes; | 1521 | for (tail = NILP (suffixes) ? list1 (empty_unibyte_string) : suffixes; |
| @@ -1579,6 +1581,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, | |||
| 1579 | /* We succeeded; return this descriptor and filename. */ | 1581 | /* We succeeded; return this descriptor and filename. */ |
| 1580 | if (storeptr) | 1582 | if (storeptr) |
| 1581 | *storeptr = string; | 1583 | *storeptr = string; |
| 1584 | SAFE_FREE (); | ||
| 1582 | UNGCPRO; | 1585 | UNGCPRO; |
| 1583 | return -2; | 1586 | return -2; |
| 1584 | } | 1587 | } |
| @@ -1651,6 +1654,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, | |||
| 1651 | /* We succeeded; return this descriptor and filename. */ | 1654 | /* We succeeded; return this descriptor and filename. */ |
| 1652 | if (storeptr) | 1655 | if (storeptr) |
| 1653 | *storeptr = string; | 1656 | *storeptr = string; |
| 1657 | SAFE_FREE (); | ||
| 1654 | UNGCPRO; | 1658 | UNGCPRO; |
| 1655 | return fd; | 1659 | return fd; |
| 1656 | } | 1660 | } |
| @@ -1661,6 +1665,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, | |||
| 1661 | { | 1665 | { |
| 1662 | if (storeptr) | 1666 | if (storeptr) |
| 1663 | *storeptr = save_string; | 1667 | *storeptr = save_string; |
| 1668 | SAFE_FREE (); | ||
| 1664 | UNGCPRO; | 1669 | UNGCPRO; |
| 1665 | return save_fd; | 1670 | return save_fd; |
| 1666 | } | 1671 | } |
| @@ -1670,6 +1675,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, | |||
| 1670 | break; | 1675 | break; |
| 1671 | } | 1676 | } |
| 1672 | 1677 | ||
| 1678 | SAFE_FREE (); | ||
| 1673 | UNGCPRO; | 1679 | UNGCPRO; |
| 1674 | errno = last_errno; | 1680 | errno = last_errno; |
| 1675 | return -1; | 1681 | return -1; |
| @@ -1774,15 +1780,17 @@ readevalloop_eager_expand_eval (Lisp_Object val, Lisp_Object macroexpand) | |||
| 1774 | val = call2 (macroexpand, val, Qnil); | 1780 | val = call2 (macroexpand, val, Qnil); |
| 1775 | if (EQ (CAR_SAFE (val), Qprogn)) | 1781 | if (EQ (CAR_SAFE (val), Qprogn)) |
| 1776 | { | 1782 | { |
| 1783 | struct gcpro gcpro1; | ||
| 1777 | Lisp_Object subforms = XCDR (val); | 1784 | Lisp_Object subforms = XCDR (val); |
| 1778 | val = Qnil; | 1785 | |
| 1779 | for (; CONSP (subforms); subforms = XCDR (subforms)) | 1786 | GCPRO1 (subforms); |
| 1787 | for (val = Qnil; CONSP (subforms); subforms = XCDR (subforms)) | ||
| 1780 | val = readevalloop_eager_expand_eval (XCAR (subforms), | 1788 | val = readevalloop_eager_expand_eval (XCAR (subforms), |
| 1781 | macroexpand); | 1789 | macroexpand); |
| 1790 | UNGCPRO; | ||
| 1782 | } | 1791 | } |
| 1783 | else | 1792 | else |
| 1784 | val = eval_sub (call2 (macroexpand, val, Qt)); | 1793 | val = eval_sub (call2 (macroexpand, val, Qt)); |
| 1785 | |||
| 1786 | return val; | 1794 | return val; |
| 1787 | } | 1795 | } |
| 1788 | 1796 | ||
| @@ -2088,9 +2096,10 @@ DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0, | |||
| 2088 | doc: /* Read one Lisp expression which is represented as text by STRING. | 2096 | doc: /* Read one Lisp expression which is represented as text by STRING. |
| 2089 | Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX). | 2097 | Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX). |
| 2090 | FINAL-STRING-INDEX is an integer giving the position of the next | 2098 | FINAL-STRING-INDEX is an integer giving the position of the next |
| 2091 | remaining character in STRING. | 2099 | remaining character in STRING. START and END optionally delimit |
| 2092 | START and END optionally delimit a substring of STRING from which to read; | 2100 | a substring of STRING from which to read; they default to 0 and |
| 2093 | they default to 0 and (length STRING) respectively. */) | 2101 | (length STRING) respectively. Negative values are counted from |
| 2102 | the end of STRING. */) | ||
| 2094 | (Lisp_Object string, Lisp_Object start, Lisp_Object end) | 2103 | (Lisp_Object string, Lisp_Object start, Lisp_Object end) |
| 2095 | { | 2104 | { |
| 2096 | Lisp_Object ret; | 2105 | Lisp_Object ret; |
| @@ -2101,10 +2110,9 @@ START and END optionally delimit a substring of STRING from which to read; | |||
| 2101 | } | 2110 | } |
| 2102 | 2111 | ||
| 2103 | /* Function to set up the global context we need in toplevel read | 2112 | /* Function to set up the global context we need in toplevel read |
| 2104 | calls. */ | 2113 | calls. START and END only used when STREAM is a string. */ |
| 2105 | static Lisp_Object | 2114 | static Lisp_Object |
| 2106 | read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) | 2115 | read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) |
| 2107 | /* `start', `end' only used when stream is a string. */ | ||
| 2108 | { | 2116 | { |
| 2109 | Lisp_Object retval; | 2117 | Lisp_Object retval; |
| 2110 | 2118 | ||
| @@ -2126,25 +2134,9 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) | |||
| 2126 | else | 2134 | else |
| 2127 | string = XCAR (stream); | 2135 | string = XCAR (stream); |
| 2128 | 2136 | ||
| 2129 | if (NILP (end)) | 2137 | validate_subarray (string, start, end, SCHARS (string), |
| 2130 | endval = SCHARS (string); | 2138 | &startval, &endval); |
| 2131 | else | ||
| 2132 | { | ||
| 2133 | CHECK_NUMBER (end); | ||
| 2134 | if (! (0 <= XINT (end) && XINT (end) <= SCHARS (string))) | ||
| 2135 | args_out_of_range (string, end); | ||
| 2136 | endval = XINT (end); | ||
| 2137 | } | ||
| 2138 | 2139 | ||
| 2139 | if (NILP (start)) | ||
| 2140 | startval = 0; | ||
| 2141 | else | ||
| 2142 | { | ||
| 2143 | CHECK_NUMBER (start); | ||
| 2144 | if (! (0 <= XINT (start) && XINT (start) <= endval)) | ||
| 2145 | args_out_of_range (string, start); | ||
| 2146 | startval = XINT (start); | ||
| 2147 | } | ||
| 2148 | read_from_string_index = startval; | 2140 | read_from_string_index = startval; |
| 2149 | read_from_string_index_byte = string_char_to_byte (string, startval); | 2141 | read_from_string_index_byte = string_char_to_byte (string, startval); |
| 2150 | read_from_string_limit = endval; | 2142 | read_from_string_limit = endval; |
| @@ -2881,11 +2873,8 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 2881 | if (c == '=') | 2873 | if (c == '=') |
| 2882 | { | 2874 | { |
| 2883 | /* Make a placeholder for #n# to use temporarily. */ | 2875 | /* Make a placeholder for #n# to use temporarily. */ |
| 2884 | Lisp_Object placeholder; | 2876 | AUTO_CONS (placeholder, Qnil, Qnil); |
| 2885 | Lisp_Object cell; | 2877 | Lisp_Object cell = Fcons (make_number (n), placeholder); |
| 2886 | |||
| 2887 | placeholder = Fcons (Qnil, Qnil); | ||
| 2888 | cell = Fcons (make_number (n), placeholder); | ||
| 2889 | read_objects = Fcons (cell, read_objects); | 2878 | read_objects = Fcons (cell, read_objects); |
| 2890 | 2879 | ||
| 2891 | /* Read the object itself. */ | 2880 | /* Read the object itself. */ |
| @@ -3364,7 +3353,7 @@ substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Obj | |||
| 3364 | substitute_in_interval contains part of the logic. */ | 3353 | substitute_in_interval contains part of the logic. */ |
| 3365 | 3354 | ||
| 3366 | INTERVAL root_interval = string_intervals (subtree); | 3355 | INTERVAL root_interval = string_intervals (subtree); |
| 3367 | Lisp_Object arg = Fcons (object, placeholder); | 3356 | AUTO_CONS (arg, object, placeholder); |
| 3368 | 3357 | ||
| 3369 | traverse_intervals_noorder (root_interval, | 3358 | traverse_intervals_noorder (root_interval, |
| 3370 | &substitute_in_interval, arg); | 3359 | &substitute_in_interval, arg); |
| @@ -3671,8 +3660,10 @@ read_list (bool flag, Lisp_Object readcharfun) | |||
| 3671 | in the installed Lisp directory. | 3660 | in the installed Lisp directory. |
| 3672 | We don't use Fexpand_file_name because that would make | 3661 | We don't use Fexpand_file_name because that would make |
| 3673 | the directory absolute now. */ | 3662 | the directory absolute now. */ |
| 3674 | elt = concat2 (build_string ("../lisp/"), | 3663 | { |
| 3675 | Ffile_name_nondirectory (elt)); | 3664 | AUTO_STRING (dot_dot_lisp, "../lisp/"); |
| 3665 | elt = concat2 (dot_dot_lisp, Ffile_name_nondirectory (elt)); | ||
| 3666 | } | ||
| 3676 | } | 3667 | } |
| 3677 | else if (EQ (elt, Vload_file_name) | 3668 | else if (EQ (elt, Vload_file_name) |
| 3678 | && ! NILP (elt) | 3669 | && ! NILP (elt) |
| @@ -3800,6 +3791,30 @@ check_obarray (Lisp_Object obarray) | |||
| 3800 | return obarray; | 3791 | return obarray; |
| 3801 | } | 3792 | } |
| 3802 | 3793 | ||
| 3794 | /* Intern a symbol with name STRING in OBARRAY using bucket INDEX. */ | ||
| 3795 | |||
| 3796 | Lisp_Object | ||
| 3797 | intern_driver (Lisp_Object string, Lisp_Object obarray, ptrdiff_t index) | ||
| 3798 | { | ||
| 3799 | Lisp_Object *ptr, sym = Fmake_symbol (string); | ||
| 3800 | |||
| 3801 | XSYMBOL (sym)->interned = (EQ (obarray, initial_obarray) | ||
| 3802 | ? SYMBOL_INTERNED_IN_INITIAL_OBARRAY | ||
| 3803 | : SYMBOL_INTERNED); | ||
| 3804 | |||
| 3805 | if ((SREF (string, 0) == ':') && EQ (obarray, initial_obarray)) | ||
| 3806 | { | ||
| 3807 | XSYMBOL (sym)->constant = 1; | ||
| 3808 | XSYMBOL (sym)->redirect = SYMBOL_PLAINVAL; | ||
| 3809 | SET_SYMBOL_VAL (XSYMBOL (sym), sym); | ||
| 3810 | } | ||
| 3811 | |||
| 3812 | ptr = aref_addr (obarray, index); | ||
| 3813 | set_symbol_next (sym, SYMBOLP (*ptr) ? XSYMBOL (*ptr) : NULL); | ||
| 3814 | *ptr = sym; | ||
| 3815 | return sym; | ||
| 3816 | } | ||
| 3817 | |||
| 3803 | /* Intern the C string STR: return a symbol with that name, | 3818 | /* Intern the C string STR: return a symbol with that name, |
| 3804 | interned in the current obarray. */ | 3819 | interned in the current obarray. */ |
| 3805 | 3820 | ||
| @@ -3809,7 +3824,8 @@ intern_1 (const char *str, ptrdiff_t len) | |||
| 3809 | Lisp_Object obarray = check_obarray (Vobarray); | 3824 | Lisp_Object obarray = check_obarray (Vobarray); |
| 3810 | Lisp_Object tem = oblookup (obarray, str, len, len); | 3825 | Lisp_Object tem = oblookup (obarray, str, len, len); |
| 3811 | 3826 | ||
| 3812 | return SYMBOLP (tem) ? tem : Fintern (make_string (str, len), obarray); | 3827 | return SYMBOLP (tem) ? tem : intern_driver (make_string (str, len), |
| 3828 | obarray, XINT (tem)); | ||
| 3813 | } | 3829 | } |
| 3814 | 3830 | ||
| 3815 | Lisp_Object | 3831 | Lisp_Object |
| @@ -3818,16 +3834,14 @@ intern_c_string_1 (const char *str, ptrdiff_t len) | |||
| 3818 | Lisp_Object obarray = check_obarray (Vobarray); | 3834 | Lisp_Object obarray = check_obarray (Vobarray); |
| 3819 | Lisp_Object tem = oblookup (obarray, str, len, len); | 3835 | Lisp_Object tem = oblookup (obarray, str, len, len); |
| 3820 | 3836 | ||
| 3821 | if (SYMBOLP (tem)) | 3837 | if (!SYMBOLP (tem)) |
| 3822 | return tem; | 3838 | { |
| 3823 | 3839 | /* Creating a non-pure string from a string literal not implemented yet. | |
| 3824 | if (NILP (Vpurify_flag)) | 3840 | We could just use make_string here and live with the extra copy. */ |
| 3825 | /* Creating a non-pure string from a string literal not | 3841 | eassert (!NILP (Vpurify_flag)); |
| 3826 | implemented yet. We could just use make_string here and live | 3842 | tem = intern_driver (make_pure_c_string (str, len), obarray, XINT (tem)); |
| 3827 | with the extra copy. */ | 3843 | } |
| 3828 | emacs_abort (); | 3844 | return tem; |
| 3829 | |||
| 3830 | return Fintern (make_pure_c_string (str, len), obarray); | ||
| 3831 | } | 3845 | } |
| 3832 | 3846 | ||
| 3833 | DEFUN ("intern", Fintern, Sintern, 1, 2, 0, | 3847 | DEFUN ("intern", Fintern, Sintern, 1, 2, 0, |
| @@ -3837,43 +3851,16 @@ A second optional argument specifies the obarray to use; | |||
| 3837 | it defaults to the value of `obarray'. */) | 3851 | it defaults to the value of `obarray'. */) |
| 3838 | (Lisp_Object string, Lisp_Object obarray) | 3852 | (Lisp_Object string, Lisp_Object obarray) |
| 3839 | { | 3853 | { |
| 3840 | register Lisp_Object tem, sym, *ptr; | 3854 | Lisp_Object tem; |
| 3841 | |||
| 3842 | if (NILP (obarray)) obarray = Vobarray; | ||
| 3843 | obarray = check_obarray (obarray); | ||
| 3844 | 3855 | ||
| 3856 | obarray = check_obarray (NILP (obarray) ? Vobarray : obarray); | ||
| 3845 | CHECK_STRING (string); | 3857 | CHECK_STRING (string); |
| 3846 | 3858 | ||
| 3847 | tem = oblookup (obarray, SSDATA (string), | 3859 | tem = oblookup (obarray, SSDATA (string), SCHARS (string), SBYTES (string)); |
| 3848 | SCHARS (string), | 3860 | if (!SYMBOLP (tem)) |
| 3849 | SBYTES (string)); | 3861 | tem = intern_driver (NILP (Vpurify_flag) ? string |
| 3850 | if (!INTEGERP (tem)) | 3862 | : Fpurecopy (string), obarray, XINT (tem)); |
| 3851 | return tem; | 3863 | return tem; |
| 3852 | |||
| 3853 | if (!NILP (Vpurify_flag)) | ||
| 3854 | string = Fpurecopy (string); | ||
| 3855 | sym = Fmake_symbol (string); | ||
| 3856 | |||
| 3857 | if (EQ (obarray, initial_obarray)) | ||
| 3858 | XSYMBOL (sym)->interned = SYMBOL_INTERNED_IN_INITIAL_OBARRAY; | ||
| 3859 | else | ||
| 3860 | XSYMBOL (sym)->interned = SYMBOL_INTERNED; | ||
| 3861 | |||
| 3862 | if ((SREF (string, 0) == ':') | ||
| 3863 | && EQ (obarray, initial_obarray)) | ||
| 3864 | { | ||
| 3865 | XSYMBOL (sym)->constant = 1; | ||
| 3866 | XSYMBOL (sym)->redirect = SYMBOL_PLAINVAL; | ||
| 3867 | SET_SYMBOL_VAL (XSYMBOL (sym), sym); | ||
| 3868 | } | ||
| 3869 | |||
| 3870 | ptr = aref_addr (obarray, XINT (tem)); | ||
| 3871 | if (SYMBOLP (*ptr)) | ||
| 3872 | set_symbol_next (sym, XSYMBOL (*ptr)); | ||
| 3873 | else | ||
| 3874 | set_symbol_next (sym, NULL); | ||
| 3875 | *ptr = sym; | ||
| 3876 | return sym; | ||
| 3877 | } | 3864 | } |
| 3878 | 3865 | ||
| 3879 | DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0, | 3866 | DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0, |
| @@ -4213,7 +4200,7 @@ load_path_check (Lisp_Object lpath) | |||
| 4213 | if (STRINGP (dirfile)) | 4200 | if (STRINGP (dirfile)) |
| 4214 | { | 4201 | { |
| 4215 | dirfile = Fdirectory_file_name (dirfile); | 4202 | dirfile = Fdirectory_file_name (dirfile); |
| 4216 | if (! file_accessible_directory_p (SSDATA (dirfile))) | 4203 | if (! file_accessible_directory_p (dirfile)) |
| 4217 | dir_warning ("Lisp directory", XCAR (path_tail)); | 4204 | dir_warning ("Lisp directory", XCAR (path_tail)); |
| 4218 | } | 4205 | } |
| 4219 | } | 4206 | } |