emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/src chartab.c


From: Kenichi Handa
Subject: [Emacs-diffs] emacs/src chartab.c
Date: Thu, 27 Nov 2008 08:01:30 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Kenichi Handa <handa>   08/11/27 08:01:30

Modified files:
        src            : chartab.c 

Log message:
        (sub_char_table_ref_and_range): Adjusted for the
        change of char_table_ref_and_range.
        (char_table_ref_and_range): Change the meaning of argument FROM
        and TO.  Now the caller must provide initial values for *FROM
        and *TO.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/src/chartab.c?cvsroot=emacs&r1=1.11&r2=1.12

Patches:
Index: chartab.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/chartab.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- chartab.c   11 Nov 2008 08:41:19 -0000      1.11
+++ chartab.c   27 Nov 2008 08:01:29 -0000      1.12
@@ -229,66 +229,60 @@
   int depth = XINT (tbl->depth);
   int min_char = XINT (tbl->min_char);
   int max_char = min_char + chartab_chars[depth - 1] - 1;
-  int index = CHARTAB_IDX (c, depth, min_char);
+  int index = CHARTAB_IDX (c, depth, min_char), idx;
   Lisp_Object val;
 
   val = tbl->contents[index];
-  *from = min_char + index * chartab_chars[depth];
-  *to = *from + chartab_chars[depth] - 1;
   if (SUB_CHAR_TABLE_P (val))
     val = sub_char_table_ref_and_range (val, c, from, to, defalt);
   else if (NILP (val))
     val = defalt;
 
-  while (*from > min_char
-        && *from == min_char + index * chartab_chars[depth])
+  idx = index;
+  while (idx > 0 && *from < min_char + idx * chartab_chars[depth])
     {
       Lisp_Object this_val;
-      int this_from = *from - chartab_chars[depth];
-      int this_to = *from - 1;
 
-      index--;
-      this_val = tbl->contents[index];
+      c = min_char + idx * chartab_chars[depth] - 1;
+      idx--;
+      this_val = tbl->contents[idx];
       if (SUB_CHAR_TABLE_P (this_val))
-       this_val = sub_char_table_ref_and_range (this_val, this_to,
-                                                &this_from, &this_to,
-                                                defalt);
+       this_val = sub_char_table_ref_and_range (this_val, c, from, to, defalt);
       else if (NILP (this_val))
        this_val = defalt;
 
       if (! EQ (this_val, val))
+       {
+         *from = c + 1;
        break;
-      *from = this_from;
     }
-  index = CHARTAB_IDX (c, depth, min_char);
-  while (*to < max_char
-        && *to == min_char + (index + 1) * chartab_chars[depth] - 1)
+    }
+  while ((c = min_char + (index + 1) * chartab_chars[depth]) < max_char
+        && *to >= c)
     {
       Lisp_Object this_val;
-      int this_from = *to + 1;
-      int this_to = this_from + chartab_chars[depth] - 1;
 
       index++;
       this_val = tbl->contents[index];
       if (SUB_CHAR_TABLE_P (this_val))
-       this_val = sub_char_table_ref_and_range (this_val, this_from,
-                                                &this_from, &this_to,
-                                                defalt);
+       this_val = sub_char_table_ref_and_range (this_val, c, from, to, defalt);
       else if (NILP (this_val))
        this_val = defalt;
       if (! EQ (this_val, val))
+       {
+         *to = c - 1;
        break;
-      *to = this_to;
+       }
     }
 
   return val;
 }
 
 
-/* Return the value for C in char-table TABLE.  Set *FROM and *TO to
-   the range of characters (containing C) that have the same value as
-   C.  It is not assured that the value of (*FROM - 1) and (*TO + 1)
-   is different from that of C.  */
+/* Return the value for C in char-table TABLE.  Shrink the range *FROM
+   and *TO to cover characters (containing C) that have the same value
+   as C.  It is not assured that the values of (*FROM - 1) and (*TO +
+   1) are different from that of C.  */
 
 Lisp_Object
 char_table_ref_and_range (table, c, from, to)
@@ -297,53 +291,56 @@
      int *from, *to;
 {
   struct Lisp_Char_Table *tbl = XCHAR_TABLE (table);
-  int index = CHARTAB_IDX (c, 0, 0);
+  int index = CHARTAB_IDX (c, 0, 0), idx;
   Lisp_Object val;
 
   val = tbl->contents[index];
-  *from = index * chartab_chars[0];
-  *to = *from + chartab_chars[0] - 1;
+  if (*from < 0)
+    *from = 0;
+  if (*to < 0)
+    *to = MAX_CHAR;
   if (SUB_CHAR_TABLE_P (val))
     val = sub_char_table_ref_and_range (val, c, from, to, tbl->defalt);
   else if (NILP (val))
     val = tbl->defalt;
 
-  while (*from > 0 && *from == index * chartab_chars[0])
+  idx = index;
+  while (*from < idx * chartab_chars[0])
     {
       Lisp_Object this_val;
-      int this_from = *from - chartab_chars[0];
-      int this_to = *from - 1;
 
-      index--;
-      this_val = tbl->contents[index];
+      c = idx * chartab_chars[0] - 1;
+      idx--;
+      this_val = tbl->contents[idx];
       if (SUB_CHAR_TABLE_P (this_val))
-       this_val = sub_char_table_ref_and_range (this_val, this_to,
-                                                &this_from, &this_to,
+       this_val = sub_char_table_ref_and_range (this_val, c, from, to,
                                                 tbl->defalt);
       else if (NILP (this_val))
        this_val = tbl->defalt;
 
       if (! EQ (this_val, val))
+       {
+         *from = c + 1;
        break;
-      *from = this_from;
     }
-  while (*to < MAX_CHAR && *to == (index + 1) * chartab_chars[0] - 1)
+    }
+  while (*to >= (index + 1) * chartab_chars[0])
     {
       Lisp_Object this_val;
-      int this_from = *to + 1;
-      int this_to = this_from + chartab_chars[0] - 1;
 
       index++;
+      c = index * chartab_chars[0];
       this_val = tbl->contents[index];
       if (SUB_CHAR_TABLE_P (this_val))
-       this_val = sub_char_table_ref_and_range (this_val, this_from,
-                                                &this_from, &this_to,
+       this_val = sub_char_table_ref_and_range (this_val, c, from, to,
                                                 tbl->defalt);
       else if (NILP (this_val))
        this_val = tbl->defalt;
       if (! EQ (this_val, val))
+       {
+         *to = c - 1;
        break;
-      *to = this_to;
+       }
     }
 
   return val;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]