+2003-08-11 MORIOKA Tomohiko <tomo@mousai.as.wakwak.ne.jp>
+
+ * mule-charset.c (Fsave_charset_mapping_table): Use libchise when
+ `CHISE' is defined.
+
+2003-08-10 MORIOKA Tomohiko <tomo@mousai.as.wakwak.ne.jp>
+
+ * chartab.c (char_table_open_db_maybe): Defined even if `CHISE' is
+ not defined; add code for non-libchise setting.
+ (char_table_close_db_maybe): Likewise.
+ (char_table_get_db): New function when `HAVE_CHISE_CLIENT' is
+ defined.
+ (Fclose_char_attribute_table): Use `char_table_close_db_maybe'
+ even if `CHISE' is not defined.
+ (Freset_char_attribute_table): Likewise.
+ (load_char_attribute_maybe): Use `char_table_open_db_maybe' and
+ `char_table_close_db_maybe' even if `CHISE' is not defined; use
+ `char_table_get_db'.
+ (Fload_char_attribute_table): Use `char_table_open_db_maybe' and
+ `char_table_close_db_maybe' even if `CHISE' is not defined.
+
+2003-08-10 MORIOKA Tomohiko <tomo@mousai.as.wakwak.ne.jp>
+
+ * chartab.c (char_table_open_db_maybe): New function.
+ (char_table_close_db_maybe): New function.
+ (Fclose_char_attribute_table): Use `char_table_close_db_maybe'.
+ (Freset_char_attribute_table): Likewise.
+ (load_char_attribute_maybe): Use `char_table_open_db_maybe' and
+ `char_table_close_db_maybe'.
+ (Fload_char_attribute_table): Likewise.
+
+2003-08-09 MORIOKA Tomohiko <tomo@mousai.as.wakwak.ne.jp>
+
+ * chartab.c: Don't include <chise.h> because it is included in
+ chartab.h.
+ (Fmake_char_table): Initialize `ct->feature_table' when `CHISE' is
+ defined.
+ (Fcopy_char_table): Copy `ct->ds' and `ct->feature_table' when
+ `CHISE' is defined.
+ (Fmount_char_attribute_table): Initialize `ct->feature_table' when
+ `CHISE' is defined.
+ (Fclose_char_attribute_table): Close `ct->feature_table' and
+ `ct->ds' when `CHISE' is defined.
+ (Freset_char_attribute_table): Likewise.
+ (load_char_attribute_maybe): Use `cit->ds' and
+ `cit->feature_table' when `CHISE' is defined.
+ (Fload_char_attribute_table): Likewise.
+
+ * chartab.h: Include <chise.h> when `CHISE' is defined.
+ (struct Lisp_Char_Table): Add new member `ds' and `feature_table'
+ when `CHISE' is defined.
+
+2003-08-09 MORIOKA Tomohiko <tomo@mousai.as.wakwak.ne.jp>
+
+ * chartab.c (mark_char_table): Member `db' is deleted when `CHISE'
+ is defined.
+ (char_table_description): Likewise.
+ (Fmake_char_table): Likewise.
+ (Fcopy_char_table): Likewise.
+ (Fmount_char_attribute_table): Likewise.
+ (Fclose_char_attribute_table): Likewise.
+ (Freset_char_attribute_table): Likewise.
+ (load_char_attribute_maybe): Likewise.
+ (Fload_char_attribute_table): Likewise.
+
+ * chartab.h (struct Lisp_Char_Table): Delete `db' when `CHISE' is
+ defined.
+
+2003-08-09 MORIOKA Tomohiko <tomo@mousai.as.wakwak.ne.jp>
+
+ * chartab.c (load_char_attribute_table_map_func): New function
+ when CHISE is defined.
+ (Qload_char_attribute_table_map_function): Don't define when CHISE
+ is defined.
+ (Fload_char_attribute_table_map_function): Likewise.
+ (Fload_char_attribute_table): Use libchise when `CHISE' is
+ defined.
+ (syms_of_chartab): Don't define
+ `load-char-attribute-table-map-function' when CHISE is defined.
+
+2003-08-06 MORIOKA Tomohiko <tomo@mousai.as.wakwak.ne.jp>
+
+ * chartab.c: Include <chise.h> when `CHISE' is defined.
+ (load_char_attribute_maybe): Use libchise when `CHISE' is defined.
+
2003-07-01 MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
* mule-charset.c (charset_code_point): Fix problem when searching
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->ds = ct->ds;
+ ctnew->feature_table = ct->feature_table;
+#else
ctnew->db = ct->db;
+#endif
if (UINT8_BYTE_TABLE_P (ct->table))
{
}
#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
+char_table_open_db_maybe (Lisp_Char_Table* cit)
+{
+ Lisp_Object attribute = CHAR_TABLE_NAME (cit);
+
+ if (!NILP (attribute))
+ {
+#ifdef CHISE
+ int modemask;
+ int accessmask = 0;
+ DBTYPE real_subtype;
+ int status;
+
+ if (cit->feature_table == NULL)
+ {
+ Lisp_Object db_dir = Vexec_directory;
+
+ if (NILP (db_dir))
+ db_dir = build_string ("../lib-src");
+ db_dir = Fexpand_file_name (build_string ("char-db"), db_dir);
+
+ status = chise_open_data_source (&cit->ds, CHISE_DS_Berkeley_DB,
+ XSTRING_DATA (db_dir));
+ if (status)
+ {
+ chise_close_data_source (&cit->ds);
+ return -1;
+ }
+
+ modemask = 0755; /* rwxr-xr-x */
+ real_subtype = DB_HASH;
+ accessmask = DB_RDONLY;
+
+ status = chise_open_feature_table (&cit->feature_table, &cit->ds,
+ XSTRING_DATA
+ (Fsymbol_name (attribute)),
+ real_subtype,
+ accessmask, modemask);
+ if (status)
+ {
+ chise_close_feature_table (cit->feature_table);
+ chise_close_data_source (&cit->ds);
+ 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_close_feature_table (cit->feature_table);
+ chise_close_data_source (&cit->ds);
+ 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_ft_get_value (cit->feature_table, ch, &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_Feature_Table *db,
+ CHISE_Char_ID cid,
+ CHISE_Value *valdatum);
+int
+load_char_attribute_table_map_func (CHISE_Feature_Table *db,
+ CHISE_Char_ID cid,
+ CHISE_Value *valdatum)
+{
+ 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 *) valdatum->data,
+ valdatum->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_ft_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;
}
DEFSUBR (Fmount_char_attribute_table);
DEFSUBR (Freset_char_attribute_table);
DEFSUBR (Fclose_char_attribute_table);
+#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);
/* Declarations having to do with Mule char tables.
Copyright (C) 1992 Free Software Foundation, Inc.
Copyright (C) 1995 Sun Microsystems, Inc.
- Copyright (C) 1999,2000,2001,2002 MORIOKA Tomohiko
+ Copyright (C) 1999,2000,2001,2002,2003 MORIOKA Tomohiko
This file is part of XEmacs.
#ifdef UTF2000
+#ifdef CHISE
+#include <chise.h>
+#endif
+
#ifdef HAVE_CHISE_CLIENT
#include "database.h"
#endif
Lisp_Object table;
Lisp_Object default_value;
Lisp_Object name;
+#ifdef CHISE
+ CHISE_DS ds;
+ CHISE_Feature_Table *feature_table;
+#else
Lisp_Object db;
+#endif
unsigned char unloaded;
#else
Lisp_Object ascii[NUM_ASCII_CHARS];
{
struct Lisp_Charset *cs;
int byte_min, byte_max;
+#ifdef CHISE
+ Lisp_Object db_dir = Vexec_directory;
+ CHISE_DS ds;
+ CHISE_Decoding_Table *dt_ccs;
+ int modemask;
+ int accessmask = 0;
+ DBTYPE real_subtype;
+ int status;
+#else
Lisp_Object db;
Lisp_Object db_file;
+#endif
charset = Fget_charset (charset);
cs = XCHARSET (charset);
+#ifdef CHISE
+ if (NILP (db_dir))
+ db_dir = build_string ("../lib-src");
+ db_dir = Fexpand_file_name (build_string ("char-db"), db_dir);
+
+ status = chise_open_data_source (&ds, CHISE_DS_Berkeley_DB,
+ XSTRING_DATA (db_dir));
+ if (status)
+ {
+ chise_close_data_source (&ds);
+ return -1;
+ }
+
+ modemask = 0755; /* rwxr-xr-x */
+ real_subtype = DB_HASH;
+ accessmask = DB_CREATE;
+
+ char_attribute_system_db_file (CHARSET_NAME (cs), Qsystem_char_id, 1);
+ status
+ = chise_open_decoding_table (&dt_ccs, &ds,
+ XSTRING_DATA (Fsymbol_name
+ (XCHARSET_NAME(charset))),
+ real_subtype,
+ accessmask, modemask);
+ if (status)
+ {
+ printf ("Can't open decoding-table %s\n",
+ XSTRING_DATA (Fsymbol_name (XCHARSET_NAME(charset))));
+ chise_close_decoding_table (dt_ccs);
+ chise_close_data_source (&ds);
+ return -1;
+ }
+#else
db_file = char_attribute_system_db_file (CHARSET_NAME (cs),
Qsystem_char_id, 1);
db = Fopen_database (db_file, Qnil, Qnil, build_string ("w+"), Qnil);
+#endif
byte_min = CHARSET_BYTE_OFFSET (cs);
byte_max = byte_min + CHARSET_BYTE_SIZE (cs);
Lisp_Object c = get_ccs_octet_table (table_c, charset, cell);
if (CHARP (c))
- Fput_database (Fprin1_to_string (make_int (cell), Qnil),
- Fprin1_to_string (c, Qnil),
- db, Qt);
+ {
+#ifdef CHISE
+ chise_dt_put_char (dt_ccs, cell, XCHAR (c));
+#else
+ Fput_database (Fprin1_to_string (make_int (cell), Qnil),
+ Fprin1_to_string (c, Qnil),
+ db, Qt);
+#endif
+ }
}
}
break;
Lisp_Object c = get_ccs_octet_table (table_c, charset, cell);
if (CHARP (c))
- Fput_database (Fprin1_to_string (make_int ((row << 8)
- | cell),
- Qnil),
- Fprin1_to_string (c, Qnil),
- db, Qt);
+ {
+#ifdef CHISE
+ chise_dt_put_char (dt_ccs,
+ (row << 8) | cell, XCHAR (c));
+#else
+ Fput_database (Fprin1_to_string (make_int ((row << 8)
+ | cell),
+ Qnil),
+ Fprin1_to_string (c, Qnil),
+ db, Qt);
+#endif
+ }
}
}
}
cell);
if (CHARP (c))
- Fput_database (Fprin1_to_string (make_int ((plane << 16)
- | (row << 8)
- | cell),
- Qnil),
- Fprin1_to_string (c, Qnil),
- db, Qt);
+ {
+#ifdef CHISE
+ chise_dt_put_char (dt_ccs,
+ (plane << 16)
+ | (row << 8)
+ | cell, XCHAR (c));
+#else
+ Fput_database (Fprin1_to_string
+ (make_int ((plane << 16)
+ | (row << 8)
+ | cell),
+ Qnil),
+ Fprin1_to_string (c, Qnil),
+ db, Qt);
+#endif
+ }
}
}
}
= get_ccs_octet_table (table_c, charset, cell);
if (CHARP (c))
- Fput_database (Fprin1_to_string
- (make_int (( group << 24)
- | (plane << 16)
- | (row << 8)
- | cell),
- Qnil),
- Fprin1_to_string (c, Qnil),
- db, Qt);
+ {
+#ifdef CHISE
+ chise_dt_put_char (dt_ccs,
+ ( group << 24)
+ | (plane << 16)
+ | (row << 8)
+ | cell, XCHAR (c));
+#else
+ Fput_database (Fprin1_to_string
+ (make_int (( group << 24)
+ | (plane << 16)
+ | (row << 8)
+ | cell),
+ Qnil),
+ Fprin1_to_string (c, Qnil),
+ db, Qt);
+#endif
+ }
}
}
}
}
}
}
+#ifdef CHISE
+ chise_close_decoding_table (dt_ccs);
+ chise_close_data_source (&ds);
+ return Qnil;
+#else
return Fclose_database (db);
+#endif
}
DEFUN ("reset-charset-mapping-table", Freset_charset_mapping_table, 1, 1, 0, /*