=== modified file 'src/casetab.c' --- src/casetab.c 2012-08-13 03:39:07 +0000 +++ src/casetab.c 2012-08-13 11:34:15 +0000 @@ -128,13 +128,13 @@ up = Fmake_char_table (Qcase_table, Qnil); map_char_table (set_identity, Qnil, table, up); map_char_table (shuffle, Qnil, table, up); - XCHAR_TABLE (table)->extras[0] = up; + char_table_set_extras (table, 0, up); } if (NILP (canon)) { canon = Fmake_char_table (Qcase_table, Qnil); - XCHAR_TABLE (table)->extras[1] = canon; + char_table_set_extras (table, 1, canon); map_char_table (set_canon, Qnil, table, table); } @@ -143,11 +143,11 @@ eqv = Fmake_char_table (Qcase_table, Qnil); map_char_table (set_identity, Qnil, canon, eqv); map_char_table (shuffle, Qnil, canon, eqv); - XCHAR_TABLE (table)->extras[2] = eqv; + char_table_set_extras (table, 2, eqv); } /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (canon)->extras[2] = eqv; + char_table_set_extras (canon, 2, eqv); if (standard) { @@ -260,7 +260,7 @@ down = Fmake_char_table (Qcase_table, Qnil); Vascii_downcase_table = down; - XCHAR_TABLE (down)->purpose = Qcase_table; + CSET (XCHAR_TABLE (down), purpose, Qcase_table); for (i = 0; i < 128; i++) { @@ -268,10 +268,10 @@ CHAR_TABLE_SET (down, i, make_number (c)); } - XCHAR_TABLE (down)->extras[1] = Fcopy_sequence (down); + char_table_set_extras (down, 1, Fcopy_sequence (down)); up = Fmake_char_table (Qcase_table, Qnil); - XCHAR_TABLE (down)->extras[0] = up; + char_table_set_extras (down, 0, up); for (i = 0; i < 128; i++) { @@ -281,7 +281,7 @@ CHAR_TABLE_SET (up, i, make_number (c)); } - XCHAR_TABLE (down)->extras[2] = Fcopy_sequence (up); + char_table_set_extras (down, 2, Fcopy_sequence (up)); /* Fill in what isn't filled in. */ set_case_table (down, 1); === modified file 'src/category.c' --- src/category.c 2012-08-13 03:44:27 +0000 +++ src/category.c 2012-08-13 11:34:15 +0000 @@ -71,11 +71,12 @@ EMACS_UINT hash; if (NILP (XCHAR_TABLE (table)->extras[1])) - XCHAR_TABLE (table)->extras[1] - = make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), - make_float (DEFAULT_REHASH_SIZE), - make_float (DEFAULT_REHASH_THRESHOLD), - Qnil, Qnil, Qnil); + char_table_set_extras + (table, 1, + make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), + make_float (DEFAULT_REHASH_SIZE), + make_float (DEFAULT_REHASH_THRESHOLD), + Qnil, Qnil, Qnil)); h = XHASH_TABLE (XCHAR_TABLE (table)->extras[1]); i = hash_lookup (h, category_set, &hash); if (i >= 0) @@ -238,10 +239,10 @@ table = copy_char_table (table); if (! NILP (XCHAR_TABLE (table)->defalt)) - XCHAR_TABLE (table)->defalt - = Fcopy_sequence (XCHAR_TABLE (table)->defalt); - XCHAR_TABLE (table)->extras[0] - = Fcopy_sequence (XCHAR_TABLE (table)->extras[0]); + CSET (XCHAR_TABLE (table), defalt, + Fcopy_sequence (XCHAR_TABLE (table)->defalt)); + char_table_set_extras + (table, 0, Fcopy_sequence (XCHAR_TABLE (table)->extras[0])); map_char_table (copy_category_entry, Qnil, table, table); return table; @@ -270,9 +271,9 @@ int i; val = Fmake_char_table (Qcategory_table, Qnil); - XCHAR_TABLE (val)->defalt = MAKE_CATEGORY_SET; + CSET (XCHAR_TABLE (val), defalt, MAKE_CATEGORY_SET); for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++) - XCHAR_TABLE (val)->contents[i] = MAKE_CATEGORY_SET; + char_table_set_contents (val, i, MAKE_CATEGORY_SET); Fset_char_table_extra_slot (val, make_number (0), Fmake_vector (make_number (95), Qnil)); return val; @@ -466,7 +467,7 @@ Vstandard_category_table = Fmake_char_table (Qcategory_table, Qnil); /* Set a category set which contains nothing to the default. */ - XCHAR_TABLE (Vstandard_category_table)->defalt = MAKE_CATEGORY_SET; + CSET (XCHAR_TABLE (Vstandard_category_table), defalt, MAKE_CATEGORY_SET); Fset_char_table_extra_slot (Vstandard_category_table, make_number (0), Fmake_vector (make_number (95), Qnil)); } === modified file 'src/chartab.c' --- src/chartab.c 2011-12-11 00:56:50 +0000 +++ src/chartab.c 2012-08-13 11:34:15 +0000 @@ -167,9 +167,9 @@ { val = XSUB_CHAR_TABLE (table)->contents[i]; if (SUB_CHAR_TABLE_P (val)) - XSUB_CHAR_TABLE (copy)->contents[i] = copy_sub_char_table (val); + sub_char_table_set_contents (copy, i, copy_sub_char_table (val)); else - XSUB_CHAR_TABLE (copy)->contents[i] = val; + sub_char_table_set_contents (copy, i, val); } return copy; @@ -185,18 +185,19 @@ copy = Fmake_vector (make_number (size), Qnil); XSETPVECTYPE (XVECTOR (copy), PVEC_CHAR_TABLE); - XCHAR_TABLE (copy)->defalt = XCHAR_TABLE (table)->defalt; - XCHAR_TABLE (copy)->parent = XCHAR_TABLE (table)->parent; - XCHAR_TABLE (copy)->purpose = XCHAR_TABLE (table)->purpose; + CSET (XCHAR_TABLE (copy), defalt, XCHAR_TABLE (table)->defalt); + CSET (XCHAR_TABLE (copy), parent, XCHAR_TABLE (table)->parent); + CSET (XCHAR_TABLE (copy), purpose, XCHAR_TABLE (table)->purpose); for (i = 0; i < chartab_size[0]; i++) - XCHAR_TABLE (copy)->contents[i] - = (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i]) - ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i]) - : XCHAR_TABLE (table)->contents[i]); - XCHAR_TABLE (copy)->ascii = char_table_ascii (copy); + char_table_set_contents + (copy, i, + (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i]) + ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i]) + : XCHAR_TABLE (table)->contents[i])); + CSET (XCHAR_TABLE (copy), ascii, char_table_ascii (copy)); size -= VECSIZE (struct Lisp_Char_Table) - 1; for (i = 0; i < size; i++) - XCHAR_TABLE (copy)->extras[i] = XCHAR_TABLE (table)->extras[i]; + char_table_set_extras (copy, i, XCHAR_TABLE (table)->extras[i]); XSETCHAR_TABLE (copy, XCHAR_TABLE (copy)); return copy; @@ -421,9 +422,7 @@ if (ASCII_CHAR_P (c) && SUB_CHAR_TABLE_P (tbl->ascii)) - { - XSUB_CHAR_TABLE (tbl->ascii)->contents[c] = val; - } + sub_char_table_set_contents (tbl->ascii, c, val); else { int i = CHARTAB_IDX (c, 0, 0); @@ -563,7 +562,7 @@ error ("Attempt to make a chartable be its own parent"); } - XCHAR_TABLE (char_table)->parent = parent; + CSET (XCHAR_TABLE (char_table), parent, parent); return parent; } @@ -640,12 +639,12 @@ { int i; - XCHAR_TABLE (char_table)->ascii = value; + CSET (XCHAR_TABLE (char_table), ascii, value); for (i = 0; i < chartab_size[0]; i++) - XCHAR_TABLE (char_table)->contents[i] = value; + char_table_set_contents (char_table, i, value); } else if (EQ (range, Qnil)) - XCHAR_TABLE (char_table)->defalt = value; + CSET (XCHAR_TABLE (char_table), defalt, value); else if (CHARACTERP (range)) char_table_set (char_table, XINT (range), value); else if (CONSP (range)) @@ -728,11 +727,11 @@ { elt = XCHAR_TABLE (char_table)->contents[i]; if (SUB_CHAR_TABLE_P (elt)) - XCHAR_TABLE (char_table)->contents[i] - = optimize_sub_char_table (elt, test); + char_table_set_contents + (char_table, i, optimize_sub_char_table (elt, test)); } /* Reset the `ascii' cache, in case it got optimized away. */ - XCHAR_TABLE (char_table)->ascii = char_table_ascii (char_table); + CSET (XCHAR_TABLE (char_table), ascii, char_table_ascii (char_table)); return Qnil; } @@ -824,9 +823,9 @@ /* This is to get a value of FROM in PARENT without checking the parent of PARENT. */ - XCHAR_TABLE (parent)->parent = Qnil; + CSET (XCHAR_TABLE (parent), parent, Qnil); val = CHAR_TABLE_REF (parent, from); - XCHAR_TABLE (parent)->parent = temp; + CSET (XCHAR_TABLE (parent), parent, temp); XSETCDR (range, make_number (c - 1)); val = map_sub_char_table (c_function, function, parent, arg, val, range, @@ -906,9 +905,9 @@ temp = XCHAR_TABLE (parent)->parent; /* This is to get a value of FROM in PARENT without checking the parent of PARENT. */ - XCHAR_TABLE (parent)->parent = Qnil; + CSET (XCHAR_TABLE (parent), parent, Qnil); val = CHAR_TABLE_REF (parent, from); - XCHAR_TABLE (parent)->parent = temp; + CSET (XCHAR_TABLE (parent), parent, temp); val = map_sub_char_table (c_function, function, parent, arg, val, range, parent); table = parent; @@ -1143,10 +1142,9 @@ int min_char = (XINT (XSUB_CHAR_TABLE (table)->min_char) + chartab_chars[2] * idx); Lisp_Object sub = make_sub_char_table (3, min_char, Qnil); - struct Lisp_Sub_Char_Table *subtbl = XSUB_CHAR_TABLE (sub); const unsigned char *p, *pend; - XSUB_CHAR_TABLE (table)->contents[idx] = sub; + sub_char_table_set_contents (table, idx, sub); p = SDATA (val), pend = p + SBYTES (val); if (*p == 1) { @@ -1156,7 +1154,8 @@ while (p < pend && idx < chartab_chars[2]) { int v = STRING_CHAR_ADVANCE (p); - subtbl->contents[idx++] = v > 0 ? make_number (v) : Qnil; + sub_char_table_set_contents + (sub, idx++, v > 0 ? make_number (v) : Qnil); } } else if (*p == 2) @@ -1181,7 +1180,7 @@ } } while (count-- > 0) - subtbl->contents[idx++] = make_number (v); + sub_char_table_set_contents (sub, idx++, make_number (v)); } } /* It seems that we don't need this function because C code won't need @@ -1284,7 +1283,7 @@ args[0] = XCHAR_TABLE (table)->extras[4]; args[1] = Fmake_vector (make_number (1), value); - XCHAR_TABLE (table)->extras[4] = Fvconcat (2, args); + char_table_set_extras (table, 4, Fvconcat (2, args)); } return make_number (i); } @@ -1346,7 +1345,7 @@ : ! NILP (val)) return Qnil; /* Prepare ASCII values in advance for CHAR_TABLE_REF. */ - XCHAR_TABLE (table)->ascii = char_table_ascii (table); + CSET (XCHAR_TABLE (table), ascii, char_table_ascii (table)); return table; } === modified file 'src/fns.c' --- src/fns.c 2012-08-08 10:23:04 +0000 +++ src/fns.c 2012-08-13 11:34:15 +0000 @@ -2150,8 +2150,8 @@ int i; for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++) - XCHAR_TABLE (array)->contents[i] = item; - XCHAR_TABLE (array)->defalt = item; + char_table_set_contents (array, i, item); + CSET (XCHAR_TABLE (array), defalt, item); } else if (STRINGP (array)) { === modified file 'src/fontset.c' --- src/fontset.c 2012-08-07 07:33:18 +0000 +++ src/fontset.c 2012-08-13 11:34:15 +0000 @@ -1918,7 +1918,7 @@ if (!EQ (fontset, Vdefault_fontset)) { tables[1] = Fmake_char_table (Qnil, Qnil); - XCHAR_TABLE (tables[0])->extras[0] = tables[1]; + char_table_set_extras (tables[0], 0, tables[1]); fontsets[1] = Vdefault_fontset; } @@ -1981,7 +1981,7 @@ if (c <= MAX_5_BYTE_CHAR) char_table_set_range (tables[k], c, to, alist); else - XCHAR_TABLE (tables[k])->defalt = alist; + CSET (XCHAR_TABLE (tables[k]), defalt, alist); /* At last, change each elements to font names. */ for (; CONSP (alist); alist = XCDR (alist)) === modified file 'src/lisp.h' --- src/lisp.h 2012-08-10 18:23:45 +0000 +++ src/lisp.h 2012-08-13 11:39:40 +0000 @@ -935,7 +935,11 @@ extern const int chartab_size[4]; -struct Lisp_Sub_Char_Table; +/* Most code should use this macro to set non-array Lisp fields in struct + Lisp_Char_Table. For CONTENTS and EXTRAS, use char_table_set_contents + and char_table_set_extras, respectively. */ + +#define CSET(c, field, value) ((c)->field = (value)) struct Lisp_Char_Table { @@ -985,6 +989,7 @@ /* Minimum character covered by the sub char-table. */ Lisp_Object min_char; + /* Use sub_char_table_set_contents to set this. */ Lisp_Object contents[1]; }; @@ -2430,6 +2435,26 @@ XSTRING (s)->intervals = i; } +/* Set different slots in (sub)character tables. */ + +LISP_INLINE +void char_table_set_extras (Lisp_Object table, ptrdiff_t idx, Lisp_Object val) +{ + XCHAR_TABLE (table)->extras[idx] = val; +} + +LISP_INLINE +void char_table_set_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val) +{ + XCHAR_TABLE (table)->contents[idx] = val; +} + +LISP_INLINE +void sub_char_table_set_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val) +{ + XSUB_CHAR_TABLE (table)->contents[idx] = val; +} + /* Defined in data.c. */ extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; === modified file 'src/search.c' --- src/search.c 2012-08-05 13:30:15 +0000 +++ src/search.c 2012-08-13 11:34:15 +0000 @@ -278,8 +278,8 @@ save_search_regs (); /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (BVAR (current_buffer, case_canon_table))->extras[2] - = BVAR (current_buffer, case_eqv_table); + char_table_set_extras (BVAR (current_buffer, case_canon_table), 2, + BVAR (current_buffer, case_eqv_table)); CHECK_STRING (string); bufp = compile_pattern (string, @@ -393,8 +393,8 @@ } /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (BVAR (current_buffer, case_canon_table))->extras[2] - = BVAR (current_buffer, case_eqv_table); + char_table_set_extras (BVAR (current_buffer, case_canon_table), 2, + BVAR (current_buffer, case_eqv_table)); bufp = compile_pattern (regexp, (NILP (Vinhibit_changing_match_data) @@ -990,8 +990,8 @@ } /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (BVAR (current_buffer, case_canon_table))->extras[2] - = BVAR (current_buffer, case_eqv_table); + char_table_set_extras (BVAR (current_buffer, case_canon_table), 2, + BVAR (current_buffer, case_eqv_table)); np = search_buffer (string, PT, PT_BYTE, lim, lim_byte, n, RE, (!NILP (BVAR (current_buffer, case_fold_search)) === modified file 'src/syntax.c' --- src/syntax.c 2012-08-13 03:39:07 +0000 +++ src/syntax.c 2012-08-13 11:34:15 +0000 @@ -819,7 +819,7 @@ /* Only the standard syntax table should have a default element. Other syntax tables should inherit from parents instead. */ - XCHAR_TABLE (copy)->defalt = Qnil; + CSET (XCHAR_TABLE (copy), defalt, Qnil); /* Copied syntax tables should all have parents. If we copied one with no parent, such as the standard syntax table,