(insert-ideograph-radical-char-data): Ignore non-Unicode UCS
[chise/xemacs-chise.git] / src / chartab.c
index b140c48..2d2db5a 100644 (file)
@@ -64,6 +64,11 @@ Lisp_Object Vword_combining_categories, Vword_separating_categories;
 \f
 #ifdef UTF2000
 
+#if defined(HAVE_DATABASE)
+EXFUN (Fload_char_attribute_table, 1);
+EXFUN (Fmap_char_attribute, 3);
+#endif
+
 #define BT_UINT8_MIN           0
 #define BT_UINT8_MAX           (UCHAR_MAX - 4)
 #define BT_UINT8_t             (UCHAR_MAX - 3)
@@ -335,7 +340,6 @@ save_uint8_byte_table (Lisp_Uint8_Byte_Table *ct, Lisp_Char_Table* root,
                             Fprin1_to_string (UINT8_DECODE (ct->property[i]),
                                               Qnil),
                             db, Qt);
-             put_char_id_table (root, make_char (c), Qunloaded);
            }
        }
       else
@@ -647,7 +651,6 @@ save_uint16_byte_table (Lisp_Uint16_Byte_Table *ct, Lisp_Char_Table* root,
                             Fprin1_to_string (UINT16_DECODE (ct->property[i]),
                                               Qnil),
                             db, Qt);
-             put_char_id_table (root, make_char (c), Qunloaded);
            }
        }
       else
@@ -927,7 +930,6 @@ save_byte_table (Lisp_Byte_Table *ct, Lisp_Char_Table* root,
              Fput_database (Fprin1_to_string (make_char (c), Qnil),
                             Fprin1_to_string (v, Qnil),
                             db, Qt);
-             put_char_id_table (root, make_char (c), Qunloaded);
            }
        }
       else
@@ -1270,7 +1272,6 @@ mark_char_table (Lisp_Object obj)
 
   mark_object (ct->table);
   mark_object (ct->name);
-  mark_object (ct->db_file);
   mark_object (ct->db);
 #else
   int i;
@@ -1601,7 +1602,6 @@ static const struct lrecord_description char_table_description[] = {
   { XD_LISP_OBJECT, offsetof(Lisp_Char_Table, table) },
   { XD_LISP_OBJECT, offsetof(Lisp_Char_Table, default_value) },
   { XD_LISP_OBJECT, offsetof(Lisp_Char_Table, name) },
-  { XD_LISP_OBJECT, offsetof(Lisp_Char_Table, db_file) },
   { XD_LISP_OBJECT, offsetof(Lisp_Char_Table, db) },
 #else
   { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Char_Table, ascii), NUM_ASCII_CHARS },
@@ -1804,7 +1804,6 @@ and 'syntax.  See `valid-char-table-type-p'.
     ct->mirror_table = Qnil;
 #else
   ct->name = Qnil;
-  ct->db_file = Qnil;
   ct->db = Qnil;
 #endif
   ct->next_table = Qnil;
@@ -1880,7 +1879,6 @@ as CHAR-TABLE.  The values will not themselves be copied.
   ctnew->default_value = ct->default_value;
   /* [tomo:2002-01-21] Perhaps this code seems wrong */
   ctnew->name = ct->name;
-  ctnew->db_file = ct->db_file;
   ctnew->db = ct->db;
 
   if (UINT8_BYTE_TABLE_P (ct->table))
@@ -2729,10 +2727,6 @@ map_char_table_for_charset_fun (struct chartab_range *range,
   return 0;
 }
 
