Mercurial > hg > xemacs-beta
comparison src/rangetab.c @ 173:8eaf7971accc r20-3b13
Import from CVS: tag r20-3b13
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:49:09 +0200 |
parents | 859a2309aef8 |
children | 3d6bfa290dbd |
comparison
equal
deleted
inserted
replaced
172:a38aed19690b | 173:8eaf7971accc |
---|---|
97 { | 97 { |
98 struct range_table_entry *rte = Dynarr_atp (rt->entries, i); | 98 struct range_table_entry *rte = Dynarr_atp (rt->entries, i); |
99 if (i > 0) | 99 if (i > 0) |
100 write_c_string (" ", printcharfun); | 100 write_c_string (" ", printcharfun); |
101 if (rte->first == rte->last) | 101 if (rte->first == rte->last) |
102 sprintf (buf, "%d ", rte->first); | 102 sprintf (buf, "%ld ", (long) (rte->first)); |
103 else | 103 else |
104 sprintf (buf, "(%d %d) ", rte->first, rte->last); | 104 sprintf (buf, "(%ld %ld) ", (long) (rte->first), (long) (rte->last)); |
105 write_c_string (buf, printcharfun); | 105 write_c_string (buf, printcharfun); |
106 print_internal (rte->val, printcharfun, 1); | 106 print_internal (rte->val, printcharfun, 1); |
107 } | 107 } |
108 write_c_string ("))", printcharfun); | 108 write_c_string ("))", printcharfun); |
109 } | 109 } |
197 /* Look up in a range table without the Dynarr wrapper. | 197 /* Look up in a range table without the Dynarr wrapper. |
198 Used also by the unified range table format. */ | 198 Used also by the unified range table format. */ |
199 | 199 |
200 static Lisp_Object | 200 static Lisp_Object |
201 get_range_table (EMACS_INT pos, int nentries, struct range_table_entry *tab, | 201 get_range_table (EMACS_INT pos, int nentries, struct range_table_entry *tab, |
202 Lisp_Object defalt) | 202 Lisp_Object default_) |
203 { | 203 { |
204 int left = 0, right = nentries; | 204 int left = 0, right = nentries; |
205 | 205 |
206 /* binary search for the entry. Based on similar code in | 206 /* binary search for the entry. Based on similar code in |
207 extent_list_locate(). */ | 207 extent_list_locate(). */ |
217 right = newpos; | 217 right = newpos; |
218 else | 218 else |
219 return entry->val; | 219 return entry->val; |
220 } | 220 } |
221 | 221 |
222 return defalt; | 222 return default_; |
223 } | 223 } |
224 | 224 |
225 DEFUN ("range-table-p", Frange_table_p, 1, 1, 0, /* | 225 DEFUN ("range-table-p", Frange_table_p, 1, 1, 0, /* |
226 Return non-nil if OBJECT is a range table. | 226 Return non-nil if OBJECT is a range table. |
227 */ | 227 */ |
228 (object)) | 228 (object)) |
229 { | 229 { |
230 return (RANGE_TABLEP (object) ? Qt : Qnil); | 230 return RANGE_TABLEP (object) ? Qt : Qnil; |
231 } | 231 } |
232 | 232 |
233 DEFUN ("make-range-table", Fmake_range_table, 0, 0, 0, /* | 233 DEFUN ("make-range-table", Fmake_range_table, 0, 0, 0, /* |
234 Make a new, empty range table. | 234 Make a new, empty range table. |
235 You can manipulate it using `put-range-table', `get-range-table', | 235 You can manipulate it using `put-range-table', `get-range-table', |
270 | 270 |
271 DEFUN ("get-range-table", Fget_range_table, 2, 3, 0, /* | 271 DEFUN ("get-range-table", Fget_range_table, 2, 3, 0, /* |
272 Find value for position POS in TABLE. | 272 Find value for position POS in TABLE. |
273 If there is no corresponding value, return DEFAULT (defaults to nil). | 273 If there is no corresponding value, return DEFAULT (defaults to nil). |
274 */ | 274 */ |
275 (pos, table, defalt)) | 275 (pos, table, default_)) |
276 { | 276 { |
277 struct Lisp_Range_Table *rt; | 277 struct Lisp_Range_Table *rt; |
278 EMACS_INT po; | 278 EMACS_INT po; |
279 | 279 |
280 CHECK_RANGE_TABLE (table); | 280 CHECK_RANGE_TABLE (table); |
282 | 282 |
283 CHECK_INT_COERCE_CHAR (pos); | 283 CHECK_INT_COERCE_CHAR (pos); |
284 po = XINT (pos); | 284 po = XINT (pos); |
285 | 285 |
286 return get_range_table (po, Dynarr_length (rt->entries), | 286 return get_range_table (po, Dynarr_length (rt->entries), |
287 Dynarr_atp (rt->entries, 0), defalt); | 287 Dynarr_atp (rt->entries, 0), default_); |
288 } | 288 } |
289 | 289 |
290 void | 290 void |
291 put_range_table (Lisp_Object table, EMACS_INT first, | 291 put_range_table (Lisp_Object table, EMACS_INT first, |
292 EMACS_INT last, Lisp_Object val) | 292 EMACS_INT last, Lisp_Object val) |
656 | 656 |
657 /* Look up a value in a unified range table. */ | 657 /* Look up a value in a unified range table. */ |
658 | 658 |
659 Lisp_Object | 659 Lisp_Object |
660 unified_range_table_lookup (void *unrangetab, EMACS_INT pos, | 660 unified_range_table_lookup (void *unrangetab, EMACS_INT pos, |
661 Lisp_Object defalt) | 661 Lisp_Object default_) |
662 { | 662 { |
663 void *new_dest; | 663 void *new_dest; |
664 struct unified_range_table *un; | 664 struct unified_range_table *un; |
665 | 665 |
666 align_the_damn_table (unrangetab); | 666 align_the_damn_table (unrangetab); |
667 new_dest = (char *) unrangetab + * (char *) unrangetab; | 667 new_dest = (char *) unrangetab + * (char *) unrangetab; |
668 un = (struct unified_range_table *) new_dest; | 668 un = (struct unified_range_table *) new_dest; |
669 | 669 |
670 return get_range_table (pos, un->nentries, &un->first, defalt); | 670 return get_range_table (pos, un->nentries, &un->first, default_); |
671 } | 671 } |
672 | 672 |
673 /* Return number of entries in a unified range table. */ | 673 /* Return number of entries in a unified range table. */ |
674 | 674 |
675 int | 675 int |