aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2007-11-14 04:52:07 +0000
committerKenichi Handa2007-11-14 04:52:07 +0000
commit1202434be82eb7b0e6b1830f5b0180f5cfd08ca9 (patch)
tree03c0ca28c0594361cf4371bcd0b08f7f07810e64 /src
parent81b5db1ddb11dc9817f63e08f0f34368765c793c (diff)
downloademacs-1202434be82eb7b0e6b1830f5b0180f5cfd08ca9.tar.gz
emacs-1202434be82eb7b0e6b1830f5b0180f5cfd08ca9.zip
(READCHAR): Call readchar with the 2nd arg NULL.
(READCHAR_REPORT_MULTIBYTE): New macro. (readchar): New 2nd arg MULTIBYTE. (read1): Use READCHAR_REPORT_MULTIBYTE for the first read. Make symbol's name multibyte according to the multibyteness of the source.
Diffstat (limited to 'src')
-rw-r--r--src/lread.c54
1 files changed, 43 insertions, 11 deletions
diff --git a/src/lread.c b/src/lread.c
index a75e615acda..9f201a504ff 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -250,9 +250,12 @@ static int readbyte_from_string P_ ((int, Lisp_Object));
250 250
251 These macros correctly read/unread multibyte characters. */ 251 These macros correctly read/unread multibyte characters. */
252 252
253#define READCHAR readchar (readcharfun) 253#define READCHAR readchar (readcharfun, NULL)
254#define UNREAD(c) unreadchar (readcharfun, c) 254#define UNREAD(c) unreadchar (readcharfun, c)
255 255
256/* Same as READCHAR but set *MULTIBYTE to the multibyteness of the source. */
257#define READCHAR_REPORT_MULTIBYTE(multibyte) readchar (readcharfun, multibyte)
258
256/* When READCHARFUN is Qget_file_char, Qget_emacs_mule_file_char, 259/* When READCHARFUN is Qget_file_char, Qget_emacs_mule_file_char,
257 Qlambda, or a cons, we use this to keep an unread character because 260 Qlambda, or a cons, we use this to keep an unread character because
258 a file stream can't handle multibyte-char unreading. The value -1 261 a file stream can't handle multibyte-char unreading. The value -1
@@ -260,8 +263,9 @@ static int readbyte_from_string P_ ((int, Lisp_Object));
260static int unread_char; 263static int unread_char;
261 264
262static int 265static int
263readchar (readcharfun) 266readchar (readcharfun, multibyte)
264 Lisp_Object readcharfun; 267 Lisp_Object readcharfun;
268 int *multibyte;
265{ 269{
266 Lisp_Object tem; 270 Lisp_Object tem;
267 register int c; 271 register int c;
@@ -270,6 +274,9 @@ readchar (readcharfun)
270 int i, len; 274 int i, len;
271 int emacs_mule_encoding = 0; 275 int emacs_mule_encoding = 0;
272 276
277 if (multibyte)
278 *multibyte = 0;
279
273 readchar_count++; 280 readchar_count++;
274 281
275 if (BUFFERP (readcharfun)) 282 if (BUFFERP (readcharfun))
@@ -287,6 +294,8 @@ readchar (readcharfun)
287 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, pt_byte); 294 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, pt_byte);
288 BUF_INC_POS (inbuffer, pt_byte); 295 BUF_INC_POS (inbuffer, pt_byte);
289 c = STRING_CHAR (p, pt_byte - orig_pt_byte); 296 c = STRING_CHAR (p, pt_byte - orig_pt_byte);
297 if (multibyte)
298 *multibyte = 1;
290 } 299 }
291 else 300 else
292 { 301 {
@@ -314,6 +323,8 @@ readchar (readcharfun)
314 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, bytepos); 323 unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, bytepos);
315 BUF_INC_POS (inbuffer, bytepos); 324 BUF_INC_POS (inbuffer, bytepos);
316 c = STRING_CHAR (p, bytepos - orig_bytepos); 325 c = STRING_CHAR (p, bytepos - orig_bytepos);
326 if (multibyte)
327 *multibyte = 1;
317 } 328 }
318 else 329 else
319 { 330 {
@@ -345,11 +356,20 @@ readchar (readcharfun)
345 { 356 {
346 if (read_from_string_index >= read_from_string_limit) 357 if (read_from_string_index >= read_from_string_limit)
347 c = -1; 358 c = -1;
359 else if (STRING_MULTIBYTE (readcharfun))
360 {
361 if (multibyte)
362 *multibyte = 1;
363 FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, readcharfun,
364 read_from_string_index,
365 read_from_string_index_byte);
366 }
348 else 367 else
349 FETCH_STRING_CHAR_ADVANCE (c, readcharfun, 368 {
350 read_from_string_index, 369 c = SREF (readcharfun, read_from_string_index_byte);
351 read_from_string_index_byte); 370 read_from_string_index++;
352 371 read_from_string_index_byte++;
372 }
353 return c; 373 return c;
354 } 374 }
355 375
@@ -387,7 +407,11 @@ readchar (readcharfun)
387 return c; 407 return c;
388 } 408 }
389 c = (*readbyte) (-1, readcharfun); 409 c = (*readbyte) (-1, readcharfun);
390 if (c < 0 || ASCII_BYTE_P (c) || load_each_byte) 410 if (c < 0 || load_each_byte)
411 return c;
412 if (multibyte)
413 *multibyte = 1;
414 if (ASCII_BYTE_P (c))
391 return c; 415 return c;
392 if (emacs_mule_encoding) 416 if (emacs_mule_encoding)
393 return read_emacs_mule_char (c, readbyte, readcharfun); 417 return read_emacs_mule_char (c, readbyte, readcharfun);
@@ -2288,13 +2312,14 @@ read1 (readcharfun, pch, first_in_list)
2288{ 2312{
2289 register int c; 2313 register int c;
2290 int uninterned_symbol = 0; 2314 int uninterned_symbol = 0;
2315 int multibyte;
2291 2316
2292 *pch = 0; 2317 *pch = 0;
2293 load_each_byte = 0; 2318 load_each_byte = 0;
2294 2319
2295 retry: 2320 retry:
2296 2321
2297 c = READCHAR; 2322 c = READCHAR_REPORT_MULTIBYTE (&multibyte);
2298 if (c < 0) 2323 if (c < 0)
2299 end_of_file_error (); 2324 end_of_file_error ();
2300 2325
@@ -2868,7 +2893,10 @@ read1 (readcharfun, pch, first_in_list)
2868 quoted = 1; 2893 quoted = 1;
2869 } 2894 }
2870 2895
2871 p += CHAR_STRING (c, p); 2896 if (multibyte)
2897 p += CHAR_STRING (c, p);
2898 else
2899 *p++ = c;
2872 c = READCHAR; 2900 c = READCHAR;
2873 } 2901 }
2874 2902
@@ -2964,8 +2992,12 @@ read1 (readcharfun, pch, first_in_list)
2964 } 2992 }
2965 } 2993 }
2966 { 2994 {
2967 Lisp_Object result = uninterned_symbol ? make_symbol (read_buffer) 2995 Lisp_Object name = make_specified_string (read_buffer, -1,
2968 : intern (read_buffer); 2996 p - read_buffer,
2997 multibyte);
2998 Lisp_Object result = (uninterned_symbol ? Fmake_symbol (name)
2999 : Fintern (name, Qnil));
3000
2969 if (EQ (Vread_with_symbol_positions, Qt) 3001 if (EQ (Vread_with_symbol_positions, Qt)
2970 || EQ (Vread_with_symbol_positions, readcharfun)) 3002 || EQ (Vread_with_symbol_positions, readcharfun))
2971 Vread_symbol_positions_list = 3003 Vread_symbol_positions_list =