X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fchartab.c;h=618ed11caf9b50ee7807488f4f7ea97b38c9c833;hb=87c4768b9f74b6d48fb56908f29fb1dccadb11ea;hp=b140c48e46ed66e6140b387a8266d1d456cc45a4;hpb=9448e479e8f1311d71f9a556b02ad437cef91257;p=chise%2Fxemacs-chise.git- diff --git a/src/chartab.c b/src/chartab.c index b140c48..618ed11 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -64,6 +64,11 @@ Lisp_Object Vword_combining_categories, Vword_separating_categories; #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) @@ -1270,7 +1275,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 +1605,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 +1807,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 +1882,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 +2730,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 +3372,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 @@ -3420,14 +3415,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 +3447,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 +3465,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 +3520,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;