changeset 22168:2156ac6d054f

(find_charset_in_str): New arg CMPCHARP. (Ffind_charset_region): Call find_charset_in_str with CMPCHARP 0. (Ffind_charset_string): Likewise.
author Kenichi Handa <handa@m17n.org>
date Thu, 21 May 1998 01:48:52 +0000
parents bb7c53dee594
children 6de2236eab5f
files src/charset.c
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.c	Thu May 21 01:48:52 1998 +0000
+++ b/src/charset.c	Thu May 21 01:48:52 1998 +0000
@@ -630,13 +630,18 @@
 /* Return number of different charsets in STR of length LEN.  In
    addition, for each found charset N, CHARSETS[N] is set 1.  The
    caller should allocate CHARSETS (MAX_CHARSET + 1 elements) in advance.
-   It may lookup a translation table TABLE if supplied.  */
+   It may lookup a translation table TABLE if supplied.
+
+   If CMPCHARP is nonzero and some composite character is found,
+   CHARSETS[128] is also set 1 and the returned number is incremented
+   by 1.  */
 
 int
-find_charset_in_str (str, len, charsets, table)
+find_charset_in_str (str, len, charsets, table, cmpcharp)
      unsigned char *str;
      int len, *charsets;
      Lisp_Object table;
+     int cmpcharp;
 {
   register int num = 0, c;
 
@@ -653,7 +658,7 @@
 	  int cmpchar_id = str_cmpchar_id (str, len);
 	  GLYPH *glyph;
 
-	  if (cmpchar_id > 0)
+	  if (cmpchar_id >= 0)
 	    {
 	      struct cmpchar_info *cmpcharp = cmpchar_table[cmpchar_id];
 	      int i;
@@ -676,6 +681,11 @@
 		}
 	      str += cmpcharp->len;
 	      len -= cmpcharp->len;
+	      if (!charsets[LEADING_CODE_COMPOSITION])
+		{
+		  charsets[LEADING_CODE_COMPOSITION] = 1;
+		  num += 1;
+		}
 	      continue;
 	    }
 
@@ -735,7 +745,7 @@
   while (1)
     {
       find_charset_in_str (BYTE_POS_ADDR (from_byte), stop_byte - from_byte,
-			   charsets, table);
+			   charsets, table, 0);
       if (stop < to)
 	{
 	  from = stop, from_byte = stop_byte;
@@ -770,7 +780,7 @@
 
   bzero (charsets, (MAX_CHARSET + 1) * sizeof (int));
   find_charset_in_str (XSTRING (str)->data, STRING_BYTES (XSTRING (str)),
-		       charsets, table);
+		       charsets, table, 0);
   val = Qnil;
   for (i = MAX_CHARSET; i >= 0; i--)
     if (charsets[i])