comparison src/casetab.c @ 13276:a09ec2a2f6dd

(Fcase_table_p, Fcurrent_case_table): Delete unused local variables. (set_case_table): Delete obsolete local variable `down'; use `table' directly where referenced. Fix assignment to `canon' when nil. Store eqv in extras[2], not extras[0]. (init_casetab_once): Case-tables have 3 extra slots, not 4.
author Erik Naggum <erik@naggum.no>
date Mon, 23 Oct 1995 04:35:45 +0000
parents 3a8c500b97c3
children a0437a2c2dd4
comparison
equal deleted inserted replaced
13275:33bdb63a2c59 13276:a09ec2a2f6dd
33 "Return t iff ARG is a case table.\n\ 33 "Return t iff ARG is a case table.\n\
34 See `set-case-table' for more information on these data structures.") 34 See `set-case-table' for more information on these data structures.")
35 (table) 35 (table)
36 Lisp_Object table; 36 Lisp_Object table;
37 { 37 {
38 Lisp_Object down, up, canon, eqv; 38 Lisp_Object up, canon, eqv;
39 39
40 if (! CHAR_TABLE_P (table)) 40 if (! CHAR_TABLE_P (table))
41 return Qnil; 41 return Qnil;
42 if (! EQ (XCHAR_TABLE (table)->purpose, Qcase_table)) 42 if (! EQ (XCHAR_TABLE (table)->purpose, Qcase_table))
43 return Qnil; 43 return Qnil;
66 66
67 DEFUN ("current-case-table", Fcurrent_case_table, Scurrent_case_table, 0, 0, 0, 67 DEFUN ("current-case-table", Fcurrent_case_table, Scurrent_case_table, 0, 0, 0,
68 "Return the case table of the current buffer.") 68 "Return the case table of the current buffer.")
69 () 69 ()
70 { 70 {
71 Lisp_Object down, up, canon, eqv;
72
73 return current_buffer->downcase_table; 71 return current_buffer->downcase_table;
74 } 72 }
75 73
76 DEFUN ("standard-case-table", Fstandard_case_table, Sstandard_case_table, 0, 0, 0, 74 DEFUN ("standard-case-table", Fstandard_case_table, Sstandard_case_table, 0, 0, 0,
77 "Return the standard case table.\n\ 75 "Return the standard case table.\n\
117 static Lisp_Object 115 static Lisp_Object
118 set_case_table (table, standard) 116 set_case_table (table, standard)
119 Lisp_Object table; 117 Lisp_Object table;
120 int standard; 118 int standard;
121 { 119 {
122 Lisp_Object down, up, canon, eqv; 120 Lisp_Object up, canon, eqv;
123 121
124 check_case_table (table); 122 check_case_table (table);
125 123
126 up = XCHAR_TABLE (table)->extras[0]; 124 up = XCHAR_TABLE (table)->extras[0];
127 canon = XCHAR_TABLE (table)->extras[1]; 125 canon = XCHAR_TABLE (table)->extras[1];
128 eqv = XCHAR_TABLE (table)->extras[2]; 126 eqv = XCHAR_TABLE (table)->extras[2];
129 127
130 if (NILP (up)) 128 if (NILP (up))
131 { 129 {
132 up = Fmake_char_table (Qcase_table, Qnil); 130 up = Fmake_char_table (Qcase_table, Qnil);
133 compute_trt_inverse (XCHAR_TABLE (down), XCHAR_TABLE (up)); 131 compute_trt_inverse (XCHAR_TABLE (table), XCHAR_TABLE (up));
134 XCHAR_TABLE (table)->extras[0] = up; 132 XCHAR_TABLE (table)->extras[0] = up;
135 } 133 }
136 134
137 if (NILP (canon)) 135 if (NILP (canon))
138 { 136 {
139 register int i; 137 register int i;
140 Lisp_Object *upvec = XCHAR_TABLE (up)->contents; 138 Lisp_Object *upvec = XCHAR_TABLE (up)->contents;
141 Lisp_Object *downvec = XCHAR_TABLE (down)->contents; 139 Lisp_Object *downvec = XCHAR_TABLE (table)->contents;
142 140
143 up = Fmake_char_table (Qcase_table, Qnil); 141 canon = Fmake_char_table (Qcase_table, Qnil);
144 142
145 /* Set up the CANON vector; for each character, 143 /* Set up the CANON vector; for each character,
146 this sequence of upcasing and downcasing ought to 144 this sequence of upcasing and downcasing ought to
147 get the "preferred" lowercase equivalent. */ 145 get the "preferred" lowercase equivalent. */
148 for (i = 0; i < 256; i++) 146 for (i = 0; i < 256; i++)
152 150
153 if (NILP (eqv)) 151 if (NILP (eqv))
154 { 152 {
155 eqv = Fmake_char_table (Qcase_table, Qnil); 153 eqv = Fmake_char_table (Qcase_table, Qnil);
156 compute_trt_inverse (XCHAR_TABLE (canon), XCHAR_TABLE (eqv)); 154 compute_trt_inverse (XCHAR_TABLE (canon), XCHAR_TABLE (eqv));
157 XCHAR_TABLE (table)->extras[0] = eqv; 155 XCHAR_TABLE (table)->extras[2] = eqv;
158 } 156 }
159 157
160 if (standard) 158 if (standard)
161 Vascii_downcase_table = down; 159 Vascii_downcase_table = table;
162 else 160 else
163 current_buffer->downcase_table = down; 161 current_buffer->downcase_table = table;
164 162
165 return table; 163 return table;
166 } 164 }
167 165
168 /* Given a translate table TRT, store the inverse mapping into INVERSE. 166 /* Given a translate table TRT, store the inverse mapping into INVERSE.
204 But don't staticpro it here--that is done in alloc.c. */ 202 But don't staticpro it here--that is done in alloc.c. */
205 Qchar_table_extra_slots = intern ("char-table-extra-slots"); 203 Qchar_table_extra_slots = intern ("char-table-extra-slots");
206 204
207 /* Now we are ready to set up this property, so we can 205 /* Now we are ready to set up this property, so we can
208 create char tables. */ 206 create char tables. */
209 Fput (Qcase_table, Qchar_table_extra_slots, make_number (4)); 207 Fput (Qcase_table, Qchar_table_extra_slots, make_number (3));
210 208
211 down = Fmake_char_table (Qcase_table, Qnil); 209 down = Fmake_char_table (Qcase_table, Qnil);
212 Vascii_downcase_table = down; 210 Vascii_downcase_table = down;
213 211
214 for (i = 0; i < 256; i++) 212 for (i = 0; i < 256; i++)