aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2008-05-30 21:07:50 +0000
committerStefan Monnier2008-05-30 21:07:50 +0000
commitd0827857e7a2e73907783ccb6e30849c2a056374 (patch)
treed191220cab996a4154122e5ffe9d932e134aa0ca /src
parent01b996adc3fe81b4e6fa38ce531e05a6506fc6bf (diff)
downloademacs-d0827857e7a2e73907783ccb6e30849c2a056374.tar.gz
emacs-d0827857e7a2e73907783ccb6e30849c2a056374.zip
* chartab.c (Foptimize_char_table, optimize_sub_char_table):
Add a `test' argument so another predicate than `equal' can be used. (map_sub_char_table): Use `eq' rather than `equal' to merge ranges. (map_char_table): Remove unused vars `c' and `i'. * lisp.h (Foptimize_char_table): Adjust declaration. * charset.c (Fclear_charset_maps): Adjust call to Foptimize_char_table.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog12
-rw-r--r--src/charset.c2
-rw-r--r--src/chartab.c35
-rw-r--r--src/lisp.h2
4 files changed, 31 insertions, 20 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index dd62f1306ea..0c1125c9e05 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,15 @@
12008-05-30 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * chartab.c (Foptimize_char_table, optimize_sub_char_table):
4 Add a `test' argument so another predicate than `equal' can be used.
5 (map_sub_char_table): Use `eq' rather than `equal' to merge ranges.
6 (map_char_table): Remove unused vars `c' and `i'.
7 * lisp.h (Foptimize_char_table): Adjust declaration.
8 * charset.c (Fclear_charset_maps): Adjust call to Foptimize_char_table.
9
12008-05-30 Kenichi Handa <handa@m17n.org> 102008-05-30 Kenichi Handa <handa@m17n.org>
2 11
3 * font.c (Ffont_info): Define only if HAVE_WINDOW_SYSTEM is 12 * font.c (Ffont_info): Define only if HAVE_WINDOW_SYSTEM is defined.
4 defined.
5 (syms_of_font): Defsubr Sfont_info only if HAVE_WINDOW_SYSTEM is 13 (syms_of_font): Defsubr Sfont_info only if HAVE_WINDOW_SYSTEM is
6 defined. 14 defined.
7 15
diff --git a/src/charset.c b/src/charset.c
index e5e8c56541e..052c511f6a3 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1952,7 +1952,7 @@ Clear encoder and decoder of charsets that are loaded from mapfiles. */)
1952 1952
1953 if (CHAR_TABLE_P (Vchar_unified_charset_table)) 1953 if (CHAR_TABLE_P (Vchar_unified_charset_table))
1954 { 1954 {
1955 Foptimize_char_table (Vchar_unified_charset_table); 1955 Foptimize_char_table (Vchar_unified_charset_table, Qnil);
1956 Vchar_unify_table = Vchar_unified_charset_table; 1956 Vchar_unify_table = Vchar_unified_charset_table;
1957 Vchar_unified_charset_table = Qnil; 1957 Vchar_unified_charset_table = Qnil;
1958 } 1958 }
diff --git a/src/chartab.c b/src/chartab.c
index 165fa0dd895..7e43aa4e315 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -159,14 +159,12 @@ copy_char_table (table)
159 XCHAR_TABLE (copy)->defalt = XCHAR_TABLE (table)->defalt; 159 XCHAR_TABLE (copy)->defalt = XCHAR_TABLE (table)->defalt;
160 XCHAR_TABLE (copy)->parent = XCHAR_TABLE (table)->parent; 160 XCHAR_TABLE (copy)->parent = XCHAR_TABLE (table)->parent;
161 XCHAR_TABLE (copy)->purpose = XCHAR_TABLE (table)->purpose; 161 XCHAR_TABLE (copy)->purpose = XCHAR_TABLE (table)->purpose;
162 XCHAR_TABLE (copy)->ascii = XCHAR_TABLE (table)->ascii;
163 for (i = 0; i < chartab_size[0]; i++) 162 for (i = 0; i < chartab_size[0]; i++)
164 XCHAR_TABLE (copy)->contents[i] 163 XCHAR_TABLE (copy)->contents[i]
165 = (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i]) 164 = (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i])
166 ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i]) 165 ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i])
167 : XCHAR_TABLE (table)->contents[i]); 166 : XCHAR_TABLE (table)->contents[i]);
168 if (SUB_CHAR_TABLE_P (XCHAR_TABLE (copy)->ascii)) 167 XCHAR_TABLE (copy)->ascii = char_table_ascii (copy);
169 XCHAR_TABLE (copy)->ascii = char_table_ascii (copy);
170 size -= VECSIZE (struct Lisp_Char_Table) - 1; 168 size -= VECSIZE (struct Lisp_Char_Table) - 1;
171 for (i = 0; i < size; i++) 169 for (i = 0; i < size; i++)
172 XCHAR_TABLE (copy)->extras[i] = XCHAR_TABLE (table)->extras[i]; 170 XCHAR_TABLE (copy)->extras[i] = XCHAR_TABLE (table)->extras[i];
@@ -656,8 +654,8 @@ char_table_translate (table, ch)
656} 654}
657 655
658static Lisp_Object 656static Lisp_Object
659optimize_sub_char_table (table) 657optimize_sub_char_table (table, test)
660 Lisp_Object table; 658 Lisp_Object table, test;
661{ 659{
662 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 660 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
663 int depth = XINT (tbl->depth); 661 int depth = XINT (tbl->depth);
@@ -666,7 +664,8 @@ optimize_sub_char_table (table)
666 664
667 elt = XSUB_CHAR_TABLE (table)->contents[0]; 665 elt = XSUB_CHAR_TABLE (table)->contents[0];
668 if (SUB_CHAR_TABLE_P (elt)) 666 if (SUB_CHAR_TABLE_P (elt))
669 elt = XSUB_CHAR_TABLE (table)->contents[0] = optimize_sub_char_table (elt); 667 elt = XSUB_CHAR_TABLE (table)->contents[0]
668 = optimize_sub_char_table (elt, test);
670 if (SUB_CHAR_TABLE_P (elt)) 669 if (SUB_CHAR_TABLE_P (elt))
671 return table; 670 return table;
672 for (i = 1; i < chartab_size[depth]; i++) 671 for (i = 1; i < chartab_size[depth]; i++)
@@ -674,9 +673,11 @@ optimize_sub_char_table (table)
674 this = XSUB_CHAR_TABLE (table)->contents[i]; 673 this = XSUB_CHAR_TABLE (table)->contents[i];
675 if (SUB_CHAR_TABLE_P (this)) 674 if (SUB_CHAR_TABLE_P (this))
676 this = XSUB_CHAR_TABLE (table)->contents[i] 675 this = XSUB_CHAR_TABLE (table)->contents[i]
677 = optimize_sub_char_table (this); 676 = optimize_sub_char_table (this, test);
678 if (SUB_CHAR_TABLE_P (this) 677 if (SUB_CHAR_TABLE_P (this)
679 || NILP (Fequal (this, elt))) 678 || (NILP (test) ? NILP (Fequal (this, elt)) /* defaults to `equal'. */
679 : EQ (test, Qeq) ? !EQ (this, elt) /* Optimize `eq' case. */
680 : NILP (call2 (test, this, elt))))
680 break; 681 break;
681 } 682 }
682 683
@@ -684,10 +685,12 @@ optimize_sub_char_table (table)
684} 685}
685 686
686DEFUN ("optimize-char-table", Foptimize_char_table, Soptimize_char_table, 687DEFUN ("optimize-char-table", Foptimize_char_table, Soptimize_char_table,
687 1, 1, 0, 688 1, 2, 0,
688 doc: /* Optimize CHAR-TABLE. */) 689 doc: /* Optimize CHAR-TABLE.
689 (char_table) 690TEST is the comparison function used to decide whether two entries are
690 Lisp_Object char_table; 691equivalent and can be merged. It defaults to `equal'. */)
692 (char_table, test)
693 Lisp_Object char_table, test;
691{ 694{
692 Lisp_Object elt; 695 Lisp_Object elt;
693 int i; 696 int i;
@@ -698,7 +701,8 @@ DEFUN ("optimize-char-table", Foptimize_char_table, Soptimize_char_table,
698 { 701 {
699 elt = XCHAR_TABLE (char_table)->contents[i]; 702 elt = XCHAR_TABLE (char_table)->contents[i];
700 if (SUB_CHAR_TABLE_P (elt)) 703 if (SUB_CHAR_TABLE_P (elt))
701 XCHAR_TABLE (char_table)->contents[i] = optimize_sub_char_table (elt); 704 XCHAR_TABLE (char_table)->contents[i]
705 = optimize_sub_char_table (elt, test);
702 } 706 }
703 return Qnil; 707 return Qnil;
704} 708}
@@ -777,7 +781,7 @@ map_sub_char_table (c_function, function, table, arg, val, range,
777 { 781 {
778 if (NILP (this)) 782 if (NILP (this))
779 this = default_val; 783 this = default_val;
780 if (NILP (Fequal (val, this))) 784 if (!EQ (val, this))
781 { 785 {
782 int different_value = 1; 786 int different_value = 1;
783 787
@@ -797,7 +801,7 @@ map_sub_char_table (c_function, function, table, arg, val, range,
797 parent, arg, val, range, 801 parent, arg, val, range,
798 XCHAR_TABLE (parent)->defalt, 802 XCHAR_TABLE (parent)->defalt,
799 XCHAR_TABLE (parent)->parent); 803 XCHAR_TABLE (parent)->parent);
800 if (! NILP (Fequal (val, this))) 804 if (EQ (val, this))
801 different_value = 0; 805 different_value = 0;
802 } 806 }
803 } 807 }
@@ -841,7 +845,6 @@ map_char_table (c_function, function, table, arg)
841 Lisp_Object function, table, arg; 845 Lisp_Object function, table, arg;
842{ 846{
843 Lisp_Object range, val; 847 Lisp_Object range, val;
844 int c, i;
845 struct gcpro gcpro1, gcpro2, gcpro3; 848 struct gcpro gcpro1, gcpro2, gcpro3;
846 849
847 range = Fcons (make_number (0), make_number (MAX_CHAR)); 850 range = Fcons (make_number (0), make_number (MAX_CHAR));
diff --git a/src/lisp.h b/src/lisp.h
index 288d9642b87..b512fb3c657 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2628,7 +2628,7 @@ EXFUN (Fset_char_table_extra_slot, 3);
2628EXFUN (Fchar_table_range, 2); 2628EXFUN (Fchar_table_range, 2);
2629EXFUN (Fset_char_table_range, 3); 2629EXFUN (Fset_char_table_range, 3);
2630EXFUN (Fset_char_table_default, 3); 2630EXFUN (Fset_char_table_default, 3);
2631EXFUN (Foptimize_char_table, 1); 2631EXFUN (Foptimize_char_table, 2);
2632EXFUN (Fmap_char_table, 2); 2632EXFUN (Fmap_char_table, 2);
2633extern Lisp_Object copy_char_table P_ ((Lisp_Object)); 2633extern Lisp_Object copy_char_table P_ ((Lisp_Object));
2634extern Lisp_Object sub_char_table_ref P_ ((Lisp_Object, int)); 2634extern Lisp_Object sub_char_table_ref P_ ((Lisp_Object, int));