if (EQ (tail, halftail) && len != 0)
break;
len++;
- if (len & 1 == 0)
+ if ((len & 1) == 0)
halftail = XCONS (halftail)->cdr;
}
/* Calculate the number of extra slots. */
size = CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (arg));
- copy = Fmake_char_table (make_number (size), Qnil);
+ copy = Fmake_char_table (XCHAR_TABLE (arg)->purpose, Qnil);
/* Copy all the slots, including the extra ones. */
bcopy (XCHAR_TABLE (arg)->contents, XCHAR_TABLE (copy)->contents,
(XCHAR_TABLE (arg)->size & PSEUDOVECTOR_SIZE_MASK) * sizeof (Lisp_Object));
if (BOOL_VECTOR_P (arg))
{
Lisp_Object val;
- int bits_per_char = INTBITS / sizeof (int);
int size_in_chars
- = (XBOOL_VECTOR (arg)->size + bits_per_char) / bits_per_char;
+ = (XBOOL_VECTOR (arg)->size + BITS_PER_CHAR) / BITS_PER_CHAR;
val = Fmake_bool_vector (Flength (arg), Qnil);
bcopy (XBOOL_VECTOR (arg)->data, XBOOL_VECTOR (val)->data,
XSETFASTINT (elt, XSTRING (this)->data[thisindex++]);
else if (BOOL_VECTOR_P (this))
{
- int bits_per_char = INTBITS / sizeof (int);
int size_in_chars
- = ((XBOOL_VECTOR (this)->size + bits_per_char)
- / bits_per_char);
+ = ((XBOOL_VECTOR (this)->size + BITS_PER_CHAR)
+ / BITS_PER_CHAR);
int byte;
- byte = XBOOL_VECTOR (val)->data[thisindex / bits_per_char];
+ byte = XBOOL_VECTOR (val)->data[thisindex / BITS_PER_CHAR];
if (byte & (1 << thisindex))
elt = Qt;
else
/* Boolvectors are compared much like strings. */
if (BOOL_VECTOR_P (o1))
{
- int bits_per_char = INTBITS / sizeof (int);
int size_in_chars
- = (XBOOL_VECTOR (o1)->size + bits_per_char) / bits_per_char;
+ = (XBOOL_VECTOR (o1)->size + BITS_PER_CHAR) / BITS_PER_CHAR;
if (XBOOL_VECTOR (o1)->size != XBOOL_VECTOR (o2)->size)
return 0;
else if (BOOL_VECTOR_P (array))
{
register unsigned char *p = XBOOL_VECTOR (array)->data;
- int bits_per_char = INTBITS / sizeof (int);
int size_in_chars
- = (XBOOL_VECTOR (array)->size + bits_per_char) / bits_per_char;
+ = (XBOOL_VECTOR (array)->size + BITS_PER_CHAR) / BITS_PER_CHAR;
charval = (! NILP (item) ? -1 : 0);
for (index = 0; index < size_in_chars; index++)
return array;
}
+DEFUN ("char-table-subtype", Fchar_table_subtype, Schar_table_subtype,
+ 1, 1, 0,
+ "Return the subtype of char-table CHAR-TABLE. The value is a symbol.")
+ (chartable)
+ Lisp_Object chartable;
+{
+ CHECK_CHAR_TABLE (chartable, 0);
+
+ return XCHAR_TABLE (chartable)->purpose;
+}
+
DEFUN ("char-table-parent", Fchar_table_parent, Schar_table_parent,
1, 1, 0,
"Return the parent char-table of CHAR-TABLE.\n\
Lisp_Object temp;
CHECK_CHAR_TABLE (chartable, 0);
- CHECK_CHAR_TABLE (parent, 0);
- for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent)
- if (EQ (temp, chartable))
- error ("Attempt to make a chartable be its own parent");
+ if (!NILP (parent))
+ {
+ CHECK_CHAR_TABLE (parent, 0);
+
+ for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent)
+ if (EQ (temp, chartable))
+ error ("Attempt to make a chartable be its own parent");
+ }
XCHAR_TABLE (chartable)->parent = parent;
return XCHAR_TABLE (chartable)->extras[XINT (n)] = value;
}
+DEFUN ("char-table-range", Fchar_table_range, Schar_table_range,
+ 2, 2, 0,
+ "Return the value in CHARTABLE for a range of characters RANGE.\n\
+RANGE should be t (for all characters), nil (for the default value)\n\
+a vector which identifies a character set or a row of a character set,\n\
+or a character code.")
+ (chartable, range)
+ Lisp_Object chartable, range;
+{
+ int i;
+
+ CHECK_CHAR_TABLE (chartable, 0);
+
+ if (EQ (range, Qnil))
+ return XCHAR_TABLE (chartable)->defalt;
+ else if (INTEGERP (range))
+ return Faref (chartable, range);
+ else if (VECTORP (range))
+ {
+ for (i = 0; i < XVECTOR (range)->size - 1; i++)
+ chartable = Faref (chartable, XVECTOR (range)->contents[i]);
+
+ if (EQ (XVECTOR (range)->contents[i], Qnil))
+ return XCHAR_TABLE (chartable)->defalt;
+ else
+ return Faref (chartable, XVECTOR (range)->contents[i]);
+ }
+ else
+ error ("Invalid RANGE argument to `char-table-range'");
+}
+
DEFUN ("set-char-table-range", Fset_char_table_range, Sset_char_table_range,
3, 3, 0,
"Set the value in CHARTABLE for a range of characters RANGE to VALUE.\n\
return value;
}
\f
-static void
-map_char_table (function, chartable, depth, indices)
- Lisp_Object function, chartable, depth, *indices;
+/* Map C_FUNCTION or FUNCTION over CHARTABLE, calling it for each
+ character or group of characters that share a value.
+ DEPTH is the current depth in the originally specified
+ chartable, and INDICES contains the vector indices
+ for the levels our callers have descended. */
+
+void
+map_char_table (c_function, function, chartable, depth, indices)
+ Lisp_Object (*c_function) (), function, chartable, depth, *indices;
{
int i;
- int size = XCHAR_TABLE (chartable)->size;
+ int size = CHAR_TABLE_ORDINARY_SLOTS;
/* Make INDICES longer if we are about to fill it up. */
if ((depth % 10) == 9)
Lisp_Object elt;
indices[depth] = i;
elt = XCHAR_TABLE (chartable)->contents[i];
- if (!CHAR_TABLE_P (elt))
- call2 (function, Fvector (depth + 1, indices), elt);
+ if (CHAR_TABLE_P (elt))
+ map_char_table (chartable, c_function, function, depth + 1, indices);
+ else if (c_function)
+ (*c_function) (depth + 1, indices, elt);
+ /* Here we should handle all cases where the range is a single character
+ by passing that character as a number. Currently, that is
+ all the time, but with the MULE code this will have to be changed. */
+ else if (depth == 0)
+ call2 (function, make_number (i), elt);
else
- map_char_table (chartable, function, depth + 1, indices);
+ call2 (function, Fvector (depth + 1, indices), elt);
}
}
Lisp_Object keyvec;
Lisp_Object *indices = (Lisp_Object *) alloca (10 * sizeof (Lisp_Object));
- map_char_table (function, chartable, 0, indices);
+ map_char_table (NULL, function, chartable, 0, indices);
return Qnil;
}
\f
while (1)
{
-#ifdef HAVE_X_MENU
+#if defined (HAVE_X_MENU) || defined (HAVE_NTGUI)
if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
&& using_x_p ())
{
CHECK_STRING (prompt, 0);
-#ifdef HAVE_X_MENU
- if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
+#if defined (HAVE_X_MENU) || defined (HAVE_NTGUI)
+ if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
&& using_x_p ())
{
Lisp_Object pane, menu, obj;
defsubr (&Sput);
defsubr (&Sequal);
defsubr (&Sfillarray);
+ defsubr (&Schar_table_subtype);
defsubr (&Schar_table_parent);
defsubr (&Sset_char_table_parent);
defsubr (&Schar_table_extra_slot);
defsubr (&Sset_char_table_extra_slot);
+ defsubr (&Schar_table_range);
defsubr (&Sset_char_table_range);
defsubr (&Smap_char_table);
defsubr (&Snconc);