changeset 23628:4a0a107fac9e

(string_to_non_ascii_char): Change the check for the varidity of multibyte form. (update_charset_table): Check validity of BYTES. Don't set bytes_by_char_head here. (init_charset_once): Set bytes_by_char_head completely.
author Kenichi Handa <handa@m17n.org>
date Wed, 04 Nov 1998 10:48:53 +0000
parents 3905e071bd2d
children ab6b58c72a04
files src/charset.c
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.c	Wed Nov 04 10:44:32 1998 +0000
+++ b/src/charset.c	Wed Nov 04 10:48:53 1998 +0000
@@ -219,7 +219,7 @@
 	  str++;
 	  if (c >= LEADING_CODE_PRIVATE_11)
 	    charset = *str++;
-	  if (char_bytes <= bytes && CHARSET_DEFINED_P (charset))
+	  if (CHARSET_DEFINED_P (charset) && char_bytes <= bytes)
 	    {
 	      c1 = *str++ & 0x7f;
 	      if (CHARSET_DIMENSION (charset) == 2)
@@ -447,6 +447,9 @@
       leading_code_ext = charset;
     } 
 
+  if (BYTES_BY_CHAR_HEAD (leading_code_base) != bytes)
+    error ("Invalid dimension for the charset-ID %d", charset);
+
   CHARSET_TABLE_INFO (charset, CHARSET_ID_IDX) = charset_id;
   CHARSET_TABLE_INFO (charset, CHARSET_BYTES_IDX) = make_number (bytes);
   CHARSET_TABLE_INFO (charset, CHARSET_DIMENSION_IDX) = dimension;
@@ -496,8 +499,6 @@
   if (charset != CHARSET_ASCII
       && charset < MIN_CHARSET_PRIVATE_DIMENSION1)
     {
-      /* Update tables bytes_by_char_head and width_by_char_head.  */
-      bytes_by_char_head[leading_code_base] = bytes;
       width_by_char_head[leading_code_base] = XINT (width);
 
       /* Update table emacs_code_class.  */
@@ -1808,15 +1809,23 @@
   bzero (cmpchar_hash_table, sizeof cmpchar_hash_table);
   cmpchar_table_size = n_cmpchars = 0;
 
-  for (i = 0; i < 256; i++)
+  for (i = 0; i < 128; i++)
     BYTES_BY_CHAR_HEAD (i) = 1;
+  for (i = MIN_CHARSET_OFFICIAL_DIMENSION1;
+       i <= MAX_CHARSET_OFFICIAL_DIMENSION1; i++)
+    BYTES_BY_CHAR_HEAD (i) = 2;
+  for (i = MIN_CHARSET_OFFICIAL_DIMENSION2;
+       i <= MAX_CHARSET_OFFICIAL_DIMENSION2; i++)
+    BYTES_BY_CHAR_HEAD (i) = 3;
   BYTES_BY_CHAR_HEAD (LEADING_CODE_PRIVATE_11) = 3;
   BYTES_BY_CHAR_HEAD (LEADING_CODE_PRIVATE_12) = 3;
   BYTES_BY_CHAR_HEAD (LEADING_CODE_PRIVATE_21) = 4;
   BYTES_BY_CHAR_HEAD (LEADING_CODE_PRIVATE_22) = 4;
-  /* The following doesn't reflect the actual bytes, but just to tell
+  /* The followings don't reflect the actual bytes, but just to tell
      that it is a start of a multibyte character.  */
   BYTES_BY_CHAR_HEAD (LEADING_CODE_COMPOSITION) = 2;
+  BYTES_BY_CHAR_HEAD (0x9E) = 2;
+  BYTES_BY_CHAR_HEAD (0x9F) = 2;
 
   for (i = 0; i < 128; i++)
     WIDTH_BY_CHAR_HEAD (i) = 1;