aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-11-27 08:01:29 +0000
committerKenichi Handa2008-11-27 08:01:29 +0000
commit7ef1f5d11c82d063cd1c0ee61253f897e7c766fb (patch)
treeba7c06395cddeb6c8cb8d67ba3237ea3882c10e4 /src
parent2bc20f0b55cd7e20da31c05aa7c1711ba3786c9a (diff)
downloademacs-7ef1f5d11c82d063cd1c0ee61253f897e7c766fb.tar.gz
emacs-7ef1f5d11c82d063cd1c0ee61253f897e7c766fb.zip
(sub_char_table_ref_and_range): Adjusted for the
change of char_table_ref_and_range. (char_table_ref_and_range): Change the meaning of argument FROM and TO. Now the caller must provide initial values for *FROM and *TO.
Diffstat (limited to 'src')
-rw-r--r--src/chartab.c91
1 files changed, 44 insertions, 47 deletions
diff --git a/src/chartab.c b/src/chartab.c
index 14a726049ea..dc7febfb47d 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -229,66 +229,60 @@ sub_char_table_ref_and_range (table, c, from, to, defalt)
229 int depth = XINT (tbl->depth); 229 int depth = XINT (tbl->depth);
230 int min_char = XINT (tbl->min_char); 230 int min_char = XINT (tbl->min_char);
231 int max_char = min_char + chartab_chars[depth - 1] - 1; 231 int max_char = min_char + chartab_chars[depth - 1] - 1;
232 int index = CHARTAB_IDX (c, depth, min_char); 232 int index = CHARTAB_IDX (c, depth, min_char), idx;
233 Lisp_Object val; 233 Lisp_Object val;
234 234
235 val = tbl->contents[index]; 235 val = tbl->contents[index];
236 *from = min_char + index * chartab_chars[depth];
237 *to = *from + chartab_chars[depth] - 1;
238 if (SUB_CHAR_TABLE_P (val)) 236 if (SUB_CHAR_TABLE_P (val))
239 val = sub_char_table_ref_and_range (val, c, from, to, defalt); 237 val = sub_char_table_ref_and_range (val, c, from, to, defalt);
240 else if (NILP (val)) 238 else if (NILP (val))
241 val = defalt; 239 val = defalt;
242 240
243 while (*from > min_char 241 idx = index;
244 && *from == min_char + index * chartab_chars[depth]) 242 while (idx > 0 && *from < min_char + idx * chartab_chars[depth])
245 { 243 {
246 Lisp_Object this_val; 244 Lisp_Object this_val;
247 int this_from = *from - chartab_chars[depth];
248 int this_to = *from - 1;
249 245
250 index--; 246 c = min_char + idx * chartab_chars[depth] - 1;
251 this_val = tbl->contents[index]; 247 idx--;
248 this_val = tbl->contents[idx];
252 if (SUB_CHAR_TABLE_P (this_val)) 249 if (SUB_CHAR_TABLE_P (this_val))
253 this_val = sub_char_table_ref_and_range (this_val, this_to, 250 this_val = sub_char_table_ref_and_range (this_val, c, from, to, defalt);
254 &this_from, &this_to,
255 defalt);
256 else if (NILP (this_val)) 251 else if (NILP (this_val))
257 this_val = defalt; 252 this_val = defalt;
258 253
259 if (! EQ (this_val, val)) 254 if (! EQ (this_val, val))
260 break; 255 {
261 *from = this_from; 256 *from = c + 1;
257 break;
258 }
262 } 259 }
263 index = CHARTAB_IDX (c, depth, min_char); 260 while ((c = min_char + (index + 1) * chartab_chars[depth]) < max_char
264 while (*to < max_char 261 && *to >= c)
265 && *to == min_char + (index + 1) * chartab_chars[depth] - 1)
266 { 262 {
267 Lisp_Object this_val; 263 Lisp_Object this_val;
268 int this_from = *to + 1;
269 int this_to = this_from + chartab_chars[depth] - 1;
270 264
271 index++; 265 index++;
272 this_val = tbl->contents[index]; 266 this_val = tbl->contents[index];
273 if (SUB_CHAR_TABLE_P (this_val)) 267 if (SUB_CHAR_TABLE_P (this_val))
274 this_val = sub_char_table_ref_and_range (this_val, this_from, 268 this_val = sub_char_table_ref_and_range (this_val, c, from, to, defalt);
275 &this_from, &this_to,
276 defalt);
277 else if (NILP (this_val)) 269 else if (NILP (this_val))
278 this_val = defalt; 270 this_val = defalt;
279 if (! EQ (this_val, val)) 271 if (! EQ (this_val, val))
280 break; 272 {
281 *to = this_to; 273 *to = c - 1;
274 break;
275 }
282 } 276 }
283 277
284 return val; 278 return val;
285} 279}
286 280
287 281
288/* Return the value for C in char-table TABLE. Set *FROM and *TO to 282/* Return the value for C in char-table TABLE. Shrink the range *FROM
289 the range of characters (containing C) that have the same value as 283 and *TO to cover characters (containing C) that have the same value
290 C. It is not assured that the value of (*FROM - 1) and (*TO + 1) 284 as C. It is not assured that the values of (*FROM - 1) and (*TO +
291 is different from that of C. */ 285 1) are different from that of C. */
292 286
293Lisp_Object 287Lisp_Object
294char_table_ref_and_range (table, c, from, to) 288char_table_ref_and_range (table, c, from, to)
@@ -297,53 +291,56 @@ char_table_ref_and_range (table, c, from, to)
297 int *from, *to; 291 int *from, *to;
298{ 292{
299 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); 293 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table);
300 int index = CHARTAB_IDX (c, 0, 0); 294 int index = CHARTAB_IDX (c, 0, 0), idx;
301 Lisp_Object val; 295 Lisp_Object val;
302 296
303 val = tbl->contents[index]; 297 val = tbl->contents[index];
304 *from = index * chartab_chars[0]; 298 if (*from < 0)
305 *to = *from + chartab_chars[0] - 1; 299 *from = 0;
300 if (*to < 0)
301 *to = MAX_CHAR;
306 if (SUB_CHAR_TABLE_P (val)) 302 if (SUB_CHAR_TABLE_P (val))
307 val = sub_char_table_ref_and_range (val, c, from, to, tbl->defalt); 303 val = sub_char_table_ref_and_range (val, c, from, to, tbl->defalt);
308 else if (NILP (val)) 304 else if (NILP (val))
309 val = tbl->defalt; 305 val = tbl->defalt;
310 306
311 while (*from > 0 && *from == index * chartab_chars[0]) 307 idx = index;
308 while (*from < idx * chartab_chars[0])
312 { 309 {
313 Lisp_Object this_val; 310 Lisp_Object this_val;
314 int this_from = *from - chartab_chars[0];
315 int this_to = *from - 1;
316 311
317 index--; 312 c = idx * chartab_chars[0] - 1;
318 this_val = tbl->contents[index]; 313 idx--;
314 this_val = tbl->contents[idx];
319 if (SUB_CHAR_TABLE_P (this_val)) 315 if (SUB_CHAR_TABLE_P (this_val))
320 this_val = sub_char_table_ref_and_range (this_val, this_to, 316 this_val = sub_char_table_ref_and_range (this_val, c, from, to,
321 &this_from, &this_to,
322 tbl->defalt); 317 tbl->defalt);
323 else if (NILP (this_val)) 318 else if (NILP (this_val))
324 this_val = tbl->defalt; 319 this_val = tbl->defalt;
325 320
326 if (! EQ (this_val, val)) 321 if (! EQ (this_val, val))
327 break; 322 {
328 *from = this_from; 323 *from = c + 1;
324 break;
325 }
329 } 326 }
330 while (*to < MAX_CHAR && *to == (index + 1) * chartab_chars[0] - 1) 327 while (*to >= (index + 1) * chartab_chars[0])
331 { 328 {
332 Lisp_Object this_val; 329 Lisp_Object this_val;
333 int this_from = *to + 1;
334 int this_to = this_from + chartab_chars[0] - 1;
335 330
336 index++; 331 index++;
332 c = index * chartab_chars[0];
337 this_val = tbl->contents[index]; 333 this_val = tbl->contents[index];
338 if (SUB_CHAR_TABLE_P (this_val)) 334 if (SUB_CHAR_TABLE_P (this_val))
339 this_val = sub_char_table_ref_and_range (this_val, this_from, 335 this_val = sub_char_table_ref_and_range (this_val, c, from, to,
340 &this_from, &this_to,
341 tbl->defalt); 336 tbl->defalt);
342 else if (NILP (this_val)) 337 else if (NILP (this_val))
343 this_val = tbl->defalt; 338 this_val = tbl->defalt;
344 if (! EQ (this_val, val)) 339 if (! EQ (this_val, val))
345 break; 340 {
346 *to = this_to; 341 *to = c - 1;
342 break;
343 }
347 } 344 }
348 345
349 return val; 346 return val;