annotate src/rangetab.c @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents abe6d1db359e
children 183866b06e0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* XEmacs routines to deal with range tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1995 Sun Microsystems, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* Written by Ben Wing, August 1995. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "rangetab.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 Lisp_Object Qrange_tablep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 Lisp_Object Qrange_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 /* Range table object */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 /* We use a sorted array of ranges.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #### We should be using the gap array stuff from extents.c. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 is not hard but just requires moving that stuff out of that file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 mark_range_table (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
46 Lisp_Range_Table *rt = XRANGE_TABLE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 for (i = 0; i < Dynarr_length (rt->entries); i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 mark_object (Dynarr_at (rt->entries, i).val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 print_range_table (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
57 Lisp_Range_Table *rt = XRANGE_TABLE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 char buf[200];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 write_c_string ("#s(range-table data (", printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 for (i = 0; i < Dynarr_length (rt->entries); i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 struct range_table_entry *rte = Dynarr_atp (rt->entries, i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 if (i > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 write_c_string (" ", printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 if (rte->first == rte->last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 sprintf (buf, "%ld ", (long) (rte->first));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 sprintf (buf, "(%ld %ld) ", (long) (rte->first), (long) (rte->last));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 write_c_string (buf, printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 print_internal (rte->val, printcharfun, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 write_c_string ("))", printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 range_table_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
80 Lisp_Range_Table *rt1 = XRANGE_TABLE (obj1);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
81 Lisp_Range_Table *rt2 = XRANGE_TABLE (obj2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 if (Dynarr_length (rt1->entries) != Dynarr_length (rt2->entries))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 for (i = 0; i < Dynarr_length (rt1->entries); i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 struct range_table_entry *rte1 = Dynarr_atp (rt1->entries, i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 struct range_table_entry *rte2 = Dynarr_atp (rt2->entries, i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 if (rte1->first != rte2->first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 || rte1->last != rte2->last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 || !internal_equal (rte1->val, rte2->val, depth + 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 static unsigned long
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 range_table_entry_hash (struct range_table_entry *rte, int depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 return HASH3 (rte->first, rte->last, internal_hash (rte->val, depth + 1));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 static unsigned long
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 range_table_hash (Lisp_Object obj, int depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
110 Lisp_Range_Table *rt = XRANGE_TABLE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 int size = Dynarr_length (rt->entries);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 unsigned long hash = size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 /* approach based on internal_array_hash(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 if (size <= 5)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 for (i = 0; i < size; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 hash = HASH2 (hash,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 range_table_entry_hash (Dynarr_atp (rt->entries, i),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 depth));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 return hash;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 /* just pick five elements scattered throughout the array.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 A slightly better approach would be to offset by some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 noise factor from the points chosen below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 for (i = 0; i < 5; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 hash = HASH2 (hash, range_table_entry_hash (Dynarr_atp (rt->entries,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 i*size/5),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 depth));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 return hash;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 static const struct lrecord_description rte_description_1[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
136 { XD_LISP_OBJECT, offsetof (range_table_entry, val) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 static const struct struct_description rte_description = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
141 sizeof (range_table_entry),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 rte_description_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 static const struct lrecord_description rted_description_1[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
146 XD_DYNARR_DESC (range_table_entry_dynarr, &rte_description),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 static const struct struct_description rted_description = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
151 sizeof (range_table_entry_dynarr),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 rted_description_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 static const struct lrecord_description range_table_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
156 { XD_STRUCT_PTR, offsetof (Lisp_Range_Table, entries), 1, &rted_description },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 DEFINE_LRECORD_IMPLEMENTATION ("range-table", range_table,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 mark_range_table, print_range_table, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 range_table_equal, range_table_hash,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 range_table_description,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
164 Lisp_Range_Table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 /* Range table operations */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 #ifdef ERROR_CHECK_TYPECHECK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
173 verify_range_table (Lisp_Range_Table *rt)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 for (i = 0; i < Dynarr_length (rt->entries); i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 struct range_table_entry *rte = Dynarr_atp (rt->entries, i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 assert (rte->last >= rte->first);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 if (i > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 assert (Dynarr_at (rt->entries, i - 1).last < rte->first);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 #define verify_range_table(rt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 /* Look up in a range table without the Dynarr wrapper.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 Used also by the unified range table format. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 get_range_table (EMACS_INT pos, int nentries, struct range_table_entry *tab,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 Lisp_Object default_)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 int left = 0, right = nentries;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 /* binary search for the entry. Based on similar code in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 extent_list_locate(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 while (left != right)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 /* RIGHT might not point to a valid entry (i.e. it's at the end
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 of the list), so NEWPOS must round down. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 unsigned int newpos = (left + right) >> 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 struct range_table_entry *entry = tab + newpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 if (pos > entry->last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 left = newpos+1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 else if (pos < entry->first)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 right = newpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 return entry->val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 return default_;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 DEFUN ("range-table-p", Frange_table_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 Return non-nil if OBJECT is a range table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 (object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 return RANGE_TABLEP (object) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 DEFUN ("make-range-table", Fmake_range_table, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 Return a new, empty range table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 You can manipulate it using `put-range-table', `get-range-table',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 `remove-range-table', and `clear-range-table'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 Lisp_Object obj;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
236 Lisp_Range_Table *rt = alloc_lcrecord_type (Lisp_Range_Table,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
237 &lrecord_range_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 rt->entries = Dynarr_new (range_table_entry);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 XSETRANGE_TABLE (obj, rt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 return obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 DEFUN ("copy-range-table", Fcopy_range_table, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
244 Return a new range table which is a copy of RANGE-TABLE.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
245 It will contain the same values for the same ranges as RANGE-TABLE.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
246 The values will not themselves be copied.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
248 (range_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
250 Lisp_Range_Table *rt, *rtnew;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 Lisp_Object obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
253 CHECK_RANGE_TABLE (range_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
254 rt = XRANGE_TABLE (range_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
256 rtnew = alloc_lcrecord_type (Lisp_Range_Table, &lrecord_range_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 rtnew->entries = Dynarr_new (range_table_entry);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 Dynarr_add_many (rtnew->entries, Dynarr_atp (rt->entries, 0),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 Dynarr_length (rt->entries));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 XSETRANGE_TABLE (obj, rtnew);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 return obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 DEFUN ("get-range-table", Fget_range_table, 2, 3, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
266 Find value for position POS in RANGE-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 If there is no corresponding value, return DEFAULT (defaults to nil).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
269 (pos, range_table, default_))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
271 Lisp_Range_Table *rt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
273 CHECK_RANGE_TABLE (range_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
274 rt = XRANGE_TABLE (range_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 CHECK_INT_COERCE_CHAR (pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 return get_range_table (XINT (pos), Dynarr_length (rt->entries),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 Dynarr_atp (rt->entries, 0), default_);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 put_range_table (Lisp_Object table, EMACS_INT first,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 EMACS_INT last, Lisp_Object val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 int insert_me_here = -1;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
288 Lisp_Range_Table *rt = XRANGE_TABLE (table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 /* Now insert in the proper place. This gets tricky because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 we may be overlapping one or more existing ranges and need
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 to fix them up. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 /* First delete all sections of any existing ranges that overlap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 the new range. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 for (i = 0; i < Dynarr_length (rt->entries); i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 struct range_table_entry *entry = Dynarr_atp (rt->entries, i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 /* We insert before the first range that begins at or after the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 new range. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 if (entry->first >= first && insert_me_here < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 insert_me_here = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 if (entry->last < first)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 /* completely before the new range. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 if (entry->first > last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 /* completely after the new range. No more possibilities of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 finding overlapping ranges. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 if (entry->first < first && entry->last <= last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 /* looks like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 [ NEW ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 [ EXISTING ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 /* truncate the end off of it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 entry->last = first - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 else if (entry->first < first && entry->last > last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 /* looks like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 [ NEW ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 [ EXISTING ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 /* need to split this one in two. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 struct range_table_entry insert_me_too;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 insert_me_too.first = last + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 insert_me_too.last = entry->last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 insert_me_too.val = entry->val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 entry->last = first - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 Dynarr_insert_many (rt->entries, &insert_me_too, 1, i + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 else if (entry->last > last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 /* looks like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 [ NEW ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 [ EXISTING ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 /* truncate the start off of it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 entry->first = last + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 /* existing is entirely within new. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 Dynarr_delete_many (rt->entries, i, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 i--; /* back up since everything shifted one to the left. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 /* Someone asked us to delete the range, not insert it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 if (UNBOUNDP (val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 /* Now insert the new entry, maybe at the end. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 if (insert_me_here < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 insert_me_here = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 struct range_table_entry insert_me;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 insert_me.first = first;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 insert_me.last = last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 insert_me.val = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 Dynarr_insert_many (rt->entries, &insert_me, 1, insert_me_here);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 /* Now see if we can combine this entry with adjacent ones just
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 before or after. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 if (insert_me_here > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 struct range_table_entry *entry = Dynarr_atp (rt->entries,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 insert_me_here - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 if (EQ (val, entry->val) && entry->last == first - 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 entry->last = last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 Dynarr_delete_many (rt->entries, insert_me_here, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 insert_me_here--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 /* We have morphed into a larger range. Update our records
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 in case we also combine with the one after. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 first = entry->first;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 if (insert_me_here < Dynarr_length (rt->entries) - 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 struct range_table_entry *entry = Dynarr_atp (rt->entries,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 insert_me_here + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 if (EQ (val, entry->val) && entry->first == last + 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 entry->first = first;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 Dynarr_delete_many (rt->entries, insert_me_here, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 DEFUN ("put-range-table", Fput_range_table, 4, 4, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
407 Set the value for range (START, END) to be VALUE in RANGE-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
409 (start, end, value, range_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 EMACS_INT first, last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
413 CHECK_RANGE_TABLE (range_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 CHECK_INT_COERCE_CHAR (start);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 first = XINT (start);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 CHECK_INT_COERCE_CHAR (end);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 last = XINT (end);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 if (first > last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 signal_simple_error_2 ("start must be <= end", start, end);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
421 put_range_table (range_table, first, last, value);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
422 verify_range_table (XRANGE_TABLE (range_table));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 DEFUN ("remove-range-table", Fremove_range_table, 3, 3, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
427 Remove the value for range (START, END) in RANGE-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
429 (start, end, range_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
431 return Fput_range_table (start, end, Qunbound, range_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 DEFUN ("clear-range-table", Fclear_range_table, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
435 Flush RANGE-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
437 (range_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
439 CHECK_RANGE_TABLE (range_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
440 Dynarr_reset (XRANGE_TABLE (range_table)->entries);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 DEFUN ("map-range-table", Fmap_range_table, 2, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
445 Map FUNCTION over entries in RANGE-TABLE, calling it with three args,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 the beginning and end of the range and the corresponding value.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
447
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
448 Results are guaranteed to be correct (i.e. each entry processed
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 exactly once) if FUNCTION modifies or deletes the current entry
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
450 \(i.e. passes the current range to `put-range-table' or
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
451 `remove-range-table'), but not otherwise.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
453 (function, range_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
455 Lisp_Range_Table *rt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
456 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
457
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
458 CHECK_RANGE_TABLE (range_table);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
459 CHECK_FUNCTION (function);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
460
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
461 rt = XRANGE_TABLE (range_table);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
462
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
463 /* Do not "optimize" by pulling out the length computation below!
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
464 FUNCTION may have changed the table. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
465 for (i = 0; i < Dynarr_length (rt->entries); i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
466 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
467 struct range_table_entry *entry = Dynarr_atp (rt->entries, i);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
468 EMACS_INT first, last;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
469 Lisp_Object args[4];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
470 int oldlen;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
471
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
472 again:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 first = entry->first;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474 last = entry->last;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
475 oldlen = Dynarr_length (rt->entries);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 args[0] = function;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477 args[1] = make_int (first);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 args[2] = make_int (last);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
479 args[3] = entry->val;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 Ffuncall (countof (args), args);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
481 /* Has FUNCTION removed the entry? */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
482 if (oldlen > Dynarr_length (rt->entries)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
483 && i < Dynarr_length (rt->entries)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
484 && (first != entry->first || last != entry->last))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
485 goto again;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
486 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
487
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 /* Range table read syntax */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 rangetab_data_validate (Lisp_Object keyword, Lisp_Object value,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 Error_behavior errb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 Lisp_Object rest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 /* #### should deal with errb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 EXTERNAL_LIST_LOOP (rest, value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 Lisp_Object range = XCAR (rest);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 rest = XCDR (rest);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 if (!CONSP (rest))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 signal_simple_error ("Invalid list format", value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 if (!INTP (range) && !CHARP (range)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 && !(CONSP (range) && CONSP (XCDR (range))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 && NILP (XCDR (XCDR (range)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 && (INTP (XCAR (range)) || CHARP (XCAR (range)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 && (INTP (XCAR (XCDR (range))) || CHARP (XCAR (XCDR (range))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 signal_simple_error ("Invalid range format", range);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 rangetab_instantiate (Lisp_Object data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 Lisp_Object rangetab = Fmake_range_table ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 if (!NILP (data))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 data = Fcar (Fcdr (data)); /* skip over 'data keyword */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 while (!NILP (data))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 Lisp_Object range = Fcar (data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 Lisp_Object val = Fcar (Fcdr (data));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 data = Fcdr (Fcdr (data));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 if (CONSP (range))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 Fput_range_table (Fcar (range), Fcar (Fcdr (range)), val,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 rangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 Fput_range_table (range, range, val, rangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 return rangetab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 /* Unified range tables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 /* A "unified range table" is a format for storing range tables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 as contiguous blocks of memory. This is used by the regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 code, which needs to use range tables to properly handle []
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 constructs in the presence of extended characters but wants to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 store an entire compiled pattern as a contiguous block of memory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 Unified range tables are designed so that they can be placed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 at an arbitrary (possibly mis-aligned) place in memory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 (Dealing with alignment is a pain in the ass.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 WARNING: No provisions for garbage collection are currently made.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 This means that there must not be any Lisp objects in a unified
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 range table that need to be marked for garbage collection.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 Good candidates for objects that can go into a range table are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 -- numbers and characters (do not need to be marked)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 -- nil, t (marked elsewhere)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 -- charsets and coding systems (automatically marked because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 they are in a marked list,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 and can't be removed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 Good but slightly less so:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 -- symbols (could be uninterned, but that is not likely)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 Somewhat less good:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 -- buffers, frames, devices (could get deleted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 It is expected that you work with range tables in the normal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 format and then convert to unified format when you are done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 making modifications. As such, no functions are provided
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 for modifying a unified range table. The only operations
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 you can do to unified range tables are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 -- look up a value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 -- retrieve all the ranges in an iterative fashion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 /* The format of a unified range table is as follows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 -- The first byte contains the number of bytes to skip to find the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 actual start of the table. This deals with alignment constraints,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 since the table might want to go at any arbitrary place in memory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 -- The next three bytes contain the number of bytes to skip (from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 *first* byte) to find the stuff after the table. It's stored in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 little-endian format because that's how God intended things. We don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 necessarily start the stuff at the very end of the table because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 we want to have at least ALIGNOF (EMACS_INT) extra space in case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 we have to move the range table around. (It appears that some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 architectures don't maintain alignment when reallocing.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 -- At the prescribed offset is a struct unified_range_table, containing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 some number of `struct range_table_entry' entries. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 struct unified_range_table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 int nentries;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 struct range_table_entry first;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 /* Return size in bytes needed to store the data in a range table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 unified_range_table_bytes_needed (Lisp_Object rangetab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 return (sizeof (struct range_table_entry) *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 (Dynarr_length (XRANGE_TABLE (rangetab)->entries) - 1) +
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 sizeof (struct unified_range_table) +
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 /* ALIGNOF a struct may be too big. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 /* We have four bytes for the size numbers, and an extra
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 four or eight bytes for making sure we get the alignment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 OK. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 ALIGNOF (EMACS_INT) + 4);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 /* Convert a range table into unified format and store in DEST,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 which must be able to hold the number of bytes returned by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 range_table_bytes_needed(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 unified_range_table_copy_data (Lisp_Object rangetab, void *dest)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 /* We cast to the above structure rather than just casting to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 char * and adding sizeof(int), because that will lead to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 mis-aligned data on the Alpha machines. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 struct unified_range_table *un;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 range_table_entry_dynarr *rted = XRANGE_TABLE (rangetab)->entries;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 int total_needed = unified_range_table_bytes_needed (rangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 void *new_dest = ALIGN_PTR ((char *) dest + 4, ALIGNOF (EMACS_INT));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 * (char *) dest = (char) ((char *) new_dest - (char *) dest);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 * ((unsigned char *) dest + 1) = total_needed & 0xFF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 total_needed >>= 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 * ((unsigned char *) dest + 2) = total_needed & 0xFF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 total_needed >>= 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 * ((unsigned char *) dest + 3) = total_needed & 0xFF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 un = (struct unified_range_table *) new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 un->nentries = Dynarr_length (rted);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 memcpy (&un->first, Dynarr_atp (rted, 0),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 sizeof (struct range_table_entry) * Dynarr_length (rted));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 /* Return number of bytes actually used by a unified range table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 unified_range_table_bytes_used (void *unrangetab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 return ((* ((unsigned char *) unrangetab + 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 + ((* ((unsigned char *) unrangetab + 2)) << 8)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 + ((* ((unsigned char *) unrangetab + 3)) << 16));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 /* Make sure the table is aligned, and move it around if it's not. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 align_the_damn_table (void *unrangetab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 void *cur_dest = (char *) unrangetab + * (char *) unrangetab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 #if LONGBITS == 64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 if ((((long) cur_dest) & 7) != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 if ((((int) cur_dest) & 3) != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 int count = (unified_range_table_bytes_used (unrangetab) - 4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 - ALIGNOF (EMACS_INT));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 /* Find the proper location, just like above. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 void *new_dest = ALIGN_PTR ((char *) unrangetab + 4,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 ALIGNOF (EMACS_INT));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 /* memmove() works in the presence of overlapping data. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 memmove (new_dest, cur_dest, count);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 * (char *) unrangetab = (char) ((char *) new_dest - (char *) unrangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 /* Look up a value in a unified range table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 unified_range_table_lookup (void *unrangetab, EMACS_INT pos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 Lisp_Object default_)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 void *new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 struct unified_range_table *un;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 align_the_damn_table (unrangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 new_dest = (char *) unrangetab + * (char *) unrangetab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 un = (struct unified_range_table *) new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 return get_range_table (pos, un->nentries, &un->first, default_);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 /* Return number of entries in a unified range table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 unified_range_table_nentries (void *unrangetab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 void *new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 struct unified_range_table *un;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 align_the_damn_table (unrangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 new_dest = (char *) unrangetab + * (char *) unrangetab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 un = (struct unified_range_table *) new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 return un->nentries;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 /* Return the OFFSETth range (counting from 0) in UNRANGETAB. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 unified_range_table_get_range (void *unrangetab, int offset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 EMACS_INT *min, EMACS_INT *max,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 Lisp_Object *val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 void *new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 struct unified_range_table *un;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 struct range_table_entry *tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 align_the_damn_table (unrangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 new_dest = (char *) unrangetab + * (char *) unrangetab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 un = (struct unified_range_table *) new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 assert (offset >= 0 && offset < un->nentries);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 tab = (&un->first) + offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 *min = tab->first;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 *max = tab->last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 *val = tab->val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 /* Initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 syms_of_rangetab (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
745 INIT_LRECORD_IMPLEMENTATION (range_table);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
746
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 defsymbol (&Qrange_tablep, "range-table-p");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 defsymbol (&Qrange_table, "range-table");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 DEFSUBR (Frange_table_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 DEFSUBR (Fmake_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 DEFSUBR (Fcopy_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 DEFSUBR (Fget_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 DEFSUBR (Fput_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 DEFSUBR (Fremove_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 DEFSUBR (Fclear_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 DEFSUBR (Fmap_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 structure_type_create_rangetab (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 struct structure_type *st;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 st = define_structure_type (Qrange_table, 0, rangetab_instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 define_structure_type_keyword (st, Qdata, rangetab_data_validate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 }