(Fmake_charset): Delete unused local variable `code_offset'.
[chise/xemacs-chise.git] / src / mule-charset.c
index 52c1291..4f1a053 100644 (file)
@@ -147,12 +147,16 @@ char_byte_table_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
 
   for (i = 0; i < 256; i++)
     if (CHAR_BYTE_TABLE_P (cte1->property[i]))
-      if (CHAR_BYTE_TABLE_P (cte2->property[i]))
-       if (!char_byte_table_equal (cte1->property[i],
+      {
+       if (CHAR_BYTE_TABLE_P (cte2->property[i]))
+         {
+           if (!char_byte_table_equal (cte1->property[i],
                                        cte2->property[i], depth + 1))
+             return 0;
+         }
+       else
          return 0;
-      else
-       return 0;
+      }
     else
       if (!internal_equal (cte1->property[i], cte2->property[i], depth + 1))
        return 0;
@@ -304,6 +308,49 @@ put_char_code_table (Emchar ch, Lisp_Object value, Lisp_Object table)
 }
 
 
+Lisp_Object Vcharacter_attribute_table;
+
+DEFUN ("char-attribute-alist", Fchar_attribute_alist, 1, 1, 0, /*
+Return the alist of attributes of CHARACTER.
+*/
+       (character))
+{
+  return get_char_code_table (XCHAR (character), Vcharacter_attribute_table);
+}
+
+DEFUN ("get-char-attribute", Fget_char_attribute, 2, 2, 0, /*
+Return the value of CHARACTER's ATTRIBUTE.
+*/
+       (character, attribute))
+{
+  Lisp_Object ret
+    = get_char_code_table (XCHAR (character), Vcharacter_attribute_table);
+
+  if (EQ (ret, Qnil))
+    return Qnil;
+  
+  return Fcdr (Fassq (attribute, ret));
+}
+
+DEFUN ("put-char-attribute", Fput_char_attribute, 3, 3, 0, /*
+Store CHARACTER's ATTRIBUTE with VALUE.
+*/
+       (character, attribute, value))
+{
+  Emchar char_code = XCHAR (character);
+  Lisp_Object ret
+    = get_char_code_table (char_code, Vcharacter_attribute_table);
+  Lisp_Object cell = Fassq (attribute, ret);
+
+  if (EQ (cell, Qnil))
+    ret = Fcons (Fcons (attribute, value), ret);
+  else
+    Fsetcdr (cell, value);
+  put_char_code_table (char_code, ret, Vcharacter_attribute_table);
+  return ret;
+}
+
+
 Lisp_Object Vutf_2000_version;
 #endif
 
@@ -359,8 +406,12 @@ Lisp_Object Ql2r, Qr2l;
 
 Lisp_Object Vcharset_hash_table;
 
+#ifdef UTF2000
+static Charset_ID next_allocated_leading_byte;
+#else
 static Charset_ID next_allocated_1_byte_leading_byte;
 static Charset_ID next_allocated_2_byte_leading_byte;
+#endif
 
 /* Composite characters are characters constructed by overstriking two
    or more regular characters.
@@ -899,6 +950,12 @@ get_unallocated_leading_byte (int dimension)
 {
   Charset_ID lb;
 
+#ifdef UTF2000
+  if (next_allocated_leading_byte > MAX_LEADING_BYTE_PRIVATE)
+    lb = 0;
+  else
+    lb = next_allocated_leading_byte++;
+#else
   if (dimension == 1)
     {
       if (next_allocated_1_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_1)
@@ -913,6 +970,7 @@ get_unallocated_leading_byte (int dimension)
       else
        lb = next_allocated_2_byte_leading_byte++;
     }
+#endif
 
   if (!lb)
     signal_simple_error
@@ -1322,50 +1380,7 @@ character set.  Recognized properties are:
     error
       ("Character set already defined for this DIMENSION/CHARS/FINAL combo");
 
-#ifdef UTF2000
-  if (dimension == 1)
-    {
-      if (chars == 94)
-       {
-         /* id = CHARSET_ID_OFFSET_94 + final; */
-         id = get_unallocated_leading_byte (dimension);
-       }
-      else if (chars == 96)
-       {
-         id = get_unallocated_leading_byte (dimension);
-       }
-      else
-       {
-         abort ();
-       }
-    }
-  else if (dimension == 2)
-    {
-      if (chars == 94)
-       {
-         id = get_unallocated_leading_byte (dimension);
-       }
-      else if (chars == 96)
-       {
-         id = get_unallocated_leading_byte (dimension);
-       }
-      else
-       {
-         abort ();
-       }
-    }
-  else
-    {
-      abort ();
-    }
-  if (final)
-    if (chars == 94)
-      byte_offset = 33;
-    else if (chars == 96)
-      byte_offset = 32;
-#else
   id = get_unallocated_leading_byte (dimension);
-#endif
 
   if (NILP (doc_string))
     doc_string = build_string ("");
@@ -1699,9 +1714,14 @@ Set mapping-table of CHARSET to TABLE.
          Lisp_Object c = XVECTOR_DATA(table)[i];
 
          if (CHARP (c))
-           put_char_code_table (XCHAR (c),
-                                make_int (i + CHARSET_BYTE_OFFSET (cs)),
-                                CHARSET_ENCODING_TABLE(cs));
+           {
+             put_char_code_table (XCHAR (c),
+                                  make_int (i + CHARSET_BYTE_OFFSET (cs)),
+                                  CHARSET_ENCODING_TABLE(cs));
+             Fput_char_attribute (c, charset,
+                                  list1
+                                  (make_int (i + CHARSET_BYTE_OFFSET (cs))));
+           }
        }
       break;
     case 2:
@@ -1724,17 +1744,30 @@ Set mapping-table of CHARSET to TABLE.
                  Lisp_Object c = XVECTOR_DATA(v)[j];
 
                  if (CHARP (c))
-                   put_char_code_table
-                     (XCHAR (c),
-                      make_int (( (i + CHARSET_BYTE_OFFSET (cs)) << 8)
-                                | (j + CHARSET_BYTE_OFFSET (cs))),
-                      CHARSET_ENCODING_TABLE(cs));
+                   {
+                     put_char_code_table
+                       (XCHAR (c),
+                        make_int (( (i + CHARSET_BYTE_OFFSET (cs)) << 8)
+                                  | (j + CHARSET_BYTE_OFFSET (cs))),
+                        CHARSET_ENCODING_TABLE(cs));
+                     Fput_char_attribute (c, charset,
+                                          list2
+                                          (make_int
+                                           (i + CHARSET_BYTE_OFFSET (cs)),
+                                           make_int
+                                           (j + CHARSET_BYTE_OFFSET (cs))));
+                   }
                }
            }
          else if (CHARP (v))
-           put_char_code_table (XCHAR (v),
-                                make_int (i + CHARSET_BYTE_OFFSET (cs)),
-                                CHARSET_ENCODING_TABLE(cs));
+           {
+             put_char_code_table (XCHAR (v),
+                                  make_int (i + CHARSET_BYTE_OFFSET (cs)),
+                                  CHARSET_ENCODING_TABLE(cs));
+             Fput_char_attribute (v, charset,
+                                  list1
+                                  (make_int (i + CHARSET_BYTE_OFFSET (cs))));
+           }
        }
       break;
     }
@@ -1947,6 +1980,9 @@ syms_of_mule_charset (void)
   DEFSUBR (Fset_charset_ccl_program);
   DEFSUBR (Fset_charset_registry);
 #ifdef UTF2000
+  DEFSUBR (Fchar_attribute_alist);
+  DEFSUBR (Fget_char_attribute);
+  DEFSUBR (Fput_char_attribute);
   DEFSUBR (Fcharset_mapping_table);
   DEFSUBR (Fset_charset_mapping_table);
 #endif
@@ -2036,10 +2072,10 @@ vars_of_mule_charset (void)
        charset_by_attributes[i][j][k] = Qnil;
 #endif
 
-  next_allocated_1_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_1;
 #ifdef UTF2000
-  next_allocated_2_byte_leading_byte = LEADING_BYTE_CHINESE_BIG5_2 + 1;
+  next_allocated_leading_byte = MIN_LEADING_BYTE_PRIVATE;
 #else
+  next_allocated_1_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_1;
   next_allocated_2_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_2;
 #endif
 
@@ -2052,15 +2088,18 @@ Leading-code of private TYPE9N charset of column-width 1.
 #endif
 
 #ifdef UTF2000
-  Vutf_2000_version = build_string("0.8 (Kami)");
+  Vutf_2000_version = build_string("0.10 (Yao)");
   DEFVAR_LISP ("utf-2000-version", &Vutf_2000_version /*
 Version number of UTF-2000.
 */ );
 
+  staticpro (&Vcharacter_attribute_table);
+  Vcharacter_attribute_table = make_char_code_table (Qnil);
+
   Vdefault_coded_charset_priority_list = Qnil;
   DEFVAR_LISP ("default-coded-charset-priority-list",
               &Vdefault_coded_charset_priority_list /*
-Default order of preferred coded-character-set.
+Default order of preferred coded-character-sets.
 */ );
 #endif
 }
@@ -2082,8 +2121,8 @@ complex_vars_of_mule_charset (void)
                  CHARSET_LEFT_TO_RIGHT,
                  build_string ("BMP"),
                  build_string ("BMP"),
-                 build_string ("BMP"),
-                 build_string ("\\(ISO10646.*-1\\|UNICODE[23]?\\)"),
+                 build_string ("ISO/IEC 10646 Group 0 Plane 0 (BMP)"),
+                 build_string ("\\(ISO10646.*-1\\|UNICODE[23]?-0\\)"),
                  Qnil, 0, 0xFFFF, 0, 0);
 #else
 # define MIN_CHAR_THAI 0