X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/fabc1281e9cde34ff9a19d843316d2ceca8647ad..8131fcfd622dd2b7fccf09b0f6a1c3f4747619a7:/src/chartab.c diff --git a/src/chartab.c b/src/chartab.c index 711a49ed39..b7b9590a53 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ #include -#include + #include "lisp.h" #include "character.h" #include "charset.h" @@ -84,6 +84,22 @@ static uniprop_decoder_t uniprop_get_decoder (Lisp_Object); (STRINGP (OBJ) && SCHARS (OBJ) > 0 \ && ((SREF (OBJ, 0) == 1 || (SREF (OBJ, 0) == 2)))) +static void +CHECK_CHAR_TABLE (Lisp_Object x) +{ + CHECK_TYPE (CHAR_TABLE_P (x), Qchar_table_p, x); +} + +static void +set_char_table_ascii (Lisp_Object table, Lisp_Object val) +{ + XCHAR_TABLE (table)->ascii = val; +} +static void +set_char_table_parent (Lisp_Object table, Lisp_Object val) +{ + XCHAR_TABLE (table)->parent = val; +} DEFUN ("make-char-table", Fmake_char_table, Smake_char_table, 1, 2, 0, doc: /* Return a newly created char-table, with purpose PURPOSE. @@ -112,7 +128,7 @@ the char-table has no extra slot. */) n_extras = XINT (n); } - size = VECSIZE (struct Lisp_Char_Table) - 1 + n_extras; + size = CHAR_TABLE_STANDARD_SLOTS + n_extras; vector = Fmake_vector (make_number (size), init); XSETPVECTYPE (XVECTOR (vector), PVEC_CHAR_TABLE); set_char_table_parent (vector, Qnil); @@ -125,7 +141,7 @@ static Lisp_Object make_sub_char_table (int depth, int min_char, Lisp_Object defalt) { Lisp_Object table; - int size = VECSIZE (struct Lisp_Sub_Char_Table) - 1 + chartab_size[depth]; + int size = CHAR_TABLE_STANDARD_SLOTS + chartab_size[depth]; table = Fmake_vector (make_number (size), defalt); XSETPVECTYPE (XVECTOR (table), PVEC_SUB_CHAR_TABLE); @@ -191,7 +207,7 @@ copy_char_table (Lisp_Object table) ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i]) : XCHAR_TABLE (table)->contents[i])); set_char_table_ascii (copy, char_table_ascii (copy)); - size -= VECSIZE (struct Lisp_Char_Table) - 1; + size -= CHAR_TABLE_STANDARD_SLOTS; for (i = 0; i < size; i++) set_char_table_extras (copy, i, XCHAR_TABLE (table)->extras[i]); @@ -200,7 +216,7 @@ copy_char_table (Lisp_Object table) } static Lisp_Object -sub_char_table_ref (Lisp_Object table, int c, int is_uniprop) +sub_char_table_ref (Lisp_Object table, int c, bool is_uniprop) { struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); int depth = XINT (tbl->depth); @@ -245,7 +261,7 @@ char_table_ref (Lisp_Object table, int c) static Lisp_Object sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, - Lisp_Object defalt, int is_uniprop) + Lisp_Object defalt, bool is_uniprop) { struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); int depth = XINT (tbl->depth); @@ -320,7 +336,7 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to) struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); int chartab_idx = CHARTAB_IDX (c, 0, 0), idx; Lisp_Object val; - int is_uniprop = UNIPROP_TABLE_P (table); + bool is_uniprop = UNIPROP_TABLE_P (table); val = tbl->contents[chartab_idx]; if (*from < 0) @@ -382,7 +398,7 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to) static void -sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, int is_uniprop) +sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, bool is_uniprop) { struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); int depth = XINT ((tbl)->depth); @@ -438,7 +454,7 @@ char_table_set (Lisp_Object table, int c, Lisp_Object val) static void sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val, - int is_uniprop) + bool is_uniprop) { struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); int depth = XINT ((tbl)->depth); @@ -484,7 +500,7 @@ char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val) char_table_set (table, from, val); else { - int is_uniprop = UNIPROP_TABLE_P (table); + bool is_uniprop = UNIPROP_TABLE_P (table); int lim = CHARTAB_IDX (to, 0, 0); int i, c; @@ -655,15 +671,6 @@ or a character code. Return VALUE. */) return value; } -DEFUN ("set-char-table-default", Fset_char_table_default, - Sset_char_table_default, 3, 3, 0, - doc: /* -This function is obsolete and has no effect. */) - (Lisp_Object char_table, Lisp_Object ch, Lisp_Object value) -{ - return Qnil; -} - /* Look up the element in TABLE at index CH, and return it as an integer. If the element is not a character, return CH itself. */ @@ -683,7 +690,8 @@ optimize_sub_char_table (Lisp_Object table, Lisp_Object test) struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); int depth = XINT (tbl->depth); Lisp_Object elt, this; - int i, optimizable; + int i; + bool optimizable; elt = XSUB_CHAR_TABLE (table)->contents[0]; if (SUB_CHAR_TABLE_P (elt)) @@ -762,7 +770,7 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object), int chars_in_block; int from = XINT (XCAR (range)), to = XINT (XCDR (range)); int i, c; - int is_uniprop = UNIPROP_TABLE_P (top); + bool is_uniprop = UNIPROP_TABLE_P (top); uniprop_decoder_t decoder = UNIPROP_GET_DECODER (top); if (SUB_CHAR_TABLE_P (table)) @@ -811,7 +819,7 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object), this = XCHAR_TABLE (top)->defalt; if (!EQ (val, this)) { - int different_value = 1; + bool different_value = 1; if (NILP (val)) { @@ -1414,7 +1422,6 @@ syms_of_chartab (void) defsubr (&Sset_char_table_extra_slot); defsubr (&Schar_table_range); defsubr (&Sset_char_table_range); - defsubr (&Sset_char_table_default); defsubr (&Soptimize_char_table); defsubr (&Smap_char_table); defsubr (&Sunicode_property_table_internal);