Mercurial > emacs
comparison src/casetab.c @ 17807:8a8e26aa76ed
(compute_trt_identity): Use make_sub_char_table.
(compute_trt_identity, compute_trt_shuffle):
Set up bytes[0] with the charset code.
Check for a sub-char-table when deciding to recurse.
Terminate the loop properly for a sub-char-table.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 15 May 1997 03:22:38 +0000 |
parents | 5977a67b9356 |
children | c407a3aca56f |
comparison
equal
deleted
inserted
replaced
17806:96eb40f791e4 | 17807:8a8e26aa76ed |
---|---|
175 unsigned char *bytes; | 175 unsigned char *bytes; |
176 int depth; | 176 int depth; |
177 struct Lisp_Char_Table *trt, *inverse; | 177 struct Lisp_Char_Table *trt, *inverse; |
178 { | 178 { |
179 register int i; | 179 register int i; |
180 | 180 int lim = (depth == 0 ? CHAR_TABLE_ORDINARY_SLOTS : SUB_CHAR_TABLE_ORDINARY_SLOTS); |
181 for (i = 0; i < CHAR_TABLE_ORDINARY_SLOTS; i++) | 181 |
182 for (i = 0; i < lim; i++) | |
182 { | 183 { |
183 if (NATNUMP (trt->contents[i])) | 184 if (NATNUMP (trt->contents[i])) |
184 { | 185 { |
185 bytes[depth] = i; | 186 bytes[depth] = i; |
186 XSETFASTINT (inverse->contents[i], | 187 XSETFASTINT (inverse->contents[i], |
187 (depth == 0 && i < CHAR_TABLE_SINGLE_BYTE_SLOTS ? i | 188 (depth == 0 && i < CHAR_TABLE_SINGLE_BYTE_SLOTS ? i |
188 : MAKE_NON_ASCII_CHAR (bytes[0]-128, | 189 : MAKE_NON_ASCII_CHAR (bytes[0], bytes[1], bytes[2]))); |
189 bytes[1], bytes[2]))); | |
190 } | 190 } |
191 else if (CHAR_TABLE_P (trt->contents[i])) | 191 else if (SUB_CHAR_TABLE_P (trt->contents[i])) |
192 { | 192 { |
193 bytes[depth] = i; | 193 bytes[depth] = i - 128; |
194 inverse->contents[i] = Fmake_char_table (Qnil, Qnil); | 194 inverse->contents[i] = make_sub_char_table (Qnil); |
195 compute_trt_identity (bytes, depth + 1, | 195 compute_trt_identity (bytes, depth + 1, |
196 XCHAR_TABLE (trt->contents[i]), | 196 XCHAR_TABLE (trt->contents[i]), |
197 XCHAR_TABLE (inverse->contents[i])); | 197 XCHAR_TABLE (inverse->contents[i])); |
198 } | 198 } |
199 else /* must be Qnil or Qidentity */ | 199 else /* must be Qnil or Qidentity */ |
208 Lisp_Object ibase; | 208 Lisp_Object ibase; |
209 struct Lisp_Char_Table *trt, *inverse; | 209 struct Lisp_Char_Table *trt, *inverse; |
210 { | 210 { |
211 register int i; | 211 register int i; |
212 Lisp_Object j, tem, q; | 212 Lisp_Object j, tem, q; |
213 | 213 int lim = (depth == 0 ? CHAR_TABLE_ORDINARY_SLOTS : SUB_CHAR_TABLE_ORDINARY_SLOTS); |
214 for (i = 0; i < CHAR_TABLE_SINGLE_BYTE_SLOTS; i++) | 214 |
215 for (i = 0; i < lim; i++) | |
215 { | 216 { |
216 bytes[depth] = i; | 217 bytes[depth] = i; |
217 XSETFASTINT (j, | 218 XSETFASTINT (j, |
218 (depth == 0 && i < CHAR_TABLE_SINGLE_BYTE_SLOTS ? i | 219 (depth == 0 && i < CHAR_TABLE_SINGLE_BYTE_SLOTS ? i |
219 : MAKE_NON_ASCII_CHAR (bytes[0]-128, | 220 : MAKE_NON_ASCII_CHAR (bytes[0], bytes[1], bytes[2]))); |
220 bytes[1], bytes[2]))); | |
221 q = trt->contents[i]; | 221 q = trt->contents[i]; |
222 if (NATNUMP (q) && XFASTINT (q) != XFASTINT (j)) | 222 if (NATNUMP (q) && XFASTINT (q) != XFASTINT (j)) |
223 { | 223 { |
224 tem = Faref (ibase, q); | 224 tem = Faref (ibase, q); |
225 Faset (ibase, q, j); | 225 Faset (ibase, q, j); |
226 Faset (ibase, j, tem); | 226 Faset (ibase, j, tem); |
227 } | 227 } |
228 else if (CHAR_TABLE_P (q)) | 228 else if (SUB_CHAR_TABLE_P (q)) |
229 { | 229 { |
230 bytes[depth] = i; | 230 bytes[depth] = i - 128; |
231 compute_trt_shuffle (bytes, depth + 1, ibase, | 231 compute_trt_shuffle (bytes, depth + 1, ibase, |
232 XCHAR_TABLE (trt->contents[i]), | 232 XCHAR_TABLE (trt->contents[i]), |
233 XCHAR_TABLE (inverse->contents[i])); | 233 XCHAR_TABLE (inverse->contents[i])); |
234 } | 234 } |
235 } | 235 } |