diff options
| author | Paul Eggert | 2017-02-01 15:18:44 -0800 |
|---|---|---|
| committer | Paul Eggert | 2017-02-01 15:23:19 -0800 |
| commit | b01ac672be1277833964d2d53f6dd26560c70343 (patch) | |
| tree | 31b886a5084f20135bec50fe831dcfeed229c619 /src/syntax.c | |
| parent | 33be50037c2b4cdb002538534e9915c6bad253b7 (diff) | |
| download | emacs-b01ac672be1277833964d2d53f6dd26560c70343.tar.gz emacs-b01ac672be1277833964d2d53f6dd26560c70343.zip | |
Revamp quitting and fix infloops
This fixes some infinite loops that cannot be quitted out of,
e.g., (defun foo () (nth most-positive-fixnum '#1=(1 . #1#)))
when byte-compiled and when run under X. See:
http://lists.gnu.org/archive/html/emacs-devel/2017-01/msg00577.html
This also attempts to keep the performance improvements I recently
added, as much as possible under the constraint that the infloops
must be caught. In some cases this fixes infloop bugs recently
introduced when I removed immediate_quit.
* src/alloc.c (Fmake_list):
Use rarely_quit, not maybe_quit, for speed in the usual case.
* src/bytecode.c (exec_byte_code):
* src/editfns.c (Fcompare_buffer_substrings):
* src/fns.c (Fnthcdr):
* src/syntax.c (scan_words, skip_chars, skip_syntaxes)
(Fbackward_prefix_chars):
Use rarely_quit so that users can C-g out of long loops.
* src/callproc.c (call_process_cleanup, call_process):
* src/fileio.c (read_non_regular, Finsert_file_contents):
* src/indent.c (compute_motion):
* src/syntax.c (scan_words, Fforward_comment):
Remove now-unnecessary maybe_quit calls.
* src/callproc.c (call_process):
* src/doc.c (get_doc_string, Fsnarf_documentation):
* src/fileio.c (Fcopy_file, read_non_regular, Finsert_file_contents):
* src/lread.c (safe_to_load_version):
* src/sysdep.c (system_process_attributes) [GNU_LINUX]:
Use emacs_read_quit instead of emacs_read in places where
C-g handling is safe.
* src/eval.c (maybe_quit): Move comment here from lisp.h.
* src/fileio.c (Fcopy_file, e_write):
Use emacs_write_quit instead of emacs_write_sig in places where
C-g handling is safe.
* src/filelock.c (create_lock_file): Use emacs_write, not
plain write, as emacs_write no longer has a problem.
(read_lock_data): Use emacs_read, not read, as emacs_read
no longer has a problem.
* src/fns.c (rarely_quit): Move to lisp.h and rename to
incr_rarely_quit. All uses changed..
* src/fns.c (Fmemq, Fmemql, Fassq, Frassq, Fplist_put, Fplist_member):
* src/indent.c (compute_motion):
* src/syntax.c (find_defun_start, back_comment, forw_comment)
(Fforward_comment, scan_lists, scan_sexps_forward):
Use incr_rarely_quit so that users can C-g out of long loops.
* src/fns.c (Fnconc): Move incr_rarely_quit call to within
inner loop, so that it catches C-g there too.
* src/keyboard.c (tty_read_avail_input): Remove commented-out
and now-obsolete code dealing with interrupts.
* src/lisp.h (rarely_quit, incr_rarely_quit): New functions,
the latter moved here from fns.c and renamed from rarely_quit.
(emacs_read_quit, emacs_write_quit): New decls.
* src/search.c (find_newline, search_buffer, find_newline1):
Add maybe_quit to catch C-g.
* src/sysdep.c (get_child_status): Always invoke maybe_quit
if interruptible, so that the caller need not bother.
(emacs_nointr_read, emacs_read_quit, emacs_write_quit):
New functions.
(emacs_read): Rewrite in terms of emacs_nointr_read.
Do not handle C-g or signals; that is now for emacs_read_quit.
(emacs_full_write): Replace PROCESS_SIGNALS two-way arg
with INTERRUPTIBLE three-way arg. All uses changed.
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 112 |
1 files changed, 72 insertions, 40 deletions
diff --git a/src/syntax.c b/src/syntax.c index e713922bf10..06fe50b866b 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -593,6 +593,7 @@ static ptrdiff_t | |||
| 593 | find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) | 593 | find_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; | ||
| 596 | 597 | ||
| 597 | /* Use previous finding, if it's valid and applies to this inquiry. */ | 598 | /* Use previous finding, if it's valid and applies to this inquiry. */ |
| 598 | if (current_buffer == find_start_buffer | 599 | if (current_buffer == find_start_buffer |
| @@ -621,11 +622,9 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) | |||
| 621 | SETUP_BUFFER_SYNTAX_TABLE (); | 622 | SETUP_BUFFER_SYNTAX_TABLE (); |
| 622 | while (PT > BEGV) | 623 | while (PT > BEGV) |
| 623 | { | 624 | { |
| 624 | int c; | ||
| 625 | |||
| 626 | /* Open-paren at start of line means we may have found our | 625 | /* Open-paren at start of line means we may have found our |
| 627 | defun-start. */ | 626 | defun-start. */ |
| 628 | c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE); | 627 | int c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE); |
| 629 | if (SYNTAX (c) == Sopen) | 628 | if (SYNTAX (c) == Sopen) |
| 630 | { | 629 | { |
| 631 | SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ | 630 | SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ |
| @@ -637,6 +636,7 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) | |||
| 637 | } | 636 | } |
| 638 | /* Move to beg of previous line. */ | 637 | /* Move to beg of previous line. */ |
| 639 | scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); | 638 | scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); |
| 639 | incr_rarely_quit (&quit_count); | ||
| 640 | } | 640 | } |
| 641 | 641 | ||
| 642 | /* Record what we found, for the next try. */ | 642 | /* Record what we found, for the next try. */ |
| @@ -715,6 +715,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 715 | ptrdiff_t nesting = 1; /* Current comment nesting. */ | 715 | ptrdiff_t nesting = 1; /* Current comment nesting. */ |
| 716 | int c; | 716 | int c; |
| 717 | int syntax = 0; | 717 | int syntax = 0; |
| 718 | unsigned short int quit_count = 0; | ||
| 718 | 719 | ||
| 719 | /* FIXME: A }} comment-ender style leads to incorrect behavior | 720 | /* FIXME: A }} comment-ender style leads to incorrect behavior |
| 720 | in the case of {{ c }}} because we ignore the last two chars which are | 721 | in the case of {{ c }}} because we ignore the last two chars which are |
| @@ -724,6 +725,8 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 724 | that determines quote parity to the comment-end. */ | 725 | that determines quote parity to the comment-end. */ |
| 725 | while (from != stop) | 726 | while (from != stop) |
| 726 | { | 727 | { |
| 728 | incr_rarely_quit (&quit_count); | ||
| 729 | |||
| 727 | ptrdiff_t temp_byte; | 730 | ptrdiff_t temp_byte; |
| 728 | int prev_syntax; | 731 | int prev_syntax; |
| 729 | bool com2start, com2end, comstart; | 732 | bool com2start, com2end, comstart; |
| @@ -951,7 +954,9 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 951 | defun_start_byte = CHAR_TO_BYTE (defun_start); | 954 | defun_start_byte = CHAR_TO_BYTE (defun_start); |
| 952 | } | 955 | } |
| 953 | } | 956 | } |
| 954 | } while (defun_start < comment_end); | 957 | incr_rarely_quit (&quit_count); |
| 958 | } | ||
| 959 | while (defun_start < comment_end); | ||
| 955 | 960 | ||
| 956 | from_byte = CHAR_TO_BYTE (from); | 961 | from_byte = CHAR_TO_BYTE (from); |
| 957 | UPDATE_SYNTAX_TABLE_FORWARD (from - 1); | 962 | UPDATE_SYNTAX_TABLE_FORWARD (from - 1); |
| @@ -1417,22 +1422,20 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1417 | COUNT negative means scan backward and stop at word beginning. */ | 1422 | COUNT negative means scan backward and stop at word beginning. */ |
| 1418 | 1423 | ||
| 1419 | ptrdiff_t | 1424 | ptrdiff_t |
| 1420 | scan_words (register ptrdiff_t from, register EMACS_INT count) | 1425 | scan_words (ptrdiff_t from, EMACS_INT count) |
| 1421 | { | 1426 | { |
| 1422 | register ptrdiff_t beg = BEGV; | 1427 | ptrdiff_t beg = BEGV; |
| 1423 | register ptrdiff_t end = ZV; | 1428 | ptrdiff_t end = ZV; |
| 1424 | register ptrdiff_t from_byte = CHAR_TO_BYTE (from); | 1429 | ptrdiff_t from_byte = CHAR_TO_BYTE (from); |
| 1425 | register enum syntaxcode code; | 1430 | enum syntaxcode code; |
| 1426 | int ch0, ch1; | 1431 | int ch0, ch1; |
| 1427 | Lisp_Object func, pos; | 1432 | Lisp_Object func, pos; |
| 1428 | 1433 | ||
| 1429 | maybe_quit (); | ||
| 1430 | |||
| 1431 | SETUP_SYNTAX_TABLE (from, count); | 1434 | SETUP_SYNTAX_TABLE (from, count); |
| 1432 | 1435 | ||
| 1433 | while (count > 0) | 1436 | while (count > 0) |
| 1434 | { | 1437 | { |
| 1435 | while (1) | 1438 | while (true) |
| 1436 | { | 1439 | { |
| 1437 | if (from == end) | 1440 | if (from == end) |
| 1438 | return 0; | 1441 | return 0; |
| @@ -1445,6 +1448,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1445 | break; | 1448 | break; |
| 1446 | if (code == Sword) | 1449 | if (code == Sword) |
| 1447 | break; | 1450 | break; |
| 1451 | rarely_quit (from); | ||
| 1448 | } | 1452 | } |
| 1449 | /* Now CH0 is a character which begins a word and FROM is the | 1453 | /* Now CH0 is a character which begins a word and FROM is the |
| 1450 | position of the next character. */ | 1454 | position of the next character. */ |
| @@ -1473,13 +1477,14 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1473 | break; | 1477 | break; |
| 1474 | INC_BOTH (from, from_byte); | 1478 | INC_BOTH (from, from_byte); |
| 1475 | ch0 = ch1; | 1479 | ch0 = ch1; |
| 1480 | rarely_quit (from); | ||
| 1476 | } | 1481 | } |
| 1477 | } | 1482 | } |
| 1478 | count--; | 1483 | count--; |
| 1479 | } | 1484 | } |
| 1480 | while (count < 0) | 1485 | while (count < 0) |
| 1481 | { | 1486 | { |
| 1482 | while (1) | 1487 | while (true) |
| 1483 | { | 1488 | { |
| 1484 | if (from == beg) | 1489 | if (from == beg) |
| 1485 | return 0; | 1490 | return 0; |
| @@ -1492,6 +1497,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1492 | break; | 1497 | break; |
| 1493 | if (code == Sword) | 1498 | if (code == Sword) |
| 1494 | break; | 1499 | break; |
| 1500 | rarely_quit (from); | ||
| 1495 | } | 1501 | } |
| 1496 | /* Now CH1 is a character which ends a word and FROM is the | 1502 | /* Now CH1 is a character which ends a word and FROM is the |
| 1497 | position of it. */ | 1503 | position of it. */ |
| @@ -1524,6 +1530,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1524 | break; | 1530 | break; |
| 1525 | } | 1531 | } |
| 1526 | ch1 = ch0; | 1532 | ch1 = ch0; |
| 1533 | rarely_quit (from); | ||
| 1527 | } | 1534 | } |
| 1528 | } | 1535 | } |
| 1529 | count++; | 1536 | count++; |
| @@ -1961,9 +1968,10 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 1961 | } | 1968 | } |
| 1962 | fwd_ok: | 1969 | fwd_ok: |
| 1963 | p += nbytes, pos++, pos_byte += nbytes; | 1970 | p += nbytes, pos++, pos_byte += nbytes; |
| 1971 | rarely_quit (pos); | ||
| 1964 | } | 1972 | } |
| 1965 | else | 1973 | else |
| 1966 | while (1) | 1974 | while (true) |
| 1967 | { | 1975 | { |
| 1968 | if (p >= stop) | 1976 | if (p >= stop) |
| 1969 | { | 1977 | { |
| @@ -1985,15 +1993,14 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 1985 | break; | 1993 | break; |
| 1986 | fwd_unibyte_ok: | 1994 | fwd_unibyte_ok: |
| 1987 | p++, pos++, pos_byte++; | 1995 | p++, pos++, pos_byte++; |
| 1996 | rarely_quit (pos); | ||
| 1988 | } | 1997 | } |
| 1989 | } | 1998 | } |
| 1990 | else | 1999 | else |
| 1991 | { | 2000 | { |
| 1992 | if (multibyte) | 2001 | if (multibyte) |
| 1993 | while (1) | 2002 | while (true) |
| 1994 | { | 2003 | { |
| 1995 | unsigned char *prev_p; | ||
| 1996 | |||
| 1997 | if (p <= stop) | 2004 | if (p <= stop) |
| 1998 | { | 2005 | { |
| 1999 | if (p <= endp) | 2006 | if (p <= endp) |
| @@ -2001,8 +2008,11 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2001 | p = GPT_ADDR; | 2008 | p = GPT_ADDR; |
| 2002 | stop = endp; | 2009 | stop = endp; |
| 2003 | } | 2010 | } |
| 2004 | prev_p = p; | 2011 | unsigned char *prev_p = p; |
| 2005 | while (--p >= stop && ! CHAR_HEAD_P (*p)); | 2012 | do |
| 2013 | p--; | ||
| 2014 | while (stop <= p && ! CHAR_HEAD_P (*p)); | ||
| 2015 | |||
| 2006 | c = STRING_CHAR (p); | 2016 | c = STRING_CHAR (p); |
| 2007 | 2017 | ||
| 2008 | if (! NILP (iso_classes) && in_classes (c, iso_classes)) | 2018 | if (! NILP (iso_classes) && in_classes (c, iso_classes)) |
| @@ -2026,9 +2036,10 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2026 | } | 2036 | } |
| 2027 | back_ok: | 2037 | back_ok: |
| 2028 | pos--, pos_byte -= prev_p - p; | 2038 | pos--, pos_byte -= prev_p - p; |
| 2039 | rarely_quit (pos); | ||
| 2029 | } | 2040 | } |
| 2030 | else | 2041 | else |
| 2031 | while (1) | 2042 | while (true) |
| 2032 | { | 2043 | { |
| 2033 | if (p <= stop) | 2044 | if (p <= stop) |
| 2034 | { | 2045 | { |
| @@ -2050,6 +2061,7 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2050 | break; | 2061 | break; |
| 2051 | back_unibyte_ok: | 2062 | back_unibyte_ok: |
| 2052 | p--, pos--, pos_byte--; | 2063 | p--, pos--, pos_byte--; |
| 2064 | rarely_quit (pos); | ||
| 2053 | } | 2065 | } |
| 2054 | } | 2066 | } |
| 2055 | 2067 | ||
| @@ -2155,6 +2167,7 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2155 | if (! fastmap[SYNTAX (c)]) | 2167 | if (! fastmap[SYNTAX (c)]) |
| 2156 | goto done; | 2168 | goto done; |
| 2157 | p += nbytes, pos++, pos_byte += nbytes; | 2169 | p += nbytes, pos++, pos_byte += nbytes; |
| 2170 | rarely_quit (pos); | ||
| 2158 | } | 2171 | } |
| 2159 | while (!parse_sexp_lookup_properties | 2172 | while (!parse_sexp_lookup_properties |
| 2160 | || pos < gl_state.e_property); | 2173 | || pos < gl_state.e_property); |
| @@ -2171,10 +2184,8 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2171 | 2184 | ||
| 2172 | if (multibyte) | 2185 | if (multibyte) |
| 2173 | { | 2186 | { |
| 2174 | while (1) | 2187 | while (true) |
| 2175 | { | 2188 | { |
| 2176 | unsigned char *prev_p; | ||
| 2177 | |||
| 2178 | if (p <= stop) | 2189 | if (p <= stop) |
| 2179 | { | 2190 | { |
| 2180 | if (p <= endp) | 2191 | if (p <= endp) |
| @@ -2183,17 +2194,22 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2183 | stop = endp; | 2194 | stop = endp; |
| 2184 | } | 2195 | } |
| 2185 | UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); | 2196 | UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); |
| 2186 | prev_p = p; | 2197 | |
| 2187 | while (--p >= stop && ! CHAR_HEAD_P (*p)); | 2198 | unsigned char *prev_p = p; |
| 2199 | do | ||
| 2200 | p--; | ||
| 2201 | while (stop <= p && ! CHAR_HEAD_P (*p)); | ||
| 2202 | |||
| 2188 | c = STRING_CHAR (p); | 2203 | c = STRING_CHAR (p); |
| 2189 | if (! fastmap[SYNTAX (c)]) | 2204 | if (! fastmap[SYNTAX (c)]) |
| 2190 | break; | 2205 | break; |
| 2191 | pos--, pos_byte -= prev_p - p; | 2206 | pos--, pos_byte -= prev_p - p; |
| 2207 | rarely_quit (pos); | ||
| 2192 | } | 2208 | } |
| 2193 | } | 2209 | } |
| 2194 | else | 2210 | else |
| 2195 | { | 2211 | { |
| 2196 | while (1) | 2212 | while (true) |
| 2197 | { | 2213 | { |
| 2198 | if (p <= stop) | 2214 | if (p <= stop) |
| 2199 | { | 2215 | { |
| @@ -2206,6 +2222,7 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2206 | if (! fastmap[SYNTAX (p[-1])]) | 2222 | if (! fastmap[SYNTAX (p[-1])]) |
| 2207 | break; | 2223 | break; |
| 2208 | p--, pos--, pos_byte--; | 2224 | p--, pos--, pos_byte--; |
| 2225 | rarely_quit (pos); | ||
| 2209 | } | 2226 | } |
| 2210 | } | 2227 | } |
| 2211 | } | 2228 | } |
| @@ -2273,9 +2290,10 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 2273 | ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, | 2290 | ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, |
| 2274 | EMACS_INT *incomment_ptr, int *last_syntax_ptr) | 2291 | EMACS_INT *incomment_ptr, int *last_syntax_ptr) |
| 2275 | { | 2292 | { |
| 2276 | register int c, c1; | 2293 | unsigned short int quit_count = 0; |
| 2277 | register enum syntaxcode code; | 2294 | int c, c1; |
| 2278 | register int syntax, other_syntax; | 2295 | enum syntaxcode code; |
| 2296 | int syntax, other_syntax; | ||
| 2279 | 2297 | ||
| 2280 | if (nesting <= 0) nesting = -1; | 2298 | if (nesting <= 0) nesting = -1; |
| 2281 | 2299 | ||
| @@ -2367,6 +2385,8 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 2367 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2385 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2368 | nesting++; | 2386 | nesting++; |
| 2369 | } | 2387 | } |
| 2388 | |||
| 2389 | incr_rarely_quit (&quit_count); | ||
| 2370 | } | 2390 | } |
| 2371 | *charpos_ptr = from; | 2391 | *charpos_ptr = from; |
| 2372 | *bytepos_ptr = from_byte; | 2392 | *bytepos_ptr = from_byte; |
| @@ -2394,13 +2414,12 @@ between them, return t; otherwise return nil. */) | |||
| 2394 | ptrdiff_t out_charpos, out_bytepos; | 2414 | ptrdiff_t out_charpos, out_bytepos; |
| 2395 | EMACS_INT dummy; | 2415 | EMACS_INT dummy; |
| 2396 | int dummy2; | 2416 | int dummy2; |
| 2417 | unsigned short int quit_count = 0; | ||
| 2397 | 2418 | ||
| 2398 | CHECK_NUMBER (count); | 2419 | CHECK_NUMBER (count); |
| 2399 | count1 = XINT (count); | 2420 | count1 = XINT (count); |
| 2400 | stop = count1 > 0 ? ZV : BEGV; | 2421 | stop = count1 > 0 ? ZV : BEGV; |
| 2401 | 2422 | ||
| 2402 | maybe_quit (); | ||
| 2403 | |||
| 2404 | from = PT; | 2423 | from = PT; |
| 2405 | from_byte = PT_BYTE; | 2424 | from_byte = PT_BYTE; |
| 2406 | 2425 | ||
| @@ -2441,6 +2460,7 @@ between them, return t; otherwise return nil. */) | |||
| 2441 | INC_BOTH (from, from_byte); | 2460 | INC_BOTH (from, from_byte); |
| 2442 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2461 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2443 | } | 2462 | } |
| 2463 | incr_rarely_quit (&quit_count); | ||
| 2444 | } | 2464 | } |
| 2445 | while (code == Swhitespace || (code == Sendcomment && c == '\n')); | 2465 | while (code == Swhitespace || (code == Sendcomment && c == '\n')); |
| 2446 | 2466 | ||
| @@ -2469,11 +2489,8 @@ between them, return t; otherwise return nil. */) | |||
| 2469 | 2489 | ||
| 2470 | while (count1 < 0) | 2490 | while (count1 < 0) |
| 2471 | { | 2491 | { |
| 2472 | while (1) | 2492 | while (true) |
| 2473 | { | 2493 | { |
| 2474 | bool quoted; | ||
| 2475 | int syntax; | ||
| 2476 | |||
| 2477 | if (from <= stop) | 2494 | if (from <= stop) |
| 2478 | { | 2495 | { |
| 2479 | SET_PT_BOTH (BEGV, BEGV_BYTE); | 2496 | SET_PT_BOTH (BEGV, BEGV_BYTE); |
| @@ -2482,9 +2499,9 @@ between them, return t; otherwise return nil. */) | |||
| 2482 | 2499 | ||
| 2483 | DEC_BOTH (from, from_byte); | 2500 | DEC_BOTH (from, from_byte); |
| 2484 | /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ | 2501 | /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ |
| 2485 | quoted = char_quoted (from, from_byte); | 2502 | bool quoted = char_quoted (from, from_byte); |
| 2486 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2503 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2487 | syntax = SYNTAX_WITH_FLAGS (c); | 2504 | int syntax = SYNTAX_WITH_FLAGS (c); |
| 2488 | code = SYNTAX (c); | 2505 | code = SYNTAX (c); |
| 2489 | comstyle = 0; | 2506 | comstyle = 0; |
| 2490 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); | 2507 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); |
| @@ -2527,6 +2544,7 @@ between them, return t; otherwise return nil. */) | |||
| 2527 | } | 2544 | } |
| 2528 | else if (from == stop) | 2545 | else if (from == stop) |
| 2529 | break; | 2546 | break; |
| 2547 | incr_rarely_quit (&quit_count); | ||
| 2530 | } | 2548 | } |
| 2531 | if (fence_found == 0) | 2549 | if (fence_found == 0) |
| 2532 | { | 2550 | { |
| @@ -2573,6 +2591,8 @@ between them, return t; otherwise return nil. */) | |||
| 2573 | SET_PT_BOTH (from, from_byte); | 2591 | SET_PT_BOTH (from, from_byte); |
| 2574 | return Qnil; | 2592 | return Qnil; |
| 2575 | } | 2593 | } |
| 2594 | |||
| 2595 | incr_rarely_quit (&quit_count); | ||
| 2576 | } | 2596 | } |
| 2577 | 2597 | ||
| 2578 | count1++; | 2598 | count1++; |
| @@ -2612,6 +2632,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2612 | EMACS_INT dummy; | 2632 | EMACS_INT dummy; |
| 2613 | int dummy2; | 2633 | int dummy2; |
| 2614 | bool multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; | 2634 | bool multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; |
| 2635 | unsigned short int quit_count = 0; | ||
| 2615 | 2636 | ||
| 2616 | if (depth > 0) min_depth = 0; | 2637 | if (depth > 0) min_depth = 0; |
| 2617 | 2638 | ||
| @@ -2627,6 +2648,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2627 | { | 2648 | { |
| 2628 | while (from < stop) | 2649 | while (from < stop) |
| 2629 | { | 2650 | { |
| 2651 | incr_rarely_quit (&quit_count); | ||
| 2630 | bool comstart_first, prefix; | 2652 | bool comstart_first, prefix; |
| 2631 | int syntax, other_syntax; | 2653 | int syntax, other_syntax; |
| 2632 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2654 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| @@ -2695,6 +2717,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2695 | goto done; | 2717 | goto done; |
| 2696 | } | 2718 | } |
| 2697 | INC_BOTH (from, from_byte); | 2719 | INC_BOTH (from, from_byte); |
| 2720 | incr_rarely_quit (&quit_count); | ||
| 2698 | } | 2721 | } |
| 2699 | goto done; | 2722 | goto done; |
| 2700 | 2723 | ||
| @@ -2766,6 +2789,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2766 | if (c_code == Scharquote || c_code == Sescape) | 2789 | if (c_code == Scharquote || c_code == Sescape) |
| 2767 | INC_BOTH (from, from_byte); | 2790 | INC_BOTH (from, from_byte); |
| 2768 | INC_BOTH (from, from_byte); | 2791 | INC_BOTH (from, from_byte); |
| 2792 | incr_rarely_quit (&quit_count); | ||
| 2769 | } | 2793 | } |
| 2770 | INC_BOTH (from, from_byte); | 2794 | INC_BOTH (from, from_byte); |
| 2771 | if (!depth && sexpflag) goto done; | 2795 | if (!depth && sexpflag) goto done; |
| @@ -2791,11 +2815,11 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2791 | { | 2815 | { |
| 2792 | while (from > stop) | 2816 | while (from > stop) |
| 2793 | { | 2817 | { |
| 2794 | int syntax; | 2818 | incr_rarely_quit (&quit_count); |
| 2795 | DEC_BOTH (from, from_byte); | 2819 | DEC_BOTH (from, from_byte); |
| 2796 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 2820 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 2797 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2821 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2798 | syntax= SYNTAX_WITH_FLAGS (c); | 2822 | int syntax = SYNTAX_WITH_FLAGS (c); |
| 2799 | code = syntax_multibyte (c, multibyte_symbol_p); | 2823 | code = syntax_multibyte (c, multibyte_symbol_p); |
| 2800 | if (depth == min_depth) | 2824 | if (depth == min_depth) |
| 2801 | last_good = from; | 2825 | last_good = from; |
| @@ -2867,6 +2891,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2867 | default: goto done2; | 2891 | default: goto done2; |
| 2868 | } | 2892 | } |
| 2869 | DEC_BOTH (from, from_byte); | 2893 | DEC_BOTH (from, from_byte); |
| 2894 | incr_rarely_quit (&quit_count); | ||
| 2870 | } | 2895 | } |
| 2871 | goto done2; | 2896 | goto done2; |
| 2872 | 2897 | ||
| @@ -2929,13 +2954,14 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2929 | if (syntax_multibyte (c, multibyte_symbol_p) == code) | 2954 | if (syntax_multibyte (c, multibyte_symbol_p) == code) |
| 2930 | break; | 2955 | break; |
| 2931 | } | 2956 | } |
| 2957 | incr_rarely_quit (&quit_count); | ||
| 2932 | } | 2958 | } |
| 2933 | if (code == Sstring_fence && !depth && sexpflag) goto done2; | 2959 | if (code == Sstring_fence && !depth && sexpflag) goto done2; |
| 2934 | break; | 2960 | break; |
| 2935 | 2961 | ||
| 2936 | case Sstring: | 2962 | case Sstring: |
| 2937 | stringterm = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2963 | stringterm = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2938 | while (1) | 2964 | while (true) |
| 2939 | { | 2965 | { |
| 2940 | if (from == stop) | 2966 | if (from == stop) |
| 2941 | goto lose; | 2967 | goto lose; |
| @@ -2949,6 +2975,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2949 | == Sstring)) | 2975 | == Sstring)) |
| 2950 | break; | 2976 | break; |
| 2951 | } | 2977 | } |
| 2978 | incr_rarely_quit (&quit_count); | ||
| 2952 | } | 2979 | } |
| 2953 | if (!depth && sexpflag) goto done2; | 2980 | if (!depth && sexpflag) goto done2; |
| 2954 | break; | 2981 | break; |
| @@ -3061,6 +3088,7 @@ the prefix syntax flag (p). */) | |||
| 3061 | if (pos <= beg) | 3088 | if (pos <= beg) |
| 3062 | break; | 3089 | break; |
| 3063 | DEC_BOTH (pos, pos_byte); | 3090 | DEC_BOTH (pos, pos_byte); |
| 3091 | rarely_quit (pos); | ||
| 3064 | } | 3092 | } |
| 3065 | 3093 | ||
| 3066 | SET_PT_BOTH (opoint, opoint_byte); | 3094 | SET_PT_BOTH (opoint, opoint_byte); |
| @@ -3131,6 +3159,7 @@ scan_sexps_forward (struct lisp_parse_state *state, | |||
| 3131 | bool found; | 3159 | bool found; |
| 3132 | ptrdiff_t out_bytepos, out_charpos; | 3160 | ptrdiff_t out_bytepos, out_charpos; |
| 3133 | int temp; | 3161 | int temp; |
| 3162 | unsigned short int quit_count = 0; | ||
| 3134 | 3163 | ||
| 3135 | prev_from = from; | 3164 | prev_from = from; |
| 3136 | prev_from_byte = from_byte; | 3165 | prev_from_byte = from_byte; |
| @@ -3200,6 +3229,7 @@ do { prev_from = from; \ | |||
| 3200 | 3229 | ||
| 3201 | while (from < end) | 3230 | while (from < end) |
| 3202 | { | 3231 | { |
| 3232 | incr_rarely_quit (&quit_count); | ||
| 3203 | INC_FROM; | 3233 | INC_FROM; |
| 3204 | 3234 | ||
| 3205 | if ((from < end) | 3235 | if ((from < end) |
| @@ -3256,6 +3286,7 @@ do { prev_from = from; \ | |||
| 3256 | goto symdone; | 3286 | goto symdone; |
| 3257 | } | 3287 | } |
| 3258 | INC_FROM; | 3288 | INC_FROM; |
| 3289 | incr_rarely_quit (&quit_count); | ||
| 3259 | } | 3290 | } |
| 3260 | symdone: | 3291 | symdone: |
| 3261 | curlevel->prev = curlevel->last; | 3292 | curlevel->prev = curlevel->last; |
| @@ -3366,6 +3397,7 @@ do { prev_from = from; \ | |||
| 3366 | break; | 3397 | break; |
| 3367 | } | 3398 | } |
| 3368 | INC_FROM; | 3399 | INC_FROM; |
| 3400 | incr_rarely_quit (&quit_count); | ||
| 3369 | } | 3401 | } |
| 3370 | } | 3402 | } |
| 3371 | string_end: | 3403 | string_end: |