]> git.eshelyaron.com Git - emacs.git/commitdiff
(copy_text): In multibyte to unibyte conversion, take
authorKenichi Handa <handa@m17n.org>
Sun, 2 Aug 1998 01:06:57 +0000 (01:06 +0000)
committerKenichi Handa <handa@m17n.org>
Sun, 2 Aug 1998 01:06:57 +0000 (01:06 +0000)
nonascii-translation-table and nonascii-insert-offset into
account.

src/insdel.c

index 481f6bf267aff231b500e16647d0ff4d12c7f018..80e9d7862f82d4d1acde5ff6c35a5abb5c0cab61 100644 (file)
@@ -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++;