aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2000-05-20 00:03:42 +0000
committerKenichi Handa2000-05-20 00:03:42 +0000
commitf0354c0337445b98281ebad9b38f96c7f01d554b (patch)
treea64e9915ee2313f82255a6d7bf12128e448456c6 /src
parent54e03a4ac40be5c30a03feef21e69b825b44ca2f (diff)
downloademacs-f0354c0337445b98281ebad9b38f96c7f01d554b.tar.gz
emacs-f0354c0337445b98281ebad9b38f96c7f01d554b.zip
(read1): On reading multibyte string, be sure to make
all 8-bit chararacters in valid multibyte form. (readchar): Use FETCH_STRING_CHAR_ADVANCE unconditionally.
Diffstat (limited to 'src')
-rw-r--r--src/lread.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/lread.c b/src/lread.c
index 67f6c956fe1..3f5b62b662e 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -296,12 +296,10 @@ readchar (readcharfun)
296 { 296 {
297 if (read_from_string_index >= read_from_string_limit) 297 if (read_from_string_index >= read_from_string_limit)
298 c = -1; 298 c = -1;
299 else if (STRING_MULTIBYTE (readcharfun)) 299 else
300 FETCH_STRING_CHAR_ADVANCE (c, readcharfun, 300 FETCH_STRING_CHAR_ADVANCE (c, readcharfun,
301 read_from_string_index, 301 read_from_string_index,
302 read_from_string_index_byte); 302 read_from_string_index_byte);
303 else
304 c = XSTRING (readcharfun)->data[read_from_string_index++];
305 303
306 return c; 304 return c;
307 } 305 }
@@ -2124,13 +2122,15 @@ read1 (readcharfun, pch, first_in_list)
2124 return make_number (0); 2122 return make_number (0);
2125 2123
2126 if (force_multibyte) 2124 if (force_multibyte)
2127 nchars = multibyte_chars_in_text (read_buffer, p - read_buffer); 2125 p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
2126 p - read_buffer, &nchars);
2128 else if (force_singlebyte) 2127 else if (force_singlebyte)
2129 nchars = p - read_buffer; 2128 nchars = p - read_buffer;
2130 else if (load_convert_to_unibyte) 2129 else if (load_convert_to_unibyte)
2131 { 2130 {
2132 Lisp_Object string; 2131 Lisp_Object string;
2133 nchars = multibyte_chars_in_text (read_buffer, p - read_buffer); 2132 p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
2133 p - read_buffer, &nchars);
2134 if (p - read_buffer != nchars) 2134 if (p - read_buffer != nchars)
2135 { 2135 {
2136 string = make_multibyte_string (read_buffer, nchars, 2136 string = make_multibyte_string (read_buffer, nchars,
@@ -2140,12 +2140,13 @@ read1 (readcharfun, pch, first_in_list)
2140 } 2140 }
2141 else if (EQ (readcharfun, Qget_file_char) 2141 else if (EQ (readcharfun, Qget_file_char)
2142 || EQ (readcharfun, Qlambda)) 2142 || EQ (readcharfun, Qlambda))
2143 /* Nowadays, reading directly from a file 2143 /* Nowadays, reading directly from a file is used only for
2144 is used only for compiled Emacs Lisp files, 2144 compiled Emacs Lisp files, and those always use the
2145 and those always use the Emacs internal encoding. 2145 Emacs internal encoding. Meanwhile, Qlambda is used
2146 Meanwhile, Qlambda is used for reading dynamic byte code 2146 for reading dynamic byte code (compiled with
2147 (compiled with byte-compile-dynamic = t). */ 2147 byte-compile-dynamic = t). */
2148 nchars = multibyte_chars_in_text (read_buffer, p - read_buffer); 2148 p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
2149 p - read_buffer, &nchars);
2149 else 2150 else
2150 /* In all other cases, if we read these bytes as 2151 /* In all other cases, if we read these bytes as
2151 separate characters, treat them as separate characters now. */ 2152 separate characters, treat them as separate characters now. */