* lisp.h (CSET): Remove.
(set_char_table_ascii, set_char_table_defalt, set_char_table_parent) (set_char_table_purpose): New functions, replacing CSET. All uses changed. For example, replace "CSET (XCHAR_TABLE (char_table), parent, parent);" with "char_table_set_parent (char_table, parent);". The old version was confusing because it used the same name 'parent' for two different things. Fixes: debbugs:12215
This commit is contained in:
parent
a04e2c62ec
commit
742af32f28
8 changed files with 61 additions and 32 deletions
|
@ -1,3 +1,14 @@
|
|||
2012-08-17 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* lisp.h (CSET): Remove (Bug#12215).
|
||||
(set_char_table_ascii, set_char_table_defalt, set_char_table_parent)
|
||||
(set_char_table_purpose): New functions,
|
||||
replacing CSET. All uses changed. For example, replace
|
||||
"CSET (XCHAR_TABLE (char_table), parent, parent);" with
|
||||
"char_table_set_parent (char_table, parent);".
|
||||
The old version was confusing because it used the same name
|
||||
'parent' for two different things.
|
||||
|
||||
2012-08-17 Dmitry Antipov <dmantipov@yandex.ru>
|
||||
|
||||
Functions to get and set Lisp_Object fields of buffer-local variables.
|
||||
|
|
|
@ -260,7 +260,7 @@ init_casetab_once (void)
|
|||
|
||||
down = Fmake_char_table (Qcase_table, Qnil);
|
||||
Vascii_downcase_table = down;
|
||||
CSET (XCHAR_TABLE (down), purpose, Qcase_table);
|
||||
set_char_table_purpose (down, Qcase_table);
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
|
|
|
@ -238,8 +238,8 @@ copy_category_table (Lisp_Object table)
|
|||
table = copy_char_table (table);
|
||||
|
||||
if (! NILP (XCHAR_TABLE (table)->defalt))
|
||||
CSET (XCHAR_TABLE (table), defalt,
|
||||
Fcopy_sequence (XCHAR_TABLE (table)->defalt));
|
||||
set_char_table_defalt (table,
|
||||
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);
|
||||
|
@ -270,7 +270,7 @@ DEFUN ("make-category-table", Fmake_category_table, Smake_category_table,
|
|||
int i;
|
||||
|
||||
val = Fmake_char_table (Qcategory_table, Qnil);
|
||||
CSET (XCHAR_TABLE (val), defalt, MAKE_CATEGORY_SET);
|
||||
set_char_table_defalt (val, MAKE_CATEGORY_SET);
|
||||
for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++)
|
||||
char_table_set_contents (val, i, MAKE_CATEGORY_SET);
|
||||
Fset_char_table_extra_slot (val, make_number (0),
|
||||
|
@ -466,7 +466,7 @@ init_category_once (void)
|
|||
|
||||
Vstandard_category_table = Fmake_char_table (Qcategory_table, Qnil);
|
||||
/* Set a category set which contains nothing to the default. */
|
||||
CSET (XCHAR_TABLE (Vstandard_category_table), defalt, MAKE_CATEGORY_SET);
|
||||
set_char_table_defalt (Vstandard_category_table, MAKE_CATEGORY_SET);
|
||||
Fset_char_table_extra_slot (Vstandard_category_table, make_number (0),
|
||||
Fmake_vector (make_number (95), Qnil));
|
||||
}
|
||||
|
|
|
@ -115,8 +115,8 @@ the char-table has no extra slot. */)
|
|||
size = VECSIZE (struct Lisp_Char_Table) - 1 + n_extras;
|
||||
vector = Fmake_vector (make_number (size), init);
|
||||
XSETPVECTYPE (XVECTOR (vector), PVEC_CHAR_TABLE);
|
||||
CSET (XCHAR_TABLE (vector), parent, Qnil);
|
||||
CSET (XCHAR_TABLE (vector), purpose, purpose);
|
||||
set_char_table_parent (vector, Qnil);
|
||||
set_char_table_purpose (vector, purpose);
|
||||
XSETCHAR_TABLE (vector, XCHAR_TABLE (vector));
|
||||
return vector;
|
||||
}
|
||||
|
@ -185,16 +185,16 @@ copy_char_table (Lisp_Object table)
|
|||
|
||||
copy = Fmake_vector (make_number (size), Qnil);
|
||||
XSETPVECTYPE (XVECTOR (copy), PVEC_CHAR_TABLE);
|
||||
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);
|
||||
set_char_table_defalt (copy, XCHAR_TABLE (table)->defalt);
|
||||
set_char_table_parent (copy, XCHAR_TABLE (table)->parent);
|
||||
set_char_table_purpose (copy, XCHAR_TABLE (table)->purpose);
|
||||
for (i = 0; i < chartab_size[0]; i++)
|
||||
char_table_set_contents
|
||||
(copy, i,
|
||||
(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));
|
||||
set_char_table_ascii (copy, char_table_ascii (copy));
|
||||
size -= VECSIZE (struct Lisp_Char_Table) - 1;
|
||||
for (i = 0; i < size; i++)
|
||||
char_table_set_extras (copy, i, XCHAR_TABLE (table)->extras[i]);
|
||||
|
@ -436,7 +436,7 @@ char_table_set (Lisp_Object table, int c, Lisp_Object val)
|
|||
}
|
||||
sub_char_table_set (sub, c, val, UNIPROP_TABLE_P (table));
|
||||
if (ASCII_CHAR_P (c))
|
||||
CSET (tbl, ascii, char_table_ascii (table));
|
||||
set_char_table_ascii (table, char_table_ascii (table));
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val)
|
|||
}
|
||||
}
|
||||
if (ASCII_CHAR_P (from))
|
||||
CSET (tbl, ascii, char_table_ascii (table));
|
||||
set_char_table_ascii (table, char_table_ascii (table));
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ Return PARENT. PARENT must be either nil or another char-table. */)
|
|||
error ("Attempt to make a chartable be its own parent");
|
||||
}
|
||||
|
||||
CSET (XCHAR_TABLE (char_table), parent, parent);
|
||||
set_char_table_parent (char_table, parent);
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
@ -640,12 +640,12 @@ or a character code. Return VALUE. */)
|
|||
{
|
||||
int i;
|
||||
|
||||
CSET (XCHAR_TABLE (char_table), ascii, value);
|
||||
set_char_table_ascii (char_table, value);
|
||||
for (i = 0; i < chartab_size[0]; i++)
|
||||
char_table_set_contents (char_table, i, value);
|
||||
}
|
||||
else if (EQ (range, Qnil))
|
||||
CSET (XCHAR_TABLE (char_table), defalt, value);
|
||||
set_char_table_defalt (char_table, value);
|
||||
else if (CHARACTERP (range))
|
||||
char_table_set (char_table, XINT (range), value);
|
||||
else if (CONSP (range))
|
||||
|
@ -736,7 +736,7 @@ equivalent and can be merged. It defaults to `equal'. */)
|
|||
(char_table, i, optimize_sub_char_table (elt, test));
|
||||
}
|
||||
/* Reset the `ascii' cache, in case it got optimized away. */
|
||||
CSET (XCHAR_TABLE (char_table), ascii, char_table_ascii (char_table));
|
||||
set_char_table_ascii (char_table, char_table_ascii (char_table));
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -828,9 +828,9 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object),
|
|||
|
||||
/* This is to get a value of FROM in PARENT
|
||||
without checking the parent of PARENT. */
|
||||
CSET (XCHAR_TABLE (parent), parent, Qnil);
|
||||
set_char_table_parent (parent, Qnil);
|
||||
val = CHAR_TABLE_REF (parent, from);
|
||||
CSET (XCHAR_TABLE (parent), parent, temp);
|
||||
set_char_table_parent (parent, temp);
|
||||
XSETCDR (range, make_number (c - 1));
|
||||
val = map_sub_char_table (c_function, function,
|
||||
parent, arg, val, range,
|
||||
|
@ -910,9 +910,9 @@ map_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object),
|
|||
temp = XCHAR_TABLE (parent)->parent;
|
||||
/* This is to get a value of FROM in PARENT without checking the
|
||||
parent of PARENT. */
|
||||
CSET (XCHAR_TABLE (parent), parent, Qnil);
|
||||
set_char_table_parent (parent, Qnil);
|
||||
val = CHAR_TABLE_REF (parent, from);
|
||||
CSET (XCHAR_TABLE (parent), parent, temp);
|
||||
set_char_table_parent (parent, temp);
|
||||
val = map_sub_char_table (c_function, function, parent, arg, val, range,
|
||||
parent);
|
||||
table = parent;
|
||||
|
@ -1350,7 +1350,7 @@ uniprop_table (Lisp_Object prop)
|
|||
: ! NILP (val))
|
||||
return Qnil;
|
||||
/* Prepare ASCII values in advance for CHAR_TABLE_REF. */
|
||||
CSET (XCHAR_TABLE (table), ascii, char_table_ascii (table));
|
||||
set_char_table_ascii (table, char_table_ascii (table));
|
||||
return table;
|
||||
}
|
||||
|
||||
|
|
|
@ -2151,7 +2151,7 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
|
|||
|
||||
for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++)
|
||||
char_table_set_contents (array, i, item);
|
||||
CSET (XCHAR_TABLE (array), defalt, item);
|
||||
set_char_table_defalt (array, item);
|
||||
}
|
||||
else if (STRINGP (array))
|
||||
{
|
||||
|
|
|
@ -1979,7 +1979,7 @@ format is the same as above. */)
|
|||
if (c <= MAX_5_BYTE_CHAR)
|
||||
char_table_set_range (tables[k], c, to, alist);
|
||||
else
|
||||
CSET (XCHAR_TABLE (tables[k]), defalt, alist);
|
||||
set_char_table_defalt (tables[k], alist);
|
||||
|
||||
/* At last, change each elements to font names. */
|
||||
for (; CONSP (alist); alist = XCDR (alist))
|
||||
|
|
30
src/lisp.h
30
src/lisp.h
|
@ -936,12 +936,6 @@ enum CHARTAB_SIZE_BITS
|
|||
|
||||
extern const int chartab_size[4];
|
||||
|
||||
/* 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
|
||||
{
|
||||
/* HEADER.SIZE is the vector's size field, which also holds the
|
||||
|
@ -2477,6 +2471,30 @@ string_set_intervals (Lisp_Object s, INTERVAL i)
|
|||
XSTRING (s)->intervals = i;
|
||||
}
|
||||
|
||||
/* Set a Lisp slot in TABLE to VAL. Most code should use this instead
|
||||
of setting slots directly. */
|
||||
|
||||
LISP_INLINE void
|
||||
set_char_table_ascii (Lisp_Object table, Lisp_Object val)
|
||||
{
|
||||
XCHAR_TABLE (table)->ascii = val;
|
||||
}
|
||||
LISP_INLINE void
|
||||
set_char_table_defalt (Lisp_Object table, Lisp_Object val)
|
||||
{
|
||||
XCHAR_TABLE (table)->defalt = val;
|
||||
}
|
||||
LISP_INLINE void
|
||||
set_char_table_parent (Lisp_Object table, Lisp_Object val)
|
||||
{
|
||||
XCHAR_TABLE (table)->parent = val;
|
||||
}
|
||||
LISP_INLINE void
|
||||
set_char_table_purpose (Lisp_Object table, Lisp_Object val)
|
||||
{
|
||||
XCHAR_TABLE (table)->purpose = val;
|
||||
}
|
||||
|
||||
/* Set different slots in (sub)character tables. */
|
||||
|
||||
LISP_INLINE void
|
||||
|
|
|
@ -818,7 +818,7 @@ It is a copy of the TABLE, which defaults to the standard syntax table. */)
|
|||
|
||||
/* Only the standard syntax table should have a default element.
|
||||
Other syntax tables should inherit from parents instead. */
|
||||
CSET (XCHAR_TABLE (copy), defalt, Qnil);
|
||||
set_char_table_defalt (copy, Qnil);
|
||||
|
||||
/* Copied syntax tables should all have parents.
|
||||
If we copied one with no parent, such as the standard syntax table,
|
||||
|
|
Loading…
Add table
Reference in a new issue