* chartab.c (chartab_chars, chartab_bits): Now static.
[bpt/emacs.git] / src / chartab.c
index 9a140eb..2f0e88b 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,
@@ -54,7 +54,7 @@ const int chartab_bits[4] =
   (((c) - (min_char)) >> chartab_bits[(depth)])
 
 
-DEFUN ("make-char-table", Fmake_char_table, Smake_char_table, 1, 2, 0,
+DEFUE ("make-char-table", Fmake_char_table, Smake_char_table, 1, 2, 0,
        doc: /* Return a newly created char-table, with purpose PURPOSE.
 Each element is initialized to INIT, which defaults to nil.
 
@@ -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 char_offset_lim = chartab_chars[depth - 1];
   int chartab_idx = CHARTAB_IDX (c, depth, min_char), idx;
   Lisp_Object val;
 
@@ -244,8 +243,8 @@ sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, Lisp
          break;
        }
     }
-
-  while ((c = (chartab_idx + 1) * chartab_chars[depth]) < char_offset_lim
+  while (((c = (chartab_idx + 1) * chartab_chars[depth])
+         < chartab_chars[depth - 1])
         && (c += min_char) <= *to)
     {
       Lisp_Object this_val;
@@ -393,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))
@@ -405,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);
     }
@@ -417,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);
     }
@@ -459,7 +459,7 @@ then the actual applicable value is inherited from the parent char-table
   return XCHAR_TABLE (char_table)->parent;
 }
 
-DEFUN ("set-char-table-parent", Fset_char_table_parent, Sset_char_table_parent,
+DEFUE ("set-char-table-parent", Fset_char_table_parent, Sset_char_table_parent,
        2, 2, 0,
        doc: /* Set the parent char-table of CHAR-TABLE to PARENT.
 Return PARENT.  PARENT must be either nil or another char-table.  */)
@@ -483,7 +483,7 @@ Return PARENT.  PARENT must be either nil or another char-table.  */)
   return parent;
 }
 
-DEFUN ("char-table-extra-slot", Fchar_table_extra_slot, Schar_table_extra_slot,
+DEFUE ("char-table-extra-slot", Fchar_table_extra_slot, Schar_table_extra_slot,
        2, 2, 0,
        doc: /* Return the value of CHAR-TABLE's extra-slot number N.  */)
   (Lisp_Object char_table, Lisp_Object n)
@@ -497,7 +497,7 @@ DEFUN ("char-table-extra-slot", Fchar_table_extra_slot, Schar_table_extra_slot,
   return XCHAR_TABLE (char_table)->extras[XINT (n)];
 }
 
-DEFUN ("set-char-table-extra-slot", Fset_char_table_extra_slot,
+DEFUE ("set-char-table-extra-slot", Fset_char_table_extra_slot,
        Sset_char_table_extra_slot,
        3, 3, 0,
        doc: /* Set CHAR-TABLE's extra-slot number N to VALUE.  */)
@@ -541,7 +541,7 @@ a cons of character codes (for characters in the range), or a character code.  *
   return val;
 }
 
-DEFUN ("set-char-table-range", Fset_char_table_range, Sset_char_table_range,
+DEFUE ("set-char-table-range", Fset_char_table_range, Sset_char_table_range,
        3, 3, 0,
        doc: /* Set the value in CHAR-TABLE for a range of characters RANGE to VALUE.
 RANGE should be t (for all characters), nil (for the default value),
@@ -626,7 +626,7 @@ optimize_sub_char_table (Lisp_Object table, Lisp_Object test)
   return (optimizable ? elt : table);
 }
 
-DEFUN ("optimize-char-table", Foptimize_char_table, Soptimize_char_table,
+DEFUE ("optimize-char-table", Foptimize_char_table, Soptimize_char_table,
        1, 2, 0,
        doc: /* Optimize CHAR-TABLE.
 TEST is the comparison function used to decide whether two entries are