diff options
| author | Kenichi Handa | 1998-08-02 01:06:57 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-08-02 01:06:57 +0000 |
| commit | f44cbcd8dc94cb1ea05e2f5c7a096d69906c6a1c (patch) | |
| tree | 24eaf3f88c41f4c86b5440115a19391d68231528 /src | |
| parent | a35fd731c7414e99794125fb239b2365300269f5 (diff) | |
| download | emacs-f44cbcd8dc94cb1ea05e2f5c7a096d69906c6a1c.tar.gz emacs-f44cbcd8dc94cb1ea05e2f5c7a096d69906c6a1c.zip | |
(copy_text): In multibyte to unibyte conversion, take
nonascii-translation-table and nonascii-insert-offset into
account.
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/insdel.c b/src/insdel.c index 481f6bf267a..80e9d7862f8 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -699,13 +699,37 @@ copy_text (from_addr, to_addr, nbytes, | |||
| 699 | { | 699 | { |
| 700 | int nchars = 0; | 700 | int nchars = 0; |
| 701 | int bytes_left = nbytes; | 701 | int bytes_left = nbytes; |
| 702 | Lisp_Object tbl = Qnil, temp; | ||
| 703 | |||
| 704 | /* We set the variable tbl to the reverse table of | ||
| 705 | Vnonascii_translation_table in advance. */ | ||
| 706 | if (CHAR_TABLE_P (Vnonascii_translation_table)) | ||
| 707 | { | ||
| 708 | tbl = Fchar_table_extra_slot (Vnonascii_translation_table, | ||
| 709 | make_number (0)); | ||
| 710 | if (!CHAR_TABLE_P (tbl)) | ||
| 711 | tbl = Qnil; | ||
| 712 | } | ||
| 702 | 713 | ||
| 703 | /* Convert multibyte to single byte. */ | 714 | /* Convert multibyte to single byte. */ |
| 704 | while (bytes_left > 0) | 715 | while (bytes_left > 0) |
| 705 | { | 716 | { |
| 706 | int thislen, c; | 717 | int thislen, c, c_save; |
| 707 | c = STRING_CHAR_AND_LENGTH (from_addr, bytes_left, thislen); | 718 | c = c_save = STRING_CHAR_AND_LENGTH (from_addr, bytes_left, thislen); |
| 708 | *to_addr++ = SINGLE_BYTE_CHAR_P (c) ? c : (c & 0177) + 0200; | 719 | if (!SINGLE_BYTE_CHAR_P (c)) |
| 720 | { | ||
| 721 | if (!NILP (tbl)) | ||
| 722 | { | ||
| 723 | temp = Faref (tbl, make_number (c)); | ||
| 724 | if (INTEGERP (temp)) | ||
| 725 | c = XINT (temp); | ||
| 726 | } | ||
| 727 | else if (nonascii_insert_offset > 0) | ||
| 728 | c -= nonascii_insert_offset; | ||
| 729 | if (c < 128 || c >= 256) | ||
| 730 | c = (c_save & 0177) + 0200; | ||
| 731 | } | ||
| 732 | *to_addr++ = c; | ||
| 709 | from_addr += thislen; | 733 | from_addr += thislen; |
| 710 | bytes_left -= thislen; | 734 | bytes_left -= thislen; |
| 711 | nchars++; | 735 | nchars++; |