diff options
| author | Richard M. Stallman | 1998-04-20 07:09:58 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-04-20 07:09:58 +0000 |
| commit | 94e554db23127711644cf24e4b625c7d197fd075 (patch) | |
| tree | c493cd6f45c08c0d5a7484e4ffe8006b50a0559a /src | |
| parent | 7e79b8e08ddba0ad1080eb1edd6bad679be3b975 (diff) | |
| download | emacs-94e554db23127711644cf24e4b625c7d197fd075.tar.gz emacs-94e554db23127711644cf24e4b625c7d197fd075.zip | |
(readevalloop): New arg UNIBYTE. Callers changed.
Use it to bind load_convert_to_unibyte.
(Feval_buffer): New arg UNIBYTE. Pass it to readevalloop.
(readevalloop_1): New unwind-protect subroutine.
(load_convert_to_unibyte): New variable.
(syms_of_lread): Set up Lisp var.
(read1): If load_convert_to_unibyte, convert strings to unibyte.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/src/lread.c b/src/lread.c index 3df769115f4..18fc07246ad 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -113,6 +113,9 @@ Lisp_Object read_objects; | |||
| 113 | /* Nonzero means load should forcibly load all dynamic doc strings. */ | 113 | /* Nonzero means load should forcibly load all dynamic doc strings. */ |
| 114 | static int load_force_doc_strings; | 114 | static int load_force_doc_strings; |
| 115 | 115 | ||
| 116 | /* Nonzero means read should convert strings to unibyte. */ | ||
| 117 | static int load_convert_to_unibyte; | ||
| 118 | |||
| 116 | /* Function to use for loading an Emacs lisp source file (not | 119 | /* Function to use for loading an Emacs lisp source file (not |
| 117 | compiled) instead of readevalloop. */ | 120 | compiled) instead of readevalloop. */ |
| 118 | Lisp_Object Vload_source_file_function; | 121 | Lisp_Object Vload_source_file_function; |
| @@ -616,7 +619,7 @@ Return t if file exists.") | |||
| 616 | load_descriptor_list | 619 | load_descriptor_list |
| 617 | = Fcons (make_number (fileno (stream)), load_descriptor_list); | 620 | = Fcons (make_number (fileno (stream)), load_descriptor_list); |
| 618 | load_in_progress++; | 621 | load_in_progress++; |
| 619 | readevalloop (Qget_file_char, stream, file, Feval, 0); | 622 | readevalloop (Qget_file_char, stream, file, Feval, 0, Qnil); |
| 620 | unbind_to (count, Qnil); | 623 | unbind_to (count, Qnil); |
| 621 | 624 | ||
| 622 | /* Run any load-hooks for this file. */ | 625 | /* Run any load-hooks for this file. */ |
| @@ -924,13 +927,25 @@ unreadpure () /* Used as unwind-protect function in readevalloop */ | |||
| 924 | return Qnil; | 927 | return Qnil; |
| 925 | } | 928 | } |
| 926 | 929 | ||
| 930 | static Lisp_Object | ||
| 931 | readevalloop_1 (old) | ||
| 932 | Lisp_Object old; | ||
| 933 | { | ||
| 934 | load_convert_to_unibyte = ! NILP (old); | ||
| 935 | return Qnil; | ||
| 936 | } | ||
| 937 | |||
| 938 | /* UNIBYTE specifies how to set load_convert_to_unibyte | ||
| 939 | for this invocation. */ | ||
| 940 | |||
| 927 | static void | 941 | static void |
| 928 | readevalloop (readcharfun, stream, sourcename, evalfun, printflag) | 942 | readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte) |
| 929 | Lisp_Object readcharfun; | 943 | Lisp_Object readcharfun; |
| 930 | FILE *stream; | 944 | FILE *stream; |
| 931 | Lisp_Object sourcename; | 945 | Lisp_Object sourcename; |
| 932 | Lisp_Object (*evalfun) (); | 946 | Lisp_Object (*evalfun) (); |
| 933 | int printflag; | 947 | int printflag; |
| 948 | int unibyte; | ||
| 934 | { | 949 | { |
| 935 | register int c; | 950 | register int c; |
| 936 | register Lisp_Object val; | 951 | register Lisp_Object val; |
| @@ -945,6 +960,8 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag) | |||
| 945 | 960 | ||
| 946 | specbind (Qstandard_input, readcharfun); | 961 | specbind (Qstandard_input, readcharfun); |
| 947 | specbind (Qcurrent_load_list, Qnil); | 962 | specbind (Qcurrent_load_list, Qnil); |
| 963 | record_unwind_protect (readevalloop_1, load_convert_to_unibyte ? Qt : Qnil); | ||
| 964 | load_convert_to_unibyte = !NILP (unibyte); | ||
| 948 | 965 | ||
| 949 | readchar_backlog = 0; | 966 | readchar_backlog = 0; |
| 950 | 967 | ||
| @@ -1006,7 +1023,7 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag) | |||
| 1006 | 1023 | ||
| 1007 | #ifndef standalone | 1024 | #ifndef standalone |
| 1008 | 1025 | ||
| 1009 | DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 3, "", | 1026 | DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 4, "", |
| 1010 | "Execute the current buffer as Lisp code.\n\ | 1027 | "Execute the current buffer as Lisp code.\n\ |
| 1011 | Programs can pass two arguments, BUFFER and PRINTFLAG.\n\ | 1028 | Programs can pass two arguments, BUFFER and PRINTFLAG.\n\ |
| 1012 | BUFFER is the buffer to evaluate (nil means use current buffer).\n\ | 1029 | BUFFER is the buffer to evaluate (nil means use current buffer).\n\ |
| @@ -1017,8 +1034,8 @@ If the optional third argument FILENAME is non-nil,\n\ | |||
| 1017 | it specifies the file name to use for `load-history'.\n\ | 1034 | it specifies the file name to use for `load-history'.\n\ |
| 1018 | \n\ | 1035 | \n\ |
| 1019 | This function preserves the position of point.") | 1036 | This function preserves the position of point.") |
| 1020 | (buffer, printflag, filename) | 1037 | (buffer, printflag, filename, unibyte) |
| 1021 | Lisp_Object buffer, printflag, filename; | 1038 | Lisp_Object buffer, printflag, filename, unibyte; |
| 1022 | { | 1039 | { |
| 1023 | int count = specpdl_ptr - specpdl; | 1040 | int count = specpdl_ptr - specpdl; |
| 1024 | Lisp_Object tem, buf; | 1041 | Lisp_Object tem, buf; |
| @@ -1041,7 +1058,7 @@ This function preserves the position of point.") | |||
| 1041 | specbind (Qstandard_output, tem); | 1058 | specbind (Qstandard_output, tem); |
| 1042 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 1059 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
| 1043 | BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); | 1060 | BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); |
| 1044 | readevalloop (buf, 0, filename, Feval, !NILP (printflag)); | 1061 | readevalloop (buf, 0, filename, Feval, !NILP (printflag), unibyte); |
| 1045 | unbind_to (count, Qnil); | 1062 | unbind_to (count, Qnil); |
| 1046 | 1063 | ||
| 1047 | return Qnil; | 1064 | return Qnil; |
| @@ -1070,7 +1087,8 @@ point remains at the end of the last character read from the buffer.") | |||
| 1070 | specbind (Qstandard_output, tem); | 1087 | specbind (Qstandard_output, tem); |
| 1071 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 1088 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
| 1072 | SET_PT (BEGV); | 1089 | SET_PT (BEGV); |
| 1073 | readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag)); | 1090 | readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, |
| 1091 | !NILP (printflag), Qnil); | ||
| 1074 | return unbind_to (count, Qnil); | 1092 | return unbind_to (count, Qnil); |
| 1075 | } | 1093 | } |
| 1076 | #endif | 1094 | #endif |
| @@ -1105,7 +1123,8 @@ This function does not move point.") | |||
| 1105 | /* This both uses start and checks its type. */ | 1123 | /* This both uses start and checks its type. */ |
| 1106 | Fgoto_char (start); | 1124 | Fgoto_char (start); |
| 1107 | Fnarrow_to_region (make_number (BEGV), end); | 1125 | Fnarrow_to_region (make_number (BEGV), end); |
| 1108 | readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag)); | 1126 | readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, |
| 1127 | !NILP (printflag), Qnil); | ||
| 1109 | 1128 | ||
| 1110 | return unbind_to (count, Qnil); | 1129 | return unbind_to (count, Qnil); |
| 1111 | } | 1130 | } |
| @@ -1757,6 +1776,8 @@ read1 (readcharfun, pch, first_in_list) | |||
| 1757 | p += length; | 1776 | p += length; |
| 1758 | continue; | 1777 | continue; |
| 1759 | } | 1778 | } |
| 1779 | /* If an escape specifies a non-ASCII single-byte character, | ||
| 1780 | this must be a unibyte string. */ | ||
| 1760 | else if (! ASCII_BYTE_P (c)) | 1781 | else if (! ASCII_BYTE_P (c)) |
| 1761 | force_singlebyte = 1; | 1782 | force_singlebyte = 1; |
| 1762 | } | 1783 | } |
| @@ -1797,9 +1818,19 @@ read1 (readcharfun, pch, first_in_list) | |||
| 1797 | 1818 | ||
| 1798 | if (force_singlebyte) | 1819 | if (force_singlebyte) |
| 1799 | nchars = p - read_buffer; | 1820 | nchars = p - read_buffer; |
| 1800 | else if (! NILP (buffer_defaults.enable_multibyte_characters) | 1821 | else if (force_multibyte) |
| 1801 | || force_multibyte) | ||
| 1802 | nchars = multibyte_chars_in_text (read_buffer, p - read_buffer); | 1822 | nchars = multibyte_chars_in_text (read_buffer, p - read_buffer); |
| 1823 | else if (load_convert_to_unibyte) | ||
| 1824 | { | ||
| 1825 | Lisp_Object string; | ||
| 1826 | nchars = multibyte_chars_in_text (read_buffer, p - read_buffer); | ||
| 1827 | if (p - read_buffer != nchars) | ||
| 1828 | { | ||
| 1829 | string = make_multibyte_string (read_buffer, nchars, | ||
| 1830 | p - read_buffer); | ||
| 1831 | return Fstring_make_unibyte (string); | ||
| 1832 | } | ||
| 1833 | } | ||
| 1803 | else | 1834 | else |
| 1804 | nchars = p - read_buffer; | 1835 | nchars = p - read_buffer; |
| 1805 | 1836 | ||
| @@ -2936,6 +2967,12 @@ See `load' for the meaning of the remaining arguments."); | |||
| 2936 | This is useful when the file being loaded is a temporary copy."); | 2967 | This is useful when the file being loaded is a temporary copy."); |
| 2937 | load_force_doc_strings = 0; | 2968 | load_force_doc_strings = 0; |
| 2938 | 2969 | ||
| 2970 | DEFVAR_BOOL ("load-convert-to-unibyte", &load_convert_to_unibyte, | ||
| 2971 | "Non-nil means `load' converts strings to unibyte whenever possible.\n\ | ||
| 2972 | This is normally used in `load-with-code-conversion'\n\ | ||
| 2973 | for loading non-compiled files."); | ||
| 2974 | load_convert_to_unibyte = 0; | ||
| 2975 | |||
| 2939 | DEFVAR_LISP ("source-directory", &Vsource_directory, | 2976 | DEFVAR_LISP ("source-directory", &Vsource_directory, |
| 2940 | "Directory in which Emacs sources were found when Emacs was built.\n\ | 2977 | "Directory in which Emacs sources were found when Emacs was built.\n\ |
| 2941 | You cannot count on them to still be there!"); | 2978 | You cannot count on them to still be there!"); |