From: Kenichi Handa Date: Sun, 2 Aug 1998 01:06:57 +0000 (+0000) Subject: (copy_text): In multibyte to unibyte conversion, take X-Git-Tag: emacs-20.3~203 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f44cbcd8dc94cb1ea05e2f5c7a096d69906c6a1c;p=emacs.git (copy_text): In multibyte to unibyte conversion, take nonascii-translation-table and nonascii-insert-offset into account. --- 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++;