diff options
| author | Alan Mackenzie | 2017-02-12 10:59:03 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2017-02-12 10:59:03 +0000 |
| commit | f4d5b687150810129b7a1d5b006e31ccf82b691b (patch) | |
| tree | 4229b13800349032697daae3904dc3773e6b7a80 /src/syntax.c | |
| parent | d5514332d4a6092673ce1f78fadcae0c57f7be64 (diff) | |
| parent | 148100d98319499f0ac6f57b8be08cbd14884a5c (diff) | |
| download | emacs-comment-cache.tar.gz emacs-comment-cache.zip | |
Merge branch 'master' into comment-cachecomment-cache
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 250 |
1 files changed, 129 insertions, 121 deletions
diff --git a/src/syntax.c b/src/syntax.c index 5bc0efa8a41..34a9e632b3c 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -1672,29 +1672,23 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1672 | COUNT negative means scan backward and stop at word beginning. */ | 1672 | COUNT negative means scan backward and stop at word beginning. */ |
| 1673 | 1673 | ||
| 1674 | ptrdiff_t | 1674 | ptrdiff_t |
| 1675 | scan_words (register ptrdiff_t from, register EMACS_INT count) | 1675 | scan_words (ptrdiff_t from, EMACS_INT count) |
| 1676 | { | 1676 | { |
| 1677 | register ptrdiff_t beg = BEGV; | 1677 | ptrdiff_t beg = BEGV; |
| 1678 | register ptrdiff_t end = ZV; | 1678 | ptrdiff_t end = ZV; |
| 1679 | register ptrdiff_t from_byte = CHAR_TO_BYTE (from); | 1679 | ptrdiff_t from_byte = CHAR_TO_BYTE (from); |
| 1680 | register enum syntaxcode code; | 1680 | enum syntaxcode code; |
| 1681 | int ch0, ch1; | 1681 | int ch0, ch1; |
| 1682 | Lisp_Object func, pos; | 1682 | Lisp_Object func, pos; |
| 1683 | 1683 | ||
| 1684 | immediate_quit = 1; | ||
| 1685 | QUIT; | ||
| 1686 | |||
| 1687 | SETUP_SYNTAX_TABLE (from, count); | 1684 | SETUP_SYNTAX_TABLE (from, count); |
| 1688 | 1685 | ||
| 1689 | while (count > 0) | 1686 | while (count > 0) |
| 1690 | { | 1687 | { |
| 1691 | while (1) | 1688 | while (true) |
| 1692 | { | 1689 | { |
| 1693 | if (from == end) | 1690 | if (from == end) |
| 1694 | { | 1691 | return 0; |
| 1695 | immediate_quit = 0; | ||
| 1696 | return 0; | ||
| 1697 | } | ||
| 1698 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 1692 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 1699 | ch0 = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 1693 | ch0 = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 1700 | code = SYNTAX (ch0); | 1694 | code = SYNTAX (ch0); |
| @@ -1704,6 +1698,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1704 | break; | 1698 | break; |
| 1705 | if (code == Sword) | 1699 | if (code == Sword) |
| 1706 | break; | 1700 | break; |
| 1701 | rarely_quit (from); | ||
| 1707 | } | 1702 | } |
| 1708 | /* Now CH0 is a character which begins a word and FROM is the | 1703 | /* Now CH0 is a character which begins a word and FROM is the |
| 1709 | position of the next character. */ | 1704 | position of the next character. */ |
| @@ -1732,19 +1727,17 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1732 | break; | 1727 | break; |
| 1733 | INC_BOTH (from, from_byte); | 1728 | INC_BOTH (from, from_byte); |
| 1734 | ch0 = ch1; | 1729 | ch0 = ch1; |
| 1730 | rarely_quit (from); | ||
| 1735 | } | 1731 | } |
| 1736 | } | 1732 | } |
| 1737 | count--; | 1733 | count--; |
| 1738 | } | 1734 | } |
| 1739 | while (count < 0) | 1735 | while (count < 0) |
| 1740 | { | 1736 | { |
| 1741 | while (1) | 1737 | while (true) |
| 1742 | { | 1738 | { |
| 1743 | if (from == beg) | 1739 | if (from == beg) |
| 1744 | { | 1740 | return 0; |
| 1745 | immediate_quit = 0; | ||
| 1746 | return 0; | ||
| 1747 | } | ||
| 1748 | DEC_BOTH (from, from_byte); | 1741 | DEC_BOTH (from, from_byte); |
| 1749 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 1742 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 1750 | ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 1743 | ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| @@ -1754,6 +1747,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1754 | break; | 1747 | break; |
| 1755 | if (code == Sword) | 1748 | if (code == Sword) |
| 1756 | break; | 1749 | break; |
| 1750 | rarely_quit (from); | ||
| 1757 | } | 1751 | } |
| 1758 | /* Now CH1 is a character which ends a word and FROM is the | 1752 | /* Now CH1 is a character which ends a word and FROM is the |
| 1759 | position of it. */ | 1753 | position of it. */ |
| @@ -1786,13 +1780,12 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1786 | break; | 1780 | break; |
| 1787 | } | 1781 | } |
| 1788 | ch1 = ch0; | 1782 | ch1 = ch0; |
| 1783 | rarely_quit (from); | ||
| 1789 | } | 1784 | } |
| 1790 | } | 1785 | } |
| 1791 | count++; | 1786 | count++; |
| 1792 | } | 1787 | } |
| 1793 | 1788 | ||
| 1794 | immediate_quit = 0; | ||
| 1795 | |||
| 1796 | return from; | 1789 | return from; |
| 1797 | } | 1790 | } |
| 1798 | 1791 | ||
| @@ -2176,7 +2169,6 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2176 | stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; | 2169 | stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; |
| 2177 | } | 2170 | } |
| 2178 | 2171 | ||
| 2179 | immediate_quit = 1; | ||
| 2180 | /* This code may look up syntax tables using functions that rely on the | 2172 | /* This code may look up syntax tables using functions that rely on the |
| 2181 | gl_state object. To make sure this object is not out of date, | 2173 | gl_state object. To make sure this object is not out of date, |
| 2182 | let's initialize it manually. | 2174 | let's initialize it manually. |
| @@ -2226,9 +2218,10 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2226 | } | 2218 | } |
| 2227 | fwd_ok: | 2219 | fwd_ok: |
| 2228 | p += nbytes, pos++, pos_byte += nbytes; | 2220 | p += nbytes, pos++, pos_byte += nbytes; |
| 2221 | rarely_quit (pos); | ||
| 2229 | } | 2222 | } |
| 2230 | else | 2223 | else |
| 2231 | while (1) | 2224 | while (true) |
| 2232 | { | 2225 | { |
| 2233 | if (p >= stop) | 2226 | if (p >= stop) |
| 2234 | { | 2227 | { |
| @@ -2250,15 +2243,14 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2250 | break; | 2243 | break; |
| 2251 | fwd_unibyte_ok: | 2244 | fwd_unibyte_ok: |
| 2252 | p++, pos++, pos_byte++; | 2245 | p++, pos++, pos_byte++; |
| 2246 | rarely_quit (pos); | ||
| 2253 | } | 2247 | } |
| 2254 | } | 2248 | } |
| 2255 | else | 2249 | else |
| 2256 | { | 2250 | { |
| 2257 | if (multibyte) | 2251 | if (multibyte) |
| 2258 | while (1) | 2252 | while (true) |
| 2259 | { | 2253 | { |
| 2260 | unsigned char *prev_p; | ||
| 2261 | |||
| 2262 | if (p <= stop) | 2254 | if (p <= stop) |
| 2263 | { | 2255 | { |
| 2264 | if (p <= endp) | 2256 | if (p <= endp) |
| @@ -2266,8 +2258,11 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2266 | p = GPT_ADDR; | 2258 | p = GPT_ADDR; |
| 2267 | stop = endp; | 2259 | stop = endp; |
| 2268 | } | 2260 | } |
| 2269 | prev_p = p; | 2261 | unsigned char *prev_p = p; |
| 2270 | while (--p >= stop && ! CHAR_HEAD_P (*p)); | 2262 | do |
| 2263 | p--; | ||
| 2264 | while (stop <= p && ! CHAR_HEAD_P (*p)); | ||
| 2265 | |||
| 2271 | c = STRING_CHAR (p); | 2266 | c = STRING_CHAR (p); |
| 2272 | 2267 | ||
| 2273 | if (! NILP (iso_classes) && in_classes (c, iso_classes)) | 2268 | if (! NILP (iso_classes) && in_classes (c, iso_classes)) |
| @@ -2291,9 +2286,10 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2291 | } | 2286 | } |
| 2292 | back_ok: | 2287 | back_ok: |
| 2293 | pos--, pos_byte -= prev_p - p; | 2288 | pos--, pos_byte -= prev_p - p; |
| 2289 | rarely_quit (pos); | ||
| 2294 | } | 2290 | } |
| 2295 | else | 2291 | else |
| 2296 | while (1) | 2292 | while (true) |
| 2297 | { | 2293 | { |
| 2298 | if (p <= stop) | 2294 | if (p <= stop) |
| 2299 | { | 2295 | { |
| @@ -2315,11 +2311,11 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2315 | break; | 2311 | break; |
| 2316 | back_unibyte_ok: | 2312 | back_unibyte_ok: |
| 2317 | p--, pos--, pos_byte--; | 2313 | p--, pos--, pos_byte--; |
| 2314 | rarely_quit (pos); | ||
| 2318 | } | 2315 | } |
| 2319 | } | 2316 | } |
| 2320 | 2317 | ||
| 2321 | SET_PT_BOTH (pos, pos_byte); | 2318 | SET_PT_BOTH (pos, pos_byte); |
| 2322 | immediate_quit = 0; | ||
| 2323 | 2319 | ||
| 2324 | SAFE_FREE (); | 2320 | SAFE_FREE (); |
| 2325 | return make_number (PT - start_point); | 2321 | return make_number (PT - start_point); |
| @@ -2393,7 +2389,6 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2393 | ptrdiff_t pos_byte = PT_BYTE; | 2389 | ptrdiff_t pos_byte = PT_BYTE; |
| 2394 | unsigned char *p, *endp, *stop; | 2390 | unsigned char *p, *endp, *stop; |
| 2395 | 2391 | ||
| 2396 | immediate_quit = 1; | ||
| 2397 | SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1); | 2392 | SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1); |
| 2398 | 2393 | ||
| 2399 | if (forwardp) | 2394 | if (forwardp) |
| @@ -2422,6 +2417,7 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2422 | if (! fastmap[SYNTAX (c)]) | 2417 | if (! fastmap[SYNTAX (c)]) |
| 2423 | goto done; | 2418 | goto done; |
| 2424 | p += nbytes, pos++, pos_byte += nbytes; | 2419 | p += nbytes, pos++, pos_byte += nbytes; |
| 2420 | rarely_quit (pos); | ||
| 2425 | } | 2421 | } |
| 2426 | while (!parse_sexp_lookup_properties | 2422 | while (!parse_sexp_lookup_properties |
| 2427 | || pos < gl_state.e_property); | 2423 | || pos < gl_state.e_property); |
| @@ -2438,10 +2434,8 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2438 | 2434 | ||
| 2439 | if (multibyte) | 2435 | if (multibyte) |
| 2440 | { | 2436 | { |
| 2441 | while (1) | 2437 | while (true) |
| 2442 | { | 2438 | { |
| 2443 | unsigned char *prev_p; | ||
| 2444 | |||
| 2445 | if (p <= stop) | 2439 | if (p <= stop) |
| 2446 | { | 2440 | { |
| 2447 | if (p <= endp) | 2441 | if (p <= endp) |
| @@ -2450,17 +2444,22 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2450 | stop = endp; | 2444 | stop = endp; |
| 2451 | } | 2445 | } |
| 2452 | UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); | 2446 | UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); |
| 2453 | prev_p = p; | 2447 | |
| 2454 | while (--p >= stop && ! CHAR_HEAD_P (*p)); | 2448 | unsigned char *prev_p = p; |
| 2449 | do | ||
| 2450 | p--; | ||
| 2451 | while (stop <= p && ! CHAR_HEAD_P (*p)); | ||
| 2452 | |||
| 2455 | c = STRING_CHAR (p); | 2453 | c = STRING_CHAR (p); |
| 2456 | if (! fastmap[SYNTAX (c)]) | 2454 | if (! fastmap[SYNTAX (c)]) |
| 2457 | break; | 2455 | break; |
| 2458 | pos--, pos_byte -= prev_p - p; | 2456 | pos--, pos_byte -= prev_p - p; |
| 2457 | rarely_quit (pos); | ||
| 2459 | } | 2458 | } |
| 2460 | } | 2459 | } |
| 2461 | else | 2460 | else |
| 2462 | { | 2461 | { |
| 2463 | while (1) | 2462 | while (true) |
| 2464 | { | 2463 | { |
| 2465 | if (p <= stop) | 2464 | if (p <= stop) |
| 2466 | { | 2465 | { |
| @@ -2473,13 +2472,13 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2473 | if (! fastmap[SYNTAX (p[-1])]) | 2472 | if (! fastmap[SYNTAX (p[-1])]) |
| 2474 | break; | 2473 | break; |
| 2475 | p--, pos--, pos_byte--; | 2474 | p--, pos--, pos_byte--; |
| 2475 | rarely_quit (pos); | ||
| 2476 | } | 2476 | } |
| 2477 | } | 2477 | } |
| 2478 | } | 2478 | } |
| 2479 | 2479 | ||
| 2480 | done: | 2480 | done: |
| 2481 | SET_PT_BOTH (pos, pos_byte); | 2481 | SET_PT_BOTH (pos, pos_byte); |
| 2482 | immediate_quit = 0; | ||
| 2483 | 2482 | ||
| 2484 | return make_number (PT - start_point); | 2483 | return make_number (PT - start_point); |
| 2485 | } | 2484 | } |
| @@ -2541,9 +2540,10 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 2541 | ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, | 2540 | ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, |
| 2542 | EMACS_INT *incomment_ptr, int *last_syntax_ptr) | 2541 | EMACS_INT *incomment_ptr, int *last_syntax_ptr) |
| 2543 | { | 2542 | { |
| 2544 | register int c, c1; | 2543 | unsigned short int quit_count = 0; |
| 2545 | register enum syntaxcode code; | 2544 | int c, c1; |
| 2546 | register int syntax, other_syntax; | 2545 | enum syntaxcode code; |
| 2546 | int syntax, other_syntax; | ||
| 2547 | 2547 | ||
| 2548 | if (nesting <= 0) nesting = -1; | 2548 | if (nesting <= 0) nesting = -1; |
| 2549 | 2549 | ||
| @@ -2635,6 +2635,8 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 2635 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2635 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2636 | nesting++; | 2636 | nesting++; |
| 2637 | } | 2637 | } |
| 2638 | |||
| 2639 | rarely_quit (++quit_count); | ||
| 2638 | } | 2640 | } |
| 2639 | *charpos_ptr = from; | 2641 | *charpos_ptr = from; |
| 2640 | *bytepos_ptr = from_byte; | 2642 | *bytepos_ptr = from_byte; |
| @@ -2662,14 +2664,12 @@ between them, return t; otherwise return nil. */) | |||
| 2662 | ptrdiff_t out_charpos, out_bytepos; | 2664 | ptrdiff_t out_charpos, out_bytepos; |
| 2663 | EMACS_INT dummy; | 2665 | EMACS_INT dummy; |
| 2664 | int dummy2; | 2666 | int dummy2; |
| 2667 | unsigned short int quit_count = 0; | ||
| 2665 | 2668 | ||
| 2666 | CHECK_NUMBER (count); | 2669 | CHECK_NUMBER (count); |
| 2667 | count1 = XINT (count); | 2670 | count1 = XINT (count); |
| 2668 | stop = count1 > 0 ? ZV : BEGV; | 2671 | stop = count1 > 0 ? ZV : BEGV; |
| 2669 | 2672 | ||
| 2670 | immediate_quit = 1; | ||
| 2671 | QUIT; | ||
| 2672 | |||
| 2673 | from = PT; | 2673 | from = PT; |
| 2674 | from_byte = PT_BYTE; | 2674 | from_byte = PT_BYTE; |
| 2675 | 2675 | ||
| @@ -2684,7 +2684,6 @@ between them, return t; otherwise return nil. */) | |||
| 2684 | if (from == stop) | 2684 | if (from == stop) |
| 2685 | { | 2685 | { |
| 2686 | SET_PT_BOTH (from, from_byte); | 2686 | SET_PT_BOTH (from, from_byte); |
| 2687 | immediate_quit = 0; | ||
| 2688 | return Qnil; | 2687 | return Qnil; |
| 2689 | } | 2688 | } |
| 2690 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2689 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| @@ -2711,6 +2710,7 @@ between them, return t; otherwise return nil. */) | |||
| 2711 | INC_BOTH (from, from_byte); | 2710 | INC_BOTH (from, from_byte); |
| 2712 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2711 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2713 | } | 2712 | } |
| 2713 | rarely_quit (++quit_count); | ||
| 2714 | } | 2714 | } |
| 2715 | while (code == Swhitespace || (code == Sendcomment && c == '\n')); | 2715 | while (code == Swhitespace || (code == Sendcomment && c == '\n')); |
| 2716 | 2716 | ||
| @@ -2718,7 +2718,6 @@ between them, return t; otherwise return nil. */) | |||
| 2718 | comstyle = ST_COMMENT_STYLE; | 2718 | comstyle = ST_COMMENT_STYLE; |
| 2719 | else if (code != Scomment) | 2719 | else if (code != Scomment) |
| 2720 | { | 2720 | { |
| 2721 | immediate_quit = 0; | ||
| 2722 | DEC_BOTH (from, from_byte); | 2721 | DEC_BOTH (from, from_byte); |
| 2723 | SET_PT_BOTH (from, from_byte); | 2722 | SET_PT_BOTH (from, from_byte); |
| 2724 | return Qnil; | 2723 | return Qnil; |
| @@ -2729,7 +2728,6 @@ between them, return t; otherwise return nil. */) | |||
| 2729 | from = out_charpos; from_byte = out_bytepos; | 2728 | from = out_charpos; from_byte = out_bytepos; |
| 2730 | if (!found) | 2729 | if (!found) |
| 2731 | { | 2730 | { |
| 2732 | immediate_quit = 0; | ||
| 2733 | SET_PT_BOTH (from, from_byte); | 2731 | SET_PT_BOTH (from, from_byte); |
| 2734 | return Qnil; | 2732 | return Qnil; |
| 2735 | } | 2733 | } |
| @@ -2741,23 +2739,19 @@ between them, return t; otherwise return nil. */) | |||
| 2741 | 2739 | ||
| 2742 | while (count1 < 0) | 2740 | while (count1 < 0) |
| 2743 | { | 2741 | { |
| 2744 | while (1) | 2742 | while (true) |
| 2745 | { | 2743 | { |
| 2746 | bool quoted; | ||
| 2747 | int syntax; | ||
| 2748 | |||
| 2749 | if (from <= stop) | 2744 | if (from <= stop) |
| 2750 | { | 2745 | { |
| 2751 | SET_PT_BOTH (BEGV, BEGV_BYTE); | 2746 | SET_PT_BOTH (BEGV, BEGV_BYTE); |
| 2752 | immediate_quit = 0; | ||
| 2753 | return Qnil; | 2747 | return Qnil; |
| 2754 | } | 2748 | } |
| 2755 | 2749 | ||
| 2756 | DEC_BOTH (from, from_byte); | 2750 | DEC_BOTH (from, from_byte); |
| 2757 | /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ | 2751 | /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ |
| 2758 | quoted = char_quoted (from, from_byte); | 2752 | bool quoted = char_quoted (from, from_byte); |
| 2759 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2753 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2760 | syntax = SYNTAX_WITH_FLAGS (c); | 2754 | int syntax = SYNTAX_WITH_FLAGS (c); |
| 2761 | code = SYNTAX (c); | 2755 | code = SYNTAX (c); |
| 2762 | comstyle = 0; | 2756 | comstyle = 0; |
| 2763 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); | 2757 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); |
| @@ -2800,6 +2794,7 @@ between them, return t; otherwise return nil. */) | |||
| 2800 | } | 2794 | } |
| 2801 | else if (from == stop) | 2795 | else if (from == stop) |
| 2802 | break; | 2796 | break; |
| 2797 | rarely_quit (++quit_count); | ||
| 2803 | } | 2798 | } |
| 2804 | if (fence_found == 0) | 2799 | if (fence_found == 0) |
| 2805 | { | 2800 | { |
| @@ -2842,18 +2837,18 @@ between them, return t; otherwise return nil. */) | |||
| 2842 | else if (code != Swhitespace || quoted) | 2837 | else if (code != Swhitespace || quoted) |
| 2843 | { | 2838 | { |
| 2844 | leave: | 2839 | leave: |
| 2845 | immediate_quit = 0; | ||
| 2846 | INC_BOTH (from, from_byte); | 2840 | INC_BOTH (from, from_byte); |
| 2847 | SET_PT_BOTH (from, from_byte); | 2841 | SET_PT_BOTH (from, from_byte); |
| 2848 | return Qnil; | 2842 | return Qnil; |
| 2849 | } | 2843 | } |
| 2844 | |||
| 2845 | rarely_quit (++quit_count); | ||
| 2850 | } | 2846 | } |
| 2851 | 2847 | ||
| 2852 | count1++; | 2848 | count1++; |
| 2853 | } | 2849 | } |
| 2854 | 2850 | ||
| 2855 | SET_PT_BOTH (from, from_byte); | 2851 | SET_PT_BOTH (from, from_byte); |
| 2856 | immediate_quit = 0; | ||
| 2857 | return Qt; | 2852 | return Qt; |
| 2858 | } | 2853 | } |
| 2859 | 2854 | ||
| @@ -2887,6 +2882,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2887 | EMACS_INT dummy; | 2882 | EMACS_INT dummy; |
| 2888 | int dummy2; | 2883 | int dummy2; |
| 2889 | bool multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; | 2884 | bool multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; |
| 2885 | unsigned short int quit_count = 0; | ||
| 2890 | 2886 | ||
| 2891 | if (depth > 0) min_depth = 0; | 2887 | if (depth > 0) min_depth = 0; |
| 2892 | 2888 | ||
| @@ -2895,14 +2891,14 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2895 | 2891 | ||
| 2896 | from_byte = CHAR_TO_BYTE (from); | 2892 | from_byte = CHAR_TO_BYTE (from); |
| 2897 | 2893 | ||
| 2898 | immediate_quit = 1; | 2894 | maybe_quit (); |
| 2899 | QUIT; | ||
| 2900 | 2895 | ||
| 2901 | SETUP_SYNTAX_TABLE (from, count); | 2896 | SETUP_SYNTAX_TABLE (from, count); |
| 2902 | while (count > 0) | 2897 | while (count > 0) |
| 2903 | { | 2898 | { |
| 2904 | while (from < stop) | 2899 | while (from < stop) |
| 2905 | { | 2900 | { |
| 2901 | rarely_quit (++quit_count); | ||
| 2906 | bool comstart_first, prefix; | 2902 | bool comstart_first, prefix; |
| 2907 | int syntax, other_syntax; | 2903 | int syntax, other_syntax; |
| 2908 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2904 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| @@ -2971,6 +2967,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2971 | goto done; | 2967 | goto done; |
| 2972 | } | 2968 | } |
| 2973 | INC_BOTH (from, from_byte); | 2969 | INC_BOTH (from, from_byte); |
| 2970 | rarely_quit (++quit_count); | ||
| 2974 | } | 2971 | } |
| 2975 | goto done; | 2972 | goto done; |
| 2976 | 2973 | ||
| @@ -3042,6 +3039,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 3042 | if (c_code == Scharquote || c_code == Sescape) | 3039 | if (c_code == Scharquote || c_code == Sescape) |
| 3043 | INC_BOTH (from, from_byte); | 3040 | INC_BOTH (from, from_byte); |
| 3044 | INC_BOTH (from, from_byte); | 3041 | INC_BOTH (from, from_byte); |
| 3042 | rarely_quit (++quit_count); | ||
| 3045 | } | 3043 | } |
| 3046 | INC_BOTH (from, from_byte); | 3044 | INC_BOTH (from, from_byte); |
| 3047 | if (!depth && sexpflag) goto done; | 3045 | if (!depth && sexpflag) goto done; |
| @@ -3056,7 +3054,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 3056 | if (depth) | 3054 | if (depth) |
| 3057 | goto lose; | 3055 | goto lose; |
| 3058 | 3056 | ||
| 3059 | immediate_quit = 0; | ||
| 3060 | return Qnil; | 3057 | return Qnil; |
| 3061 | 3058 | ||
| 3062 | /* End of object reached */ | 3059 | /* End of object reached */ |
| @@ -3068,11 +3065,11 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 3068 | { | 3065 | { |
| 3069 | while (from > stop) | 3066 | while (from > stop) |
| 3070 | { | 3067 | { |
| 3071 | int syntax; | 3068 | rarely_quit (++quit_count); |
| 3072 | DEC_BOTH (from, from_byte); | 3069 | DEC_BOTH (from, from_byte); |
| 3073 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 3070 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 3074 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 3071 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 3075 | syntax= SYNTAX_WITH_FLAGS (c); | 3072 | int syntax = SYNTAX_WITH_FLAGS (c); |
| 3076 | code = syntax_multibyte (c, multibyte_symbol_p); | 3073 | code = syntax_multibyte (c, multibyte_symbol_p); |
| 3077 | if (depth == min_depth) | 3074 | if (depth == min_depth) |
| 3078 | last_good = from; | 3075 | last_good = from; |
| @@ -3144,6 +3141,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 3144 | default: goto done2; | 3141 | default: goto done2; |
| 3145 | } | 3142 | } |
| 3146 | DEC_BOTH (from, from_byte); | 3143 | DEC_BOTH (from, from_byte); |
| 3144 | rarely_quit (++quit_count); | ||
| 3147 | } | 3145 | } |
| 3148 | goto done2; | 3146 | goto done2; |
| 3149 | 3147 | ||
| @@ -3206,13 +3204,14 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 3206 | if (syntax_multibyte (c, multibyte_symbol_p) == code) | 3204 | if (syntax_multibyte (c, multibyte_symbol_p) == code) |
| 3207 | break; | 3205 | break; |
| 3208 | } | 3206 | } |
| 3207 | rarely_quit (++quit_count); | ||
| 3209 | } | 3208 | } |
| 3210 | if (code == Sstring_fence && !depth && sexpflag) goto done2; | 3209 | if (code == Sstring_fence && !depth && sexpflag) goto done2; |
| 3211 | break; | 3210 | break; |
| 3212 | 3211 | ||
| 3213 | case Sstring: | 3212 | case Sstring: |
| 3214 | stringterm = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 3213 | stringterm = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 3215 | while (1) | 3214 | while (true) |
| 3216 | { | 3215 | { |
| 3217 | if (from == stop) | 3216 | if (from == stop) |
| 3218 | goto lose; | 3217 | goto lose; |
| @@ -3226,6 +3225,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 3226 | == Sstring)) | 3225 | == Sstring)) |
| 3227 | break; | 3226 | break; |
| 3228 | } | 3227 | } |
| 3228 | rarely_quit (++quit_count); | ||
| 3229 | } | 3229 | } |
| 3230 | if (!depth && sexpflag) goto done2; | 3230 | if (!depth && sexpflag) goto done2; |
| 3231 | break; | 3231 | break; |
| @@ -3239,7 +3239,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 3239 | if (depth) | 3239 | if (depth) |
| 3240 | goto lose; | 3240 | goto lose; |
| 3241 | 3241 | ||
| 3242 | immediate_quit = 0; | ||
| 3243 | return Qnil; | 3242 | return Qnil; |
| 3244 | 3243 | ||
| 3245 | done2: | 3244 | done2: |
| @@ -3247,7 +3246,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 3247 | } | 3246 | } |
| 3248 | 3247 | ||
| 3249 | 3248 | ||
| 3250 | immediate_quit = 0; | ||
| 3251 | XSETFASTINT (val, from); | 3249 | XSETFASTINT (val, from); |
| 3252 | return val; | 3250 | return val; |
| 3253 | 3251 | ||
| @@ -3340,6 +3338,7 @@ the prefix syntax flag (p). */) | |||
| 3340 | if (pos <= beg) | 3338 | if (pos <= beg) |
| 3341 | break; | 3339 | break; |
| 3342 | DEC_BOTH (pos, pos_byte); | 3340 | DEC_BOTH (pos, pos_byte); |
| 3341 | rarely_quit (pos); | ||
| 3343 | } | 3342 | } |
| 3344 | 3343 | ||
| 3345 | SET_PT_BOTH (opoint, opoint_byte); | 3344 | SET_PT_BOTH (opoint, opoint_byte); |
| @@ -3347,6 +3346,36 @@ the prefix syntax flag (p). */) | |||
| 3347 | return Qnil; | 3346 | return Qnil; |
| 3348 | } | 3347 | } |
| 3349 | 3348 | ||
| 3349 | |||
| 3350 | /* If the character at FROM_BYTE is the second part of a 2-character | ||
| 3351 | comment opener based on PREV_FROM_SYNTAX, update STATE and return | ||
| 3352 | true. */ | ||
| 3353 | static bool | ||
| 3354 | in_2char_comment_start (struct lisp_parse_state *state, | ||
| 3355 | int prev_from_syntax, | ||
| 3356 | ptrdiff_t prev_from, | ||
| 3357 | ptrdiff_t from_byte) | ||
| 3358 | { | ||
| 3359 | int c1, syntax; | ||
| 3360 | if (SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) | ||
| 3361 | && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), | ||
| 3362 | syntax = SYNTAX_WITH_FLAGS (c1), | ||
| 3363 | SYNTAX_FLAGS_COMSTART_SECOND (syntax))) | ||
| 3364 | { | ||
| 3365 | /* Record the comment style we have entered so that only | ||
| 3366 | the comment-end sequence of the same style actually | ||
| 3367 | terminates the comment section. */ | ||
| 3368 | state->comstyle | ||
| 3369 | = SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_from_syntax); | ||
| 3370 | bool comnested = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) | ||
| 3371 | | SYNTAX_FLAGS_COMMENT_NESTED (syntax)); | ||
| 3372 | state->incomment = comnested ? 1 : -1; | ||
| 3373 | state->comstr_start = prev_from; | ||
| 3374 | return true; | ||
| 3375 | } | ||
| 3376 | return false; | ||
| 3377 | } | ||
| 3378 | |||
| 3350 | /* Parse forward from FROM / FROM_BYTE to END, | 3379 | /* Parse forward from FROM / FROM_BYTE to END, |
| 3351 | assuming that FROM has state STATE, | 3380 | assuming that FROM has state STATE, |
| 3352 | and return a description of the state of the parse at END. | 3381 | and return a description of the state of the parse at END. |
| @@ -3362,8 +3391,6 @@ scan_sexps_forward (struct lisp_parse_state *state, | |||
| 3362 | int commentstop) | 3391 | int commentstop) |
| 3363 | { | 3392 | { |
| 3364 | enum syntaxcode code; | 3393 | enum syntaxcode code; |
| 3365 | int c1; | ||
| 3366 | bool comnested; | ||
| 3367 | struct level { ptrdiff_t last, prev; }; | 3394 | struct level { ptrdiff_t last, prev; }; |
| 3368 | struct level levelstart[100]; | 3395 | struct level levelstart[100]; |
| 3369 | struct level *curlevel = levelstart; | 3396 | struct level *curlevel = levelstart; |
| @@ -3377,12 +3404,12 @@ scan_sexps_forward (struct lisp_parse_state *state, | |||
| 3377 | ptrdiff_t prev_from; /* Keep one character before FROM. */ | 3404 | ptrdiff_t prev_from; /* Keep one character before FROM. */ |
| 3378 | ptrdiff_t prev_from_byte; | 3405 | ptrdiff_t prev_from_byte; |
| 3379 | int prev_from_syntax, prev_prev_from_syntax; | 3406 | int prev_from_syntax, prev_prev_from_syntax; |
| 3380 | int syntax; | ||
| 3381 | bool boundary_stop = commentstop == -1; | 3407 | bool boundary_stop = commentstop == -1; |
| 3382 | bool nofence; | 3408 | bool nofence; |
| 3383 | bool found; | 3409 | bool found; |
| 3384 | ptrdiff_t out_bytepos, out_charpos; | 3410 | ptrdiff_t out_bytepos, out_charpos; |
| 3385 | int temp; | 3411 | int temp; |
| 3412 | unsigned short int quit_count = 0; | ||
| 3386 | 3413 | ||
| 3387 | prev_from = from; | 3414 | prev_from = from; |
| 3388 | prev_from_byte = from_byte; | 3415 | prev_from_byte = from_byte; |
| @@ -3401,8 +3428,7 @@ do { prev_from = from; \ | |||
| 3401 | UPDATE_SYNTAX_TABLE_FORWARD (from); \ | 3428 | UPDATE_SYNTAX_TABLE_FORWARD (from); \ |
| 3402 | } while (0) | 3429 | } while (0) |
| 3403 | 3430 | ||
| 3404 | immediate_quit = 1; | 3431 | maybe_quit (); |
| 3405 | QUIT; | ||
| 3406 | 3432 | ||
| 3407 | depth = state->depth; | 3433 | depth = state->depth; |
| 3408 | start_quoted = state->quoted; | 3434 | start_quoted = state->quoted; |
| @@ -3442,53 +3468,32 @@ do { prev_from = from; \ | |||
| 3442 | } | 3468 | } |
| 3443 | else if (start_quoted) | 3469 | else if (start_quoted) |
| 3444 | goto startquoted; | 3470 | goto startquoted; |
| 3471 | else if ((from < end) | ||
| 3472 | && (in_2char_comment_start (state, prev_from_syntax, | ||
| 3473 | prev_from, from_byte))) | ||
| 3474 | { | ||
| 3475 | INC_FROM; | ||
| 3476 | prev_from_syntax = Smax; /* the syntax has already been "used up". */ | ||
| 3477 | goto atcomment; | ||
| 3478 | } | ||
| 3445 | 3479 | ||
| 3446 | while (from < end) | 3480 | while (from < end) |
| 3447 | { | 3481 | { |
| 3448 | if (SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) | 3482 | rarely_quit (++quit_count); |
| 3449 | && (c1 = FETCH_CHAR (from_byte), | 3483 | INC_FROM; |
| 3450 | syntax = SYNTAX_WITH_FLAGS (c1), | 3484 | |
| 3451 | SYNTAX_FLAGS_COMSTART_SECOND (syntax))) | 3485 | if ((from < end) |
| 3452 | { | 3486 | && (in_2char_comment_start (state, prev_from_syntax, |
| 3453 | /* Record the comment style we have entered so that only | 3487 | prev_from, from_byte))) |
| 3454 | the comment-end sequence of the same style actually | ||
| 3455 | terminates the comment section. */ | ||
| 3456 | state->comstyle | ||
| 3457 | = SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_from_syntax); | ||
| 3458 | comnested = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) | ||
| 3459 | | SYNTAX_FLAGS_COMMENT_NESTED (syntax)); | ||
| 3460 | state->incomment = comnested ? 1 : -1; | ||
| 3461 | state->comstr_start = prev_from; | ||
| 3462 | INC_FROM; | ||
| 3463 | prev_from_syntax = Smax; /* the syntax has already been | ||
| 3464 | "used up". */ | ||
| 3465 | code = Scomment; | ||
| 3466 | } | ||
| 3467 | else | ||
| 3468 | { | 3488 | { |
| 3469 | INC_FROM; | 3489 | INC_FROM; |
| 3470 | code = prev_from_syntax & 0xff; | 3490 | prev_from_syntax = Smax; /* the syntax has already been "used up". */ |
| 3471 | if (code == Scomment_fence) | 3491 | goto atcomment; |
| 3472 | { | ||
| 3473 | /* Record the comment style we have entered so that only | ||
| 3474 | the comment-end sequence of the same style actually | ||
| 3475 | terminates the comment section. */ | ||
| 3476 | state->comstyle = ST_COMMENT_STYLE; | ||
| 3477 | state->incomment = -1; | ||
| 3478 | state->comstr_start = prev_from; | ||
| 3479 | code = Scomment; | ||
| 3480 | } | ||
| 3481 | else if (code == Scomment) | ||
| 3482 | { | ||
| 3483 | state->comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax, 0); | ||
| 3484 | state->incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? | ||
| 3485 | 1 : -1); | ||
| 3486 | state->comstr_start = prev_from; | ||
| 3487 | } | ||
| 3488 | } | 3492 | } |
| 3489 | 3493 | ||
| 3490 | if (SYNTAX_FLAGS_PREFIX (prev_from_syntax)) | 3494 | if (SYNTAX_FLAGS_PREFIX (prev_from_syntax)) |
| 3491 | continue; | 3495 | continue; |
| 3496 | code = prev_from_syntax & 0xff; | ||
| 3492 | switch (code) | 3497 | switch (code) |
| 3493 | { | 3498 | { |
| 3494 | case Sescape: | 3499 | case Sescape: |
| @@ -3507,24 +3512,15 @@ do { prev_from = from; \ | |||
| 3507 | symstarted: | 3512 | symstarted: |
| 3508 | while (from < end) | 3513 | while (from < end) |
| 3509 | { | 3514 | { |
| 3510 | int symchar = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 3515 | if (in_2char_comment_start (state, prev_from_syntax, |
| 3511 | 3516 | prev_from, from_byte)) | |
| 3512 | if (SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) | ||
| 3513 | && (syntax = SYNTAX_WITH_FLAGS (symchar), | ||
| 3514 | SYNTAX_FLAGS_COMSTART_SECOND (syntax))) | ||
| 3515 | { | 3517 | { |
| 3516 | state->comstyle | ||
| 3517 | = SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_from_syntax); | ||
| 3518 | comnested = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) | ||
| 3519 | | SYNTAX_FLAGS_COMMENT_NESTED (syntax)); | ||
| 3520 | state->incomment = comnested ? 1 : -1; | ||
| 3521 | state->comstr_start = prev_from; | ||
| 3522 | INC_FROM; | 3518 | INC_FROM; |
| 3523 | prev_from_syntax = Smax; | 3519 | prev_from_syntax = Smax; /* the syntax has already been "used up". */ |
| 3524 | code = Scomment; | ||
| 3525 | goto atcomment; | 3520 | goto atcomment; |
| 3526 | } | 3521 | } |
| 3527 | 3522 | ||
| 3523 | int symchar = FETCH_CHAR_AS_MULTIBYTE (from_byte); | ||
| 3528 | switch (SYNTAX (symchar)) | 3524 | switch (SYNTAX (symchar)) |
| 3529 | { | 3525 | { |
| 3530 | case Scharquote: | 3526 | case Scharquote: |
| @@ -3540,13 +3536,25 @@ do { prev_from = from; \ | |||
| 3540 | goto symdone; | 3536 | goto symdone; |
| 3541 | } | 3537 | } |
| 3542 | INC_FROM; | 3538 | INC_FROM; |
| 3539 | rarely_quit (++quit_count); | ||
| 3543 | } | 3540 | } |
| 3544 | symdone: | 3541 | symdone: |
| 3545 | curlevel->prev = curlevel->last; | 3542 | curlevel->prev = curlevel->last; |
| 3546 | break; | 3543 | break; |
| 3547 | 3544 | ||
| 3548 | case Scomment_fence: /* Can't happen because it's handled above. */ | 3545 | case Scomment_fence: |
| 3546 | /* Record the comment style we have entered so that only | ||
| 3547 | the comment-end sequence of the same style actually | ||
| 3548 | terminates the comment section. */ | ||
| 3549 | state->comstyle = ST_COMMENT_STYLE; | ||
| 3550 | state->incomment = -1; | ||
| 3551 | state->comstr_start = prev_from; | ||
| 3552 | goto atcomment; | ||
| 3549 | case Scomment: | 3553 | case Scomment: |
| 3554 | state->comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax, 0); | ||
| 3555 | state->incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? | ||
| 3556 | 1 : -1); | ||
| 3557 | state->comstr_start = prev_from; | ||
| 3550 | atcomment: | 3558 | atcomment: |
| 3551 | if (commentstop || boundary_stop) goto done; | 3559 | if (commentstop || boundary_stop) goto done; |
| 3552 | startincomment: | 3560 | startincomment: |
| @@ -3639,6 +3647,7 @@ do { prev_from = from; \ | |||
| 3639 | break; | 3647 | break; |
| 3640 | } | 3648 | } |
| 3641 | INC_FROM; | 3649 | INC_FROM; |
| 3650 | rarely_quit (++quit_count); | ||
| 3642 | } | 3651 | } |
| 3643 | } | 3652 | } |
| 3644 | string_end: | 3653 | string_end: |
| @@ -3680,7 +3689,6 @@ do { prev_from = from; \ | |||
| 3680 | state->levelstarts); | 3689 | state->levelstarts); |
| 3681 | state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax) | 3690 | state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax) |
| 3682 | || state->quoted) ? prev_from_syntax : Smax; | 3691 | || state->quoted) ? prev_from_syntax : Smax; |
| 3683 | immediate_quit = 0; | ||
| 3684 | } | 3692 | } |
| 3685 | 3693 | ||
| 3686 | /* Convert a (lisp) parse state to the internal form used in | 3694 | /* Convert a (lisp) parse state to the internal form used in |