Mercurial > hg > xemacs-beta
diff src/rangetab.c @ 185:3d6bfa290dbd r20-3b19
Import from CVS: tag r20-3b19
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:55:28 +0200 |
parents | 8eaf7971accc |
children | c5d627a313b1 |
line wrap: on
line diff
--- a/src/rangetab.c Mon Aug 13 09:54:24 2007 +0200 +++ b/src/rangetab.c Mon Aug 13 09:55:28 2007 +0200 @@ -26,6 +26,7 @@ #include <config.h> #include "lisp.h" +typedef struct range_table_entry range_table_entry; struct range_table_entry { EMACS_INT first; @@ -33,9 +34,9 @@ Lisp_Object val; }; -typedef struct range_table_entry_dynarr_type +typedef struct { - Dynarr_declare (struct range_table_entry); + Dynarr_declare (range_table_entry); } range_table_entry_dynarr; struct Lisp_Range_Table @@ -117,7 +118,7 @@ if (Dynarr_length (rt1->entries) != Dynarr_length (rt2->entries)) return 0; - + for (i = 0; i < Dynarr_length (rt1->entries); i++) { struct range_table_entry *rte1 = Dynarr_atp (rt1->entries, i); @@ -155,7 +156,7 @@ depth)); return hash; } - + /* just pick five elements scattered throughout the array. A slightly better approach would be to offset by some noise factor from the points chosen below. */ @@ -202,7 +203,7 @@ Lisp_Object default_) { int left = 0, right = nentries; - + /* binary search for the entry. Based on similar code in extent_list_locate(). */ while (left != right) @@ -237,12 +238,10 @@ */ ()) { - struct Lisp_Range_Table *rt; Lisp_Object obj; - - rt = (struct Lisp_Range_Table *) - alloc_lcrecord (sizeof (struct Lisp_Range_Table), lrecord_range_table); - rt->entries = Dynarr_new (struct range_table_entry); + struct Lisp_Range_Table *rt = alloc_lcrecord_type (struct Lisp_Range_Table, + lrecord_range_table); + rt->entries = Dynarr_new (range_table_entry); XSETRANGE_TABLE (obj, rt); return obj; } @@ -258,9 +257,9 @@ CHECK_RANGE_TABLE (old_table); rt = XRANGE_TABLE (old_table); - rtnew = (struct Lisp_Range_Table *) - alloc_lcrecord (sizeof (struct Lisp_Range_Table), lrecord_range_table); - rtnew->entries = Dynarr_new (struct range_table_entry); + + rtnew = alloc_lcrecord_type (struct Lisp_Range_Table, lrecord_range_table); + rtnew->entries = Dynarr_new (range_table_entry); Dynarr_add_many (rtnew->entries, Dynarr_atp (rt->entries, 0), Dynarr_length (rt->entries)); @@ -331,12 +330,12 @@ [ NEW ] [ EXISTING ] - + */ /* need to split this one in two. */ { struct range_table_entry insert_me_too; - + insert_me_too.first = last + 1; insert_me_too.last = entry->last; insert_me_too.val = entry->val; @@ -346,7 +345,7 @@ else if (entry->last > last) { /* looks like: - + [ NEW ] [ EXISTING ] @@ -365,15 +364,15 @@ /* Someone asked us to delete the range, not insert it. */ if (UNBOUNDP (val)) return; - + /* Now insert the new entry, maybe at the end. */ - + if (insert_me_here < 0) insert_me_here = i; { struct range_table_entry insert_me; - + insert_me.first = first; insert_me.last = last; insert_me.val = val; @@ -383,7 +382,7 @@ /* Now see if we can combine this entry with adjacent ones just before or after. */ - + if (insert_me_here > 0) { struct range_table_entry *entry = Dynarr_atp (rt->entries, @@ -500,7 +499,7 @@ { Lisp_Object range = Fcar (data); Lisp_Object val = Fcar (Fcdr (data)); - + data = Fcdr (Fcdr (data)); if (CONSP (range)) Fput_range_table (Fcar (range), Fcar (Fcdr (range)), val, @@ -556,7 +555,7 @@ -- look up a value -- retrieve all the ranges in an iterative fashion - + */ /* The format of a unified range table is as follows: @@ -579,7 +578,7 @@ int nentries; struct range_table_entry first; }; - + /* Return size in bytes needed to store the data in a range table. */ int @@ -632,7 +631,7 @@ + ((* ((unsigned char *) unrangetab + 3)) << 16)); } -/* Make sure the table is aligned, and move it around if it's not. */ +/* Make sure the table is aligned, and move it around if it's not. */ static void align_the_damn_table (void *unrangetab) { @@ -653,7 +652,7 @@ * (char *) unrangetab = (char) ((char *) new_dest - (char *) unrangetab); } } - + /* Look up a value in a unified range table. */ Lisp_Object