diff options
author | Kenichi Handa <handa@m17n.org> | 1998-08-02 01:06:57 +0000 |
---|---|---|
committer | Kenichi Handa <handa@m17n.org> | 1998-08-02 01:06:57 +0000 |
commit | 98e06438a52ab3153fd7d3af071f2b9ffd57f439 (patch) | |
tree | a45b1feb0f10079fb75875f966b71a72a778284e /src | |
parent | 5667a9e954da0f7f8c134172aa164e0b68cec9b9 (diff) | |
download | emacs-98e06438a52ab3153fd7d3af071f2b9ffd57f439.tar.gz |
(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, { int nchars = 0; int bytes_left = nbytes; + Lisp_Object tbl = Qnil, temp; + + /* We set the variable tbl to the reverse table of + Vnonascii_translation_table in advance. */ + if (CHAR_TABLE_P (Vnonascii_translation_table)) + { + tbl = Fchar_table_extra_slot (Vnonascii_translation_table, + make_number (0)); + if (!CHAR_TABLE_P (tbl)) + tbl = Qnil; + } /* Convert multibyte to single byte. */ while (bytes_left > 0) { - int thislen, c; - c = STRING_CHAR_AND_LENGTH (from_addr, bytes_left, thislen); - *to_addr++ = SINGLE_BYTE_CHAR_P (c) ? c : (c & 0177) + 0200; + int thislen, c, c_save; + c = c_save = STRING_CHAR_AND_LENGTH (from_addr, bytes_left, thislen); + if (!SINGLE_BYTE_CHAR_P (c)) + { + if (!NILP (tbl)) + { + temp = Faref (tbl, make_number (c)); + if (INTEGERP (temp)) + c = XINT (temp); + } + else if (nonascii_insert_offset > 0) + c -= nonascii_insert_offset; + if (c < 128 || c >= 256) + c = (c_save & 0177) + 0200; + } + *to_addr++ = c; from_addr += thislen; bytes_left -= thislen; nchars++; |