annotate src/rangetab.c @ 5856:27876789edc5

Be more careful about saving a non-nil value for START in message-stack. lisp/ChangeLog addition: 2015-03-12 Aidan Kehoe <kehoea@parhasard.net> * simple.el (append-message): Be more careful about saving a non-nil value for START in message-stack.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 12 Mar 2015 00:59:27 +0000
parents 56144c8593a8
children
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.
4831
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
3 Copyright (C) 1995, 2002, 2004, 2005, 2010 Ben Wing.
428
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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5222
diff changeset
7 XEmacs is free software: you can redistribute it and/or modify it
428
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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5222
diff changeset
9 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5222
diff changeset
10 option) any later version.
428
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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5222
diff changeset
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 /* Synched up with: Not in FSF. */
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 /* Written by Ben Wing, August 1995. */
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 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include "rangetab.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 Lisp_Object Qrange_tablep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 Lisp_Object Qrange_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
31 Lisp_Object Qstart_closed_end_open;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
32 Lisp_Object Qstart_open_end_open;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
33 Lisp_Object Qstart_closed_end_closed;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
34 Lisp_Object Qstart_open_end_closed;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
35
428
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 /* Range table object */
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
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
41 static enum range_table_type
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
42 range_table_symbol_to_type (Lisp_Object symbol)
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
43 {
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
44 if (NILP (symbol))
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
45 return RANGE_START_CLOSED_END_OPEN;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
46
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
47 CHECK_SYMBOL (symbol);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
48 if (EQ (symbol, Qstart_closed_end_open))
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
49 return RANGE_START_CLOSED_END_OPEN;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
50 if (EQ (symbol, Qstart_closed_end_closed))
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
51 return RANGE_START_CLOSED_END_CLOSED;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
52 if (EQ (symbol, Qstart_open_end_open))
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
53 return RANGE_START_OPEN_END_OPEN;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
54 if (EQ (symbol, Qstart_open_end_closed))
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
55 return RANGE_START_OPEN_END_CLOSED;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
56
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
57 invalid_constant ("Unknown range table type", symbol);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
58 RETURN_NOT_REACHED (RANGE_START_CLOSED_END_OPEN);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
59 }
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
60
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
61 static Lisp_Object
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
62 range_table_type_to_symbol (enum range_table_type type)
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
63 {
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
64 switch (type)
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
65 {
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
66 case RANGE_START_CLOSED_END_OPEN:
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
67 return Qstart_closed_end_open;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
68 case RANGE_START_CLOSED_END_CLOSED:
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
69 return Qstart_closed_end_closed;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
70 case RANGE_START_OPEN_END_OPEN:
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
71 return Qstart_open_end_open;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
72 case RANGE_START_OPEN_END_CLOSED:
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
73 return Qstart_open_end_closed;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
74 }
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
75
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2425
diff changeset
76 ABORT ();
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
77 return Qnil;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
78 }
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
79
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 /* We use a sorted array of ranges.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #### We should be using the gap array stuff from extents.c. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 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
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 mark_range_table (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
88 Lisp_Range_Table *rt = XRANGE_TABLE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
91 for (i = 0; i < gap_array_length (rt->entries); i++)
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
92 mark_object (rangetab_gap_array_at (rt->entries, i).val);
4690
257b468bf2ca Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4391
diff changeset
93
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 }
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 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
98 print_range_table (Lisp_Object obj, Lisp_Object printcharfun,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
99 int UNUSED (escapeflag))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
101 Lisp_Range_Table *rt = XRANGE_TABLE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
104 if (print_readably)
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
105 write_fmt_string_lisp (printcharfun, "#s(range-table :type %s :data (",
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
106 1, range_table_type_to_symbol (rt->type));
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
107 else
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4831
diff changeset
108 write_ascstring (printcharfun, "#<range-table ");
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
109 for (i = 0; i < gap_array_length (rt->entries); i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 {
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
111 struct range_table_entry rte = rangetab_gap_array_at (rt->entries, i);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
112 int so, ec;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 if (i > 0)
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4831
diff changeset
114 write_ascstring (printcharfun, " ");
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
115 switch (rt->type)
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
116 {
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
117 case RANGE_START_CLOSED_END_OPEN: so = 0, ec = 0; break;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
118 case RANGE_START_CLOSED_END_CLOSED: so = 0, ec = 1; break;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
119 case RANGE_START_OPEN_END_OPEN: so = 1, ec = 0; break;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
120 case RANGE_START_OPEN_END_CLOSED: so = 1; ec = 1; break;
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2425
diff changeset
121 default: ABORT (); so = 0, ec = 0; break;
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
122 }
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
123 write_fmt_string (printcharfun, "%c%ld %ld%c ",
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
124 print_readably ? '(' : so ? '(' : '[',
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
125 (long) (rte.first - so),
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
126 (long) (rte.last - ec),
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
127 print_readably ? ')' : ec ? ']' : ')'
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
128 );
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
129 print_internal (rte.val, printcharfun, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 }
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
131 if (print_readably)
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4831
diff changeset
132 write_ascstring (printcharfun, "))");
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
133 else
5146
88bd4f3ef8e4 make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents: 5142
diff changeset
134 write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
5560
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
137 static void
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
138 range_table_print_preprocess (Lisp_Object object,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
139 Lisp_Object print_number_table,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
140 Elemcount *seen_object_count)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
141 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
142 Lisp_Range_Table *rt = XRANGE_TABLE (object);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
143 Elemcount ii;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
144
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
145 for (ii = 0; ii < gap_array_length (rt->entries); ii++)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
146 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
147 struct range_table_entry *entry
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
148 = gap_array_atp (rt->entries, ii, struct range_table_entry);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
149 PRINT_PREPROCESS (entry->val, print_number_table, seen_object_count);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
150 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
151 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
152
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
153 static void
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
154 range_table_nsubst_structures_descend (Lisp_Object new_, Lisp_Object old,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
155 Lisp_Object object,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
156 Lisp_Object number_table,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
157 Boolint test_not_unboundp)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
158 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
159 Lisp_Range_Table *rt = XRANGE_TABLE (object);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
160 Elemcount ii;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
161
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
162 /* We don't have to worry about the range table START and END values if
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
163 we're limiting nsubst_descend to the Lisp reader; it's a similar case
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
164 to the hash table test. */
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
165 for (ii = 0; ii < gap_array_length (rt->entries); ii++)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
166 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
167 struct range_table_entry *entry
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
168 = gap_array_atp (rt->entries, ii, struct range_table_entry);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
169
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
170 if (EQ (old, entry->val) == test_not_unboundp)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
171 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
172 entry->val = new_;
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
173 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
174 else if (LRECORDP (entry->val) &&
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
175 HAS_OBJECT_METH_P (entry->val, nsubst_structures_descend))
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
176 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
177 nsubst_structures_descend (new_, old, entry->val, number_table,
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
178 test_not_unboundp);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
179 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
180 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
181 }
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
182
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 static int
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4831
diff changeset
184 range_table_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, int foldcase)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
186 Lisp_Range_Table *rt1 = XRANGE_TABLE (obj1);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
187 Lisp_Range_Table *rt2 = XRANGE_TABLE (obj2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
190 if (gap_array_length (rt1->entries) != gap_array_length (rt2->entries))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
193 for (i = 0; i < gap_array_length (rt1->entries); i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 {
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
195 struct range_table_entry *rte1 =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
196 rangetab_gap_array_atp (rt1->entries, i);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
197 struct range_table_entry *rte2 =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
198 rangetab_gap_array_atp (rt2->entries, i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 if (rte1->first != rte2->first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 || rte1->last != rte2->last
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4831
diff changeset
202 || !internal_equal_0 (rte1->val, rte2->val, depth + 1, foldcase))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2500
diff changeset
209 static Hashcode
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5169
diff changeset
210 range_table_entry_hash (struct range_table_entry *rte, int depth,
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5169
diff changeset
211 Boolint equalp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 {
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5169
diff changeset
213 return HASH3 (rte->first, rte->last,
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5169
diff changeset
214 internal_hash (rte->val, depth + 1, equalp));
428
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
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2500
diff changeset
217 static Hashcode
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5169
diff changeset
218 range_table_hash (Lisp_Object obj, int depth, Boolint equalp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
220 Lisp_Range_Table *rt = XRANGE_TABLE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 int i;
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
222 int size = gap_array_length (rt->entries);
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2500
diff changeset
223 Hashcode hash = size;
428
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 /* approach based on internal_array_hash(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 if (size <= 5)
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 for (i = 0; i < size; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 hash = HASH2 (hash,
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
230 range_table_entry_hash
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5169
diff changeset
231 (rangetab_gap_array_atp (rt->entries, i), depth, equalp));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 return hash;
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 /* just pick five elements scattered throughout the array.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 A slightly better approach would be to offset by some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 noise factor from the points chosen below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 for (i = 0; i < 5; i++)
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
239 hash = HASH2 (hash,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
240 range_table_entry_hash
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5169
diff changeset
241 (rangetab_gap_array_atp (rt->entries, i*size/5),
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5169
diff changeset
242 depth, equalp));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 return hash;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245
5169
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
246 #ifndef NEW_GC
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
247
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
248 /* #### This leaks memory under NEW_GC. To fix this, convert to Lisp object
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
249 gap array. */
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
250
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
251 static void
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
252 finalize_range_table (Lisp_Object obj)
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
253 {
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
254 Lisp_Range_Table *rt = XRANGE_TABLE (obj);
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
255 if (rt->entries)
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
256 {
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
257 if (!DUMPEDP (rt->entries))
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
258 free_gap_array (rt->entries);
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
259 rt->entries = 0;
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
260 }
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
261 }
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
262
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
263 #endif /* not NEW_GC */
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
264
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 934
diff changeset
265 static const struct memory_description rte_description_1[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
266 { XD_LISP_OBJECT, offsetof (range_table_entry, val) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 934
diff changeset
270 static const struct sized_memory_description rte_description = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
271 sizeof (range_table_entry),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 rte_description_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
275 static const struct memory_description rtega_description_1[] = {
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
276 XD_GAP_ARRAY_DESC (&rte_description),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
280 static const struct sized_memory_description rtega_description = {
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
281 0, rtega_description_1
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 934
diff changeset
284 static const struct memory_description range_table_description[] = {
2551
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
285 { XD_BLOCK_PTR, offsetof (Lisp_Range_Table, entries), 1,
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
286 { &rtega_description } },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4713
diff changeset
290 DEFINE_DUMPABLE_LISP_OBJECT ("range-table", range_table,
5169
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
291 mark_range_table, print_range_table,
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5168
diff changeset
292 IF_OLD_GC (finalize_range_table),
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4713
diff changeset
293 range_table_equal, range_table_hash,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4713
diff changeset
294 range_table_description,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4713
diff changeset
295 Lisp_Range_Table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296
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 /* Range table operations */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
301 #ifdef ERROR_CHECK_STRUCTURES
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
304 verify_range_table (Lisp_Range_Table *rt)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
308 for (i = 0; i < gap_array_length (rt->entries); i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 {
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
310 struct range_table_entry *rte = rangetab_gap_array_atp (rt->entries, i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 assert (rte->last >= rte->first);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 if (i > 0)
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
313 assert (rangetab_gap_array_at (rt->entries, i - 1).last <= rte->first);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 }
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 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 #define verify_range_table(rt)
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 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
323 /* Locate the range table entry corresponding to the value POS, and return
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
324 it. If found, FOUNDP is set to 1 and the return value specifies an entry
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
325 that encloses POS. Otherwise, FOUNDP is set to 0 and the return value
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
326 specifies where an entry that encloses POS would be inserted. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
328 static Elemcount
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
329 get_range_table_pos (Elemcount pos, Elemcount nentries,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
330 struct range_table_entry *tab,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
331 Elemcount gappos, Elemcount gapsize,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
332 int *foundp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 {
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
334 Elemcount left = 0, right = nentries;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 /* binary search for the entry. Based on similar code in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 extent_list_locate(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 while (left != right)
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 /* 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
341 of the list), so NEWPOS must round down. */
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
342 Elemcount newpos = (left + right) >> 1;
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
343 struct range_table_entry *entry =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
344 tab + GAP_ARRAY_ARRAY_TO_MEMORY_POS_1 (newpos, gappos, gapsize);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
345 if (pos >= entry->last)
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
346 left = newpos + 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 else if (pos < entry->first)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 right = newpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 else
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
350 {
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
351 *foundp = 1;
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
352 return newpos;
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
353 }
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
354 }
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
355
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
356 *foundp = 0;
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
357 return left;
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
358 }
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
359
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
360 /* Look up in a range table without the gap array wrapper.
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
361 Used also by the unified range table format. */
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
362
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
363 static Lisp_Object
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
364 get_range_table (Elemcount pos, Elemcount nentries,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
365 struct range_table_entry *tab,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
366 Elemcount gappos, Elemcount gapsize,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
367 Lisp_Object default_)
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
368 {
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
369 int foundp;
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
370 Elemcount entrypos = get_range_table_pos (pos, nentries, tab, gappos,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
371 gapsize, &foundp);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
372 if (foundp)
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
373 {
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
374 struct range_table_entry *entry =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
375 tab + GAP_ARRAY_ARRAY_TO_MEMORY_POS_1 (entrypos, gappos, gapsize);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
376 return entry->val;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 }
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 return default_;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 DEFUN ("range-table-p", Frange_table_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 Return non-nil if OBJECT is a range table.
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 (object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 return RANGE_TABLEP (object) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
390 DEFUN ("range-table-type", Frange_table_type, 1, 1, 0, /*
4713
312503644bc3 Correct the docstring for #'range-table-type.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
391 Return the type of RANGE-TABLE.
312503644bc3 Correct the docstring for #'range-table-type.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
392
312503644bc3 Correct the docstring for #'range-table-type.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
393 This will be a symbol describing how ranges in RANGE-TABLE function at their
312503644bc3 Correct the docstring for #'range-table-type.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
394 ends; see `make-range-table'.
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
395 */
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
396 (range_table))
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
397 {
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
398 CHECK_RANGE_TABLE (range_table);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
399 return range_table_type_to_symbol (XRANGE_TABLE (range_table)->type);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
400 }
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
401
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
402 DEFUN ("make-range-table", Fmake_range_table, 0, 1, 0, /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 Return a new, empty range table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 You can manipulate it using `put-range-table', `get-range-table',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 `remove-range-table', and `clear-range-table'.
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
406 Range tables allow you to efficiently set values for ranges of integers.
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
407
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
408 TYPE is a symbol indicating how ranges are assumed to function at their
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
409 ends. It can be one of
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
410
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
411 SYMBOL RANGE-START RANGE-END
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
412 ------ ----------- ---------
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
413 `start-closed-end-open' (the default) closed open
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
414 `start-closed-end-closed' closed closed
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
415 `start-open-end-open' open open
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
416 `start-open-end-closed' open closed
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
417
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
418 A `closed' endpoint of a range means that the number at that end is included
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
419 in the range. For an `open' endpoint, the number would not be included.
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
420
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
421 For example, a closed-open range from 5 to 20 would be indicated as [5,
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
422 20) where a bracket indicates a closed end and a parenthesis an open end,
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
423 and would mean `all the numbers between 5 and 20', including 5 but not 20.
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
424 This seems a little strange at first but is in fact extremely common in
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
425 the outside world as well as in computers and makes things work sensibly.
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
426 For example, if I say "there are seven days between today and next week
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
427 today", I'm including today but not next week today; if I included both,
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
428 there would be eight days. Similarly, there are 15 (= 20 - 5) elements in
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
429 the range [5, 20), but 16 in the range [5, 20].
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 */
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
431 (type))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 {
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
433 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (range_table);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
434 Lisp_Range_Table *rt = XRANGE_TABLE (obj);
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
435 rt->entries = make_gap_array (sizeof (struct range_table_entry), 0);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
436 rt->type = range_table_symbol_to_type (type);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
437 return obj;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 DEFUN ("copy-range-table", Fcopy_range_table, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
441 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
442 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
443 The values will not themselves be copied.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
445 (range_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
447 Lisp_Range_Table *rt, *rtnew;
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
448 Lisp_Object obj;
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
449 Elemcount i;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
451 CHECK_RANGE_TABLE (range_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
452 rt = XRANGE_TABLE (range_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
454 obj = ALLOC_NORMAL_LISP_OBJECT (range_table);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
455 rtnew = XRANGE_TABLE (obj);
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
456 rtnew->entries = make_gap_array (sizeof (struct range_table_entry), 0);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
457 rtnew->type = rt->type;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
459 for (i = 0; i < gap_array_length (rt->entries); i++)
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
460 rtnew->entries =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
461 gap_array_insert_els (rtnew->entries, i,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
462 rangetab_gap_array_atp (rt->entries, i), 1);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
463 return obj;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 DEFUN ("get-range-table", Fget_range_table, 2, 3, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
467 Find value for position POS in RANGE-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 If there is no corresponding value, return DEFAULT (defaults to nil).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
470 (pos, range_table, default_))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
472 Lisp_Range_Table *rt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
474 CHECK_RANGE_TABLE (range_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
475 rt = XRANGE_TABLE (range_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
477 CHECK_FIXNUM_COERCE_CHAR (pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
479 return get_range_table (XFIXNUM (pos), gap_array_length (rt->entries),
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
480 gap_array_begin (rt->entries,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
481 struct range_table_entry),
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
482 gap_array_gappos (rt->entries),
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
483 gap_array_gapsize (rt->entries),
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
484 default_);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
4831
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
487 static void
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
488 external_to_internal_adjust_ends (enum range_table_type type,
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
489 EMACS_INT *first, EMACS_INT *last)
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
490 {
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
491 /* Fix up the numbers in accordance with the open/closedness to make
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
492 them behave like default open/closed. */
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
493 switch (type)
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
494 {
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
495 case RANGE_START_CLOSED_END_OPEN: break;
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
496 case RANGE_START_CLOSED_END_CLOSED: (*last)++; break;
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
497 case RANGE_START_OPEN_END_OPEN: (*first)++; break;
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
498 case RANGE_START_OPEN_END_CLOSED: (*first)++, (*last)++; break;
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
499 }
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
500 }
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
501
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
502 static void
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
503 internal_to_external_adjust_ends (enum range_table_type type,
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
504 EMACS_INT *first, EMACS_INT *last)
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
505 {
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
506 /* Reverse the changes made in external_to_internal_adjust_ends().
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
507 */
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
508 switch (type)
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
509 {
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
510 case RANGE_START_CLOSED_END_OPEN: break;
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
511 case RANGE_START_CLOSED_END_CLOSED: (*last)--; break;
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
512 case RANGE_START_OPEN_END_OPEN: (*first)--; break;
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
513 case RANGE_START_OPEN_END_CLOSED: (*first)--, (*last)--; break;
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
514 }
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
515 }
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
516
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 put_range_table (Lisp_Object table, EMACS_INT first,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 EMACS_INT last, Lisp_Object val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 int insert_me_here = -1;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
523 Lisp_Range_Table *rt = XRANGE_TABLE (table);
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
524 int foundp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525
4831
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
526 external_to_internal_adjust_ends (rt->type, &first, &last);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
527 if (first == last)
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
528 return;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
529 if (first > last)
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
530 /* This will happen if originally first == last and both ends are
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
531 open. #### Should we signal an error? */
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
532 return;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
533
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
534 if (DUMPEDP (rt->entries))
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
535 rt->entries = gap_array_clone (rt->entries);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
536
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
537 i = get_range_table_pos (first, gap_array_length (rt->entries),
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
538 gap_array_begin (rt->entries,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
539 struct range_table_entry),
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
540 gap_array_gappos (rt->entries),
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
541 gap_array_gapsize (rt->entries), &foundp);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
542
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
543 #ifdef ERROR_CHECK_TYPES
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
544 if (foundp)
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
545 {
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
546 if (i < gap_array_length (rt->entries))
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
547 {
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
548 struct range_table_entry *entry =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
549 rangetab_gap_array_atp (rt->entries, i);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
550 assert (first >= entry->first && first < entry->last);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
551 }
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
552 }
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
553 else
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
554 {
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
555 if (i < gap_array_length (rt->entries))
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
556 {
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
557 struct range_table_entry *entry =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
558 rangetab_gap_array_atp (rt->entries, i);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
559 assert (first < entry->first);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
560 }
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
561 if (i > 0)
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
562 {
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
563 struct range_table_entry *entry =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
564 rangetab_gap_array_atp (rt->entries, i - 1);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
565 assert (first >= entry->last);
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
566 }
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
567 }
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
568 #endif /* ERROR_CHECK_TYPES */
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
569
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
570 /* If the beginning of the new range isn't within any existing range,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
571 it might still be just grazing the end of an end-open range (remember,
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
572 internally all ranges are start-close end-open); so back up one
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
573 so we consider this range. */
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
574 if (!foundp && i > 0)
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
575 i--;
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
576
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 /* Now insert in the proper place. This gets tricky because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 we may be overlapping one or more existing ranges and need
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 to fix them up. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 /* First delete all sections of any existing ranges that overlap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 the new range. */
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
583 for (; i < gap_array_length (rt->entries); i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 {
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
585 struct range_table_entry *entry =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
586 rangetab_gap_array_atp (rt->entries, i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 /* We insert before the first range that begins at or after the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 new range. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 if (entry->first >= first && insert_me_here < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 insert_me_here = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 if (entry->last < first)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 /* completely before the new range. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 if (entry->first > last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 /* completely after the new range. No more possibilities of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 finding overlapping ranges. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 break;
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
598 /* At this point the existing ENTRY overlaps or touches the new one. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 if (entry->first < first && entry->last <= last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 /* looks like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
603 [ NEW )
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
604 [ EXISTING )
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
605
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
606 or
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
607
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
608 [ NEW )
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
609 [ EXISTING )
428
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 /* truncate the end off of it. */
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
613 entry->last = first;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 else if (entry->first < first && entry->last > last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 /* looks like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
618 [ NEW )
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
619 [ EXISTING )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 /* need to split this one in two. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 struct range_table_entry insert_me_too;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
626 insert_me_too.first = last;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 insert_me_too.last = entry->last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 insert_me_too.val = entry->val;
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
629 entry->last = first;
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
630 rt->entries =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
631 gap_array_insert_els (rt->entries, i + 1, &insert_me_too, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 }
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
633 else if (entry->last >= last)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 /* looks like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
637 [ NEW )
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
638 [ EXISTING )
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
639
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
640 or
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
641
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
642 [ NEW )
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
643 [ EXISTING )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 /* truncate the start off of it. */
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
647 entry->first = last;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 /* existing is entirely within new. */
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
652 gap_array_delete_els (rt->entries, i, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 i--; /* back up since everything shifted one to the left. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 /* Someone asked us to delete the range, not insert it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 if (UNBOUNDP (val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 /* Now insert the new entry, maybe at the end. */
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 if (insert_me_here < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 insert_me_here = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 struct range_table_entry insert_me;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 insert_me.first = first;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 insert_me.last = last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 insert_me.val = val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
673 rt->entries =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
674 gap_array_insert_els (rt->entries, insert_me_here, &insert_me, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 /* Now see if we can combine this entry with adjacent ones just
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 before or after. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 if (insert_me_here > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 {
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
682 struct range_table_entry *entry =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
683 rangetab_gap_array_atp (rt->entries, insert_me_here - 1);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
684 if (EQ (val, entry->val) && entry->last == first)
428
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 entry->last = last;
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
687 gap_array_delete_els (rt->entries, insert_me_here, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 insert_me_here--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 /* We have morphed into a larger range. Update our records
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 in case we also combine with the one after. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 first = entry->first;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
695 if (insert_me_here < gap_array_length (rt->entries) - 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 {
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
697 struct range_table_entry *entry =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
698 rangetab_gap_array_atp (rt->entries, insert_me_here + 1);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
699 if (EQ (val, entry->val) && entry->first == last)
428
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 entry->first = first;
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
702 gap_array_delete_els (rt->entries, insert_me_here, 1);
428
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 }
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 DEFUN ("put-range-table", Fput_range_table, 4, 4, 0, /*
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
708 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
709 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
710 (start, end, value, range_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 EMACS_INT first, last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
714 CHECK_RANGE_TABLE (range_table);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
715 CHECK_FIXNUM_COERCE_CHAR (start);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
716 first = XFIXNUM (start);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
717 CHECK_FIXNUM_COERCE_CHAR (end);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
718 last = XFIXNUM (end);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 if (first > last)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
720 invalid_argument_2 ("start must be <= end", start, end);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
722 put_range_table (range_table, first, last, value);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
723 verify_range_table (XRANGE_TABLE (range_table));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 return Qnil;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 DEFUN ("remove-range-table", Fremove_range_table, 3, 3, 0, /*
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
728 Remove the value for range START .. END in RANGE-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
730 (start, end, range_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
732 return Fput_range_table (start, end, Qunbound, range_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 DEFUN ("clear-range-table", Fclear_range_table, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
736 Flush RANGE-TABLE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
738 (range_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
740 CHECK_RANGE_TABLE (range_table);
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
741 gap_array_delete_all_els (XRANGE_TABLE (range_table)->entries);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 DEFUN ("map-range-table", Fmap_range_table, 2, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
746 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
747 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
748
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
749 Results are guaranteed to be correct (i.e. each entry processed
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
750 exactly once) if FUNCTION modifies or deletes the current entry
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
751 \(i.e. passes the current range to `put-range-table' or
4391
cbf129b005df Clarify #'map-range-table docstring.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3017
diff changeset
752 `remove-range-table'). If FUNCTION modifies or deletes any other entry,
cbf129b005df Clarify #'map-range-table docstring.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3017
diff changeset
753 this guarantee doesn't hold.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
755 (function, range_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
757 Lisp_Range_Table *rt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
758 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
759
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
760 CHECK_RANGE_TABLE (range_table);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
761 CHECK_FUNCTION (function);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
762
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
763 rt = XRANGE_TABLE (range_table);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
764
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
765 /* Do not "optimize" by pulling out the length computation below!
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
766 FUNCTION may have changed the table. */
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
767 for (i = 0; i < gap_array_length (rt->entries); i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
768 {
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
769 struct range_table_entry entry =
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
770 rangetab_gap_array_at (rt->entries, i);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
771 EMACS_INT first, last;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
772 Lisp_Object args[4];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
773 int oldlen;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
774
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
775 again:
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
776 first = entry.first;
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
777 last = entry.last;
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
778 oldlen = gap_array_length (rt->entries);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
779 args[0] = function;
2952
861a7995b9fe [xemacs-hg @ 2005-09-26 08:29:27 by ben]
ben
parents: 2720
diff changeset
780 /* Fix up the numbers in accordance with the open/closedness of the
861a7995b9fe [xemacs-hg @ 2005-09-26 08:29:27 by ben]
ben
parents: 2720
diff changeset
781 table. */
861a7995b9fe [xemacs-hg @ 2005-09-26 08:29:27 by ben]
ben
parents: 2720
diff changeset
782 {
861a7995b9fe [xemacs-hg @ 2005-09-26 08:29:27 by ben]
ben
parents: 2720
diff changeset
783 EMACS_INT premier = first, dernier = last;
4831
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
784 internal_to_external_adjust_ends (rt->type, &premier, &dernier);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
785 args[1] = make_fixnum (premier);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
786 args[2] = make_fixnum (dernier);
2952
861a7995b9fe [xemacs-hg @ 2005-09-26 08:29:27 by ben]
ben
parents: 2720
diff changeset
787 }
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
788 args[3] = entry.val;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
789 Ffuncall (countof (args), args);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
790 /* Has FUNCTION removed the entry? */
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
791 if (oldlen > gap_array_length (rt->entries)
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
792 && i < gap_array_length (rt->entries)
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
793 && (first != entry.first || last != entry.last))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
794 goto again;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
795 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
796
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 /* Range table read syntax */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 static int
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
806 rangetab_type_validate (Lisp_Object UNUSED (keyword), Lisp_Object value,
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
807 Error_Behavior UNUSED (errb))
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
808 {
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
809 /* #### should deal with ERRB */
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
810 range_table_symbol_to_type (value);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
811 return 1;
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
812 }
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
813
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
814 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
815 rangetab_data_validate (Lisp_Object UNUSED (keyword), Lisp_Object value,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
816 Error_Behavior UNUSED (errb))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
818 /* #### should deal with ERRB */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
819 EXTERNAL_PROPERTY_LIST_LOOP_3 (range, data, value)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
821 if (!FIXNUMP (range) && !CHARP (range)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 && !(CONSP (range) && CONSP (XCDR (range))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 && NILP (XCDR (XCDR (range)))
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
824 && (FIXNUMP (XCAR (range)) || CHARP (XCAR (range)))
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5560
diff changeset
825 && (FIXNUMP (XCAR (XCDR (range))) || CHARP (XCAR (XCDR (range))))))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
826 sferror ("Invalid range format", range);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 static Lisp_Object
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
833 rangetab_instantiate (Lisp_Object plist)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 {
2425
b3315b0c8558 [xemacs-hg @ 2004-12-06 23:27:15 by ben]
ben
parents: 2421
diff changeset
835 Lisp_Object data = Qnil, type = Qnil, rangetab;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
837 if (KEYWORDP (Fcar (plist)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 {
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
839 PROPERTY_LIST_LOOP_3 (key, value, plist)
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
840 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
841 if (EQ (key, Q_type)) type = value;
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
842 else if (EQ (key, Q_data)) data = value;
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
843 else if (!KEYWORDP (key))
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
844 signal_error
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
845 (Qinvalid_read_syntax,
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
846 "can't mix keyword and non-keyword structure syntax",
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
847 key);
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
848 else
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
849 ABORT ();
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
850 }
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
851 }
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
852 #ifdef NEED_TO_HANDLE_21_4_CODE
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
853 else
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
854 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
855 PROPERTY_LIST_LOOP_3 (key, value, plist)
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
856 {
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
857 if (EQ (key, Qtype)) type = value;
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
858 else if (EQ (key, Qdata)) data = value;
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
859 else if (KEYWORDP (key))
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
860 signal_error
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
861 (Qinvalid_read_syntax,
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
862 "can't mix keyword and non-keyword structure syntax",
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
863 key);
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
864 else
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
865 ABORT ();
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
866 }
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
867 }
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
868 #endif /* NEED_TO_HANDLE_21_4_CODE */
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
869
2425
b3315b0c8558 [xemacs-hg @ 2004-12-06 23:27:15 by ben]
ben
parents: 2421
diff changeset
870 rangetab = Fmake_range_table (type);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
872 {
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
873 PROPERTY_LIST_LOOP_3 (range, val, data)
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
874 {
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
875 if (CONSP (range))
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
876 Fput_range_table (Fcar (range), Fcar (Fcdr (range)), val,
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
877 rangetab);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
878 else
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
879 Fput_range_table (range, range, val, rangetab);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
880 }
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
881 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 return rangetab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 /* Unified range tables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 /* A "unified range table" is a format for storing range tables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 as contiguous blocks of memory. This is used by the regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 code, which needs to use range tables to properly handle []
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 constructs in the presence of extended characters but wants to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 store an entire compiled pattern as a contiguous block of memory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 Unified range tables are designed so that they can be placed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 at an arbitrary (possibly mis-aligned) place in memory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 (Dealing with alignment is a pain in the ass.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 WARNING: No provisions for garbage collection are currently made.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 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
903 range table that need to be marked for garbage collection.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 Good candidates for objects that can go into a range table are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 -- numbers and characters (do not need to be marked)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 -- nil, t (marked elsewhere)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 -- charsets and coding systems (automatically marked because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 they are in a marked list,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 and can't be removed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 Good but slightly less so:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 -- symbols (could be uninterned, but that is not likely)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 Somewhat less good:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 -- buffers, frames, devices (could get deleted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 It is expected that you work with range tables in the normal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 format and then convert to unified format when you are done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 making modifications. As such, no functions are provided
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 for modifying a unified range table. The only operations
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 you can do to unified range tables are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 -- look up a value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 -- retrieve all the ranges in an iterative fashion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 /* The format of a unified range table is as follows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 -- 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
935 actual start of the table. This deals with alignment constraints,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 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
937 -- 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
938 *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
939 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
940 necessarily start the stuff at the very end of the table because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 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
942 we have to move the range table around. (It appears that some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 architectures don't maintain alignment when reallocing.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 -- At the prescribed offset is a struct unified_range_table, containing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 some number of `struct range_table_entry' entries. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 struct unified_range_table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 int nentries;
4831
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
950 enum range_table_type type;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 struct range_table_entry first;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 /* 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
955
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 unified_range_table_bytes_needed (Lisp_Object rangetab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 return (sizeof (struct range_table_entry) *
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
960 (gap_array_length (XRANGE_TABLE (rangetab)->entries) - 1) +
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 sizeof (struct unified_range_table) +
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 /* ALIGNOF a struct may be too big. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 /* We have four bytes for the size numbers, and an extra
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 four or eight bytes for making sure we get the alignment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 OK. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 ALIGNOF (EMACS_INT) + 4);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 /* Convert a range table into unified format and store in DEST,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 which must be able to hold the number of bytes returned by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 range_table_bytes_needed(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 unified_range_table_copy_data (Lisp_Object rangetab, void *dest)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 /* We cast to the above structure rather than just casting to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 char * and adding sizeof(int), because that will lead to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 mis-aligned data on the Alpha machines. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 struct unified_range_table *un;
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
980 Gap_Array *rtega = XRANGE_TABLE (rangetab)->entries;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 int total_needed = unified_range_table_bytes_needed (rangetab);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
982 void *new_dest = ALIGN_PTR ((char *) dest + 4, EMACS_INT);
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
983 Elemcount i;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 * (char *) dest = (char) ((char *) new_dest - (char *) dest);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 * ((unsigned char *) dest + 1) = total_needed & 0xFF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 total_needed >>= 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 * ((unsigned char *) dest + 2) = total_needed & 0xFF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 total_needed >>= 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 * ((unsigned char *) dest + 3) = total_needed & 0xFF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 un = (struct unified_range_table *) new_dest;
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
992 un->nentries = gap_array_length (rtega);
4831
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
993 un->type = XRANGE_TABLE (rangetab)->type;
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
994 for (i = 0; i < gap_array_length (rtega); i++)
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
995 (&un->first)[i] = rangetab_gap_array_at (rtega, i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 /* Return number of bytes actually used by a unified range table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 unified_range_table_bytes_used (void *unrangetab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 return ((* ((unsigned char *) unrangetab + 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 + ((* ((unsigned char *) unrangetab + 2)) << 8)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 + ((* ((unsigned char *) unrangetab + 3)) << 16));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 /* 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
1009 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 align_the_damn_table (void *unrangetab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 void *cur_dest = (char *) unrangetab + * (char *) unrangetab;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
1013 if (cur_dest != ALIGN_PTR (cur_dest, EMACS_INT))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 int count = (unified_range_table_bytes_used (unrangetab) - 4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 - ALIGNOF (EMACS_INT));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 /* Find the proper location, just like above. */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
1018 void *new_dest = ALIGN_PTR ((char *) unrangetab + 4, EMACS_INT);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 /* memmove() works in the presence of overlapping data. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 memmove (new_dest, cur_dest, count);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 * (char *) unrangetab = (char) ((char *) new_dest - (char *) unrangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 /* Look up a value in a unified range table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 unified_range_table_lookup (void *unrangetab, EMACS_INT pos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 Lisp_Object default_)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 void *new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 struct unified_range_table *un;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 align_the_damn_table (unrangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 new_dest = (char *) unrangetab + * (char *) unrangetab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 un = (struct unified_range_table *) new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037
5168
cf900a2f1fa3 extract gap array from extents.c, use in range tables
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
1038 return get_range_table (pos, un->nentries, &un->first, 0, 0, default_);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 /* Return number of entries in a unified range table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 unified_range_table_nentries (void *unrangetab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 void *new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 struct unified_range_table *un;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 align_the_damn_table (unrangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 new_dest = (char *) unrangetab + * (char *) unrangetab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 un = (struct unified_range_table *) new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 return un->nentries;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 /* Return the OFFSETth range (counting from 0) in UNRANGETAB. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 unified_range_table_get_range (void *unrangetab, int offset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 EMACS_INT *min, EMACS_INT *max,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 Lisp_Object *val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 void *new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 struct unified_range_table *un;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 struct range_table_entry *tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 align_the_damn_table (unrangetab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 new_dest = (char *) unrangetab + * (char *) unrangetab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 un = (struct unified_range_table *) new_dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 assert (offset >= 0 && offset < un->nentries);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 tab = (&un->first) + offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 *min = tab->first;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 *max = tab->last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 *val = tab->val;
4831
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
1074
2e15c29cc2b3 fix bug in returning range table ends in unified range table code
Ben Wing <ben@xemacs.org>
parents: 4713
diff changeset
1075 internal_to_external_adjust_ends (un->type, min, max);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 /* Initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 /************************************************************************/
5560
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
1082 void
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
1083 rangetab_objects_create (void)
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
1084 {
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
1085 OBJECT_HAS_METHOD (range_table, print_preprocess);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
1086 OBJECT_HAS_METHOD (range_table, nsubst_structures_descend);
58b38d5b32d0 Implement print-circle, allowing recursive and circular structures to be read.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
1087 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 syms_of_rangetab (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 {
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3017
diff changeset
1092 INIT_LISP_OBJECT (range_table);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1093
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
1094 DEFSYMBOL_MULTIWORD_PREDICATE (Qrange_tablep);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
1095 DEFSYMBOL (Qrange_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
1097 DEFSYMBOL (Qstart_closed_end_open);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
1098 DEFSYMBOL (Qstart_open_end_open);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
1099 DEFSYMBOL (Qstart_closed_end_closed);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
1100 DEFSYMBOL (Qstart_open_end_closed);
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
1101
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 DEFSUBR (Frange_table_p);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
1103 DEFSUBR (Frange_table_type);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 DEFSUBR (Fmake_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 DEFSUBR (Fcopy_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 DEFSUBR (Fget_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 DEFSUBR (Fput_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 DEFSUBR (Fremove_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 DEFSUBR (Fclear_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 DEFSUBR (Fmap_range_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 structure_type_create_rangetab (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 struct structure_type *st;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 st = define_structure_type (Qrange_table, 0, rangetab_instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1120 define_structure_type_keyword (st, Q_data, rangetab_data_validate);
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1121 define_structure_type_keyword (st, Q_type, rangetab_type_validate);
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1122 #ifdef NEED_TO_HANDLE_21_4_CODE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 define_structure_type_keyword (st, Qdata, rangetab_data_validate);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
1124 define_structure_type_keyword (st, Qtype, rangetab_type_validate);
5222
18c0b5909d16 Use keywords in structure syntax; new #define, NEED_TO_HANDLE_21_4_CODE 1
Aidan Kehoe <kehoea@parhasard.net>
parents: 5191
diff changeset
1125 #endif /* NEED_TO_HANDLE_21_4_CODE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 }