From: tomo Date: Wed, 13 Aug 2003 16:22:36 +0000 (+0000) Subject: Sync with r21-4-12-chise-0_21-pre3-for-libchise-0_1_1-pre1. X-Git-Tag: r21-4-12-chise-0_21-pre3-for-libchise-b1-r0_2_0-pre3~6 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7bd21a1b263d73914e84d6b67bb2ee4a830d154;p=chise%2Fxemacs-chise.git Sync with r21-4-12-chise-0_21-pre3-for-libchise-0_1_1-pre1. --- diff --git a/src/ChangeLog b/src/ChangeLog index 9b505c4..4369da2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,88 @@ +2003-08-11 MORIOKA Tomohiko + + * mule-charset.c (Fsave_charset_mapping_table): Use libchise when + `CHISE' is defined. + +2003-08-10 MORIOKA Tomohiko + + * 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 + + * 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 + + * chartab.c: Don't include 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 when `CHISE' is defined. + (struct Lisp_Char_Table): Add new member `ds' and `feature_table' + when `CHISE' is defined. + +2003-08-09 MORIOKA Tomohiko + + * 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 + + * 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 + + * chartab.c: Include when `CHISE' is defined. + (load_char_attribute_maybe): Use libchise when `CHISE' is defined. + 2003-07-01 MORIOKA Tomohiko * mule-charset.c (charset_code_point): Fix problem when searching diff --git a/src/chartab.c b/src/chartab.c index e5663c1..c5b76d8 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -1272,7 +1272,9 @@ mark_char_table (Lisp_Object obj) mark_object (ct->table); mark_object (ct->name); +#ifndef CHISE mark_object (ct->db); +#endif #else int i; @@ -1602,7 +1604,9 @@ 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) }, +#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 @@ -1804,8 +1808,12 @@ and 'syntax. See `valid-char-table-type-p'. 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) @@ -1879,7 +1887,12 @@ 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; +#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)) { @@ -3315,6 +3328,121 @@ Remove CHARACTER's ATTRIBUTE. } #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) @@ -3432,7 +3560,11 @@ Mount database file on char-attribute-table ATTRIBUTE. 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 @@ -3453,13 +3585,7 @@ Close database of ATTRIBUTE. 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; } @@ -3486,9 +3612,7 @@ Reset values of ATTRIBUTE with database file. } 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; } @@ -3503,36 +3627,43 @@ load_char_attribute_maybe (Lisp_Char_Table* cit, Emchar ch) 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", @@ -3549,6 +3680,7 @@ For internal use. Don't use it. 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. @@ -3560,29 +3692,27 @@ 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; } @@ -4113,9 +4243,11 @@ syms_of_chartab (void) 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); diff --git a/src/chartab.h b/src/chartab.h index 8fa102b..4cdc49c 100644 --- a/src/chartab.h +++ b/src/chartab.h @@ -1,7 +1,7 @@ /* 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. @@ -31,6 +31,10 @@ Boston, MA 02111-1307, USA. */ #ifdef UTF2000 +#ifdef CHISE +#include +#endif + #ifdef HAVE_CHISE_CLIENT #include "database.h" #endif @@ -170,7 +174,12 @@ struct Lisp_Char_Table 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]; diff --git a/src/mule-charset.c b/src/mule-charset.c index 449e4d7..d6d0ede 100644 --- a/src/mule-charset.c +++ b/src/mule-charset.c @@ -2078,15 +2078,59 @@ Save mapping-table of CHARSET. { 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); @@ -2102,9 +2146,15 @@ Save mapping-table of CHARSET. 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; @@ -2123,11 +2173,18 @@ Save mapping-table of CHARSET. 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 + } } } } @@ -2155,12 +2212,22 @@ Save mapping-table of CHARSET. 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 + } } } } @@ -2195,21 +2262,37 @@ Save mapping-table of CHARSET. = 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, /*