aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-01-16 17:52:16 +0000
committerRichard M. Stallman1998-01-16 17:52:16 +0000
commitc292db29eb2df4d3cee5908342a501f0a86e3693 (patch)
tree519f8abf6e3c5b8d32c6023aee046364c854b033
parentf1e3ff8000b7df96d43ba37b0e38fcf0d845b2c1 (diff)
downloademacs-c292db29eb2df4d3cee5908342a501f0a86e3693.tar.gz
emacs-c292db29eb2df4d3cee5908342a501f0a86e3693.zip
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
(struct gl_state_s): New field `object'. (SETUP_SYNTAX_TABLE_FOR_OBJECT): Set it. Handle non-current buffer properly. Args renamed to all caps. (SETUP_SYNTAX_TABLE): Set `object'. Args renamed to all caps. (UPDATE_SYNTAX_TABLE): Use gl_state.object. (UPDATE_SYNTAX_TABLE_FORWARD, UPDATE_SYNTAX_TABLE_BACKWARD): Likewise. (SETUP_SYNTAX_TABLE_FOR_OBJECT): Add gl_state.offset when using the arg FROM. Use BYTE_TO_CHAR.
-rw-r--r--src/syntax.h73
1 files changed, 53 insertions, 20 deletions
diff --git a/src/syntax.h b/src/syntax.h
index da243e8cce5..d1acaa33994 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -194,27 +194,50 @@ extern unsigned char syntax_spec_code[0400];
194 194
195extern char syntax_code_spec[16]; 195extern char syntax_code_spec[16];
196 196
197/* Convert the byte offset BYTEPOS into a character position,
198 for the object recorded in gl_state with SETUP_SYNTAX_TABLE_FOR_OBJECT. */
199
200#define SYNTAX_TABLE_BYTE_TO_CHAR(bytepos) \
201 (STRINGP (gl_state.object) \
202 ? string_byte_to_char (gl_state.object, (bytepos)) \
203 : BUFFERP (gl_state.object) \
204 ? buf_bytepos_to_charpos (XBUFFER (gl_state.object), (bytepos)) \
205 : NILP (gl_state.object) \
206 ? BYTE_TO_CHAR ((bytepos)) \
207 : (bytepos))
208
197/* Make syntax table state (gl_state) good for POS, assuming it is 209/* Make syntax table state (gl_state) good for POS, assuming it is
198 currently good for a position before POS. */ 210 currently good for a position before POS. */
199 211
200#define UPDATE_SYNTAX_TABLE_FORWARD(pos) \ 212#define UPDATE_SYNTAX_TABLE_FORWARD(pos) \
201 ((pos) >= gl_state.e_property - gl_state.offset \ 213 ((pos) >= gl_state.e_property - gl_state.offset \
202 ? (update_syntax_table ((pos) + gl_state.offset, 1, 0, Qnil), 1) : 0) 214 ? (update_syntax_table ((pos) + gl_state.offset, 1, 0, \
215 gl_state.object), \
216 1) \
217 : 0)
203 218
204/* Make syntax table state (gl_state) good for POS, assuming it is 219/* Make syntax table state (gl_state) good for POS, assuming it is
205 currently good for a position after POS. */ 220 currently good for a position after POS. */
206 221
207#define UPDATE_SYNTAX_TABLE_BACKWARD(pos) \ 222#define UPDATE_SYNTAX_TABLE_BACKWARD(pos) \
208 ((pos) <= gl_state.b_property - gl_state.offset \ 223 ((pos) <= gl_state.b_property - gl_state.offset \
209 ? (update_syntax_table ((pos) + gl_state.offset, -1, 0, Qnil), 1) : 0) 224 ? (update_syntax_table ((pos) + gl_state.offset, -1, 0, \
225 gl_state.object), \
226 1) \
227 : 0)
210 228
211/* Make syntax table good for POS. */ 229/* Make syntax table good for POS. */
212 230
213#define UPDATE_SYNTAX_TABLE(pos) \ 231#define UPDATE_SYNTAX_TABLE(pos) \
214 ((pos) <= gl_state.b_property - gl_state.offset \ 232 ((pos) <= gl_state.b_property - gl_state.offset \
215 ? (update_syntax_table ((pos) + gl_state.offset, -1, 0, Qnil), 1) \ 233 ? (update_syntax_table ((pos) + gl_state.offset, -1, 0, \
216 : ((pos) >= gl_state.e_property - gl_state.offset \ 234 gl_state.object), \
217 ? (update_syntax_table ((pos) + gl_state.offset, 1, 0, Qnil), 1) : 0)) 235 1) \
236 : ((pos) >= gl_state.e_property - gl_state.offset \
237 ? (update_syntax_table ((pos) + gl_state.offset, 1, 0, \
238 gl_state.object), \
239 1) \
240 : 0))
218 241
219/* This macro should be called with FROM at the start of forward 242/* This macro should be called with FROM at the start of forward
220 search, or after the last position of the backward search. It 243 search, or after the last position of the backward search. It
@@ -224,14 +247,15 @@ extern char syntax_code_spec[16];
224 Sign of COUNT gives the direction of the search. 247 Sign of COUNT gives the direction of the search.
225 */ 248 */
226 249
227#define SETUP_SYNTAX_TABLE(from,count) \ 250#define SETUP_SYNTAX_TABLE(FROM, COUNT) \
228 gl_state.b_property = BEGV - 1; \ 251 gl_state.b_property = BEGV - 1; \
229 gl_state.e_property = ZV + 1; \ 252 gl_state.e_property = ZV + 1; \
253 gl_state.object = Qnil; \
230 gl_state.use_global = 0; \ 254 gl_state.use_global = 0; \
231 gl_state.offset = 0; \ 255 gl_state.offset = 0; \
232 gl_state.current_syntax_table = current_buffer->syntax_table; \ 256 gl_state.current_syntax_table = current_buffer->syntax_table; \
233 if (parse_sexp_lookup_properties) \ 257 if (parse_sexp_lookup_properties) \
234 update_syntax_table ((count) > 0 ? (from) : (from) - 1, (count), \ 258 update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT), \
235 1, Qnil); 259 1, Qnil);
236 260
237/* Same as above, but in OBJECT. If OBJECT is nil, use current buffer. 261/* Same as above, but in OBJECT. If OBJECT is nil, use current buffer.
@@ -241,16 +265,24 @@ extern char syntax_code_spec[16];
241 to the UPDATE_SYNTAX_TABLE macros which are relative to BEGV. 265 to the UPDATE_SYNTAX_TABLE macros which are relative to BEGV.
242 So if it is a buffer, we set the offset field to BEGV. */ 266 So if it is a buffer, we set the offset field to BEGV. */
243 267
244#define SETUP_SYNTAX_TABLE_FOR_OBJECT(object, from, count) \ 268#define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT) \
245if (1) \ 269if (1) \
246 { \ 270 { \
247 if (BUFFERP (object) || NILP (object)) \ 271 gl_state.object = (OBJECT); \
272 if (BUFFERP (gl_state.object)) \
273 { \
274 struct buffer *buf = XBUFFER (gl_state.object); \
275 gl_state.b_property = BUF_BEGV (buf) - 1; \
276 gl_state.e_property = BUF_ZV (buf); \
277 gl_state.offset = BUF_BEGV (buf) - 1; \
278 } \
279 else if (NILP (gl_state.object)) \
248 { \ 280 { \
249 gl_state.b_property = BEGV - 1; \ 281 gl_state.b_property = BEGV - 1; \
250 gl_state.e_property = ZV; \ 282 gl_state.e_property = ZV; \
251 gl_state.offset = BEGV - 1; \ 283 gl_state.offset = BEGV - 1; \
252 } \ 284 } \
253 else if (EQ (object, Qt)) \ 285 else if (EQ (gl_state.object, Qt)) \
254 { \ 286 { \
255 gl_state.b_property = - 1; \ 287 gl_state.b_property = - 1; \
256 gl_state.e_property = 1500000000; \ 288 gl_state.e_property = 1500000000; \
@@ -259,20 +291,21 @@ if (1) \
259 else \ 291 else \
260 { \ 292 { \
261 gl_state.b_property = -1; \ 293 gl_state.b_property = -1; \
262 gl_state.e_property = 1 + XSTRING (object)->size; \ 294 gl_state.e_property = 1 + XSTRING (gl_state.object)->size; \
263 gl_state.offset = 0; \ 295 gl_state.offset = 0; \
264 } \ 296 } \
265 gl_state.use_global = 0; \ 297 gl_state.use_global = 0; \
266 gl_state.current_syntax_table = current_buffer->syntax_table; \ 298 gl_state.current_syntax_table = current_buffer->syntax_table; \
267 if (parse_sexp_lookup_properties) \ 299 if (parse_sexp_lookup_properties) \
268 update_syntax_table ((bytepos_to_charpos (from) \ 300 update_syntax_table ((BYTE_TO_CHAR ((FROM) + gl_state.offset) \
269 + (count > 0 ? 0 : -1)), \ 301 + (COUNT > 0 ? 0 : -1)), \
270 count, 1, object); \ 302 COUNT, 1, gl_state.object); \
271 } \ 303 } \
272else 304else
273 305
274struct gl_state_s 306struct gl_state_s
275{ 307{
308 Lisp_Object object; /* The object we are scanning. */
276 int start; /* Where to stop. */ 309 int start; /* Where to stop. */
277 int stop; /* Where to stop. */ 310 int stop; /* Where to stop. */
278 int use_global; /* Whether to use global_code 311 int use_global; /* Whether to use global_code