#endif /* MULE */
\f
+#ifdef CHISE
+CHISE_DS *default_chise_data_source = NULL;
+#endif
+
#ifdef UTF2000
EXFUN (Fchar_refs_simplify_char_specs, 1);
mark_object (ct->table);
mark_object (ct->name);
+#ifndef CHISE
mark_object (ct->db);
+#endif
#else
int i;
{ 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) },
+#ifndef CHISE
{ XD_LISP_OBJECT, offsetof(Lisp_Char_Table, db) },
+#endif
#else
{ XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Char_Table, ascii), NUM_ASCII_CHARS },
#ifdef MULE
ct->mirror_table = Qnil;
#else
ct->name = Qnil;
+#ifdef CHISE
+ ct->feature_table = NULL;
+#else
ct->db = Qnil;
#endif
+#endif
ct->next_table = Qnil;
XSETCHAR_TABLE (obj, ct);
if (ty == CHAR_TABLE_TYPE_SYNTAX)
ctnew->default_value = ct->default_value;
/* [tomo:2002-01-21] Perhaps this code seems wrong */
ctnew->name = ct->name;
+#ifdef CHISE
+ ctnew->feature_table = ct->feature_table;
+#else
ctnew->db = ct->db;
+#endif
if (UINT8_BYTE_TABLE_P (ct->table))
{
*/
(c, value))
{
- put_char_id_table_0 (char_attribute_table_to_put, c, value_to_put);
+ put_char_id_table_0 (char_attribute_table_to_put,
+ XCHAR (c), value_to_put);
return Qnil;
}
#endif
*/
if ( CHAR_TABLEP (encoding_table) )
{
+ Lisp_Object mother = XCHARSET_MOTHER (range->charset);
+
char_attribute_table_to_put = ct;
value_to_put = val;
Fmap_char_attribute (Qput_char_table_map_function,
XCHAR_TABLE_NAME (encoding_table),
Qnil);
+ if ( CHARSETP (mother) )
+ {
+ struct chartab_range r;
+
+ r.type = CHARTAB_RANGE_CHARSET;
+ r.charset = mother;
+ put_char_table (ct, &r, val);
+ }
}
#if 0
else
}
#ifdef HAVE_CHISE_CLIENT
+
+int char_table_open_db_maybe (Lisp_Char_Table* cit);
+void char_table_close_db_maybe (Lisp_Char_Table* cit);
+Lisp_Object char_table_get_db (Lisp_Char_Table* cit, Emchar ch);
+
+int
+open_chise_data_source_maybe ()
+{
+ if (default_chise_data_source == NULL)
+ {
+ Lisp_Object db_dir = Vexec_directory;
+ int modemask = 0755; /* rwxr-xr-x */
+
+ if (NILP (db_dir))
+ db_dir = build_string ("../lib-src");
+ db_dir = Fexpand_file_name (build_string ("char-db"), db_dir);
+
+ default_chise_data_source
+ = chise_open_data_source (CHISE_DS_Berkeley_DB,
+ XSTRING_DATA (db_dir),
+ DB_HASH, modemask);
+ if (default_chise_data_source == NULL)
+ return -1;
+ }
+ return 0;
+}
+
+DEFUN ("close-char-data-source", Fclose_char_data_source, 0, 0, 0, /*
+Close data-source of CHISE.
+*/
+ ())
+{
+#ifdef CHISE
+ int status = chise_ds_close (default_chise_data_source);
+
+ default_chise_data_source = NULL;
+ if (status)
+ return Qt;
+#endif
+ return Qnil;
+}
+
+int
+char_table_open_db_maybe (Lisp_Char_Table* cit)
+{
+ Lisp_Object attribute = CHAR_TABLE_NAME (cit);
+
+ if (!NILP (attribute))
+ {
+#ifdef CHISE
+ if (cit->feature_table == NULL)
+ {
+ if ( open_chise_data_source_maybe () )
+ return -1;
+
+ cit->feature_table
+ = chise_ds_get_feature (default_chise_data_source,
+ XSTRING_DATA (Fsymbol_name (attribute)));
+ if (cit->feature_table == NULL)
+ return -1;
+ }
+#else
+ if (NILP (Fdatabase_live_p (cit->db)))
+ {
+ 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))
+ return -1;
+ }
+#endif
+ return 0;
+ }
+ else
+ return -1;
+}
+
+void
+char_table_close_db_maybe (Lisp_Char_Table* cit)
+{
+#ifdef CHISE
+ if (cit->feature_table != NULL)
+ {
+ /* chise_ft_close (cit->feature_table); */
+ cit->feature_table = NULL;
+ }
+#else
+ if (!NILP (cit->db))
+ {
+ if (!NILP (Fdatabase_live_p (cit->db)))
+ Fclose_database (cit->db);
+ cit->db = Qnil;
+ }
+#endif
+}
+
+Lisp_Object
+char_table_get_db (Lisp_Char_Table* cit, Emchar ch)
+{
+ Lisp_Object val;
+#ifdef CHISE
+ CHISE_Value value;
+ int status
+ = chise_char_load_feature_value (ch, cit->feature_table, &value);
+
+ if (!status)
+ {
+ val = Fread (make_string (chise_value_data (&value),
+ chise_value_size (&value) ));
+ }
+ else
+ val = Qunbound;
+#else
+ val = Fget_database (Fprin1_to_string (make_char (ch), Qnil),
+ cit->db, Qunbound);
+ if (!UNBOUNDP (val))
+ val = Fread (val);
+ else
+ val = Qunbound;
+#endif
+ return val;
+}
+
Lisp_Object
char_attribute_system_db_file (Lisp_Object key_type, Lisp_Object attribute,
int writing_mode)
ct = XCHAR_TABLE (table);
ct->table = Qunloaded;
XCHAR_TABLE_UNLOADED(table) = 1;
+#ifdef CHISE
+ ct->feature_table = NULL;
+#else
ct->db = Qnil;
+#endif
return Qt;
}
#endif
ct = XCHAR_TABLE (table);
else
return Qnil;
-
- if (!NILP (ct->db))
- {
- if (!NILP (Fdatabase_live_p (ct->db)))
- Fclose_database (ct->db);
- ct->db = Qnil;
- }
+ char_table_close_db_maybe (ct);
#endif
return Qnil;
}
}
ct = XCHAR_TABLE (table);
ct->table = Qunloaded;
- if (!NILP (Fdatabase_live_p (ct->db)))
- Fclose_database (ct->db);
- ct->db = Qnil;
+ char_table_close_db_maybe (ct);
XCHAR_TABLE_UNLOADED(table) = 1;
return Qt;
}
if (!NILP (attribute))
{
- if (NILP (Fdatabase_live_p (cit->db)))
- {
- Lisp_Object db_file
- = char_attribute_system_db_file (Qsystem_char_id, attribute, 0);
+ Lisp_Object val;
- cit->db = Fopen_database (db_file, Qnil, Qnil,
- build_string ("r"), Qnil);
- }
- if (!NILP (cit->db))
- {
- Lisp_Object val
- = Fget_database (Fprin1_to_string (make_char (ch), Qnil),
- cit->db, Qunbound);
- if (!UNBOUNDP (val))
- val = Fread (val);
- else
- val = Qunbound;
- if (!NILP (Vchar_db_stingy_mode))
- {
- Fclose_database (cit->db);
- cit->db = Qnil;
- }
- return val;
- }
+ if (char_table_open_db_maybe (cit))
+ return Qunbound;
+
+ val = char_table_get_db (cit, ch);
+
+ if (!NILP (Vchar_db_stingy_mode))
+ char_table_close_db_maybe (cit);
+
+ return val;
}
return Qunbound;
}
Lisp_Char_Table* char_attribute_table_to_load;
+#ifdef CHISE
+int
+load_char_attribute_table_map_func (CHISE_Char_ID cid,
+ CHISE_Feature feature,
+ CHISE_Value *value);
+int
+load_char_attribute_table_map_func (CHISE_Char_ID cid,
+ CHISE_Feature feature,
+ CHISE_Value *value)
+{
+ Emchar code = cid;
+ Lisp_Object ret = get_char_id_table_0 (char_attribute_table_to_load, code);
+
+ if (EQ (ret, Qunloaded))
+ put_char_id_table_0 (char_attribute_table_to_load, code,
+ Fread (make_string ((Bufbyte *) value->data,
+ value->size)));
+ return 0;
+}
+#else
Lisp_Object Qload_char_attribute_table_map_function;
DEFUN ("load-char-attribute-table-map-function",
put_char_id_table_0 (char_attribute_table_to_load, code, Fread (value));
return Qnil;
}
+#endif
DEFUN ("load-char-attribute-table", Fload_char_attribute_table, 1, 1, 0, /*
Load values of ATTRIBUTE into database file.
Qunbound);
if (CHAR_TABLEP (table))
{
- Lisp_Char_Table *ct = XCHAR_TABLE (table);
+ Lisp_Char_Table *cit = XCHAR_TABLE (table);
- if (NILP (Fdatabase_live_p (ct->db)))
- {
- Lisp_Object db_file
- = char_attribute_system_db_file (Qsystem_char_id, attribute, 0);
+ if (char_table_open_db_maybe (cit))
+ return Qnil;
- ct->db = Fopen_database (db_file, Qnil, Qnil,
- build_string ("r"), Qnil);
- }
- if (!NILP (ct->db))
- {
- struct gcpro gcpro1;
-
- char_attribute_table_to_load = XCHAR_TABLE (table);
- GCPRO1 (table);
- Fmap_database (Qload_char_attribute_table_map_function, ct->db);
- UNGCPRO;
- Fclose_database (ct->db);
- ct->db = Qnil;
- XCHAR_TABLE_UNLOADED(table) = 0;
- return Qt;
- }
+ char_attribute_table_to_load = XCHAR_TABLE (table);
+ {
+ struct gcpro gcpro1;
+
+ GCPRO1 (table);
+#ifdef CHISE
+ chise_char_feature_value_iterate
+ (cit->feature_table,
+ &load_char_attribute_table_map_func);
+#else
+ Fmap_database (Qload_char_attribute_table_map_function, cit->db);
+#endif
+ UNGCPRO;
+ }
+ char_table_close_db_maybe (cit);
+ XCHAR_TABLE_UNLOADED(table) = 0;
+ return Qt;
}
return Qnil;
}
c2 = cmpchar_component (c2, 0, 1);
#endif
+#ifndef UTF2000
if (EQ (CHAR_CHARSET (c1), CHAR_CHARSET (c2)))
+#endif
{
tail = Vword_separating_categories;
default_result = 0;
}
+#ifndef UTF2000
else
{
tail = Vword_combining_categories;
default_result = 1;
}
+#endif
category_set1 = CATEGORY_SET (c1);
if (NILP (category_set1))
DEFSUBR (Fmount_char_attribute_table);
DEFSUBR (Freset_char_attribute_table);
DEFSUBR (Fclose_char_attribute_table);
+ DEFSUBR (Fclose_char_data_source);
+#ifndef CHISE
defsymbol (&Qload_char_attribute_table_map_function,
"load-char-attribute-table-map-function");
DEFSUBR (Fload_char_attribute_table_map_function);
+#endif
DEFSUBR (Fload_char_attribute_table);
#endif
DEFSUBR (Fchar_attribute_alist);