annotate src/buffer.h @ 167:85ec50267440 r20-3b10

Import from CVS: tag r20-3b10
author cvs
date Mon, 13 Aug 2007 09:45:46 +0200
parents 0d2f883870bc
children bfd6434d15b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Header file for the buffer manipulation primitives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 Copyright (C) 1995 Sun Microsystems, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* Synched up with: FSF 19.30. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 /* Authorship:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 FSF: long ago.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 JWZ: separated out bufslots.h, early in Lemacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 Ben Wing: almost completely rewritten for Mule, 19.12.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #ifndef _XEMACS_BUFFER_H_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #define _XEMACS_BUFFER_H_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
35 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
36 #include "mule-charset.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
37 #endif
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
38
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 /* definition of Lisp buffer object */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 /* Note: we keep both Bytind and Bufpos versions of some of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 important buffer positions because they are accessed so much.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 If we didn't do this, we would constantly be invalidating the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 bufpos<->bytind cache under Mule.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 Note that under non-Mule, both versions will always be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 same so we don't really need to keep track of them. But it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 simplifies the logic to go ahead and do so all the time and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 the memory loss is insignificant. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 /* Formerly, it didn't much matter what went inside the struct buffer_text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 and what went outside it. Now it does, with the advent of "indirect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 buffers" that share text with another buffer. An indirect buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 shares the same *text* as another buffer, but has its own buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 variables, its own accessible region, and its own markers and extents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (Due to the nature of markers, it doesn't actually matter much whether
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 we stick them inside or out of the struct buffer_text -- the user won't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 notice any difference -- but we go ahead and put them outside for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 consistency and overall saneness of algorithm.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 FSFmacs gets away with not maintaining any "children" pointers from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 a buffer to the indirect buffers that refer to it by putting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 markers inside of the struct buffer_text, using markers to keep track
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 of BEGV and ZV in indirect buffers, and relying on the fact that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 all intervals (text properties and overlays) use markers for their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 start and end points. We don't do this for extents (markers are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 inefficient anyway and take up space), so we have to maintain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 children pointers. This is not terribly hard, though, and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 code to maintain this is just like the code already present in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 extent-parent and extent-children.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 struct buffer_text
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
78 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
79 Bufbyte *beg; /* Actual address of buffer contents. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
80 Bytind gpt; /* Index of gap in buffer. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
81 Bytind z; /* Index of end of buffer. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
82 Bufpos bufz; /* Equivalent as a Bufpos. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
83 int gap_size; /* Size of buffer's gap */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
84 int end_gap_size; /* Size of buffer's end gap */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
85 long modiff; /* This counts buffer-modification events
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
86 for this buffer. It is incremented for
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
87 each such event, and never otherwise
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
88 changed. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
89 long save_modiff; /* Previous value of modiff, as of last
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
90 time buffer visited or saved a file. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
92 #ifdef MULE
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
93 /* We keep track of a "known" region for very fast access.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
94 This information is text-only so it goes here. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
95 Bufpos mule_bufmin, mule_bufmax;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
96 Bytind mule_bytmin, mule_bytmax;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
97 int mule_shifter, mule_three_p;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
98
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
99 /* And we also cache 16 positions for fairly fast access near those
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
100 positions. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
101 Bufpos mule_bufpos_cache[16];
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
102 Bytind mule_bytind_cache[16];
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
103 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
105 /* Change data that goes with the text. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
106 struct buffer_text_change_data *changes;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
108 };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 struct buffer
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
111 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
112 struct lcrecord_header header;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
114 /* This structure holds the coordinates of the buffer contents
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
115 in ordinary buffers. In indirect buffers, this is not used. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
116 struct buffer_text own_text;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
118 /* This points to the `struct buffer_text' that is used for this buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
119 In an ordinary buffer, this is the own_text field above.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
120 In an indirect buffer, this is the own_text field of another buffer. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
121 struct buffer_text *text;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
123 Bytind pt; /* Position of point in buffer. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
124 Bufpos bufpt; /* Equivalent as a Bufpos. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
125 Bytind begv; /* Index of beginning of accessible range. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
126 Bufpos bufbegv; /* Equivalent as a Bufpos. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
127 Bytind zv; /* Index of end of accessible range. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
128 Bufpos bufzv; /* Equivalent as a Bufpos. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
130 int face_change; /* This is set when a change in how the text should
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
131 be displayed (e.g., font, color) is made. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
133 /* change data indicating what portion of the text has changed
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
134 since the last time this was reset. Used by redisplay.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
135 Logically we should keep this with the text structure, but
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
136 redisplay resets it for each buffer individually and we don't
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
137 want interference between an indirect buffer and its base
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
138 buffer. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
139 struct each_buffer_change_data *changes;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 #ifdef REGION_CACHE_NEEDS_WORK
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
142 /* If the long line scan cache is enabled (i.e. the buffer-local
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
143 variable cache-long-line-scans is non-nil), newline_cache
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
144 points to the newline cache, and width_run_cache points to the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
145 width run cache.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
147 The newline cache records which stretches of the buffer are
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
148 known *not* to contain newlines, so that they can be skipped
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
149 quickly when we search for newlines.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
151 The width run cache records which stretches of the buffer are
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
152 known to contain characters whose widths are all the same. If
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
153 the width run cache maps a character to a value > 0, that value
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
154 is the character's width; if it maps a character to zero, we
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
155 don't know what its width is. This allows compute_motion to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
156 process such regions very quickly, using algebra instead of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
157 inspecting each character. See also width_table, below. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
158 struct region_cache *newline_cache;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
159 struct region_cache *width_run_cache;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
160 #endif /* REGION_CACHE_NEEDS_WORK */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
162 /* The markers that refer to this buffer. This is actually a single
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
163 marker -- successive elements in its marker `chain' are the other
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
164 markers referring to this buffer */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
165 struct Lisp_Marker *markers;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
167 /* The buffer's extent info. This is its own type, an extent-info
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
168 object (done this way for ease in marking / finalizing). */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
169 Lisp_Object extent_info;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
171 /* ----------------------------------------------------------------- */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
172 /* All the stuff above this line is the responsibility of insdel.c,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
173 with some help from marker.c and extents.c.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
174 All the stuff below this line is the responsibility of buffer.c. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
176 /* In an indirect buffer, this points to the base buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
177 In an ordinary buffer, it is 0.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
178 We DO mark through this slot. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
179 struct buffer *base_buffer;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
181 /* List of indirect buffers whose base is this buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
182 If we are an indirect buffer, this will be nil.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
183 Do NOT mark through this. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
184 Lisp_Object indirect_children;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
186 /* Flags saying which DEFVAR_PER_BUFFER variables
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
187 are local to this buffer. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
188 int local_var_flags;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
190 /* Set to the modtime of the visited file when read or written.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
191 -1 means visited file was nonexistent.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
192 0 means visited file modtime unknown; in no case complain
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
193 about any mismatch on next save attempt. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
194 int modtime;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
196 /* the value of text->modiff at the last auto-save. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
197 int auto_save_modified;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
199 /* The time at which we detected a failure to auto-save,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
200 Or -1 if we didn't have a failure. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
201 int auto_save_failure_time;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
203 /* Position in buffer at which display started
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
204 the last time this buffer was displayed. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
205 int last_window_start;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
207 /* Everything from here down must be a Lisp_Object */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 #define MARKED_SLOT(x) Lisp_Object x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 #include "bufslots.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 #undef MARKED_SLOT
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
212 };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 DECLARE_LRECORD (buffer, struct buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 #define XBUFFER(x) XRECORD (x, buffer, struct buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 #define XSETBUFFER(x, p) XSETRECORD (x, p, buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 #define BUFFERP(x) RECORDP (x, buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 #define GC_BUFFERP(x) GC_RECORDP (x, buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 #define CHECK_BUFFER(x) CHECK_RECORD (x, buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 #define CONCHECK_BUFFER(x) CONCHECK_RECORD (x, buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 #define BUFFER_LIVE_P(b) (!NILP ((b)->name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 extern Lisp_Object Qbuffer_live_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 #define CHECK_LIVE_BUFFER(x) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 do { CHECK_BUFFER (x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 if (!BUFFER_LIVE_P (XBUFFER (x))) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 dead_wrong_type_argument (Qbuffer_live_p, (x)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 #define CONCHECK_LIVE_BUFFER(x) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 do { CONCHECK_BUFFER (x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 if (!BUFFER_LIVE_P (XBUFFER (x))) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 x = wrong_type_argument (Qbuffer_live_p, (x)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 #define BUFFER_OR_STRING_P(x) (BUFFERP (x) || STRINGP (x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 extern Lisp_Object Qbuffer_or_string_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 #define CHECK_BUFFER_OR_STRING(x) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 do { if (!BUFFER_OR_STRING_P (x)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 dead_wrong_type_argument (Qbuffer_or_string_p, (x)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 #define CONCHECK_BUFFER_OR_STRING(x) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 do { if (!BUFFER_OR_STRING_P (x)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 x = wrong_type_argument (Qbuffer_or_string_p, (x)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 #define CHECK_LIVE_BUFFER_OR_STRING(x) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 do { CHECK_BUFFER_OR_STRING (x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 if (BUFFERP (x)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 CHECK_LIVE_BUFFER (x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 #define CONCHECK_LIVE_BUFFER_OR_STRING(x) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 do { CONCHECK_BUFFER_OR_STRING (x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 if (BUFFERP (x)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 CONCHECK_LIVE_BUFFER (x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 /* NOTE: In all the following macros, we follow these rules concerning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 multiple evaluation of the arguments:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 1) Anything that's an lvalue can be evaluated more than once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 2) Anything that's a Lisp Object can be evaluated more than once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 This should probably be changed, but this follows the way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 that all the macros in lisp.h do things.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 3) 'struct buffer *' arguments can be evaluated more than once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 4) Nothing else can be evaluated more than once. Use MTxx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 variables to prevent multiple evaluation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 5) An exception to (4) is that there are some macros below that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 may evaluate their arguments more than once. They are all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 denoted with the word "unsafe" in their name and are generally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 meant to be called only by other macros that have already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 stored the calling values in temporary variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 /* working with raw internal-format data */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 /* Use these on contiguous strings of data. If the text you're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 operating on is known to come from a buffer, use the buffer-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 functions below -- they know about the gap and may be more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 efficient. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 /* Functions are as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (A) For working with charptr's (pointers to internally-formatted text):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 -----------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 VALID_CHARPTR_P(ptr):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 Given a charptr, does it point to the beginning of a character?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ASSERT_VALID_CHARPTR(ptr):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 If error-checking is enabled, assert that the given charptr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 points to the beginning of a character. Otherwise, do nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 INC_CHARPTR(ptr):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 Given a charptr (assumed to point at the beginning of a character),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 modify that pointer so it points to the beginning of the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 DEC_CHARPTR(ptr):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 Given a charptr (assumed to point at the beginning of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 character or at the very end of the text), modify that pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 so it points to the beginning of the previous character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 VALIDATE_CHARPTR_BACKWARD(ptr):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 Make sure that PTR is pointing to the beginning of a character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 If not, back up until this is the case. Note that there are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 too many places where it is legitimate to do this sort of thing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 It's an error if you're passed an "invalid" char * pointer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 NOTE: PTR *must* be pointing to a valid part of the string (i.e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 not the very end, unless the string is zero-terminated or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 something) in order for this function to not cause crashes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 VALIDATE_CHARPTR_FORWARD(ptr):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 Make sure that PTR is pointing to the beginning of a character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 If not, move forward until this is the case. Note that there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 are not too many places where it is legitimate to do this sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 of thing. It's an error if you're passed an "invalid" char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 pointer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (B) For working with the length (in bytes and characters) of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 section of internally-formatted text:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 --------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 bytecount_to_charcount(ptr, nbi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 Given a pointer to a text string and a length in bytes,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 return the equivalent length in characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 charcount_to_bytecount(ptr, nch):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 Given a pointer to a text string and a length in characters,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 return the equivalent length in bytes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 charptr_n_addr(ptr, n):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 Return a pointer to the beginning of the character offset N
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (in characters) from PTR.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 charptr_length(ptr):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 Given a zero-terminated pointer to Emacs characters,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 return the number of Emacs characters contained within.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (C) For retrieving or changing the character pointed to by a charptr:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ---------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 charptr_emchar(ptr):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 Retrieve the character pointed to by PTR as an Emchar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 charptr_emchar_n(ptr, n):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 Retrieve the character at offset N (in characters) from PTR,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 as an Emchar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 set_charptr_emchar(ptr, ch):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 Store the character CH (an Emchar) as internally-formatted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 text starting at PTR. Return the number of bytes stored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 charptr_copy_char(ptr, ptr2):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 Retrieve the character pointed to by PTR and store it as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 internally-formatted text in PTR2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (D) For working with Emchars:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 -----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
372 [Note that there are other functions/macros for working with Emchars
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
373 in mule-charset.h, for retrieving the charset of an Emchar
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
374 and such. These are only valid when MULE is defined.]
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
375
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 valid_char_p(ch):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 Return whether the given Emchar is valid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 CHARP(ch):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 Return whether the given Lisp_Object is a valid character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 This is approximately the same as saying the Lisp_Object is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 an int whose value is a valid Emchar. (But not exactly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 because when MULE is not defined, we allow arbitrary values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 in all but the lowest 8 bits and mask them off, for backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 compatibility.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 CHECK_CHAR_COERCE_INT(ch):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 Signal an error if CH is not a valid character as per CHARP().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 Also canonicalize the value into a valid Emchar, as necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (This only means anything when MULE is not defined.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 COERCE_CHAR(ch):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 Coerce an object that is known to satisfy CHARP() into a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 valid Emchar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 MAX_EMCHAR_LEN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 Maximum number of buffer bytes per Emacs character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 /* ---------------------------------------------------------------------- */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 /* (A) For working with charptr's (pointers to internally-formatted text) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 /* ---------------------------------------------------------------------- */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
406 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
407 # define VALID_CHARPTR_P(ptr) BUFBYTE_FIRST_BYTE_P (* (unsigned char *) ptr)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
408 #else
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
409 # define VALID_CHARPTR_P(ptr) 1
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
410 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 #ifdef ERROR_CHECK_BUFPOS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 # define ASSERT_VALID_CHARPTR(ptr) assert (VALID_CHARPTR_P (ptr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 # define ASSERT_VALID_CHARPTR(ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 /* Note that INC_CHARPTR() and DEC_CHARPTR() have to be written in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 completely separate ways. INC_CHARPTR() cannot use the DEC_CHARPTR()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 trick of looking for a valid first byte because it might run off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 the end of the string. DEC_CHARPTR() can't use the INC_CHARPTR()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 method because it doesn't have easy access to the first byte of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 the character it's moving over. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 #define real_inc_charptr_fun(ptr) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ((ptr) += REP_BYTES_BY_FIRST_BYTE (* (unsigned char *) (ptr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 #ifdef ERROR_CHECK_BUFPOS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 #define inc_charptr_fun(ptr) (ASSERT_VALID_CHARPTR (ptr), \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 real_inc_charptr_fun (ptr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 #define inc_charptr_fun(ptr) real_inc_charptr_fun (ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 #define REAL_INC_CHARPTR(ptr) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 real_inc_charptr_fun (ptr); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 #define INC_CHARPTR(ptr) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 ASSERT_VALID_CHARPTR (ptr); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 REAL_INC_CHARPTR (ptr); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 #define REAL_DEC_CHARPTR(ptr) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (ptr)--; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 } while (!VALID_CHARPTR_P (ptr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 #ifdef ERROR_CHECK_BUFPOS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 #define DEC_CHARPTR(ptr) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 CONST Bufbyte *__dcptr__ = (ptr); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 CONST Bufbyte *__dcptr2__ = __dcptr__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 REAL_DEC_CHARPTR (__dcptr2__); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 assert (__dcptr__ - __dcptr2__ == \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 REP_BYTES_BY_FIRST_BYTE (*__dcptr2__)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (ptr) = __dcptr2__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 #define DEC_CHARPTR(ptr) REAL_DEC_CHARPTR (ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
464 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
465
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
466 #define VALIDATE_CHARPTR_BACKWARD(ptr) do \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
467 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
468 while (!VALID_CHARPTR_P (ptr)) ptr--; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
469 } while (0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
470
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
471 /* This needs to be trickier to avoid the possibility of running off
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
472 the end of the string. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
473
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
474 #define VALIDATE_CHARPTR_FORWARD(ptr) do \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
475 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
476 Bufbyte *__vcfptr__ = (ptr); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
477 VALIDATE_CHARPTR_BACKWARD (__vcfptr__); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
478 if (__vcfptr__ != (ptr)) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
479 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
480 (ptr) = __vcfptr__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
481 INC_CHARPTR (ptr); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
482 } \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
483 } while (0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
484
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
485 #else /* not MULE */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 #define VALIDATE_CHARPTR_BACKWARD(ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 #define VALIDATE_CHARPTR_FORWARD(ptr)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
488 #endif /* not MULE */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 /* -------------------------------------------------------------- */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 /* (B) For working with the length (in bytes and characters) of a */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 /* section of internally-formatted text */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 /* -------------------------------------------------------------- */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 INLINE CONST Bufbyte *charptr_n_addr (CONST Bufbyte *ptr, Charcount offset);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 INLINE CONST Bufbyte *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 charptr_n_addr (CONST Bufbyte *ptr, Charcount offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 return ptr + charcount_to_bytecount (ptr, offset);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 INLINE Charcount charptr_length (CONST Bufbyte *ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 INLINE Charcount
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 charptr_length (CONST Bufbyte *ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 return bytecount_to_charcount (ptr, strlen ((CONST char *) ptr));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 /* -------------------------------------------------------------------- */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 /* (C) For retrieving or changing the character pointed to by a charptr */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 /* -------------------------------------------------------------------- */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 #define simple_charptr_emchar(ptr) ((Emchar) (ptr)[0])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 #define simple_set_charptr_emchar(ptr, x) ((ptr)[0] = (Bufbyte) (x), 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 #define simple_charptr_copy_char(ptr, ptr2) ((ptr2)[0] = *(ptr), 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
518 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
519
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
520 Emchar non_ascii_charptr_emchar (CONST Bufbyte *ptr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
521 Bytecount non_ascii_set_charptr_emchar (Bufbyte *ptr, Emchar c);
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
522 Bytecount non_ascii_charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
523
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
524 INLINE Emchar charptr_emchar (CONST Bufbyte *ptr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
525 INLINE Emchar
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
526 charptr_emchar (CONST Bufbyte *ptr)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
527 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
528 if (BYTE_ASCII_P (*ptr))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
529 return simple_charptr_emchar (ptr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
530 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
531 return non_ascii_charptr_emchar (ptr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
532 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
533
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
534 INLINE Bytecount set_charptr_emchar (Bufbyte *ptr, Emchar x);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
535 INLINE Bytecount
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
536 set_charptr_emchar (Bufbyte *ptr, Emchar x)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
537 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
538 if (!CHAR_MULTIBYTE_P (x))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
539 return simple_set_charptr_emchar (ptr, x);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
540 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
541 return non_ascii_set_charptr_emchar (ptr, x);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
542 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
543
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
544 INLINE Bytecount charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
545 INLINE Bytecount
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
546 charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
547 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
548 if (BYTE_ASCII_P (*ptr))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
549 return simple_charptr_copy_char (ptr, ptr2);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
550 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
551 return non_ascii_charptr_copy_char (ptr, ptr2);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
552 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
553
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
554 #else /* not MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
555
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 # define charptr_emchar(ptr) simple_charptr_emchar (ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 # define set_charptr_emchar(ptr, x) simple_set_charptr_emchar (ptr, x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 # define charptr_copy_char(ptr, ptr2) simple_charptr_copy_char (ptr, ptr2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
560 #endif /* not MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
561
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 #define charptr_emchar_n(ptr, offset) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 charptr_emchar (charptr_n_addr (ptr, offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 /* ---------------------------- */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 /* (D) For working with Emchars */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 /* ---------------------------- */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
570 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
571
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
572 int non_ascii_valid_char_p (Emchar ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
573
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
574 INLINE int valid_char_p (Emchar ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
575 INLINE int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
576 valid_char_p (Emchar ch)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
577 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
578 if (ch >= 0 && ch < 0400)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
579 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
580 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
581 return non_ascii_valid_char_p (ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
582 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
583
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
584 #else /* not MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
585
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 #define valid_char_p(ch) ((unsigned int) (ch) < 0400)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
588 #endif /* not MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
589
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 #define CHAR_INTP(x) (INTP (x) && valid_char_p (XINT (x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 #ifdef ERROR_CHECK_TYPECHECK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 INLINE Emchar XCHAR_OR_CHAR_INT (Lisp_Object obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 INLINE Emchar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 XCHAR_OR_CHAR_INT (Lisp_Object obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 assert (CHAR_OR_CHAR_INTP (obj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 return XREALINT (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 #define XCHAR_OR_CHAR_INT(obj) XREALINT (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 #define CHECK_CHAR_COERCE_INT(x) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 do { if (CHARP (x)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 else if (CHAR_INTP (x)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 x = make_char (XINT (x)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 else \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 x = wrong_type_argument (Qcharacterp, x); } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
618 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
619 # define MAX_EMCHAR_LEN 4
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
620 #else
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
621 # define MAX_EMCHAR_LEN 1
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
622 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 /* Accessor macros for important positions in a buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 /* We put them here because some stuff below wants them before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 place where we would normally put them. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 /* None of these are lvalues. Use the settor macros below to change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 the positions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 /* Beginning of buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 #define BI_BUF_BEG(buf) ((Bytind) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 #define BUF_BEG(buf) ((Bufpos) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 /* Beginning of accessible range of buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 #define BI_BUF_BEGV(buf) ((buf)->begv + 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 #define BUF_BEGV(buf) ((buf)->bufbegv + 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 /* End of accessible range of buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 #define BI_BUF_ZV(buf) ((buf)->zv + 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 #define BUF_ZV(buf) ((buf)->bufzv + 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 /* End of buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 #define BI_BUF_Z(buf) ((buf)->text->z + 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 #define BUF_Z(buf) ((buf)->text->bufz + 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 /* Point. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 #define BI_BUF_PT(buf) ((buf)->pt + 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 #define BUF_PT(buf) ((buf)->bufpt + 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 /* Converting between positions and addresses */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 /* Convert the address of a byte in the buffer into a position. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 INLINE Bytind BI_BUF_PTR_BYTE_POS (struct buffer *buf, Bufbyte *ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 INLINE Bytind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 BI_BUF_PTR_BYTE_POS (struct buffer *buf, Bufbyte *ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 return ((ptr) - (buf)->text->beg + 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 - ((ptr - (buf)->text->beg + 1) > (buf)->text->gpt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 ? (buf)->text->gap_size : 0));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 #define BUF_PTR_BYTE_POS(buf, ptr) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 bytind_to_bufpos (buf, BI_BUF_PTR_BYTE_POS (buf, ptr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 /* Address of byte at position POS in buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 INLINE Bufbyte * BI_BUF_BYTE_ADDRESS (struct buffer *buf, Bytind pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 INLINE Bufbyte *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 BI_BUF_BYTE_ADDRESS (struct buffer *buf, Bytind pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 return ((buf)->text->beg +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 ((pos >= (buf)->text->gpt ? (pos + (buf)->text->gap_size) : pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 - 1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 #define BUF_BYTE_ADDRESS(buf, pos) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 BI_BUF_BYTE_ADDRESS (buf, bufpos_to_bytind (buf, pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 /* Address of byte before position POS in buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 INLINE Bufbyte * BI_BUF_BYTE_ADDRESS_BEFORE (struct buffer *buf, Bytind pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 INLINE Bufbyte *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 BI_BUF_BYTE_ADDRESS_BEFORE (struct buffer *buf, Bytind pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 return ((buf)->text->beg +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 ((pos > (buf)->text->gpt ? (pos + (buf)->text->gap_size) : pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 - 2));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 #define BUF_BYTE_ADDRESS_BEFORE(buf, pos) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 BI_BUF_BYTE_ADDRESS_BEFORE (buf, bufpos_to_bytind (buf, pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 /* Converting between byte indices and memory indices */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 INLINE int valid_memind_p (struct buffer *buf, Memind x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 INLINE int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 valid_memind_p (struct buffer *buf, Memind x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 if (x >= 1 && x <= (Memind) (buf)->text->gpt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 if (x > (Memind) ((buf)->text->gpt + (buf)->text->gap_size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 && x <= (Memind) ((buf)->text->z + (buf)->text->gap_size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 INLINE Memind bytind_to_memind (struct buffer *buf, Bytind x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 INLINE Memind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 bytind_to_memind (struct buffer *buf, Bytind x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 if (x > (buf)->text->gpt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 return (Memind) (x + (buf)->text->gap_size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 return (Memind) (x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 #ifdef ERROR_CHECK_BUFPOS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 INLINE Bytind memind_to_bytind (struct buffer *buf, Memind x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 INLINE Bytind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 memind_to_bytind (struct buffer *buf, Memind x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 assert (valid_memind_p (buf, x));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 if (x > (Memind) (buf)->text->gpt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 return (Bytind) (x - (buf)->text->gap_size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 return (Bytind) (x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 INLINE Bytind memind_to_bytind (struct buffer *buf, Memind x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 INLINE Bytind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 memind_to_bytind (struct buffer *buf, Memind x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 if (x > (Memind) (buf)->text->gpt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 return (Bytind) (x - (buf)->text->gap_size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 return (Bytind) (x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 #define memind_to_bufpos(buf, x) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 bytind_to_bufpos (buf, memind_to_bytind (buf, x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 #define bufpos_to_memind(buf, x) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 bytind_to_memind (buf, bufpos_to_bytind (buf, x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 /* These macros generalize many standard buffer-position functions to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 either a buffer or a string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 /* Converting between Meminds and Bytinds, for a buffer-or-string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 For strings, this is a no-op. For buffers, this resolves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 to the standard memind<->bytind converters. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 #define buffer_or_string_bytind_to_memind(obj, ind) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (BUFFERP (obj) ? bytind_to_memind (XBUFFER (obj), ind) : (Memind) ind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 #define buffer_or_string_memind_to_bytind(obj, ind) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (BUFFERP (obj) ? memind_to_bytind (XBUFFER (obj), ind) : (Bytind) ind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 /* Converting between Bufpos's and Bytinds, for a buffer-or-string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 For strings, this maps to the bytecount<->charcount converters. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 #define buffer_or_string_bufpos_to_bytind(obj, pos) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (BUFFERP (obj) ? bufpos_to_bytind (XBUFFER (obj), pos) : \
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
774 (Bytind) charcount_to_bytecount (XSTRING_DATA (obj), pos))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 #define buffer_or_string_bytind_to_bufpos(obj, ind) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (BUFFERP (obj) ? bytind_to_bufpos (XBUFFER (obj), ind) : \
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
778 (Bufpos) bytecount_to_charcount (XSTRING_DATA (obj), ind))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 /* Similar for Bufpos's and Meminds. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 #define buffer_or_string_bufpos_to_memind(obj, pos) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (BUFFERP (obj) ? bufpos_to_memind (XBUFFER (obj), pos) : \
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
784 (Memind) charcount_to_bytecount (XSTRING_DATA (obj), pos))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 #define buffer_or_string_memind_to_bufpos(obj, ind) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (BUFFERP (obj) ? memind_to_bufpos (XBUFFER (obj), ind) : \
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
788 (Bufpos) bytecount_to_charcount (XSTRING_DATA (obj), ind))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 /* working with buffer-level data */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (A) Working with byte indices:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 ------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 VALID_BYTIND_P(buf, bi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 Given a byte index, does it point to the beginning of a character?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ASSERT_VALID_BYTIND_UNSAFE(buf, bi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 If error-checking is enabled, assert that the given byte index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 is within range and points to the beginning of a character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 or to the end of the buffer. Otherwise, do nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ASSERT_VALID_BYTIND_BACKWARD_UNSAFE(buf, bi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 If error-checking is enabled, assert that the given byte index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 is within range and satisfies ASSERT_VALID_BYTIND() and also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 does not refer to the beginning of the buffer. (i.e. movement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 backwards is OK.) Otherwise, do nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ASSERT_VALID_BYTIND_FORWARD_UNSAFE(buf, bi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 If error-checking is enabled, assert that the given byte index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 is within range and satisfies ASSERT_VALID_BYTIND() and also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 does not refer to the end of the buffer. (i.e. movement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 forwards is OK.) Otherwise, do nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 VALIDATE_BYTIND_BACKWARD(buf, bi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 Make sure that the given byte index is pointing to the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 of a character. If not, back up until this is the case. Note
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 that there are not too many places where it is legitimate to do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 this sort of thing. It's an error if you're passed an "invalid"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 byte index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 VALIDATE_BYTIND_FORWARD(buf, bi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 Make sure that the given byte index is pointing to the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 of a character. If not, move forward until this is the case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 Note that there are not too many places where it is legitimate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 to do this sort of thing. It's an error if you're passed an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 "invalid" byte index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 INC_BYTIND(buf, bi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 Given a byte index (assumed to point at the beginning of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 character), modify that value so it points to the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 of the next character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 DEC_BYTIND(buf, bi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 Given a byte index (assumed to point at the beginning of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 character), modify that value so it points to the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 of the previous character. Unlike for DEC_CHARPTR(), we can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 do all the assert()s because there are sentinels at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 beginning of the gap and the end of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 BYTIND_INVALID:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 A constant representing an invalid Bytind. Valid Bytinds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 can never have this value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (B) Converting between Bufpos's and Bytinds:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 --------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 bufpos_to_bytind(buf, bu):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 Given a Bufpos, return the equivalent Bytind.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 bytind_to_bufpos(buf, bi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 Given a Bytind, return the equivalent Bufpos.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 make_bufpos(buf, bi):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 Given a Bytind, return the equivalent Bufpos as a Lisp Object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 /* working with byte indices */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
870 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
871 # define VALID_BYTIND_P(buf, x) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
872 BUFBYTE_FIRST_BYTE_P (*BI_BUF_BYTE_ADDRESS (buf, x))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
873 #else
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
874 # define VALID_BYTIND_P(buf, x) 1
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
875 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 #ifdef ERROR_CHECK_BUFPOS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 # define ASSERT_VALID_BYTIND_UNSAFE(buf, x) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 assert (BUFFER_LIVE_P (buf)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 assert ((x) >= BI_BUF_BEG (buf) && x <= BI_BUF_Z (buf)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 assert (VALID_BYTIND_P (buf, x)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 # define ASSERT_VALID_BYTIND_BACKWARD_UNSAFE(buf, x) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 assert (BUFFER_LIVE_P (buf)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 assert ((x) > BI_BUF_BEG (buf) && x <= BI_BUF_Z (buf)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 assert (VALID_BYTIND_P (buf, x)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 # define ASSERT_VALID_BYTIND_FORWARD_UNSAFE(buf, x) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 assert (BUFFER_LIVE_P (buf)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 assert ((x) >= BI_BUF_BEG (buf) && x < BI_BUF_Z (buf)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 assert (VALID_BYTIND_P (buf, x)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 #else /* not ERROR_CHECK_BUFPOS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 # define ASSERT_VALID_BYTIND_UNSAFE(buf, x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 # define ASSERT_VALID_BYTIND_BACKWARD_UNSAFE(buf, x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 # define ASSERT_VALID_BYTIND_FORWARD_UNSAFE(buf, x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 #endif /* not ERROR_CHECK_BUFPOS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
905 /* Note that, although the Mule version will work fine for non-Mule
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
906 as well (it should reduce down to nothing), we provide a separate
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
907 version to avoid compilation warnings and possible non-optimal
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
908 results with stupid compilers. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
909
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
910 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
911 # define VALIDATE_BYTIND_BACKWARD(buf, x) do \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
912 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
913 Bufbyte *__ibptr = BI_BUF_BYTE_ADDRESS (buf, x); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
914 while (!BUFBYTE_FIRST_BYTE_P (*__ibptr)) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
915 __ibptr--, (x)--; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
916 } while (0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
917 #else
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
918 # define VALIDATE_BYTIND_BACKWARD(buf, x)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
919 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
921 /* Note that, although the Mule version will work fine for non-Mule
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
922 as well (it should reduce down to nothing), we provide a separate
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
923 version to avoid compilation warnings and possible non-optimal
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
924 results with stupid compilers. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
925
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
926 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
927 # define VALIDATE_BYTIND_FORWARD(buf, x) do \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
928 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
929 Bufbyte *__ibptr = BI_BUF_BYTE_ADDRESS (buf, x); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
930 while (!BUFBYTE_FIRST_BYTE_P (*__ibptr)) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
931 __ibptr++, (x)++; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
932 } while (0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
933 #else
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
934 # define VALIDATE_BYTIND_FORWARD(buf, x)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
935 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 /* Note that in the simplest case (no MULE, no ERROR_CHECK_BUFPOS),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 this crap reduces down to simply (x)++. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 #define INC_BYTIND(buf, x) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 ASSERT_VALID_BYTIND_FORWARD_UNSAFE (buf, x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 /* Note that we do the increment first to \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 make sure that the pointer in \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 VALIDATE_BYTIND_FORWARD() ends up on \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 the correct side of the gap */ \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (x)++; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 VALIDATE_BYTIND_FORWARD (buf, x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 /* Note that in the simplest case (no MULE, no ERROR_CHECK_BUFPOS),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 this crap reduces down to simply (x)--. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 #define DEC_BYTIND(buf, x) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ASSERT_VALID_BYTIND_BACKWARD_UNSAFE (buf, x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 /* Note that we do the decrement first to \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 make sure that the pointer in \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 VALIDATE_BYTIND_BACKWARD() ends up on \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 the correct side of the gap */ \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (x)--; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 VALIDATE_BYTIND_BACKWARD (buf, x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 INLINE Bytind prev_bytind (struct buffer *buf, Bytind x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 INLINE Bytind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 prev_bytind (struct buffer *buf, Bytind x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 DEC_BYTIND (buf, x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 return x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 INLINE Bytind next_bytind (struct buffer *buf, Bytind x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 INLINE Bytind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 next_bytind (struct buffer *buf, Bytind x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 INC_BYTIND (buf, x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 return x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 #define BYTIND_INVALID ((Bytind) -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 /* Converting between buffer positions and byte indices */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
987 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
988
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
989 Bytind bufpos_to_bytind_func (struct buffer *buf, Bufpos x);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
990 Bufpos bytind_to_bufpos_func (struct buffer *buf, Bytind x);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
991
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
992 /* The basic algorithm we use is to keep track of a known region of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
993 characters in each buffer, all of which are of the same width. We
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
994 keep track of the boundaries of the region in both Bufpos and
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
995 Bytind coordinates and also keep track of the char width, which
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
996 is 1 - 4 bytes. If the position we're translating is not in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
997 the known region, then we invoke a function to update the known
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
998 region to surround the position in question. This assumes
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
999 locality of reference, which is usually the case.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1000
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1001 Note that the function to update the known region can be simple
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1002 or complicated depending on how much information we cache.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1003 For the moment, we don't cache any information, and just move
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1004 linearly forward or back from the known region, with a few
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1005 shortcuts to catch all-ASCII buffers. (Note that this will
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1006 thrash with bad locality of reference.) A smarter method would
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1007 be to keep some sort of pseudo-extent layer over the buffer;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1008 maybe keep track of the bufpos/bytind correspondence at the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1009 beginning of each line, which would allow us to do a binary
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1010 search over the pseudo-extents to narrow things down to the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1011 correct line, at which point you could use a linear movement
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1012 method. This would also mesh well with efficiently
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1013 implementing a line-numbering scheme.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1014
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1015 Note also that we have to multiply or divide by the char width
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1016 in order to convert the positions. We do some tricks to avoid
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1017 ever actually having to do a multiply or divide, because that
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1018 is typically an expensive operation (esp. divide). Multiplying
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1019 or dividing by 1, 2, or 4 can be implemented simply as a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1020 shift left or shift right, and we keep track of a shifter value
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1021 (0, 1, or 2) indicating how much to shift. Multiplying by 3
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1022 can be implemented by doubling and then adding the original
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1023 value. Dividing by 3, alas, cannot be implemented in any
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1024 simple shift/subtract method, as far as I know; so we just
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1025 do a table lookup. For simplicity, we use a table of size
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1026 128K, which indexes the "divide-by-3" values for the first
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1027 64K non-negative numbers. (Note that we can increase the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1028 size up to 384K, i.e. indexing the first 192K non-negative
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1029 numbers, while still using shorts in the array.) This also
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1030 means that the size of the known region can be at most
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1031 64K for width-three characters.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1032 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1033
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1034 extern short three_to_one_table[];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1035
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1036 INLINE int real_bufpos_to_bytind (struct buffer *buf, Bufpos x);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1037 INLINE int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1038 real_bufpos_to_bytind (struct buffer *buf, Bufpos x)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1039 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1040 if (x >= buf->text->mule_bufmin && x <= buf->text->mule_bufmax)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1041 return (buf->text->mule_bytmin +
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1042 ((x - buf->text->mule_bufmin) << buf->text->mule_shifter) +
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1043 (buf->text->mule_three_p ? (x - buf->text->mule_bufmin) : 0));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1044 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1045 return bufpos_to_bytind_func (buf, x);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1046 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1047
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1048 INLINE int real_bytind_to_bufpos (struct buffer *buf, Bytind x);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1049 INLINE int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1050 real_bytind_to_bufpos (struct buffer *buf, Bytind x)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1051 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1052 if (x >= buf->text->mule_bytmin && x <= buf->text->mule_bytmax)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1053 return (buf->text->mule_bufmin +
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1054 ((buf->text->mule_three_p
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1055 ? three_to_one_table[x - buf->text->mule_bytmin]
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1056 : (x - buf->text->mule_bytmin) >> buf->text->mule_shifter)));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1057 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1058 return bytind_to_bufpos_func (buf, x);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1059 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1060
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1061 #else /* not MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1062
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1063 # define real_bufpos_to_bytind(buf, x) ((Bytind) x)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1064 # define real_bytind_to_bufpos(buf, x) ((Bufpos) x)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1066 #endif /* not MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1067
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 #ifdef ERROR_CHECK_BUFPOS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 Bytind bufpos_to_bytind (struct buffer *buf, Bufpos x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 Bufpos bytind_to_bufpos (struct buffer *buf, Bytind x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 #else /* not ERROR_CHECK_BUFPOS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 #define bufpos_to_bytind real_bufpos_to_bytind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 #define bytind_to_bufpos real_bytind_to_bufpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 #endif /* not ERROR_CHECK_BUFPOS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 #define make_bufpos(buf, ind) make_int (bytind_to_bufpos (buf, ind))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 /* Converting between buffer bytes and Emacs characters */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 /* The character at position POS in buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 #define BI_BUF_FETCH_CHAR(buf, pos) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 charptr_emchar (BI_BUF_BYTE_ADDRESS (buf, pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 #define BUF_FETCH_CHAR(buf, pos) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 BI_BUF_FETCH_CHAR (buf, bufpos_to_bytind (buf, pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 /* The character at position POS in buffer, as a string. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 equivalent to set_charptr_emchar (str, BUF_FETCH_CHAR (buf, pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 but is faster for Mule. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 # define BI_BUF_CHARPTR_COPY_CHAR(buf, pos, str) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 charptr_copy_char (BI_BUF_BYTE_ADDRESS (buf, pos), str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 #define BUF_CHARPTR_COPY_CHAR(buf, pos, str) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 BI_BUF_CHARPTR_COPY_CHAR (buf, bufpos_to_bytind (buf, pos), str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 /* working with externally-formatted data */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 /* Sometimes strings need to be converted into one or another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 external format, for passing to a library function. (Note
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 that we encapsulate and automatically convert the arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 of some functions, but not others.) At times this conversion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 also has to go the other way -- i.e. when we get external-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 format strings back from a library function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1120 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1121
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1122 /* WARNING: These use a static buffer. This can lead to disaster if
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1123 these functions are not used *very* carefully. Under normal
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1124 circumstances, do not call these functions; call the front ends
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1125 below. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1126
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1127 CONST Extbyte *convert_to_external_format (CONST Bufbyte *ptr,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1128 Bytecount len,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1129 Extcount *len_out,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1130 enum external_data_format fmt);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1131 CONST Bufbyte *convert_from_external_format (CONST Extbyte *ptr,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1132 Extcount len,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1133 Bytecount *len_out,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1134 enum external_data_format fmt);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1135
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1136 #else /* ! MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1137
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 #define convert_to_external_format(ptr, len, len_out, fmt) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (*(len_out) = (int) (len), (CONST Extbyte *) (ptr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 #define convert_from_external_format(ptr, len, len_out, fmt) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (*(len_out) = (Bytecount) (len), (CONST Bufbyte *) (ptr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1143 #endif /* ! MULE */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 /* In all of the following macros we use the following general principles:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 -- Functions that work with charptr's accept two sorts of charptr's:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 a) Pointers to memory with a length specified. The pointer will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 fundamentally of type `unsigned char *' (although labelled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 as `Bufbyte *' for internal-format data and `Extbyte *' for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 external-format data) and the length will be fundamentally of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 type `int' (although labelled as `Bytecount' for internal-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 data and `Extcount' for external-format data). The length is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 always a count in bytes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 b) Zero-terminated pointers; no length specified. The pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 is of type `char *', whether the data pointed to is internal-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 or external-format. These sorts of pointers are available for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 convenience in working with C library functions and literal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 strings. In general you should use these sorts of pointers only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 to interface to library routines and not for general manipulation,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 as you are liable to lose embedded nulls and such. This could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 be a big problem for routines that want Unicode-formatted data,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 which is likely to have lots of embedded nulls in it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 -- Functions that work with Lisp strings accept strings as Lisp Objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (as opposed to the `struct Lisp_String *' for some of the other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 string accessors). This is for convenience in working with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 functions, as otherwise you will almost always have to call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 XSTRING() on the object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 -- Functions that work with charptr's are not guaranteed to copy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 their data into alloca()ed space. Functions that work with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 Lisp strings are, however. The reason is that Lisp strings can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 be relocated any time a GC happens, and it could happen at some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 rather unexpected times. The internal-external conversion is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 rarely done in time-critical functions, and so the slight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 extra time required for alloca() and copy is well-worth the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 safety of knowing your string data won't be relocated out from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 under you.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 /* Maybe convert charptr's data into ext-format and store the result in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 alloca()'ed space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 You may wonder why this is written in this fashion and not as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 function call. With a little trickery it could certainly be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 written this way, but it won't work because of those DAMN GCC WANKERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 who couldn't be bothered to handle alloca() properly on the x86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 architecture. (If you put a call to alloca() in the argument to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 a function call, the stack space gets allocated right in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 middle of the arguments to the function call and you are unbelievably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 hosed.) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1196 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1197
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1198 #define GET_CHARPTR_EXT_DATA_ALLOCA(ptr, len, fmt, stick_value_here, stick_len_here) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1199 do \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1200 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1201 Bytecount __gceda_len_in__ = (len); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1202 Extcount __gceda_len_out__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1203 CONST Bufbyte *__gceda_ptr_in__ = (ptr); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1204 CONST Extbyte *__gceda_ptr_out__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1205 \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1206 __gceda_ptr_out__ = \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1207 convert_to_external_format (__gceda_ptr_in__, __gceda_len_in__, \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1208 &__gceda_len_out__, fmt); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1209 /* If the new string is identical to the old (will be the case most \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1210 of the time), just return the same string back. This saves \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1211 on alloca()ing, which can be useful on C alloca() machines and \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1212 on stack-space-challenged environments. */ \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1213 \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1214 if (__gceda_len_in__ == __gceda_len_out__ && \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1215 !memcmp (__gceda_ptr_in__, __gceda_ptr_out__, __gceda_len_out__)) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1216 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1217 (stick_value_here) = (CONST Extbyte *) __gceda_ptr_in__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1218 (stick_len_here) = (Extcount) __gceda_len_in__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1219 } \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1220 else \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1221 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1222 (stick_value_here) = (CONST Extbyte *) alloca(1 + __gceda_len_out__);\
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1223 memcpy ((Extbyte *) stick_value_here, __gceda_ptr_out__, \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1224 1 + __gceda_len_out__); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1225 (stick_len_here) = (Extcount) __gceda_len_out__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1226 } \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1227 } while (0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1228
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1229 #else /* ! MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1230
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 #define GET_CHARPTR_EXT_DATA_ALLOCA(ptr, len, fmt, stick_value_here, stick_len_here)\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (stick_value_here) = (CONST Extbyte *) (ptr); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (stick_len_here) = (Extcount) (len); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1238 #endif /* ! MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1239
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 #define GET_C_CHARPTR_EXT_DATA_ALLOCA(ptr, fmt, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 Extcount __gcceda_ignored_len__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 CONST char *__gcceda_ptr_in__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 CONST Extbyte *__gcceda_ptr_out__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 __gcceda_ptr_in__ = ptr; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 GET_CHARPTR_EXT_DATA_ALLOCA ((CONST Extbyte *) __gcceda_ptr_in__, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 strlen (__gcceda_ptr_in__), fmt, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 __gcceda_ptr_out__, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 __gcceda_ignored_len__); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (stick_value_here) = (CONST char *) __gcceda_ptr_out__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 #define GET_C_CHARPTR_EXT_BINARY_DATA_ALLOCA(ptr, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 GET_C_CHARPTR_EXT_DATA_ALLOCA (ptr, FORMAT_BINARY, stick_value_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 #define GET_CHARPTR_EXT_BINARY_DATA_ALLOCA(ptr, len, stick_value_here, stick_len_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 GET_CHARPTR_EXT_DATA_ALLOCA (ptr, len, FORMAT_BINARY, stick_value_here, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 stick_len_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 #define GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA(ptr, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 GET_C_CHARPTR_EXT_DATA_ALLOCA (ptr, FORMAT_FILENAME, stick_value_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 #define GET_CHARPTR_EXT_FILENAME_DATA_ALLOCA(ptr, len, stick_value_here, stick_len_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 GET_CHARPTR_EXT_DATA_ALLOCA (ptr, len, FORMAT_FILENAME, stick_value_here, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 stick_len_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 #define GET_C_CHARPTR_EXT_CTEXT_DATA_ALLOCA(ptr, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 GET_C_CHARPTR_EXT_DATA_ALLOCA (ptr, FORMAT_CTEXT, stick_value_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 #define GET_CHARPTR_EXT_CTEXT_DATA_ALLOCA(ptr, len, stick_value_here, stick_len_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 GET_CHARPTR_EXT_DATA_ALLOCA (ptr, len, FORMAT_CTEXT, stick_value_here, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 stick_len_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 /* Maybe convert external charptr's data into internal format and store
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 the result in alloca()'ed space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 You may wonder why this is written in this fashion and not as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 function call. With a little trickery it could certainly be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 written this way, but it won't work because of those DAMN GCC WANKERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 who couldn't be bothered to handle alloca() properly on the x86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 architecture. (If you put a call to alloca() in the argument to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 a function call, the stack space gets allocated right in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 middle of the arguments to the function call and you are unbelievably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 hosed.) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1285 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1286
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 #define GET_CHARPTR_INT_DATA_ALLOCA(ptr, len, fmt, stick_value_here, stick_len_here)\
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1288 do \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1289 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1290 Extcount __gcida_len_in__ = (len); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1291 Bytecount __gcida_len_out__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1292 CONST Extbyte *__gcida_ptr_in__ = (ptr); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1293 CONST Bufbyte *__gcida_ptr_out__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1294 \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1295 __gcida_ptr_out__ = \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1296 convert_from_external_format (__gcida_ptr_in__, __gcida_len_in__, \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1297 &__gcida_len_out__, fmt); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1298 /* If the new string is identical to the old (will be the case most \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1299 of the time), just return the same string back. This saves \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1300 on alloca()ing, which can be useful on C alloca() machines and \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1301 on stack-space-challenged environments. */ \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1302 \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1303 if (__gcida_len_in__ == __gcida_len_out__ && \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1304 !memcmp (__gcida_ptr_in__, __gcida_ptr_out__, __gcida_len_out__)) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1305 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1306 (stick_value_here) = (CONST Bufbyte *) __gcida_ptr_in__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1307 (stick_len_here) = (Bytecount) __gcida_len_in__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1308 } \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1309 else \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1310 { \
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
1311 (stick_value_here) = (CONST Extbyte *) alloca (1 + __gcida_len_out__); \
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1312 memcpy ((Bufbyte *) stick_value_here, __gcida_ptr_out__, \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1313 1 + __gcida_len_out__); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1314 (stick_len_here) = __gcida_len_out__; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1315 } \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1318 #else /* ! MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1319
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1320 #define GET_CHARPTR_INT_DATA_ALLOCA(ptr, len, fmt, stick_value_here, stick_len_here)\
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1321 do \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1322 { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1323 (stick_value_here) = (CONST Bufbyte *) (ptr); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1324 (stick_len_here) = (Bytecount) (len); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1325 } while (0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1326
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1327 #endif /* ! MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1328
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 #define GET_C_CHARPTR_INT_DATA_ALLOCA(ptr, fmt, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 Bytecount __gccida_ignored_len__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 CONST char *__gccida_ptr_in__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 CONST Bufbyte *__gccida_ptr_out__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 __gccida_ptr_in__ = ptr; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 GET_CHARPTR_INT_DATA_ALLOCA ((CONST Extbyte *) __gccida_ptr_in__, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 strlen (__gccida_ptr_in__), fmt, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 __gccida_ptr_out__, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 __gccida_ignored_len__); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (stick_value_here) = (CONST char *) __gccida_ptr_out__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 #define GET_C_CHARPTR_INT_BINARY_DATA_ALLOCA(ptr, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 GET_C_CHARPTR_INT_DATA_ALLOCA (ptr, FORMAT_BINARY, stick_value_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 #define GET_CHARPTR_INT_BINARY_DATA_ALLOCA(ptr, len, stick_value_here, stick_len_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 GET_CHARPTR_INT_DATA_ALLOCA (ptr, len, FORMAT_BINARY, stick_value_here, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 stick_len_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 #define GET_C_CHARPTR_INT_FILENAME_DATA_ALLOCA(ptr, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 GET_C_CHARPTR_INT_DATA_ALLOCA (ptr, FORMAT_FILENAME, stick_value_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 #define GET_CHARPTR_INT_FILENAME_DATA_ALLOCA(ptr, len, stick_value_here, stick_len_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 GET_CHARPTR_INT_DATA_ALLOCA (ptr, len, FORMAT_FILENAME, stick_value_here, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 stick_len_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 #define GET_C_CHARPTR_INT_CTEXT_DATA_ALLOCA(ptr, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 GET_C_CHARPTR_INT_DATA_ALLOCA (ptr, FORMAT_CTEXT, stick_value_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 #define GET_CHARPTR_INT_CTEXT_DATA_ALLOCA(ptr, len, stick_value_here, stick_len_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 GET_CHARPTR_INT_DATA_ALLOCA (ptr, len, FORMAT_CTEXT, stick_value_here, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 stick_len_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 /* Maybe convert Lisp string's data into ext-format and store the result in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 alloca()'ed space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 You may wonder why this is written in this fashion and not as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 function call. With a little trickery it could certainly be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 written this way, but it won't work because of those DAMN GCC WANKERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 who couldn't be bothered to handle alloca() properly on the x86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 architecture. (If you put a call to alloca() in the argument to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 a function call, the stack space gets allocated right in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 middle of the arguments to the function call and you are unbelievably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 hosed.) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 #define GET_STRING_EXT_DATA_ALLOCA(s, fmt, stick_value_here, stick_len_here)\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 Extcount __gseda_len__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 CONST Extbyte *__gseda_ptr__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 struct Lisp_String *__gseda_s__ = XSTRING (s); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 __gseda_ptr__ = convert_to_external_format (string_data (__gseda_s__), \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 string_length (__gseda_s__), \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 &__gseda_len__, fmt); \
84
ac0620f6398e Import from CVS: tag r20-0b92
cvs
parents: 82
diff changeset
1385 (stick_value_here) = (CONST Extbyte *) alloca (1 + __gseda_len__); \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 memcpy ((Extbyte *) stick_value_here, __gseda_ptr__, 1 + __gseda_len__); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (stick_len_here) = __gseda_len__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 #define GET_C_STRING_EXT_DATA_ALLOCA(s, fmt, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 Extcount __gcseda_ignored_len__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 CONST Extbyte *__gcseda_ptr__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 GET_STRING_EXT_DATA_ALLOCA (s, fmt, __gcseda_ptr__, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 __gcseda_ignored_len__); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (stick_value_here) = (CONST char *) __gcseda_ptr__; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 #define GET_STRING_BINARY_DATA_ALLOCA(s, stick_value_here, stick_len_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 GET_STRING_EXT_DATA_ALLOCA (s, FORMAT_BINARY, stick_value_here, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 stick_len_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 #define GET_C_STRING_BINARY_DATA_ALLOCA(s, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 GET_C_STRING_EXT_DATA_ALLOCA (s, FORMAT_BINARY, stick_value_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 #define GET_STRING_FILENAME_DATA_ALLOCA(s, stick_value_here, stick_len_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 GET_STRING_EXT_DATA_ALLOCA (s, FORMAT_FILENAME, stick_value_here, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 stick_len_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 #define GET_C_STRING_FILENAME_DATA_ALLOCA(s, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 GET_C_STRING_EXT_DATA_ALLOCA (s, FORMAT_FILENAME, stick_value_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 #define GET_STRING_OS_DATA_ALLOCA(s, stick_value_here, stick_len_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 GET_STRING_EXT_DATA_ALLOCA (s, FORMAT_OS, stick_value_here, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 stick_len_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 #define GET_C_STRING_OS_DATA_ALLOCA(s, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 GET_C_STRING_EXT_DATA_ALLOCA (s, FORMAT_OS, stick_value_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 #define GET_STRING_CTEXT_DATA_ALLOCA(s, stick_value_here, stick_len_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 GET_STRING_EXT_DATA_ALLOCA (s, FORMAT_CTEXT, stick_value_here, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 stick_len_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 #define GET_C_STRING_CTEXT_DATA_ALLOCA(s, stick_value_here) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 GET_C_STRING_EXT_DATA_ALLOCA (s, FORMAT_CTEXT, stick_value_here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 /* fake charset functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1434 /* used when MULE is not defined, so that Charset-type stuff can still
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1435 be done */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1436
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1437 #ifndef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1438
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 #define Vcharset_ascii Qnil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 #define CHAR_CHARSET(ch) Vcharset_ascii
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 #define CHAR_LEADING_BYTE(ch) LEADING_BYTE_ASCII
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 #define LEADING_BYTE_ASCII 0x80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 #define NUM_LEADING_BYTES 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 #define MIN_LEADING_BYTE 0x80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 #define CHARSETP(cs) 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 #define CHARSET_BY_LEADING_BYTE(cs) Vcharset_ascii
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 #define XCHARSET_LEADING_BYTE(cs) LEADING_BYTE_ASCII
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 #define XCHARSET_GRAPHIC(cs) -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 #define XCHARSET_COLUMNS(cs) 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 #define XCHARSET_DIMENSION(cs) 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 #define REP_BYTES_BY_FIRST_BYTE(fb) 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 #define BREAKUP_CHAR(ch, charset, byte1, byte2)\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (charset) = Vcharset_ascii; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (byte1) = (ch); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (byte2) = 0; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 } while (0)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
1460 #define BYTE_ASCII_P(byte) 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1462 #endif /* ! MULE */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 /* higher-level buffer-position functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 /* Settor macros for important positions in a buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 /* Set beginning of accessible range of buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 #define SET_BOTH_BUF_BEGV(buf, val, bival) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (buf)->begv = (bival); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (buf)->bufbegv = (val); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 /* Set end of accessible range of buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 #define SET_BOTH_BUF_ZV(buf, val, bival) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (buf)->zv = (bival); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (buf)->bufzv = (val); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 /* Set point. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 /* Since BEGV and ZV are almost never set, it's reasonable to enforce
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 the restriction that the Bufpos and Bytind values must both be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 specified. However, point is set in lots and lots of places. So
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 we provide the ability to specify both (for efficiency) or just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 one. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 #define BOTH_BUF_SET_PT(buf, val, bival) set_buffer_point (buf, val, bival)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 #define BI_BUF_SET_PT(buf, bival) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 BOTH_BUF_SET_PT (buf, bytind_to_bufpos (buf, bival), bival)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 #define BUF_SET_PT(buf, value) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 BOTH_BUF_SET_PT (buf, value, bufpos_to_bytind (buf, value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 #if 0 /* FSFmacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 /* These macros exist in FSFmacs because SET_PT() in FSFmacs incorrectly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 does too much stuff, such as moving out of invisible extents. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 #define TEMP_SET_PT(position) (temp_set_point ((position), current_buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 #define SET_BUF_PT(buf, value) ((buf)->pt = (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 /* Miscellaneous buffer values */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 /*----------------------------------------------------------------------*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 /* Number of characters in buffer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 #define BUF_SIZE(buf) (BUF_Z (buf) - BUF_BEG (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 /* Is this buffer narrowed? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 #define BUF_NARROWED(buf) ((BI_BUF_BEGV (buf) != BI_BUF_BEG (buf)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 || (BI_BUF_ZV (buf) != BI_BUF_Z (buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 /* Modification count. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 #define BUF_MODIFF(buf) ((buf)->text->modiff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 /* Saved modification count. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 #define BUF_SAVE_MODIFF(buf) ((buf)->text->save_modiff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 /* Face changed. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 #define BUF_FACECHANGE(buf) ((buf)->face_change)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 #define POINT_MARKER_P(marker) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (XMARKER (marker)->buffer != 0 && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 EQ ((marker), XMARKER (marker)->buffer->point_marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 #define BUF_MARKERS(buf) ((buf)->markers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 /* WARNING:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 The new definitions of CEILING_OF() and FLOOR_OF() differ semantically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 from the old ones (in FSF Emacs and XEmacs 19.11 and before).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 Conversion is as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 OLD_BI_CEILING_OF(n) = NEW_BI_CEILING_OF(n) - 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 OLD_BI_FLOOR_OF(n) = NEW_BI_FLOOR_OF(n + 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 The definitions were changed because the new definitions are more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 consistent with the way everything else works in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 /* Properties of CEILING_OF and FLOOR_OF (also apply to BI_ variants):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 1) FLOOR_OF (CEILING_OF (n)) = n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 CEILING_OF (FLOOR_OF (n)) = n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 2) CEILING_OF (n) = n if and only if n = ZV
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 FLOOR_OF (n) = n if and only if n = BEGV
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 3) CEILING_OF (CEILING_OF (n)) = ZV
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 FLOOR_OF (FLOOR_OF (n)) = BEGV
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 4) The bytes in the regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 [BYTE_ADDRESS (n), BYTE_ADDRESS_BEFORE (CEILING_OF (n))]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 [BYTE_ADDRESS (FLOOR_OF (n)), BYTE_ADDRESS_BEFORE (n)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 are contiguous.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 /* Return the maximum index in the buffer it is safe to scan forwards
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 past N to. This is used to prevent buffer scans from running into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 the gap (e.g. search.c). All characters between N and CEILING_OF(N)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 are located contiguous in memory. Note that the character *at*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 CEILING_OF(N) is not contiguous in memory. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 #define BI_BUF_CEILING_OF(b, n) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 ((n) < (b)->text->gpt && (b)->text->gpt < BI_BUF_ZV (b) ? \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (b)->text->gpt : BI_BUF_ZV (b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 #define BUF_CEILING_OF(b, n) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 bytind_to_bufpos (b, BI_BUF_CEILING_OF (b, bufpos_to_bytind (b, n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 /* Return the minimum index in the buffer it is safe to scan backwards
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 past N to. All characters between FLOOR_OF(N) and N are located
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 contiguous in memory. Note that the character *at* N may not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 contiguous in memory. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 #define BI_BUF_FLOOR_OF(b, n) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (BI_BUF_BEGV (b) < (b)->text->gpt && (b)->text->gpt < (n) ? \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (b)->text->gpt : BI_BUF_BEGV (b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 #define BUF_FLOOR_OF(b, n) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 bytind_to_bufpos (b, BI_BUF_FLOOR_OF (b, bufpos_to_bytind (b, n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 #define BI_BUF_CEILING_OF_IGNORE_ACCESSIBLE(b, n) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 ((n) < (b)->text->gpt && (b)->text->gpt < BI_BUF_Z (b) ? \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (b)->text->gpt : BI_BUF_Z (b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 #define BUF_CEILING_OF_IGNORE_ACCESSIBLE(b, n) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 bytind_to_bufpos \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (b, BI_BUF_CEILING_OF_IGNORE_ACCESSIBLE (b, bufpos_to_bytind (b, n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 #define BI_BUF_FLOOR_OF_IGNORE_ACCESSIBLE(b, n) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (BI_BUF_BEG (b) < (b)->text->gpt && (b)->text->gpt < (n) ? \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (b)->text->gpt : BI_BUF_BEG (b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 #define BUF_FLOOR_OF_IGNORE_ACCESSIBLE(b, n) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 bytind_to_bufpos \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (b, BI_BUF_FLOOR_OF_IGNORE_ACCESSIBLE (b, bufpos_to_bytind (b, n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 extern struct buffer *current_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 /* This structure holds the default values of the buffer-local variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 defined with DEFVAR_BUFFER_LOCAL, that have special slots in each buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 The default value occupies the same slot in this structure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 as an individual buffer's value occupies in that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 Setting the default value also goes through the alist of buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 and stores into each buffer that does not say it has a local value. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 extern Lisp_Object Vbuffer_defaults;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 /* This structure marks which slots in a buffer have corresponding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 default values in buffer_defaults.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 Each such slot has a nonzero value in this structure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 The value has only one nonzero bit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 When a buffer has its own local value for a slot,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 the bit for that slot (found in the same slot in this structure)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 is turned on in the buffer's local_var_flags slot.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 If a slot in this structure is zero, then even though there may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 be a DEFVAR_BUFFER_LOCAL for the slot, there is no default value for it;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 and the corresponding slot in buffer_defaults is not used. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 extern struct buffer buffer_local_flags;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 /* Allocation of buffer data. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 #ifdef REL_ALLOC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 char *r_alloc (char **, unsigned long);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 char *r_re_alloc (char **, unsigned long);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 void r_alloc_free (void **);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 #define BUFFER_ALLOC(data,size) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 ((Bufbyte *) r_alloc ((char **) &data, (size) * sizeof(Bufbyte)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 #define BUFFER_REALLOC(data,size) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 ((Bufbyte *) r_re_alloc ((char **) &data, (size) * sizeof(Bufbyte)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 #define BUFFER_FREE(data) r_alloc_free ((void **) &(data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 #define R_ALLOC_DECLARE(var,data) r_alloc_declare (&(var), data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 #else /* !REL_ALLOC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 #define BUFFER_ALLOC(data,size)\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (data = (Bufbyte *) xmalloc ((size) * sizeof(Bufbyte)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 #define BUFFER_REALLOC(data,size)\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 ((Bufbyte *) xrealloc (data, (size) * sizeof(Bufbyte)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 /* Avoid excess parentheses, or syntax errors may rear their heads. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 #define BUFFER_FREE(data) xfree (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 #define R_ALLOC_DECLARE(var,data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 #endif /* !REL_ALLOC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 extern Lisp_Object Vbuffer_alist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 void set_buffer_internal (struct buffer *b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 struct buffer *decode_buffer (Lisp_Object buffer, int allow_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 /* from editfns.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 void widen_buffer (struct buffer *b, int no_clip);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 int beginning_of_line_p (struct buffer *b, Bufpos pt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 /* from insdel.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 void set_buffer_point (struct buffer *buf, Bufpos pos, Bytind bipos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 void find_charsets_in_bufbyte_string (unsigned char *charsets,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 CONST Bufbyte *str,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 Bytecount len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 void find_charsets_in_emchar_string (unsigned char *charsets,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 CONST Emchar *str,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 Charcount len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 int bufbyte_string_displayed_columns (CONST Bufbyte *str, Bytecount len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 int emchar_string_displayed_columns (CONST Emchar *str, Charcount len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 void convert_bufbyte_string_into_emchar_dynarr (CONST Bufbyte *str,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 Bytecount len,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 emchar_dynarr *dyn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 int convert_bufbyte_string_into_emchar_string (CONST Bufbyte *str,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 Bytecount len,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 Emchar *arr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 void convert_emchar_string_into_bufbyte_dynarr (Emchar *arr, int nels,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 bufbyte_dynarr *dyn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 Bufbyte *convert_emchar_string_into_malloced_string (Emchar *arr, int nels,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 Bytecount *len_out);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 /* flags for get_buffer_pos_char(), get_buffer_range_char(), etc. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 /* At most one of GB_COERCE_RANGE and GB_NO_ERROR_IF_BAD should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 specified. At most one of GB_NEGATIVE_FROM_END and GB_NO_ERROR_IF_BAD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 should be specified. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 #define GB_ALLOW_PAST_ACCESSIBLE (1 << 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 #define GB_ALLOW_NIL (1 << 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 #define GB_CHECK_ORDER (1 << 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 #define GB_COERCE_RANGE (1 << 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 #define GB_NO_ERROR_IF_BAD (1 << 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 #define GB_NEGATIVE_FROM_END (1 << 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 #define GB_HISTORICAL_STRING_BEHAVIOR (GB_NEGATIVE_FROM_END | GB_ALLOW_NIL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 Bufpos get_buffer_pos_char (struct buffer *b, Lisp_Object pos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 Bytind get_buffer_pos_byte (struct buffer *b, Lisp_Object pos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 void get_buffer_range_char (struct buffer *b, Lisp_Object from, Lisp_Object to,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 Bufpos *from_out, Bufpos *to_out,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 void get_buffer_range_byte (struct buffer *b, Lisp_Object from, Lisp_Object to,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 Bytind *from_out, Bytind *to_out,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 Charcount get_string_pos_char (Lisp_Object string, Lisp_Object pos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 Bytecount get_string_pos_byte (Lisp_Object string, Lisp_Object pos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 void get_string_range_char (Lisp_Object string, Lisp_Object from,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 Lisp_Object to, Charcount *from_out,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 Charcount *to_out, unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 void get_string_range_byte (Lisp_Object string, Lisp_Object from,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 Lisp_Object to, Bytecount *from_out,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 Bytecount *to_out, unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 Bufpos get_buffer_or_string_pos_char (Lisp_Object object, Lisp_Object pos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 Bytind get_buffer_or_string_pos_byte (Lisp_Object object, Lisp_Object pos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 void get_buffer_or_string_range_char (Lisp_Object object, Lisp_Object from,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 Lisp_Object to, Bufpos *from_out,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 Bufpos *to_out, unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 void get_buffer_or_string_range_byte (Lisp_Object object, Lisp_Object from,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 Lisp_Object to, Bytind *from_out,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 Bytind *to_out, unsigned int flags);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 Bufpos buffer_or_string_accessible_begin_char (Lisp_Object object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 Bufpos buffer_or_string_accessible_end_char (Lisp_Object object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 Bytind buffer_or_string_accessible_begin_byte (Lisp_Object object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 Bytind buffer_or_string_accessible_end_byte (Lisp_Object object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 Bufpos buffer_or_string_absolute_begin_char (Lisp_Object object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 Bufpos buffer_or_string_absolute_end_char (Lisp_Object object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 Bytind buffer_or_string_absolute_begin_byte (Lisp_Object object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 Bytind buffer_or_string_absolute_end_byte (Lisp_Object object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 void record_buffer (Lisp_Object buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 Lisp_Object get_buffer (Lisp_Object name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 int error_if_deleted_or_does_not_exist);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 int map_over_sharing_buffers (struct buffer *buf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 int (*mapfun) (struct buffer *buf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 void *closure),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 void *closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 /* Case conversion */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 /* A "trt" table is a mapping from characters to other characters,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 typically used to convert between uppercase and lowercase. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 compatibility reasons, trt tables are currently in the form of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 a Lisp string of 256 characters, specifying the conversion for each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 of the first 256 Emacs characters (i.e. the 256 extended-ASCII
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 characters). This should be generalized at some point to support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 conversions for all of the allowable Mule characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 /* The _1 macros are named as such because they assume that you have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 already guaranteed that the character values are all in the range
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 0 - 255. Bad lossage will happen otherwise. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 # define MAKE_TRT_TABLE() Fmake_string (make_int (256), make_char (0))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1771 # define TRT_TABLE_AS_STRING(table) XSTRING_DATA (table)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 # define TRT_TABLE_CHAR_1(table, ch) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 string_char (XSTRING (table), (Charcount) ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 # define SET_TRT_TABLE_CHAR_1(table, ch1, ch2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 set_string_char (XSTRING (table), (Charcount) ch1, ch2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1777 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1778 # define MAKE_MIRROR_TRT_TABLE() make_opaque (256, 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1779 # define MIRROR_TRT_TABLE_AS_STRING(table) ((Bufbyte *) XOPAQUE_DATA (table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1780 # define MIRROR_TRT_TABLE_CHAR_1(table, ch) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1781 ((Emchar) (MIRROR_TRT_TABLE_AS_STRING (table)[ch]))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1782 # define SET_MIRROR_TRT_TABLE_CHAR_1(table, ch1, ch2) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1783 (MIRROR_TRT_TABLE_AS_STRING (table)[ch1] = (Bufbyte) (ch2))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1784 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1785
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 # define IN_TRT_TABLE_DOMAIN(c) (((unsigned EMACS_INT) (c)) < 0400)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1788 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1789 #define MIRROR_DOWNCASE_TABLE_AS_STRING(buf) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1790 MIRROR_TRT_TABLE_AS_STRING (buf->mirror_downcase_table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1791 #define MIRROR_UPCASE_TABLE_AS_STRING(buf) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1792 MIRROR_TRT_TABLE_AS_STRING (buf->mirror_upcase_table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1793 #define MIRROR_CANON_TABLE_AS_STRING(buf) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1794 MIRROR_TRT_TABLE_AS_STRING (buf->mirror_case_canon_table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1795 #define MIRROR_EQV_TABLE_AS_STRING(buf) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1796 MIRROR_TRT_TABLE_AS_STRING (buf->mirror_case_eqv_table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1797 #else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 #define MIRROR_DOWNCASE_TABLE_AS_STRING(buf) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 TRT_TABLE_AS_STRING (buf->downcase_table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 #define MIRROR_UPCASE_TABLE_AS_STRING(buf) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 TRT_TABLE_AS_STRING (buf->upcase_table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 #define MIRROR_CANON_TABLE_AS_STRING(buf) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 TRT_TABLE_AS_STRING (buf->case_canon_table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 #define MIRROR_EQV_TABLE_AS_STRING(buf) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 TRT_TABLE_AS_STRING (buf->case_eqv_table)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
1806 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 INLINE Emchar TRT_TABLE_OF (Lisp_Object trt, Emchar c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 INLINE Emchar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 TRT_TABLE_OF (Lisp_Object trt, Emchar c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 if (IN_TRT_TABLE_DOMAIN (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 return TRT_TABLE_CHAR_1 (trt, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 return c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 /* Macros used below. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 #define DOWNCASE_TABLE_OF(buf, c) TRT_TABLE_OF (buf->downcase_table, c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 #define UPCASE_TABLE_OF(buf, c) TRT_TABLE_OF (buf->upcase_table, c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 /* 1 if CH is upper case. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 INLINE int UPPERCASEP (struct buffer *buf, Emchar ch);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 INLINE int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 UPPERCASEP (struct buffer *buf, Emchar ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 return (DOWNCASE_TABLE_OF (buf, ch) != ch);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 /* 1 if CH is lower case. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 INLINE int LOWERCASEP (struct buffer *buf, Emchar ch);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 INLINE int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 LOWERCASEP (struct buffer *buf, Emchar ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 return (UPCASE_TABLE_OF (buf, ch) != ch &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 DOWNCASE_TABLE_OF (buf, ch) == ch);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 /* 1 if CH is neither upper nor lower case. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 INLINE int NOCASEP (struct buffer *buf, Emchar ch);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 INLINE int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 NOCASEP (struct buffer *buf, Emchar ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 return (UPCASE_TABLE_OF (buf, ch) == ch);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 /* Upcase a character, or make no change if that cannot be done. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 INLINE Emchar UPCASE (struct buffer *buf, Emchar ch);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 INLINE Emchar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 UPCASE (struct buffer *buf, Emchar ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 {
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
1856 return (DOWNCASE_TABLE_OF (buf, ch) == ch) ?
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
1857 UPCASE_TABLE_OF (buf, ch) : ch;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 /* Upcase a character known to be not upper case. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 #define UPCASE1(buf, ch) UPCASE_TABLE_OF (buf, ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 /* Downcase a character, or make no change if that cannot be done. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 #define DOWNCASE(buf, ch) DOWNCASE_TABLE_OF (buf, ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 98
diff changeset
1869 /* put it here, somewhat arbitrarily ... it needs to be in *some*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 header file. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 DECLARE_LRECORD (range_table, struct Lisp_Range_Table);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 #endif /* _XEMACS_BUFFER_H_ */