aboutsummaryrefslogtreecommitdiffstats
path: root/src/chartab.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/chartab.c')
-rw-r--r--src/chartab.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/src/chartab.c b/src/chartab.c
index cd8aa784eb4..85aa5932ac3 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -118,7 +118,7 @@ char_table_ascii (Lisp_Object table)
118 return XSUB_CHAR_TABLE (sub)->contents[0]; 118 return XSUB_CHAR_TABLE (sub)->contents[0];
119} 119}
120 120
121Lisp_Object 121static Lisp_Object
122copy_sub_char_table (Lisp_Object table) 122copy_sub_char_table (Lisp_Object table)
123{ 123{
124 Lisp_Object copy; 124 Lisp_Object copy;
@@ -216,16 +216,16 @@ sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, Lisp
216 int depth = XINT (tbl->depth); 216 int depth = XINT (tbl->depth);
217 int min_char = XINT (tbl->min_char); 217 int min_char = XINT (tbl->min_char);
218 int max_char = min_char + chartab_chars[depth - 1] - 1; 218 int max_char = min_char + chartab_chars[depth - 1] - 1;
219 int index = CHARTAB_IDX (c, depth, min_char), idx; 219 int chartab_idx = CHARTAB_IDX (c, depth, min_char), idx;
220 Lisp_Object val; 220 Lisp_Object val;
221 221
222 val = tbl->contents[index]; 222 val = tbl->contents[chartab_idx];
223 if (SUB_CHAR_TABLE_P (val)) 223 if (SUB_CHAR_TABLE_P (val))
224 val = sub_char_table_ref_and_range (val, c, from, to, defalt); 224 val = sub_char_table_ref_and_range (val, c, from, to, defalt);
225 else if (NILP (val)) 225 else if (NILP (val))
226 val = defalt; 226 val = defalt;
227 227
228 idx = index; 228 idx = chartab_idx;
229 while (idx > 0 && *from < min_char + idx * chartab_chars[depth]) 229 while (idx > 0 && *from < min_char + idx * chartab_chars[depth])
230 { 230 {
231 Lisp_Object this_val; 231 Lisp_Object this_val;
@@ -244,13 +244,13 @@ sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, Lisp
244 break; 244 break;
245 } 245 }
246 } 246 }
247 while ((c = min_char + (index + 1) * chartab_chars[depth]) <= max_char 247 while ((c = min_char + (chartab_idx + 1) * chartab_chars[depth]) <= max_char
248 && *to >= c) 248 && *to >= c)
249 { 249 {
250 Lisp_Object this_val; 250 Lisp_Object this_val;
251 251
252 index++; 252 chartab_idx++;
253 this_val = tbl->contents[index]; 253 this_val = tbl->contents[chartab_idx];
254 if (SUB_CHAR_TABLE_P (this_val)) 254 if (SUB_CHAR_TABLE_P (this_val))
255 this_val = sub_char_table_ref_and_range (this_val, c, from, to, defalt); 255 this_val = sub_char_table_ref_and_range (this_val, c, from, to, defalt);
256 else if (NILP (this_val)) 256 else if (NILP (this_val))
@@ -275,10 +275,10 @@ Lisp_Object
275char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to) 275char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to)
276{ 276{
277 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); 277 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table);
278 int index = CHARTAB_IDX (c, 0, 0), idx; 278 int chartab_idx = CHARTAB_IDX (c, 0, 0), idx;
279 Lisp_Object val; 279 Lisp_Object val;
280 280
281 val = tbl->contents[index]; 281 val = tbl->contents[chartab_idx];
282 if (*from < 0) 282 if (*from < 0)
283 *from = 0; 283 *from = 0;
284 if (*to < 0) 284 if (*to < 0)
@@ -288,7 +288,7 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to)
288 else if (NILP (val)) 288 else if (NILP (val))
289 val = tbl->defalt; 289 val = tbl->defalt;
290 290
291 idx = index; 291 idx = chartab_idx;
292 while (*from < idx * chartab_chars[0]) 292 while (*from < idx * chartab_chars[0])
293 { 293 {
294 Lisp_Object this_val; 294 Lisp_Object this_val;
@@ -308,13 +308,13 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to)
308 break; 308 break;
309 } 309 }
310 } 310 }
311 while (*to >= (index + 1) * chartab_chars[0]) 311 while (*to >= (chartab_idx + 1) * chartab_chars[0])
312 { 312 {
313 Lisp_Object this_val; 313 Lisp_Object this_val;
314 314
315 index++; 315 chartab_idx++;
316 c = index * chartab_chars[0]; 316 c = chartab_idx * chartab_chars[0];
317 this_val = tbl->contents[index]; 317 this_val = tbl->contents[chartab_idx];
318 if (SUB_CHAR_TABLE_P (this_val)) 318 if (SUB_CHAR_TABLE_P (this_val))
319 this_val = sub_char_table_ref_and_range (this_val, c, from, to, 319 this_val = sub_char_table_ref_and_range (this_val, c, from, to,
320 tbl->defalt); 320 tbl->defalt);
@@ -331,20 +331,6 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to)
331} 331}
332 332
333 333
334#define ASET_RANGE(ARRAY, FROM, TO, LIMIT, VAL) \
335 do { \
336 int limit = (TO) < (LIMIT) ? (TO) : (LIMIT); \
337 for (; (FROM) < limit; (FROM)++) (ARRAY)->contents[(FROM)] = (VAL); \
338 } while (0)
339
340#define GET_SUB_CHAR_TABLE(TABLE, SUBTABLE, IDX, DEPTH, MIN_CHAR) \
341 do { \
342 (SUBTABLE) = (TABLE)->contents[(IDX)]; \
343 if (!SUB_CHAR_TABLE_P (SUBTABLE)) \
344 (SUBTABLE) = make_sub_char_table ((DEPTH), (MIN_CHAR), (SUBTABLE)); \
345 } while (0)
346
347
348static void 334static void
349sub_char_table_set (Lisp_Object table, int c, Lisp_Object val) 335sub_char_table_set (Lisp_Object table, int c, Lisp_Object val)
350{ 336{
@@ -951,7 +937,7 @@ map_sub_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object),
951 map_charset_chars. */ 937 map_charset_chars. */
952 938
953void 939void
954map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), 940map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object),
955 Lisp_Object function, Lisp_Object table, Lisp_Object arg, 941 Lisp_Object function, Lisp_Object table, Lisp_Object arg,
956 struct charset *charset, 942 struct charset *charset,
957 unsigned from, unsigned to) 943 unsigned from, unsigned to)
@@ -1012,4 +998,3 @@ syms_of_chartab (void)
1012 defsubr (&Soptimize_char_table); 998 defsubr (&Soptimize_char_table);
1013 defsubr (&Smap_char_table); 999 defsubr (&Smap_char_table);
1014} 1000}
1015