annotate src/rangetab.c @ 800:a5954632b187

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