aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.c
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2019-04-27 18:33:39 +0900
committerYAMAMOTO Mitsuharu2019-04-27 18:33:39 +0900
commit886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28 (patch)
treeb5770d9fc10a704ad8aeb3474c6940121252c770 /src/syntax.c
parent015a6e1df2772bd43680df5cbeaffccf98a881da (diff)
parent8dc00b2f1e6523c634df3e24379afbe712a32b27 (diff)
downloademacs-886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28.tar.gz
emacs-886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28.zip
Merge branch 'master' into harfbuzz
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c99
1 files changed, 40 insertions, 59 deletions
diff --git a/src/syntax.c b/src/syntax.c
index 432d82cdf0f..edfdae22590 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1,5 +1,5 @@
1/* GNU Emacs routines to deal with syntax tables; also word and list parsing. 1/* GNU Emacs routines to deal with syntax tables; also word and list parsing.
2 Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2018 Free 2 Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2019 Free
3 Software Foundation, Inc. 3 Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -175,7 +175,7 @@ static ptrdiff_t find_start_value;
175static ptrdiff_t find_start_value_byte; 175static ptrdiff_t find_start_value_byte;
176static struct buffer *find_start_buffer; 176static struct buffer *find_start_buffer;
177static ptrdiff_t find_start_begv; 177static ptrdiff_t find_start_begv;
178static EMACS_INT find_start_modiff; 178static modiff_count find_start_modiff;
179 179
180 180
181static Lisp_Object skip_chars (bool, Lisp_Object, Lisp_Object, bool); 181static Lisp_Object skip_chars (bool, Lisp_Object, Lisp_Object, bool);
@@ -309,7 +309,7 @@ SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object,
309} 309}
310 310
311/* Update gl_state to an appropriate interval which contains CHARPOS. The 311/* Update gl_state to an appropriate interval which contains CHARPOS. The
312 sign of COUNT give the relative position of CHARPOS wrt the previously 312 sign of COUNT gives the relative position of CHARPOS wrt the previously
313 valid interval. If INIT, only [be]_property fields of gl_state are 313 valid interval. If INIT, only [be]_property fields of gl_state are
314 valid at start, the rest is filled basing on OBJECT. 314 valid at start, the rest is filled basing on OBJECT.
315 315
@@ -340,59 +340,46 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init,
340 invalidate = false; 340 invalidate = false;
341 if (!i) 341 if (!i)
342 return; 342 return;
343 /* interval_of updates only ->position of the return value, so
344 update the parents manually to speed up update_interval. */
345 while (!NULL_PARENT (i))
346 {
347 if (AM_RIGHT_CHILD (i))
348 INTERVAL_PARENT (i)->position = i->position
349 - LEFT_TOTAL_LENGTH (i) + TOTAL_LENGTH (i) /* right end */
350 - TOTAL_LENGTH (INTERVAL_PARENT (i))
351 + LEFT_TOTAL_LENGTH (INTERVAL_PARENT (i));
352 else
353 INTERVAL_PARENT (i)->position = i->position - LEFT_TOTAL_LENGTH (i)
354 + TOTAL_LENGTH (i);
355 i = INTERVAL_PARENT (i);
356 }
357 i = gl_state.forward_i; 343 i = gl_state.forward_i;
358 gl_state.b_property = i->position - gl_state.offset; 344 gl_state.b_property = i->position - gl_state.offset;
359 gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; 345 gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset;
360 goto update;
361 }
362 i = count > 0 ? gl_state.forward_i : gl_state.backward_i;
363
364 /* We are guaranteed to be called with CHARPOS either in i,
365 or further off. */
366 if (!i)
367 error ("Error in syntax_table logic for to-the-end intervals");
368 else if (charpos < i->position) /* Move left. */
369 {
370 if (count > 0)
371 error ("Error in syntax_table logic for intervals <-");
372 /* Update the interval. */
373 i = update_interval (i, charpos);
374 if (INTERVAL_LAST_POS (i) != gl_state.b_property)
375 {
376 invalidate = false;
377 gl_state.forward_i = i;
378 gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset;
379 }
380 } 346 }
381 else if (charpos >= INTERVAL_LAST_POS (i)) /* Move right. */ 347 else
382 { 348 {
383 if (count < 0) 349 i = count > 0 ? gl_state.forward_i : gl_state.backward_i;
384 error ("Error in syntax_table logic for intervals ->"); 350
385 /* Update the interval. */ 351 /* We are guaranteed to be called with CHARPOS either in i,
386 i = update_interval (i, charpos); 352 or further off. */
387 if (i->position != gl_state.e_property) 353 if (!i)
388 { 354 error ("Error in syntax_table logic for to-the-end intervals");
389 invalidate = false; 355 else if (charpos < i->position) /* Move left. */
390 gl_state.backward_i = i; 356 {
391 gl_state.b_property = i->position - gl_state.offset; 357 if (count > 0)
392 } 358 error ("Error in syntax_table logic for intervals <-");
359 /* Update the interval. */
360 i = update_interval (i, charpos);
361 if (INTERVAL_LAST_POS (i) != gl_state.b_property)
362 {
363 invalidate = false;
364 gl_state.forward_i = i;
365 gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset;
366 }
367 }
368 else if (charpos >= INTERVAL_LAST_POS (i)) /* Move right. */
369 {
370 if (count < 0)
371 error ("Error in syntax_table logic for intervals ->");
372 /* Update the interval. */
373 i = update_interval (i, charpos);
374 if (i->position != gl_state.e_property)
375 {
376 invalidate = false;
377 gl_state.backward_i = i;
378 gl_state.b_property = i->position - gl_state.offset;
379 }
380 }
393 } 381 }
394 382
395 update:
396 tmp_table = textget (i->plist, Qsyntax_table); 383 tmp_table = textget (i->plist, Qsyntax_table);
397 384
398 if (invalidate) 385 if (invalidate)
@@ -489,7 +476,7 @@ parse_sexp_propertize (ptrdiff_t charpos)
489 if (syntax_propertize__done <= charpos 476 if (syntax_propertize__done <= charpos
490 && syntax_propertize__done < zv) 477 && syntax_propertize__done < zv)
491 { 478 {
492 EMACS_INT modiffs = CHARS_MODIFF; 479 modiff_count modiffs = CHARS_MODIFF;
493 safe_call1 (Qinternal__syntax_propertize, 480 safe_call1 (Qinternal__syntax_propertize,
494 make_fixnum (min (zv, 1 + charpos))); 481 make_fixnum (min (zv, 1 + charpos)));
495 if (modiffs != CHARS_MODIFF) 482 if (modiffs != CHARS_MODIFF)
@@ -608,7 +595,7 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
608 595
609 if (!NILP (Vcomment_use_syntax_ppss)) 596 if (!NILP (Vcomment_use_syntax_ppss))
610 { 597 {
611 EMACS_INT modiffs = CHARS_MODIFF; 598 modiff_count modiffs = CHARS_MODIFF;
612 Lisp_Object ppss = call1 (Qsyntax_ppss, make_fixnum (pos)); 599 Lisp_Object ppss = call1 (Qsyntax_ppss, make_fixnum (pos));
613 if (modiffs != CHARS_MODIFF) 600 if (modiffs != CHARS_MODIFF)
614 error ("syntax-ppss modified the buffer!"); 601 error ("syntax-ppss modified the buffer!");
@@ -3490,10 +3477,7 @@ internalize_parse_state (Lisp_Object external, struct lisp_parse_state *state)
3490 else 3477 else
3491 { 3478 {
3492 tem = Fcar (external); 3479 tem = Fcar (external);
3493 if (!NILP (tem)) 3480 state->depth = FIXNUMP (tem) ? XFIXNUM (tem) : 0;
3494 state->depth = XFIXNUM (tem);
3495 else
3496 state->depth = 0;
3497 3481
3498 external = Fcdr (external); 3482 external = Fcdr (external);
3499 external = Fcdr (external); 3483 external = Fcdr (external);
@@ -3730,12 +3714,9 @@ syms_of_syntax (void)
3730 staticpro (&gl_state.current_syntax_table); 3714 staticpro (&gl_state.current_syntax_table);
3731 staticpro (&gl_state.old_prop); 3715 staticpro (&gl_state.old_prop);
3732 3716
3733 /* Defined in regex-emacs.c. */
3734 staticpro (&re_match_object);
3735
3736 DEFSYM (Qscan_error, "scan-error"); 3717 DEFSYM (Qscan_error, "scan-error");
3737 Fput (Qscan_error, Qerror_conditions, 3718 Fput (Qscan_error, Qerror_conditions,
3738 listn (CONSTYPE_PURE, 2, Qscan_error, Qerror)); 3719 pure_list (Qscan_error, Qerror));
3739 Fput (Qscan_error, Qerror_message, 3720 Fput (Qscan_error, Qerror_message,
3740 build_pure_c_string ("Scan error")); 3721 build_pure_c_string ("Scan error"));
3741 3722