]> git.eshelyaron.com Git - emacs.git/commitdiff
(find_charset_in_str): Handle the case that STR
authorKenichi Handa <handa@m17n.org>
Sat, 8 Nov 1997 03:05:44 +0000 (03:05 +0000)
committerKenichi Handa <handa@m17n.org>
Sat, 8 Nov 1997 03:05:44 +0000 (03:05 +0000)
contains invalid multibyte-form.

src/charset.c

index 56dc15e78dacbd77c2ad4a82195013374e352f51..3241d9b7194057f49880da4bff8e6e0ed858c8b1 100644 (file)
@@ -545,9 +545,7 @@ find_charset_in_str (str, len, charsets, table)
      int len, *charsets;
      Lisp_Object table;
 {
-  int num = 0;
-  int cmpcharp = 0;
-  unsigned char str_work[4], *str_tmp;
+  register int num = 0, c;
 
   if (! CHAR_TABLE_P (table))
     table = Qnil;
@@ -555,46 +553,52 @@ find_charset_in_str (str, len, charsets, table)
   while (len > 0)
     {
       int bytes, charset;
+      c = *str;
       
-      if (*str == LEADING_CODE_COMPOSITION)
+      if (c == LEADING_CODE_COMPOSITION)
        {
-         str++;
-         len--;
-         cmpcharp = 1;
-       }
-      else if (CHAR_HEAD_P (str))
-       cmpcharp = 0;
+         int cmpchar_id = str_cmpchar_id (str, len);
+         GLYPH *glyph;
 
-      if (cmpcharp)
-       {
-         if (*str == 0xA0)
-           {
-             str++;
-             len--;
-             str_work[0] = *str & 0x7F;
-           }
-         else
+         if (cmpchar_id > 0)
            {
-             bcopy (str, str_work, min (4, len));
-             str_work[0] -= 0x20;
+             struct cmpchar_info *cmpcharp = cmpchar_table[cmpchar_id];
+             int i;
+
+             for (i = 0; i < cmpcharp->glyph_len; i++)
+               {
+                 c = cmpcharp->glyph[i];
+                 if (!NILP (table))
+                   {
+                     if ((c = unify_char (table, c, 0, 0, 0)) < 0)
+                       c = cmpcharp->glyph[i];
+                   }
+                 if ((charset = CHAR_CHARSET (c)) < 0)
+                   charset = CHARSET_ASCII;
+                 if (!charsets[charset])
+                   {
+                     charsets[charset] = 1;
+                     num += 1;
+                   }
+               }
+             str += cmpcharp->len;
+             len -= cmpcharp->len;
+             continue;
            }
-         str_tmp = str_work;
-       }
-      else
-       str_tmp = str;
-         
-      bytes = BYTES_BY_CHAR_HEAD (*str_tmp);
 
-      if (NILP (table))
-       charset = CHARSET_AT (str_tmp);
+         charset = CHARSET_ASCII;
+         bytes = 1;
+       }
       else
        {
-         int c;
-         unsigned char c1, c2;
-
-         SPLIT_STRING(str_tmp, bytes, charset, c1, c2);
-         if ((c = unify_char (table, -1, charset, c1, c2)) >= 0)
-           charset = CHAR_CHARSET (c);
+         c = STRING_CHAR_AND_LENGTH (str, len, bytes);
+         if (! NILP (table))
+           {
+             int c1 = unify_char (table, c, 0, 0, 0);
+             if (c1 >= 0)
+               c = c1;
+           }
+         charset = CHAR_CHARSET (c);
        }
 
       if (!charsets[charset])