]> code.delx.au - gnu-emacs/blobdiff - src/chartab.c
* dispextern.h (struct face.stipple):
[gnu-emacs] / src / chartab.c
index ec5b2ffab76165b52b1bf7ac78ea9a633980acd4..ed5b238646e6ba9987237bef9b7f949a0e973491 100644 (file)
@@ -36,7 +36,7 @@ const int chartab_size[4] =
 
 /* Number of characters each element of Nth level char-table
    covers.  */
-const int chartab_chars[4] =
+static const int chartab_chars[4] =
   { (1 << (CHARTAB_SIZE_BITS_1 + CHARTAB_SIZE_BITS_2 + CHARTAB_SIZE_BITS_3)),
     (1 << (CHARTAB_SIZE_BITS_2 + CHARTAB_SIZE_BITS_3)),
     (1 << CHARTAB_SIZE_BITS_3),
@@ -44,7 +44,7 @@ const int chartab_chars[4] =
 
 /* Number of characters (in bits) each element of Nth level char-table
    covers.  */
-const int chartab_bits[4] =
+static const int chartab_bits[4] =
   { (CHARTAB_SIZE_BITS_1 + CHARTAB_SIZE_BITS_2 + CHARTAB_SIZE_BITS_3),
     (CHARTAB_SIZE_BITS_2 + CHARTAB_SIZE_BITS_3),
     CHARTAB_SIZE_BITS_3,
@@ -146,7 +146,7 @@ Lisp_Object
 copy_char_table (Lisp_Object table)
 {
   Lisp_Object copy;
-  int size = XCHAR_TABLE (table)->size & PSEUDOVECTOR_SIZE_MASK;
+  int size = XCHAR_TABLE (table)->header.size & PSEUDOVECTOR_SIZE_MASK;
   int i;
 
   copy = Fmake_vector (make_number (size), Qnil);
@@ -215,7 +215,6 @@ sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, Lisp
   struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
   int depth = XINT (tbl->depth);
   int min_char = XINT (tbl->min_char);
-  int max_char = min_char + chartab_chars[depth - 1] - 1;
   int chartab_idx = CHARTAB_IDX (c, depth, min_char), idx;
   Lisp_Object val;
 
@@ -244,8 +243,9 @@ sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, Lisp
          break;
        }
     }
-  while ((c = min_char + (chartab_idx + 1) * chartab_chars[depth]) <= max_char
-        && *to >= c)
+  while (((c = (chartab_idx + 1) * chartab_chars[depth])
+         < chartab_chars[depth - 1])
+        && (c += min_char) <= *to)
     {
       Lisp_Object this_val;
 
@@ -331,20 +331,6 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to)
 }
 
 
-#define ASET_RANGE(ARRAY, FROM, TO, LIMIT, VAL)                                \
-  do {                                                                 \
-    int limit = (TO) < (LIMIT) ? (TO) : (LIMIT);                       \
-    for (; (FROM) < limit; (FROM)++) (ARRAY)->contents[(FROM)] = (VAL);        \
-  } while (0)
-
-#define GET_SUB_CHAR_TABLE(TABLE, SUBTABLE, IDX, DEPTH, MIN_CHAR)        \
-  do {                                                                   \
-    (SUBTABLE) = (TABLE)->contents[(IDX)];                               \
-    if (!SUB_CHAR_TABLE_P (SUBTABLE))                                    \
-      (SUBTABLE) = make_sub_char_table ((DEPTH), (MIN_CHAR), (SUBTABLE)); \
-  } while (0)
-
-
 static void
 sub_char_table_set (Lisp_Object table, int c, Lisp_Object val)
 {
@@ -406,7 +392,8 @@ sub_char_table_set_range (Lisp_Object *table, int depth, int min_char, int from,
     *table = val;
   else
     {
-      int i, j;
+      int i;
+      unsigned j;
 
       depth++;
       if (! SUB_CHAR_TABLE_P (*table))
@@ -418,7 +405,7 @@ sub_char_table_set_range (Lisp_Object *table, int depth, int min_char, int from,
       i = CHARTAB_IDX (from, depth, min_char);
       j = CHARTAB_IDX (to, depth, min_char);
       min_char += chartab_chars[depth] * i;
-      for (; i <= j; i++, min_char += chartab_chars[depth])
+      for (j++; i < j; i++, min_char += chartab_chars[depth])
        sub_char_table_set_range (XSUB_CHAR_TABLE (*table)->contents + i,
                                  depth, min_char, from, to, val);
     }
@@ -430,16 +417,16 @@ char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val)
 {
   struct Lisp_Char_Table *tbl = XCHAR_TABLE (table);
   Lisp_Object *contents = tbl->contents;
-  int i, min_char;
+  int i;
 
   if (from == to)
     char_table_set (table, from, val);
   else
     {
-      for (i = CHARTAB_IDX (from, 0, 0), min_char = i * chartab_chars[0];
-          min_char <= to;
-          i++, min_char += chartab_chars[0])
-       sub_char_table_set_range (contents + i, 0, min_char, from, to, val);
+      unsigned lim = to / chartab_chars[0] + 1;
+      for (i = CHARTAB_IDX (from, 0, 0); i < lim; i++)
+       sub_char_table_set_range (contents + i, 0, i * chartab_chars[0],
+                                 from, to, val);
       if (ASCII_CHAR_P (from))
        tbl->ascii = char_table_ascii (table);
     }
@@ -537,15 +524,15 @@ a cons of character codes (for characters in the range), or a character code.  *
 
   if (EQ (range, Qnil))
     val = XCHAR_TABLE (char_table)->defalt;
-  else if (INTEGERP (range))
-    val = CHAR_TABLE_REF (char_table, XINT (range));
+  else if (CHARACTERP (range))
+    val = CHAR_TABLE_REF (char_table, XFASTINT (range));
   else if (CONSP (range))
     {
       int from, to;
 
       CHECK_CHARACTER_CAR (range);
       CHECK_CHARACTER_CDR (range);
-      val = char_table_ref_and_range (char_table, XINT (XCAR (range)),
+      val = char_table_ref_and_range (char_table, XFASTINT (XCAR (range)),
                                      &from, &to);
       /* Not yet implemented. */
     }