aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.c
diff options
context:
space:
mode:
authorPaul Eggert2017-02-01 15:18:44 -0800
committerPaul Eggert2017-02-01 15:23:19 -0800
commitb4c9f9120d8b0da0593f2fbde69b40374f56451d (patch)
tree8f40be80730a41e83e58e0632ff539ac752eb453 /src/syntax.c
parentb01ac672be1277833964d2d53f6dd26560c70343 (diff)
downloademacs-b4c9f9120d8b0da0593f2fbde69b40374f56451d.tar.gz
emacs-b4c9f9120d8b0da0593f2fbde69b40374f56451d.zip
Fix quitting bug when buffers are frozen
Problem noted by Eli Zaretskii in: http://lists.gnu.org/archive/html/emacs-devel/2017-01/msg00721.html This patch also fixes some other issues in that report. * src/lisp.h (incr_rarely_quit): Remove. All callers changed to use rarely_quit directly. * src/search.c (freeze_buffer_relocation) (thaw_buffer_relocation): New functions. (looking_at_1, fast_looking_at, search_buffer): Use them to fix bug when quitting when buffers are frozen. * src/sysdep.c (emacs_intr_read): Rename from emacs_nointr_read. All uses changed.
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/syntax.c b/src/syntax.c
index 06fe50b866b..7aa43e6e5c7 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -593,7 +593,6 @@ static ptrdiff_t
593find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) 593find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
594{ 594{
595 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; 595 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE;
596 unsigned short int quit_count = 0;
597 596
598 /* Use previous finding, if it's valid and applies to this inquiry. */ 597 /* Use previous finding, if it's valid and applies to this inquiry. */
599 if (current_buffer == find_start_buffer 598 if (current_buffer == find_start_buffer
@@ -636,7 +635,6 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
636 } 635 }
637 /* Move to beg of previous line. */ 636 /* Move to beg of previous line. */
638 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); 637 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1);
639 incr_rarely_quit (&quit_count);
640 } 638 }
641 639
642 /* Record what we found, for the next try. */ 640 /* Record what we found, for the next try. */
@@ -725,7 +723,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
725 that determines quote parity to the comment-end. */ 723 that determines quote parity to the comment-end. */
726 while (from != stop) 724 while (from != stop)
727 { 725 {
728 incr_rarely_quit (&quit_count); 726 rarely_quit (++quit_count);
729 727
730 ptrdiff_t temp_byte; 728 ptrdiff_t temp_byte;
731 int prev_syntax; 729 int prev_syntax;
@@ -954,7 +952,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
954 defun_start_byte = CHAR_TO_BYTE (defun_start); 952 defun_start_byte = CHAR_TO_BYTE (defun_start);
955 } 953 }
956 } 954 }
957 incr_rarely_quit (&quit_count); 955 rarely_quit (++quit_count);
958 } 956 }
959 while (defun_start < comment_end); 957 while (defun_start < comment_end);
960 958
@@ -2386,7 +2384,7 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
2386 nesting++; 2384 nesting++;
2387 } 2385 }
2388 2386
2389 incr_rarely_quit (&quit_count); 2387 rarely_quit (++quit_count);
2390 } 2388 }
2391 *charpos_ptr = from; 2389 *charpos_ptr = from;
2392 *bytepos_ptr = from_byte; 2390 *bytepos_ptr = from_byte;
@@ -2460,7 +2458,7 @@ between them, return t; otherwise return nil. */)
2460 INC_BOTH (from, from_byte); 2458 INC_BOTH (from, from_byte);
2461 UPDATE_SYNTAX_TABLE_FORWARD (from); 2459 UPDATE_SYNTAX_TABLE_FORWARD (from);
2462 } 2460 }
2463 incr_rarely_quit (&quit_count); 2461 rarely_quit (++quit_count);
2464 } 2462 }
2465 while (code == Swhitespace || (code == Sendcomment && c == '\n')); 2463 while (code == Swhitespace || (code == Sendcomment && c == '\n'));
2466 2464
@@ -2544,7 +2542,7 @@ between them, return t; otherwise return nil. */)
2544 } 2542 }
2545 else if (from == stop) 2543 else if (from == stop)
2546 break; 2544 break;
2547 incr_rarely_quit (&quit_count); 2545 rarely_quit (++quit_count);
2548 } 2546 }
2549 if (fence_found == 0) 2547 if (fence_found == 0)
2550 { 2548 {
@@ -2592,7 +2590,7 @@ between them, return t; otherwise return nil. */)
2592 return Qnil; 2590 return Qnil;
2593 } 2591 }
2594 2592
2595 incr_rarely_quit (&quit_count); 2593 rarely_quit (++quit_count);
2596 } 2594 }
2597 2595
2598 count1++; 2596 count1++;
@@ -2648,7 +2646,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2648 { 2646 {
2649 while (from < stop) 2647 while (from < stop)
2650 { 2648 {
2651 incr_rarely_quit (&quit_count); 2649 rarely_quit (++quit_count);
2652 bool comstart_first, prefix; 2650 bool comstart_first, prefix;
2653 int syntax, other_syntax; 2651 int syntax, other_syntax;
2654 UPDATE_SYNTAX_TABLE_FORWARD (from); 2652 UPDATE_SYNTAX_TABLE_FORWARD (from);
@@ -2717,7 +2715,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2717 goto done; 2715 goto done;
2718 } 2716 }
2719 INC_BOTH (from, from_byte); 2717 INC_BOTH (from, from_byte);
2720 incr_rarely_quit (&quit_count); 2718 rarely_quit (++quit_count);
2721 } 2719 }
2722 goto done; 2720 goto done;
2723 2721
@@ -2789,7 +2787,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2789 if (c_code == Scharquote || c_code == Sescape) 2787 if (c_code == Scharquote || c_code == Sescape)
2790 INC_BOTH (from, from_byte); 2788 INC_BOTH (from, from_byte);
2791 INC_BOTH (from, from_byte); 2789 INC_BOTH (from, from_byte);
2792 incr_rarely_quit (&quit_count); 2790 rarely_quit (++quit_count);
2793 } 2791 }
2794 INC_BOTH (from, from_byte); 2792 INC_BOTH (from, from_byte);
2795 if (!depth && sexpflag) goto done; 2793 if (!depth && sexpflag) goto done;
@@ -2815,7 +2813,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2815 { 2813 {
2816 while (from > stop) 2814 while (from > stop)
2817 { 2815 {
2818 incr_rarely_quit (&quit_count); 2816 rarely_quit (++quit_count);
2819 DEC_BOTH (from, from_byte); 2817 DEC_BOTH (from, from_byte);
2820 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2818 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2821 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2819 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
@@ -2891,7 +2889,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2891 default: goto done2; 2889 default: goto done2;
2892 } 2890 }
2893 DEC_BOTH (from, from_byte); 2891 DEC_BOTH (from, from_byte);
2894 incr_rarely_quit (&quit_count); 2892 rarely_quit (++quit_count);
2895 } 2893 }
2896 goto done2; 2894 goto done2;
2897 2895
@@ -2954,7 +2952,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2954 if (syntax_multibyte (c, multibyte_symbol_p) == code) 2952 if (syntax_multibyte (c, multibyte_symbol_p) == code)
2955 break; 2953 break;
2956 } 2954 }
2957 incr_rarely_quit (&quit_count); 2955 rarely_quit (++quit_count);
2958 } 2956 }
2959 if (code == Sstring_fence && !depth && sexpflag) goto done2; 2957 if (code == Sstring_fence && !depth && sexpflag) goto done2;
2960 break; 2958 break;
@@ -2975,7 +2973,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2975 == Sstring)) 2973 == Sstring))
2976 break; 2974 break;
2977 } 2975 }
2978 incr_rarely_quit (&quit_count); 2976 rarely_quit (++quit_count);
2979 } 2977 }
2980 if (!depth && sexpflag) goto done2; 2978 if (!depth && sexpflag) goto done2;
2981 break; 2979 break;
@@ -3229,7 +3227,7 @@ do { prev_from = from; \
3229 3227
3230 while (from < end) 3228 while (from < end)
3231 { 3229 {
3232 incr_rarely_quit (&quit_count); 3230 rarely_quit (++quit_count);
3233 INC_FROM; 3231 INC_FROM;
3234 3232
3235 if ((from < end) 3233 if ((from < end)
@@ -3286,7 +3284,7 @@ do { prev_from = from; \
3286 goto symdone; 3284 goto symdone;
3287 } 3285 }
3288 INC_FROM; 3286 INC_FROM;
3289 incr_rarely_quit (&quit_count); 3287 rarely_quit (++quit_count);
3290 } 3288 }
3291 symdone: 3289 symdone:
3292 curlevel->prev = curlevel->last; 3290 curlevel->prev = curlevel->last;
@@ -3397,7 +3395,7 @@ do { prev_from = from; \
3397 break; 3395 break;
3398 } 3396 }
3399 INC_FROM; 3397 INC_FROM;
3400 incr_rarely_quit (&quit_count); 3398 rarely_quit (++quit_count);
3401 } 3399 }
3402 } 3400 }
3403 string_end: 3401 string_end: