From f0d9dd92533b37aa4ba1cbb094435a7be911e22c Mon Sep 17 00:00:00 2001 From: tomo Date: Wed, 30 Jan 2002 18:45:35 +0000 Subject: [PATCH] (fill_char_table): Initialize `ct->unloaded'. (Fput_char_attribute): Set XCHAR_TABLE_UNLOADED(table) if HAVE_DATABASE is defined. (char_attribute_table_to_load): New variable of UTF-2000 with external database support. (Qload_char_attribute_table_map_function): Likewise. (Fload_char_attribute_table_map_function): New function of UTF-2000 with external database support. (Fload_char_attribute_table): New function of UTF-2000. (Fmap_char_attribute): Call Fload_char_attribute_table if CHAR_TABLE_UNLOADED(ct) is set when HAVE_DATABASE is defined. (syms_of_chartab): Add new symbol and function `load-char-attribute-table-map-function' in UTF-2000 with external database support; add new function `load-char-attribute-table' in UTF-2000. --- src/chartab.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/chartab.c b/src/chartab.c index 1bce902..fcac6e3 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -1572,6 +1572,7 @@ fill_char_table (Lisp_Char_Table *ct, Lisp_Object value) #ifdef UTF2000 ct->table = Qunbound; ct->default_value = value; + ct->unloaded = 0; #else int i; @@ -3092,6 +3093,7 @@ Store CHARACTER's ATTRIBUTE with VALUE. db, Qt); /* put_char_id_table (XCHAR_TABLE(table), character, value); */ put_char_id_table (XCHAR_TABLE(table), character, Qunloaded); + XCHAR_TABLE_UNLOADED(table) = 1; Fclose_database (db); } else @@ -3164,7 +3166,67 @@ load_char_attribute_maybe (Emchar ch, Lisp_Object attribute) else return Qunbound; } + +Lisp_Char_Table* char_attribute_table_to_load; + +Lisp_Object Qload_char_attribute_table_map_function; + +DEFUN ("load-char-attribute-table-map-function", + Fload_char_attribute_table_map_function, 2, 2, 0, /* +For internal use. Don't use it. +*/ + (key, value)) +{ + Lisp_Object c = Fread (key); + Emchar code = XCHAR (c); + Lisp_Object ret = get_char_id_table (char_attribute_table_to_load, code); + + if (EQ (ret, Qunloaded)) + 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. +*/ + (attribute)) +{ +#ifdef HAVE_DATABASE + Lisp_Object db; + Lisp_Object db_dir = Vdata_directory; + Lisp_Object db_file; + + if (NILP (db_dir)) + db_dir = build_string ("../etc"); + db_dir = Fexpand_file_name (build_string ("system-char-id"), db_dir); + db_file = Fexpand_file_name (Fsymbol_name (attribute), db_dir); + db = Fopen_database (db_file, Qnil, Qnil, Qnil, Qnil); + if (!NILP (db)) + { + Lisp_Object table = Fgethash (attribute, + Vchar_attribute_hash_table, + Qunbound); + struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; + + if (CHAR_TABLEP (table)) + char_attribute_table_to_load = XCHAR_TABLE (table); + else + { + Fclose_database (db); + return Qnil; + } + GCPRO4 (db, db_dir, db_file, table); + Fmap_database (Qload_char_attribute_table_map_function, db); + UNGCPRO; + Fclose_database (db); + XCHAR_TABLE_UNLOADED(table) = 0; + return Qt; + } + else + return Qnil; #endif +} DEFUN ("map-char-attribute", Fmap_char_attribute, 2, 3, 0, /* Map FUNCTION over entries in ATTRIBUTE, calling it with two args, @@ -3204,6 +3266,10 @@ the entire table. if (NILP (range)) range = Qt; decode_char_table_range (range, &rainj); +#ifdef HAVE_DATABASE + if (CHAR_TABLE_UNLOADED(ct)) + Fload_char_attribute_table (attribute); +#endif slarg.function = function; slarg.retval = Qnil; GCPRO2 (slarg.function, slarg.retval); @@ -3678,6 +3744,12 @@ syms_of_chartab (void) DEFSUBR (Fchar_attribute_list); DEFSUBR (Ffind_char_attribute_table); +#ifdef HAVE_DATABASE + 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); DEFSUBR (Fchar_attribute_alist); DEFSUBR (Fget_char_attribute); DEFSUBR (Fput_char_attribute); -- 1.7.10.4