aboutsummaryrefslogtreecommitdiffstats
path: root/src/chartab.c
diff options
context:
space:
mode:
authorStefan Monnier2012-03-25 16:37:21 -0400
committerStefan Monnier2012-03-25 16:37:21 -0400
commit699c782b7668c44d0fa4446331b0590a6d5dac82 (patch)
tree5dcce364741d0761920a3d274b0fc8aba4103d45 /src/chartab.c
parent98fb480ee31bf74cf554044f60f21df16566dd7f (diff)
parente99a9b8bdccadded1f6fae88ee7a2a93dfd4eacf (diff)
downloademacs-pending.tar.gz
emacs-pending.zip
Merge from trunkpending
Diffstat (limited to 'src/chartab.c')
-rw-r--r--src/chartab.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/chartab.c b/src/chartab.c
index e900a3ae71f..8d903749284 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -485,7 +485,6 @@ Lisp_Object
485char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val) 485char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val)
486{ 486{
487 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); 487 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table);
488 Lisp_Object *contents = tbl->contents;
489 488
490 if (from == to) 489 if (from == to)
491 char_table_set (table, from, val); 490 char_table_set (table, from, val);
@@ -590,8 +589,6 @@ DEFUN ("set-char-table-extra-slot", Fset_char_table_extra_slot,
590 (Lisp_Object char_table, Lisp_Object n, Lisp_Object value) 589 (Lisp_Object char_table, Lisp_Object n, Lisp_Object value)
591{ 590{
592 CHECK_CHAR_TABLE (char_table); 591 CHECK_CHAR_TABLE (char_table);
593 if (EQ (XCHAR_TABLE (char_table)->purpose, Qchar_code_property_table))
594 error ("Can't change extra-slot of char-code-property-table");
595 CHECK_NUMBER (n); 592 CHECK_NUMBER (n);
596 if (XINT (n) < 0 593 if (XINT (n) < 0
597 || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table))) 594 || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table)))
@@ -750,7 +747,7 @@ equivalent and can be merged. It defaults to `equal'. */)
750 ARG is passed to C_FUNCTION when that is called. 747 ARG is passed to C_FUNCTION when that is called.
751 748
752 It returns the value of last character covered by TABLE (not the 749 It returns the value of last character covered by TABLE (not the
753 value inheritted from the parent), and by side-effect, the car part 750 value inherited from the parent), and by side-effect, the car part
754 of RANGE is updated to the minimum character C where C and all the 751 of RANGE is updated to the minimum character C where C and all the
755 following characters in TABLE have the same value. */ 752 following characters in TABLE have the same value. */
756 753
@@ -759,11 +756,9 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object),
759 Lisp_Object function, Lisp_Object table, Lisp_Object arg, Lisp_Object val, 756 Lisp_Object function, Lisp_Object table, Lisp_Object arg, Lisp_Object val,
760 Lisp_Object range, Lisp_Object top) 757 Lisp_Object range, Lisp_Object top)
761{ 758{
762 /* Pointer to the elements of TABLE. */
763 Lisp_Object *contents;
764 /* Depth of TABLE. */ 759 /* Depth of TABLE. */
765 int depth; 760 int depth;
766 /* Minimum and maxinum characters covered by TABLE. */ 761 /* Minimum and maximum characters covered by TABLE. */
767 int min_char, max_char; 762 int min_char, max_char;
768 /* Number of characters covered by one element of TABLE. */ 763 /* Number of characters covered by one element of TABLE. */
769 int chars_in_block; 764 int chars_in_block;
@@ -777,14 +772,12 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object),
777 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 772 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
778 773
779 depth = XINT (tbl->depth); 774 depth = XINT (tbl->depth);
780 contents = tbl->contents;
781 min_char = XINT (tbl->min_char); 775 min_char = XINT (tbl->min_char);
782 max_char = min_char + chartab_chars[depth - 1] - 1; 776 max_char = min_char + chartab_chars[depth - 1] - 1;
783 } 777 }
784 else 778 else
785 { 779 {
786 depth = 0; 780 depth = 0;
787 contents = XCHAR_TABLE (table)->contents;
788 min_char = 0; 781 min_char = 0;
789 max_char = MAX_CHAR; 782 max_char = MAX_CHAR;
790 } 783 }
@@ -1100,22 +1093,31 @@ map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object),
1100 1093
1101/* Unicode character property tables. 1094/* Unicode character property tables.
1102 1095
1103 This section provides a convenient and efficient way to get a 1096 This section provides a convenient and efficient way to get Unicode
1104 Unicode character property from C code (from Lisp, you must use 1097 character properties of characters from C code (from Lisp, you must
1105 get-char-code-property). 1098 use get-char-code-property).
1106 1099
1107 The typical usage is to get a char-table for a specific property at 1100 The typical usage is to get a char-table object for a specific
1108 a proper initialization time as this: 1101 property like this (use of the "bidi-class" property below is just
1102 an example):
1109 1103
1110 Lisp_Object bidi_class_table = uniprop_table (intern ("bidi-class")); 1104 Lisp_Object bidi_class_table = uniprop_table (intern ("bidi-class"));
1111 1105
1112 and get a property value for character CH as this: 1106 (uniprop_table can return nil if it fails to find data for the
1107 named property, or if it fails to load the appropriate Lisp support
1108 file, so the return value should be tested to be non-nil, before it
1109 is used.)
1113 1110
1114 Lisp_Object bidi_class = CHAR_TABLE_REF (CH, bidi_class_table); 1111 To get a property value for character CH use CHAR_TABLE_REF:
1112
1113 Lisp_Object bidi_class = CHAR_TABLE_REF (bidi_class_table, CH);
1115 1114
1116 In this case, what you actually get is an index number to the 1115 In this case, what you actually get is an index number to the
1117 vector of property values (symbols nil, L, R, etc). 1116 vector of property values (symbols nil, L, R, etc).
1118 1117
1118 The full list of Unicode character properties supported by Emacs is
1119 documented in the ELisp manual, in the node "Character Properties".
1120
1119 A table for Unicode character property has these characteristics: 1121 A table for Unicode character property has these characteristics:
1120 1122
1121 o The purpose is `char-code-property-table', which implies that the 1123 o The purpose is `char-code-property-table', which implies that the
@@ -1127,7 +1129,7 @@ map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object),
1127 means that we don't have to decode values. 1129 means that we don't have to decode values.
1128 1130
1129 o The third extra slot is a Lisp function, an index (integer) to 1131 o The third extra slot is a Lisp function, an index (integer) to
1130 the array uniprop_enncoder[], or nil. If it is a Lisp function, we 1132 the array uniprop_encoder[], or nil. If it is a Lisp function, we
1131 can't use such a table from C (at the moment). If it is nil, it 1133 can't use such a table from C (at the moment). If it is nil, it
1132 means that we don't have to encode values. */ 1134 means that we don't have to encode values. */
1133 1135
@@ -1143,7 +1145,6 @@ uniprop_table_uncompress (Lisp_Object table, int idx)
1143 Lisp_Object sub = make_sub_char_table (3, min_char, Qnil); 1145 Lisp_Object sub = make_sub_char_table (3, min_char, Qnil);
1144 struct Lisp_Sub_Char_Table *subtbl = XSUB_CHAR_TABLE (sub); 1146 struct Lisp_Sub_Char_Table *subtbl = XSUB_CHAR_TABLE (sub);
1145 const unsigned char *p, *pend; 1147 const unsigned char *p, *pend;
1146 int i;
1147 1148
1148 XSUB_CHAR_TABLE (table)->contents[idx] = sub; 1149 XSUB_CHAR_TABLE (table)->contents[idx] = sub;
1149 p = SDATA (val), pend = p + SBYTES (val); 1150 p = SDATA (val), pend = p + SBYTES (val);
@@ -1195,7 +1196,7 @@ uniprop_table_uncompress (Lisp_Object table, int idx)
1195} 1196}
1196 1197
1197 1198
1198/* Decode VALUE as an elemnet of char-table TABLE. */ 1199/* Decode VALUE as an element of char-table TABLE. */
1199 1200
1200static Lisp_Object 1201static Lisp_Object
1201uniprop_decode_value_run_length (Lisp_Object table, Lisp_Object value) 1202uniprop_decode_value_run_length (Lisp_Object table, Lisp_Object value)