-#if defined(HAVE_DATABASE)
-EXFUN (Fload_char_attribute_table, 1);
-#endif
-
 #endif
 
 /* Map FN (with client data ARG) over range RANGE in char table CT.
@@ -3375,27 +3369,25 @@ Save values of ATTRIBUTE into database file.
   Lisp_Object table = Fgethash (attribute,
                                Vchar_attribute_hash_table, Qunbound);
   Lisp_Char_Table *ct;
+  Lisp_Object db_file;
+  Lisp_Object db;
 
   if (CHAR_TABLEP (table))
     ct = XCHAR_TABLE (table);
   else
     return Qnil;
 
-  if (NILP (ct->db_file))
-    ct->db_file
-      = char_attribute_system_db_file (Qsystem_char_id, attribute, 1);
-  if (NILP (Fdatabase_live_p (ct->db)))
-    ct->db = Fopen_database (ct->db_file, Qnil, Qnil, Qnil, Qnil);
-  if (!NILP (ct->db))
+  db_file = char_attribute_system_db_file (Qsystem_char_id, attribute, 1);
+  db = Fopen_database (db_file, Qnil, Qnil, build_string ("w+"), Qnil);
+  if (!NILP (db))
     {
       if (UINT8_BYTE_TABLE_P (ct->table))
-       save_uint8_byte_table (XUINT8_BYTE_TABLE(ct->table), ct, ct->db, 0, 3);
+       save_uint8_byte_table (XUINT8_BYTE_TABLE(ct->table), ct, db, 0, 3);
       else if (UINT16_BYTE_TABLE_P (ct->table))
-       save_uint16_byte_table (XUINT16_BYTE_TABLE(ct->table), ct, ct->db, 0, 3);
+       save_uint16_byte_table (XUINT16_BYTE_TABLE(ct->table), ct, db, 0, 3);
       else if (BYTE_TABLE_P (ct->table))
-       save_byte_table (XBYTE_TABLE(ct->table), ct, ct->db, 0, 3);
-      Fclose_database (ct->db);
-      ct->db = Qnil;
+       save_byte_table (XBYTE_TABLE(ct->table), ct, db, 0, 3);
+      Fclose_database (db);
       return Qt;
     }
   else
@@ -3405,6 +3397,32 @@ Save values of ATTRIBUTE into database file.
 #endif
 }
 
+DEFUN ("mount-char-attribute-table", Fmount_char_attribute_table, 1, 1, 0, /*
+Mount database file on char-attribute-table ATTRIBUTE.
+*/
+       (attribute))
+{
+#ifdef HAVE_DATABASE
+  Lisp_Object table = Fgethash (attribute,
+                               Vchar_attribute_hash_table, Qunbound);
+
+  if (UNBOUNDP (table))
+    {
+      Lisp_Char_Table *ct;
+
+      table = make_char_id_table (Qunbound);
+      Fputhash (attribute, table, Vchar_attribute_hash_table);
+      XCHAR_TABLE_NAME(table) = attribute;
+      ct = XCHAR_TABLE (table);
+      ct->table = Qunloaded;
+      XCHAR_TABLE_UNLOADED(table) = 1;
+      ct->db = Qnil;
+      return Qt;
+    }
+#endif
+  return Qnil;
+}
+
 DEFUN ("close-char-attribute-table", Fclose_char_attribute_table, 1, 1, 0, /*
 Close database of ATTRIBUTE.
 */
@@ -3420,14 +3438,11 @@ Close database of ATTRIBUTE.
   else
     return Qnil;
 
-  if (!NILP (Fdatabase_live_p (ct->db)))
-    {
-      Fclose_database (ct->db);
-    }
   if (!NILP (ct->db))
     {
+      if (!NILP (Fdatabase_live_p (ct->db)))
+       Fclose_database (ct->db);
       ct->db = Qnil;
-      ct->db_file = Qnil;
     }
 #endif
   return Qnil;
@@ -3455,7 +3470,6 @@ Reset values of ATTRIBUTE with database file.
        }
       ct = XCHAR_TABLE (table);
       ct->table = Qunloaded;
-      ct->db_file = db_file;
       if (!NILP (Fdatabase_live_p (ct->db)))
        Fclose_database (ct->db);
       ct->db = Qnil;
@@ -3474,11 +3488,13 @@ load_char_attribute_maybe (Lisp_Char_Table* cit, Emchar ch)
 
   if (!NILP (attribute))
     {
-      if (NILP (cit->db_file))
-       cit->db_file
-         = char_attribute_system_db_file (Qsystem_char_id, attribute, 0);
       if (NILP (Fdatabase_live_p (cit->db)))
-       cit->db = Fopen_database (cit->db_file, Qnil, Qnil, Qnil, Qnil);
+       {
+         Lisp_Object db_file
+           = char_attribute_system_db_file (Qsystem_char_id, attribute, 0);
+
+         cit->db = Fopen_database (db_file, Qnil, Qnil, build_string ("r"), Qnil);
+       }
       if (!NILP (cit->db))
        {
          Lisp_Object val
@@ -3527,11 +3543,13 @@ Load values of ATTRIBUTE into database file.
     {
       Lisp_Char_Table *ct = XCHAR_TABLE (table);
 
-      if (NILP (ct->db_file))
-       ct->db_file
-         = char_attribute_system_db_file (Qsystem_char_id, attribute, 0);
       if (NILP (Fdatabase_live_p (ct->db)))
-       ct->db = Fopen_database (ct->db_file, Qnil, Qnil, Qnil, Qnil);
+       {
+         Lisp_Object db_file
+             = char_attribute_system_db_file (Qsystem_char_id, attribute, 0);
+
+         ct->db = Fopen_database (db_file, Qnil, Qnil, build_string ("r"), Qnil);
+       }
       if (!NILP (ct->db))
        {
          struct gcpro gcpro1;
@@ -4072,6 +4090,7 @@ syms_of_chartab (void)
   defsymbol (&Qput_char_table_map_function, "put-char-table-map-function");
   DEFSUBR (Fput_char_table_map_function);
   DEFSUBR (Fsave_char_attribute_table);
+  DEFSUBR (Fmount_char_attribute_table);
   DEFSUBR (Freset_char_attribute_table);
   DEFSUBR (Fclose_char_attribute_table);
 #ifdef HAVE_DATABASE