Mercurial > emacs
comparison src/print.c @ 88384:4bff91d684f4
* print.c: Include "character.h" instead of "charset.h".
(print_string): Convert 8-bit raw bytes to octal form by
string_escape_byte8.
(print_object): Adjusted for the new multibyte form. Print 8-bit
raw bytes always in octal form. Handle sub char table correctly.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 01 Mar 2002 01:45:03 +0000 |
parents | 4c2f1d0b1397 |
children | c88e9fa13453 |
comparison
equal
deleted
inserted
replaced
88383:0b4249d736a0 | 88384:4bff91d684f4 |
---|---|
22 | 22 |
23 #include <config.h> | 23 #include <config.h> |
24 #include <stdio.h> | 24 #include <stdio.h> |
25 #include "lisp.h" | 25 #include "lisp.h" |
26 #include "buffer.h" | 26 #include "buffer.h" |
27 #include "charset.h" | 27 #include "character.h" |
28 #include "keyboard.h" | 28 #include "keyboard.h" |
29 #include "frame.h" | 29 #include "frame.h" |
30 #include "window.h" | 30 #include "window.h" |
31 #include "process.h" | 31 #include "process.h" |
32 #include "dispextern.h" | 32 #include "dispextern.h" |
458 { | 458 { |
459 if (EQ (printcharfun, Qt) || NILP (printcharfun)) | 459 if (EQ (printcharfun, Qt) || NILP (printcharfun)) |
460 { | 460 { |
461 int chars; | 461 int chars; |
462 | 462 |
463 if (print_escape_nonascii) | |
464 string = string_escape_byte8 (string); | |
465 | |
463 if (STRING_MULTIBYTE (string)) | 466 if (STRING_MULTIBYTE (string)) |
464 chars = XSTRING (string)->size; | 467 chars = XSTRING (string)->size; |
465 else if (EQ (printcharfun, Qt) | 468 else if (! print_escape_nonascii |
466 ? ! NILP (buffer_defaults.enable_multibyte_characters) | 469 && (EQ (printcharfun, Qt) |
467 : ! NILP (current_buffer->enable_multibyte_characters)) | 470 ? ! NILP (buffer_defaults.enable_multibyte_characters) |
471 : ! NILP (current_buffer->enable_multibyte_characters))) | |
468 { | 472 { |
469 /* If unibyte string STRING contains 8-bit codes, we must | 473 /* If unibyte string STRING contains 8-bit codes, we must |
470 convert STRING to a multibyte string containing the same | 474 convert STRING to a multibyte string containing the same |
471 character codes. */ | 475 character codes. */ |
472 Lisp_Object newstr; | 476 Lisp_Object newstr; |
1407 | 1411 |
1408 if (multibyte) | 1412 if (multibyte) |
1409 { | 1413 { |
1410 c = STRING_CHAR_AND_LENGTH (str + i_byte, | 1414 c = STRING_CHAR_AND_LENGTH (str + i_byte, |
1411 size_byte - i_byte, len); | 1415 size_byte - i_byte, len); |
1412 if (CHAR_VALID_P (c, 0)) | 1416 i_byte += len; |
1413 i_byte += len; | |
1414 else | |
1415 c = str[i_byte++]; | |
1416 } | 1417 } |
1417 else | 1418 else |
1418 c = str[i_byte++]; | 1419 c = str[i_byte++]; |
1419 | 1420 |
1420 QUIT; | 1421 QUIT; |
1428 { | 1429 { |
1429 PRINTCHAR ('\\'); | 1430 PRINTCHAR ('\\'); |
1430 PRINTCHAR ('f'); | 1431 PRINTCHAR ('f'); |
1431 } | 1432 } |
1432 else if (multibyte && ! ASCII_BYTE_P (c) | 1433 else if (multibyte && ! ASCII_BYTE_P (c) |
1433 && print_escape_multibyte) | 1434 && (print_escape_multibyte || CHAR_BYTE8_P (c))) |
1434 { | 1435 { |
1435 /* When multibyte is disabled, | 1436 /* When multibyte is disabled, |
1436 print multibyte string chars using hex escapes. */ | 1437 print multibyte string chars using hex escapes. */ |
1437 unsigned char outbuf[50]; | 1438 unsigned char outbuf[50]; |
1438 sprintf (outbuf, "\\x%x", c); | 1439 |
1440 if (CHAR_BYTE8_P (c)) | |
1441 sprintf (outbuf, "\\%03o", CHAR_TO_BYTE8 (c)); | |
1442 else | |
1443 sprintf (outbuf, "\\x%04x", c); | |
1439 strout (outbuf, -1, -1, printcharfun, 0); | 1444 strout (outbuf, -1, -1, printcharfun, 0); |
1440 need_nonhex = 1; | 1445 need_nonhex = 1; |
1441 } | 1446 } |
1442 else if (! multibyte | 1447 else if (! multibyte |
1443 && SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c) | 1448 && SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c) |
1785 if (COMPILEDP (obj)) | 1790 if (COMPILEDP (obj)) |
1786 { | 1791 { |
1787 PRINTCHAR ('#'); | 1792 PRINTCHAR ('#'); |
1788 size &= PSEUDOVECTOR_SIZE_MASK; | 1793 size &= PSEUDOVECTOR_SIZE_MASK; |
1789 } | 1794 } |
1790 if (CHAR_TABLE_P (obj)) | 1795 if (CHAR_TABLE_P (obj) || SUB_CHAR_TABLE_P (obj)) |
1791 { | 1796 { |
1792 /* We print a char-table as if it were a vector, | 1797 /* We print a char-table as if it were a vector, |
1793 lumping the parent and default slots in with the | 1798 lumping the parent and default slots in with the |
1794 character slots. But we add #^ as a prefix. */ | 1799 character slots. But we add #^ as a prefix. */ |
1795 PRINTCHAR ('#'); | 1800 PRINTCHAR ('#'); |