219 |
} |
} |
220 |
|
|
221 |
static Lisp_Object |
static Lisp_Object |
222 |
sub_char_table_ref_and_range (table, c, from, to) |
sub_char_table_ref_and_range (table, c, from, to, defalt) |
223 |
Lisp_Object table; |
Lisp_Object table; |
224 |
int c; |
int c; |
225 |
int *from, *to; |
int *from, *to; |
226 |
|
Lisp_Object defalt; |
227 |
{ |
{ |
228 |
struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); |
struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); |
229 |
int depth = XINT (tbl->depth); |
int depth = XINT (tbl->depth); |
230 |
int min_char = XINT (tbl->min_char); |
int min_char = XINT (tbl->min_char); |
231 |
|
int max_char = min_char + chartab_chars[depth - 1] - 1; |
232 |
|
int index = CHARTAB_IDX (c, depth, min_char); |
233 |
Lisp_Object val; |
Lisp_Object val; |
234 |
|
|
235 |
val = tbl->contents[CHARTAB_IDX (c, depth, min_char)]; |
val = tbl->contents[index]; |
236 |
if (depth == 3) |
*from = min_char + index * chartab_chars[depth]; |
237 |
{ |
*to = *from + chartab_chars[depth] - 1; |
238 |
*from = *to = c; |
if (SUB_CHAR_TABLE_P (val)) |
239 |
} |
val = sub_char_table_ref_and_range (val, c, from, to, defalt); |
240 |
else if (SUB_CHAR_TABLE_P (val)) |
else if (NILP (val)) |
241 |
{ |
val = defalt; |
242 |
val = sub_char_table_ref_and_range (val, c, from, to); |
|
243 |
|
while (*from > min_char |
244 |
|
&& *from == min_char + index * chartab_chars[depth]) |
245 |
|
{ |
246 |
|
Lisp_Object this_val; |
247 |
|
int this_from = *from - chartab_chars[depth]; |
248 |
|
int this_to = *from - 1; |
249 |
|
|
250 |
|
index--; |
251 |
|
this_val = tbl->contents[index]; |
252 |
|
if (SUB_CHAR_TABLE_P (this_val)) |
253 |
|
this_val = sub_char_table_ref_and_range (this_val, this_to, |
254 |
|
&this_from, &this_to, |
255 |
|
defalt); |
256 |
|
else if (NILP (this_val)) |
257 |
|
this_val = defalt; |
258 |
|
|
259 |
|
if (! EQ (this_val, val)) |
260 |
|
break; |
261 |
|
*from = this_from; |
262 |
} |
} |
263 |
else |
index = CHARTAB_IDX (c, depth, min_char); |
264 |
{ |
while (*to < max_char |
265 |
*from = (CHARTAB_IDX (c, depth, min_char) * chartab_chars[depth] |
&& *to == min_char + (index + 1) * chartab_chars[depth] - 1) |
266 |
+ min_char); |
{ |
267 |
*to = *from + chartab_chars[depth] - 1; |
Lisp_Object this_val; |
268 |
|
int this_from = *to + 1; |
269 |
|
int this_to = this_from + chartab_chars[depth] - 1; |
270 |
|
|
271 |
|
index++; |
272 |
|
this_val = tbl->contents[index]; |
273 |
|
if (SUB_CHAR_TABLE_P (this_val)) |
274 |
|
this_val = sub_char_table_ref_and_range (this_val, this_from, |
275 |
|
&this_from, &this_to, |
276 |
|
defalt); |
277 |
|
else if (NILP (this_val)) |
278 |
|
this_val = defalt; |
279 |
|
if (! EQ (this_val, val)) |
280 |
|
break; |
281 |
|
*to = this_to; |
282 |
} |
} |
283 |
|
|
284 |
return val; |
return val; |
285 |
} |
} |
286 |
|
|
287 |
|
|
288 |
|
/* Return the value for C in char-table TABLE. Set *FROM and *TO to |
289 |
|
the range of characters (containing C) that have the same value as |
290 |
|
C. It is not assured that the value of (*FROM - 1) and (*TO + 1) |
291 |
|
is different from that of C. */ |
292 |
|
|
293 |
Lisp_Object |
Lisp_Object |
294 |
char_table_ref_and_range (table, c, from, to) |
char_table_ref_and_range (table, c, from, to) |
295 |
Lisp_Object table; |
Lisp_Object table; |
297 |
int *from, *to; |
int *from, *to; |
298 |
{ |
{ |
299 |
struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); |
300 |
|
int index = CHARTAB_IDX (c, 0, 0); |
301 |
Lisp_Object val; |
Lisp_Object val; |
302 |
|
|
303 |
if (ASCII_CHAR_P (c)) |
val = tbl->contents[index]; |
304 |
{ |
*from = index * chartab_chars[0]; |
305 |
val = tbl->ascii; |
*to = *from + chartab_chars[0] - 1; |
306 |
if (SUB_CHAR_TABLE_P (val)) |
if (SUB_CHAR_TABLE_P (val)) |
307 |
{ |
val = sub_char_table_ref_and_range (val, c, from, to, tbl->defalt); |
308 |
val = XSUB_CHAR_TABLE (val)->contents[c]; |
else if (NILP (val)) |
309 |
*from = *to = c; |
val = tbl->defalt; |
310 |
} |
|
311 |
else |
while (*from > 0 && *from == index * chartab_chars[0]) |
312 |
{ |
{ |
313 |
*from = 0, *to = 127; |
Lisp_Object this_val; |
314 |
} |
int this_from = *from - chartab_chars[0]; |
315 |
|
int this_to = *from - 1; |
316 |
|
|
317 |
|
index--; |
318 |
|
this_val = tbl->contents[index]; |
319 |
|
if (SUB_CHAR_TABLE_P (this_val)) |
320 |
|
this_val = sub_char_table_ref_and_range (this_val, this_to, |
321 |
|
&this_from, &this_to, |
322 |
|
tbl->defalt); |
323 |
|
else if (NILP (this_val)) |
324 |
|
this_val = tbl->defalt; |
325 |
|
|
326 |
|
if (! EQ (this_val, val)) |
327 |
|
break; |
328 |
|
*from = this_from; |
329 |
} |
} |
330 |
else |
while (*to < MAX_CHAR && *to == (index + 1) * chartab_chars[0] - 1) |
331 |
{ |
{ |
332 |
val = tbl->contents[CHARTAB_IDX (c, 0, 0)]; |
Lisp_Object this_val; |
333 |
if (SUB_CHAR_TABLE_P (val)) |
int this_from = *to + 1; |
334 |
{ |
int this_to = this_from + chartab_chars[0] - 1; |
335 |
val = sub_char_table_ref_and_range (val, c, from, to); |
|
336 |
} |
index++; |
337 |
else |
this_val = tbl->contents[index]; |
338 |
{ |
if (SUB_CHAR_TABLE_P (this_val)) |
339 |
*from = CHARTAB_IDX (c, 0, 0) * chartab_chars[0]; |
this_val = sub_char_table_ref_and_range (this_val, this_from, |
340 |
*to = *from + chartab_chars[0] - 1; |
&this_from, &this_to, |
341 |
} |
tbl->defalt); |
342 |
|
else if (NILP (this_val)) |
343 |
|
this_val = tbl->defalt; |
344 |
|
if (! EQ (this_val, val)) |
345 |
|
break; |
346 |
|
*to = this_to; |
347 |
} |
} |
348 |
|
|
|
if (NILP (val)) |
|
|
{ |
|
|
val = tbl->defalt; |
|
|
*from = 0, *to = MAX_CHAR; |
|
|
if (NILP (val) && CHAR_TABLE_P (tbl->parent)) |
|
|
val = char_table_ref_and_range (tbl->parent, c, from, to); |
|
|
} |
|
349 |
return val; |
return val; |
350 |
} |
} |
351 |
|
|
352 |
|
|
353 |
#define ASET_RANGE(ARRAY, FROM, TO, LIMIT, VAL) \ |
#define ASET_RANGE(ARRAY, FROM, TO, LIMIT, VAL) \ |
810 |
return Qnil; |
return Qnil; |
811 |
} |
} |
812 |
|
|
813 |
|
|
814 |
|
static void |
815 |
|
map_sub_char_table_for_charset (c_function, function, table, arg, range, |
816 |
|
charset, from, to) |
817 |
|
void (*c_function) P_ ((Lisp_Object, Lisp_Object)); |
818 |
|
Lisp_Object function, table, arg, range; |
819 |
|
struct charset *charset; |
820 |
|
unsigned from, to; |
821 |
|
{ |
822 |
|
struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); |
823 |
|
int depth = XINT (tbl->depth); |
824 |
|
int c, i; |
825 |
|
|
826 |
|
if (depth < 3) |
827 |
|
for (i = 0, c = XINT (tbl->min_char); i < chartab_size[depth]; |
828 |
|
i++, c += chartab_chars[depth]) |
829 |
|
{ |
830 |
|
Lisp_Object this; |
831 |
|
|
832 |
|
this = tbl->contents[i]; |
833 |
|
if (SUB_CHAR_TABLE_P (this)) |
834 |
|
map_sub_char_table_for_charset (c_function, function, this, arg, |
835 |
|
range, charset, from, to); |
836 |
|
else |
837 |
|
{ |
838 |
|
if (! NILP (XCAR (range))) |
839 |
|
{ |
840 |
|
XSETCDR (range, make_number (c - 1)); |
841 |
|
if (c_function) |
842 |
|
(*c_function) (arg, range); |
843 |
|
else |
844 |
|
call2 (function, range, arg); |
845 |
|
} |
846 |
|
XSETCAR (range, Qnil); |
847 |
|
} |
848 |
|
} |
849 |
|
else |
850 |
|
for (i = 0, c = XINT (tbl->min_char); i < chartab_size[depth]; i++, c ++) |
851 |
|
{ |
852 |
|
Lisp_Object this; |
853 |
|
unsigned code; |
854 |
|
|
855 |
|
this = tbl->contents[i]; |
856 |
|
if (NILP (this) |
857 |
|
|| (charset |
858 |
|
&& (code = ENCODE_CHAR (charset, c), |
859 |
|
(code < from || code > to)))) |
860 |
|
{ |
861 |
|
if (! NILP (XCAR (range))) |
862 |
|
{ |
863 |
|
XSETCDR (range, make_number (c - 1)); |
864 |
|
if (c_function) |
865 |
|
(*c_function) (range, arg); |
866 |
|
else |
867 |
|
call2 (function, range, arg); |
868 |
|
XSETCAR (range, Qnil); |
869 |
|
} |
870 |
|
} |
871 |
|
else |
872 |
|
{ |
873 |
|
if (NILP (XCAR (range))) |
874 |
|
XSETCAR (range, make_number (c)); |
875 |
|
} |
876 |
|
} |
877 |
|
} |
878 |
|
|
879 |
|
|
880 |
|
void |
881 |
|
map_char_table_for_charset (c_function, function, table, arg, |
882 |
|
charset, from, to) |
883 |
|
void (*c_function) P_ ((Lisp_Object, Lisp_Object)); |
884 |
|
Lisp_Object function, table, arg; |
885 |
|
struct charset *charset; |
886 |
|
unsigned from, to; |
887 |
|
{ |
888 |
|
Lisp_Object range; |
889 |
|
int c, i; |
890 |
|
|
891 |
|
if (NILP (char_table_ref (table, 0))) |
892 |
|
range = Fcons (Qnil, Qnil); |
893 |
|
else |
894 |
|
range = Fcons (make_number (0), make_number (0)); |
895 |
|
|
896 |
|
for (i = 0, c = 0; i < chartab_size[0]; i++, c += chartab_chars[0]) |
897 |
|
{ |
898 |
|
Lisp_Object this; |
899 |
|
|
900 |
|
this = XCHAR_TABLE (table)->contents[i]; |
901 |
|
if (SUB_CHAR_TABLE_P (this)) |
902 |
|
map_sub_char_table_for_charset (c_function, function, this, arg, |
903 |
|
range, charset, from, to); |
904 |
|
else |
905 |
|
{ |
906 |
|
if (! NILP (XCAR (range))) |
907 |
|
{ |
908 |
|
XSETCDR (range, make_number (c - 1)); |
909 |
|
if (c_function) |
910 |
|
(*c_function) (arg, range); |
911 |
|
else |
912 |
|
call2 (function, range, arg); |
913 |
|
} |
914 |
|
XSETCAR (range, Qnil); |
915 |
|
} |
916 |
|
} |
917 |
|
if (! NILP (XCAR (range))) |
918 |
|
{ |
919 |
|
XSETCDR (range, make_number (c - 1)); |
920 |
|
if (c_function) |
921 |
|
(*c_function) (arg, range); |
922 |
|
else |
923 |
|
call2 (function, range, arg); |
924 |
|
} |
925 |
|
} |
926 |
|
|
927 |
|
|
928 |
|
|
929 |
#if 0 |
#if 0 |
930 |
Lisp_Object |
Lisp_Object |