aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.h
diff options
context:
space:
mode:
authorRichard M. Stallman1997-07-08 11:12:53 +0000
committerRichard M. Stallman1997-07-08 11:12:53 +0000
commite2d8d746dec658fe4637182b86fb5c401bf89dd2 (patch)
treefd2c1e5ff6decb45d9ccde26ece26b6487ce5ee2 /src/syntax.h
parent21e989e3f52ad317b6dbe1554f8566cdac09f0fb (diff)
downloademacs-e2d8d746dec658fe4637182b86fb5c401bf89dd2.tar.gz
emacs-e2d8d746dec658fe4637182b86fb5c401bf89dd2.zip
(struct gl_state_s): New field `offset'.
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Set offset field. (SETUP_SYNTAX_TABLE): Clear offset field. (UPDATE_SYNTAX_TABLE, UPDATE_SYNTAX_TABLE_FORWARD): (UPDATE_SYNTAX_TABLE_BACKWARD): Use the offset field.
Diffstat (limited to 'src/syntax.h')
-rw-r--r--src/syntax.h41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/syntax.h b/src/syntax.h
index c8c29cba7cc..0e5e298b64a 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -197,23 +197,25 @@ extern char syntax_code_spec[16];
197 197
198/* Make syntax table state (gl_state) good for POS, assuming it is 198/* Make syntax table state (gl_state) good for POS, assuming it is
199 currently good for a position before POS. */ 199 currently good for a position before POS. */
200#define UPDATE_SYNTAX_TABLE_FORWARD(pos) \
201 ((pos) >= gl_state.e_property ? \
202 ( update_syntax_table ((pos), 1, 0), 1 ) : 0)
203 200
201#define UPDATE_SYNTAX_TABLE_FORWARD(pos) \
202 ((pos) >= gl_state.e_property - gl_state.offset \
203 ? (update_syntax_table ((pos) + gl_state.offset, 1, 0), 1) : 0)
204 204
205/* Make syntax table state (gl_state) good for POS, assuming it is 205/* Make syntax table state (gl_state) good for POS, assuming it is
206 currently good for a position after POS. */ 206 currently good for a position after POS. */
207#define UPDATE_SYNTAX_TABLE_BACKWARD(pos) \
208 ((pos) <= gl_state.b_property ? \
209 ( update_syntax_table ((pos), -1, 0), 1 ) : 0)
210 207
211/* Make syntax table good for POS. */ 208#define UPDATE_SYNTAX_TABLE_BACKWARD(pos) \
209 ((pos) <= gl_state.b_property - gl_state.offset \
210 ? (update_syntax_table ((pos) + gl_state.offset, -1, 0), 1) : 0)
211
212/* Make syntax table good for POS. */
213
212#define UPDATE_SYNTAX_TABLE(pos) \ 214#define UPDATE_SYNTAX_TABLE(pos) \
213 ((pos) <= gl_state.b_property ? \ 215 ((pos) <= gl_state.b_property - gl_state.offset \
214 ( update_syntax_table ((pos), -1, 0), 1 ) : \ 216 ? (update_syntax_table ((pos) + gl_state.offset, -1, 0), 1) \
215 ( (pos) >= gl_state.e_property ? \ 217 : ((pos) >= gl_state.e_property - gl_state.offset \
216 ( update_syntax_table ((pos), 1, 0), 1 ) : 0)) 218 ? (update_syntax_table ((pos) + gl_state.offset, 1, 0), 1) : 0))
217 219
218/* This macro should be called with FROM at the start of forward 220/* This macro should be called with FROM at the start of forward
219 search, or after the last position of the backward search. It 221 search, or after the last position of the backward search. It
@@ -227,28 +229,37 @@ extern char syntax_code_spec[16];
227 gl_state.b_property = BEGV - 1; \ 229 gl_state.b_property = BEGV - 1; \
228 gl_state.e_property = ZV + 1; \ 230 gl_state.e_property = ZV + 1; \
229 gl_state.use_global = 0; \ 231 gl_state.use_global = 0; \
232 gl_state.offset = 0; \
230 gl_state.current_syntax_table = current_buffer->syntax_table; \ 233 gl_state.current_syntax_table = current_buffer->syntax_table; \
231 if (parse_sexp_lookup_properties) \ 234 if (parse_sexp_lookup_properties) \
232 update_syntax_table ((count) > 0 ? (from) : (from) - 1, (count), 1, Qnil); 235 update_syntax_table ((count) > 0 ? (from) : (from) - 1, (count), \
236 1, Qnil);
233 237
234/* Same as above, but in OBJECT. If OBJECT is nil, use current buffer. 238/* Same as above, but in OBJECT. If OBJECT is nil, use current buffer.
235 If it is t, ignore properties altogether. */ 239 If it is t, ignore properties altogether.
240
241 This is meant for regex.c to use. For buffers, regex.c passes arguments
242 to the UPDATE_SYNTAX_TABLE macros which are relative to BEGV.
243 So if it is a buffer,a we set the offset field to BEGV. */
236 244
237#define SETUP_SYNTAX_TABLE_FOR_OBJECT(object, from, count) \ 245#define SETUP_SYNTAX_TABLE_FOR_OBJECT(object, from, count) \
238 if (BUFFERP (object) || NILP (object)) \ 246 if (BUFFERP (object) || NILP (object)) \
239 { \ 247 { \
240 gl_state.b_property = BEGV - 1; \ 248 gl_state.b_property = BEGV - 1; \
241 gl_state.e_property = ZV; \ 249 gl_state.e_property = ZV; \
250 gl_state.offset = BEGV; \
242 } \ 251 } \
243 else if (EQ (object, Qt)) \ 252 else if (EQ (object, Qt)) \
244 { \ 253 { \
245 gl_state.b_property = - 1; \ 254 gl_state.b_property = - 1; \
246 gl_state.e_property = 1500000000; \ 255 gl_state.e_property = 1500000000; \
256 gl_state.offset = 0; \
247 } \ 257 } \
248 else \ 258 else \
249 { \ 259 { \
250 gl_state.b_property = -1; \ 260 gl_state.b_property = -1; \
251 gl_state.e_property = 1 + XSTRING (object)->size; \ 261 gl_state.e_property = 1 + XSTRING (object)->size; \
262 gl_state.offset = 0; \
252 } \ 263 } \
253 gl_state.use_global = 0; \ 264 gl_state.use_global = 0; \
254 gl_state.current_syntax_table = current_buffer->syntax_table; \ 265 gl_state.current_syntax_table = current_buffer->syntax_table; \
@@ -275,10 +286,12 @@ struct gl_state_s
275 and possibly at the 286 and possibly at the
276 intervals too, depending 287 intervals too, depending
277 on: */ 288 on: */
289 /* Offset for positions specified to UPDATE_SYNTAX_TABLE. */
290 int offset;
278 char left_ok; 291 char left_ok;
279 char right_ok; 292 char right_ok;
280}; 293};
281 294
282extern struct gl_state_s gl_state; 295extern struct gl_state_s gl_state;
283extern int parse_sexp_lookup_properties; 296extern int parse_sexp_lookup_properties;
284extern INTERVAL interval_of(); 297extern INTERVAL interval_of ();