aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.c
diff options
context:
space:
mode:
authorNickolas Lloyd2017-02-01 22:31:55 -0500
committerNickolas Lloyd2017-02-01 22:31:55 -0500
commit9a15b5509abb49a11c97c1101ad216f4ef258368 (patch)
tree7311337d92833cb8f233eaa696a967a15a306a80 /src/syntax.c
parent5d8f2548ceaa5a0b33c08a39f1d6c11071ec63aa (diff)
parent70d36dda26465b43c1a63e8e13153e070af86456 (diff)
downloademacs-nick.lloyd-bytecode-jit.tar.gz
emacs-nick.lloyd-bytecode-jit.zip
Merge branch 'master' into nick.lloyd-bytecode-jitnick.lloyd-bytecode-jit
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c140
1 files changed, 72 insertions, 68 deletions
diff --git a/src/syntax.c b/src/syntax.c
index f9e4093765c..7aa43e6e5c7 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -621,11 +621,9 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
621 SETUP_BUFFER_SYNTAX_TABLE (); 621 SETUP_BUFFER_SYNTAX_TABLE ();
622 while (PT > BEGV) 622 while (PT > BEGV)
623 { 623 {
624 int c;
625
626 /* Open-paren at start of line means we may have found our 624 /* Open-paren at start of line means we may have found our
627 defun-start. */ 625 defun-start. */
628 c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE); 626 int c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE);
629 if (SYNTAX (c) == Sopen) 627 if (SYNTAX (c) == Sopen)
630 { 628 {
631 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ 629 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */
@@ -715,6 +713,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
715 ptrdiff_t nesting = 1; /* Current comment nesting. */ 713 ptrdiff_t nesting = 1; /* Current comment nesting. */
716 int c; 714 int c;
717 int syntax = 0; 715 int syntax = 0;
716 unsigned short int quit_count = 0;
718 717
719 /* FIXME: A }} comment-ender style leads to incorrect behavior 718 /* FIXME: A }} comment-ender style leads to incorrect behavior
720 in the case of {{ c }}} because we ignore the last two chars which are 719 in the case of {{ c }}} because we ignore the last two chars which are
@@ -724,6 +723,8 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
724 that determines quote parity to the comment-end. */ 723 that determines quote parity to the comment-end. */
725 while (from != stop) 724 while (from != stop)
726 { 725 {
726 rarely_quit (++quit_count);
727
727 ptrdiff_t temp_byte; 728 ptrdiff_t temp_byte;
728 int prev_syntax; 729 int prev_syntax;
729 bool com2start, com2end, comstart; 730 bool com2start, com2end, comstart;
@@ -951,7 +952,9 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
951 defun_start_byte = CHAR_TO_BYTE (defun_start); 952 defun_start_byte = CHAR_TO_BYTE (defun_start);
952 } 953 }
953 } 954 }
954 } while (defun_start < comment_end); 955 rarely_quit (++quit_count);
956 }
957 while (defun_start < comment_end);
955 958
956 from_byte = CHAR_TO_BYTE (from); 959 from_byte = CHAR_TO_BYTE (from);
957 UPDATE_SYNTAX_TABLE_FORWARD (from - 1); 960 UPDATE_SYNTAX_TABLE_FORWARD (from - 1);
@@ -1417,29 +1420,23 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value,
1417 COUNT negative means scan backward and stop at word beginning. */ 1420 COUNT negative means scan backward and stop at word beginning. */
1418 1421
1419ptrdiff_t 1422ptrdiff_t
1420scan_words (register ptrdiff_t from, register EMACS_INT count) 1423scan_words (ptrdiff_t from, EMACS_INT count)
1421{ 1424{
1422 register ptrdiff_t beg = BEGV; 1425 ptrdiff_t beg = BEGV;
1423 register ptrdiff_t end = ZV; 1426 ptrdiff_t end = ZV;
1424 register ptrdiff_t from_byte = CHAR_TO_BYTE (from); 1427 ptrdiff_t from_byte = CHAR_TO_BYTE (from);
1425 register enum syntaxcode code; 1428 enum syntaxcode code;
1426 int ch0, ch1; 1429 int ch0, ch1;
1427 Lisp_Object func, pos; 1430 Lisp_Object func, pos;
1428 1431
1429 immediate_quit = true;
1430 maybe_quit ();
1431
1432 SETUP_SYNTAX_TABLE (from, count); 1432 SETUP_SYNTAX_TABLE (from, count);
1433 1433
1434 while (count > 0) 1434 while (count > 0)
1435 { 1435 {
1436 while (1) 1436 while (true)
1437 { 1437 {
1438 if (from == end) 1438 if (from == end)
1439 { 1439 return 0;
1440 immediate_quit = false;
1441 return 0;
1442 }
1443 UPDATE_SYNTAX_TABLE_FORWARD (from); 1440 UPDATE_SYNTAX_TABLE_FORWARD (from);
1444 ch0 = FETCH_CHAR_AS_MULTIBYTE (from_byte); 1441 ch0 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
1445 code = SYNTAX (ch0); 1442 code = SYNTAX (ch0);
@@ -1449,6 +1446,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1449 break; 1446 break;
1450 if (code == Sword) 1447 if (code == Sword)
1451 break; 1448 break;
1449 rarely_quit (from);
1452 } 1450 }
1453 /* Now CH0 is a character which begins a word and FROM is the 1451 /* Now CH0 is a character which begins a word and FROM is the
1454 position of the next character. */ 1452 position of the next character. */
@@ -1477,19 +1475,17 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1477 break; 1475 break;
1478 INC_BOTH (from, from_byte); 1476 INC_BOTH (from, from_byte);
1479 ch0 = ch1; 1477 ch0 = ch1;
1478 rarely_quit (from);
1480 } 1479 }
1481 } 1480 }
1482 count--; 1481 count--;
1483 } 1482 }
1484 while (count < 0) 1483 while (count < 0)
1485 { 1484 {
1486 while (1) 1485 while (true)
1487 { 1486 {
1488 if (from == beg) 1487 if (from == beg)
1489 { 1488 return 0;
1490 immediate_quit = false;
1491 return 0;
1492 }
1493 DEC_BOTH (from, from_byte); 1489 DEC_BOTH (from, from_byte);
1494 UPDATE_SYNTAX_TABLE_BACKWARD (from); 1490 UPDATE_SYNTAX_TABLE_BACKWARD (from);
1495 ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); 1491 ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
@@ -1499,6 +1495,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1499 break; 1495 break;
1500 if (code == Sword) 1496 if (code == Sword)
1501 break; 1497 break;
1498 rarely_quit (from);
1502 } 1499 }
1503 /* Now CH1 is a character which ends a word and FROM is the 1500 /* Now CH1 is a character which ends a word and FROM is the
1504 position of it. */ 1501 position of it. */
@@ -1531,13 +1528,12 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1531 break; 1528 break;
1532 } 1529 }
1533 ch1 = ch0; 1530 ch1 = ch0;
1531 rarely_quit (from);
1534 } 1532 }
1535 } 1533 }
1536 count++; 1534 count++;
1537 } 1535 }
1538 1536
1539 immediate_quit = false;
1540
1541 return from; 1537 return from;
1542} 1538}
1543 1539
@@ -1921,7 +1917,6 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
1921 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; 1917 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp;
1922 } 1918 }
1923 1919
1924 immediate_quit = true;
1925 /* This code may look up syntax tables using functions that rely on the 1920 /* This code may look up syntax tables using functions that rely on the
1926 gl_state object. To make sure this object is not out of date, 1921 gl_state object. To make sure this object is not out of date,
1927 let's initialize it manually. 1922 let's initialize it manually.
@@ -1971,9 +1966,10 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
1971 } 1966 }
1972 fwd_ok: 1967 fwd_ok:
1973 p += nbytes, pos++, pos_byte += nbytes; 1968 p += nbytes, pos++, pos_byte += nbytes;
1969 rarely_quit (pos);
1974 } 1970 }
1975 else 1971 else
1976 while (1) 1972 while (true)
1977 { 1973 {
1978 if (p >= stop) 1974 if (p >= stop)
1979 { 1975 {
@@ -1995,15 +1991,14 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
1995 break; 1991 break;
1996 fwd_unibyte_ok: 1992 fwd_unibyte_ok:
1997 p++, pos++, pos_byte++; 1993 p++, pos++, pos_byte++;
1994 rarely_quit (pos);
1998 } 1995 }
1999 } 1996 }
2000 else 1997 else
2001 { 1998 {
2002 if (multibyte) 1999 if (multibyte)
2003 while (1) 2000 while (true)
2004 { 2001 {
2005 unsigned char *prev_p;
2006
2007 if (p <= stop) 2002 if (p <= stop)
2008 { 2003 {
2009 if (p <= endp) 2004 if (p <= endp)
@@ -2011,8 +2006,11 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
2011 p = GPT_ADDR; 2006 p = GPT_ADDR;
2012 stop = endp; 2007 stop = endp;
2013 } 2008 }
2014 prev_p = p; 2009 unsigned char *prev_p = p;
2015 while (--p >= stop && ! CHAR_HEAD_P (*p)); 2010 do
2011 p--;
2012 while (stop <= p && ! CHAR_HEAD_P (*p));
2013
2016 c = STRING_CHAR (p); 2014 c = STRING_CHAR (p);
2017 2015
2018 if (! NILP (iso_classes) && in_classes (c, iso_classes)) 2016 if (! NILP (iso_classes) && in_classes (c, iso_classes))
@@ -2036,9 +2034,10 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
2036 } 2034 }
2037 back_ok: 2035 back_ok:
2038 pos--, pos_byte -= prev_p - p; 2036 pos--, pos_byte -= prev_p - p;
2037 rarely_quit (pos);
2039 } 2038 }
2040 else 2039 else
2041 while (1) 2040 while (true)
2042 { 2041 {
2043 if (p <= stop) 2042 if (p <= stop)
2044 { 2043 {
@@ -2060,11 +2059,11 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
2060 break; 2059 break;
2061 back_unibyte_ok: 2060 back_unibyte_ok:
2062 p--, pos--, pos_byte--; 2061 p--, pos--, pos_byte--;
2062 rarely_quit (pos);
2063 } 2063 }
2064 } 2064 }
2065 2065
2066 SET_PT_BOTH (pos, pos_byte); 2066 SET_PT_BOTH (pos, pos_byte);
2067 immediate_quit = false;
2068 2067
2069 SAFE_FREE (); 2068 SAFE_FREE ();
2070 return make_number (PT - start_point); 2069 return make_number (PT - start_point);
@@ -2138,7 +2137,6 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
2138 ptrdiff_t pos_byte = PT_BYTE; 2137 ptrdiff_t pos_byte = PT_BYTE;
2139 unsigned char *p, *endp, *stop; 2138 unsigned char *p, *endp, *stop;
2140 2139
2141 immediate_quit = true;
2142 SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1); 2140 SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1);
2143 2141
2144 if (forwardp) 2142 if (forwardp)
@@ -2167,6 +2165,7 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
2167 if (! fastmap[SYNTAX (c)]) 2165 if (! fastmap[SYNTAX (c)])
2168 goto done; 2166 goto done;
2169 p += nbytes, pos++, pos_byte += nbytes; 2167 p += nbytes, pos++, pos_byte += nbytes;
2168 rarely_quit (pos);
2170 } 2169 }
2171 while (!parse_sexp_lookup_properties 2170 while (!parse_sexp_lookup_properties
2172 || pos < gl_state.e_property); 2171 || pos < gl_state.e_property);
@@ -2183,10 +2182,8 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
2183 2182
2184 if (multibyte) 2183 if (multibyte)
2185 { 2184 {
2186 while (1) 2185 while (true)
2187 { 2186 {
2188 unsigned char *prev_p;
2189
2190 if (p <= stop) 2187 if (p <= stop)
2191 { 2188 {
2192 if (p <= endp) 2189 if (p <= endp)
@@ -2195,17 +2192,22 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
2195 stop = endp; 2192 stop = endp;
2196 } 2193 }
2197 UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); 2194 UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1);
2198 prev_p = p; 2195
2199 while (--p >= stop && ! CHAR_HEAD_P (*p)); 2196 unsigned char *prev_p = p;
2197 do
2198 p--;
2199 while (stop <= p && ! CHAR_HEAD_P (*p));
2200
2200 c = STRING_CHAR (p); 2201 c = STRING_CHAR (p);
2201 if (! fastmap[SYNTAX (c)]) 2202 if (! fastmap[SYNTAX (c)])
2202 break; 2203 break;
2203 pos--, pos_byte -= prev_p - p; 2204 pos--, pos_byte -= prev_p - p;
2205 rarely_quit (pos);
2204 } 2206 }
2205 } 2207 }
2206 else 2208 else
2207 { 2209 {
2208 while (1) 2210 while (true)
2209 { 2211 {
2210 if (p <= stop) 2212 if (p <= stop)
2211 { 2213 {
@@ -2218,13 +2220,13 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
2218 if (! fastmap[SYNTAX (p[-1])]) 2220 if (! fastmap[SYNTAX (p[-1])])
2219 break; 2221 break;
2220 p--, pos--, pos_byte--; 2222 p--, pos--, pos_byte--;
2223 rarely_quit (pos);
2221 } 2224 }
2222 } 2225 }
2223 } 2226 }
2224 2227
2225 done: 2228 done:
2226 SET_PT_BOTH (pos, pos_byte); 2229 SET_PT_BOTH (pos, pos_byte);
2227 immediate_quit = false;
2228 2230
2229 return make_number (PT - start_point); 2231 return make_number (PT - start_point);
2230 } 2232 }
@@ -2286,9 +2288,10 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
2286 ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, 2288 ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr,
2287 EMACS_INT *incomment_ptr, int *last_syntax_ptr) 2289 EMACS_INT *incomment_ptr, int *last_syntax_ptr)
2288{ 2290{
2289 register int c, c1; 2291 unsigned short int quit_count = 0;
2290 register enum syntaxcode code; 2292 int c, c1;
2291 register int syntax, other_syntax; 2293 enum syntaxcode code;
2294 int syntax, other_syntax;
2292 2295
2293 if (nesting <= 0) nesting = -1; 2296 if (nesting <= 0) nesting = -1;
2294 2297
@@ -2380,6 +2383,8 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
2380 UPDATE_SYNTAX_TABLE_FORWARD (from); 2383 UPDATE_SYNTAX_TABLE_FORWARD (from);
2381 nesting++; 2384 nesting++;
2382 } 2385 }
2386
2387 rarely_quit (++quit_count);
2383 } 2388 }
2384 *charpos_ptr = from; 2389 *charpos_ptr = from;
2385 *bytepos_ptr = from_byte; 2390 *bytepos_ptr = from_byte;
@@ -2407,14 +2412,12 @@ between them, return t; otherwise return nil. */)
2407 ptrdiff_t out_charpos, out_bytepos; 2412 ptrdiff_t out_charpos, out_bytepos;
2408 EMACS_INT dummy; 2413 EMACS_INT dummy;
2409 int dummy2; 2414 int dummy2;
2415 unsigned short int quit_count = 0;
2410 2416
2411 CHECK_NUMBER (count); 2417 CHECK_NUMBER (count);
2412 count1 = XINT (count); 2418 count1 = XINT (count);
2413 stop = count1 > 0 ? ZV : BEGV; 2419 stop = count1 > 0 ? ZV : BEGV;
2414 2420
2415 immediate_quit = true;
2416 maybe_quit ();
2417
2418 from = PT; 2421 from = PT;
2419 from_byte = PT_BYTE; 2422 from_byte = PT_BYTE;
2420 2423
@@ -2429,7 +2432,6 @@ between them, return t; otherwise return nil. */)
2429 if (from == stop) 2432 if (from == stop)
2430 { 2433 {
2431 SET_PT_BOTH (from, from_byte); 2434 SET_PT_BOTH (from, from_byte);
2432 immediate_quit = false;
2433 return Qnil; 2435 return Qnil;
2434 } 2436 }
2435 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2437 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
@@ -2456,6 +2458,7 @@ between them, return t; otherwise return nil. */)
2456 INC_BOTH (from, from_byte); 2458 INC_BOTH (from, from_byte);
2457 UPDATE_SYNTAX_TABLE_FORWARD (from); 2459 UPDATE_SYNTAX_TABLE_FORWARD (from);
2458 } 2460 }
2461 rarely_quit (++quit_count);
2459 } 2462 }
2460 while (code == Swhitespace || (code == Sendcomment && c == '\n')); 2463 while (code == Swhitespace || (code == Sendcomment && c == '\n'));
2461 2464
@@ -2463,7 +2466,6 @@ between them, return t; otherwise return nil. */)
2463 comstyle = ST_COMMENT_STYLE; 2466 comstyle = ST_COMMENT_STYLE;
2464 else if (code != Scomment) 2467 else if (code != Scomment)
2465 { 2468 {
2466 immediate_quit = false;
2467 DEC_BOTH (from, from_byte); 2469 DEC_BOTH (from, from_byte);
2468 SET_PT_BOTH (from, from_byte); 2470 SET_PT_BOTH (from, from_byte);
2469 return Qnil; 2471 return Qnil;
@@ -2474,7 +2476,6 @@ between them, return t; otherwise return nil. */)
2474 from = out_charpos; from_byte = out_bytepos; 2476 from = out_charpos; from_byte = out_bytepos;
2475 if (!found) 2477 if (!found)
2476 { 2478 {
2477 immediate_quit = false;
2478 SET_PT_BOTH (from, from_byte); 2479 SET_PT_BOTH (from, from_byte);
2479 return Qnil; 2480 return Qnil;
2480 } 2481 }
@@ -2486,23 +2487,19 @@ between them, return t; otherwise return nil. */)
2486 2487
2487 while (count1 < 0) 2488 while (count1 < 0)
2488 { 2489 {
2489 while (1) 2490 while (true)
2490 { 2491 {
2491 bool quoted;
2492 int syntax;
2493
2494 if (from <= stop) 2492 if (from <= stop)
2495 { 2493 {
2496 SET_PT_BOTH (BEGV, BEGV_BYTE); 2494 SET_PT_BOTH (BEGV, BEGV_BYTE);
2497 immediate_quit = false;
2498 return Qnil; 2495 return Qnil;
2499 } 2496 }
2500 2497
2501 DEC_BOTH (from, from_byte); 2498 DEC_BOTH (from, from_byte);
2502 /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ 2499 /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */
2503 quoted = char_quoted (from, from_byte); 2500 bool quoted = char_quoted (from, from_byte);
2504 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2501 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2505 syntax = SYNTAX_WITH_FLAGS (c); 2502 int syntax = SYNTAX_WITH_FLAGS (c);
2506 code = SYNTAX (c); 2503 code = SYNTAX (c);
2507 comstyle = 0; 2504 comstyle = 0;
2508 comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); 2505 comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax);
@@ -2545,6 +2542,7 @@ between them, return t; otherwise return nil. */)
2545 } 2542 }
2546 else if (from == stop) 2543 else if (from == stop)
2547 break; 2544 break;
2545 rarely_quit (++quit_count);
2548 } 2546 }
2549 if (fence_found == 0) 2547 if (fence_found == 0)
2550 { 2548 {
@@ -2587,18 +2585,18 @@ between them, return t; otherwise return nil. */)
2587 else if (code != Swhitespace || quoted) 2585 else if (code != Swhitespace || quoted)
2588 { 2586 {
2589 leave: 2587 leave:
2590 immediate_quit = false;
2591 INC_BOTH (from, from_byte); 2588 INC_BOTH (from, from_byte);
2592 SET_PT_BOTH (from, from_byte); 2589 SET_PT_BOTH (from, from_byte);
2593 return Qnil; 2590 return Qnil;
2594 } 2591 }
2592
2593 rarely_quit (++quit_count);
2595 } 2594 }
2596 2595
2597 count1++; 2596 count1++;
2598 } 2597 }
2599 2598
2600 SET_PT_BOTH (from, from_byte); 2599 SET_PT_BOTH (from, from_byte);
2601 immediate_quit = false;
2602 return Qt; 2600 return Qt;
2603} 2601}
2604 2602
@@ -2632,6 +2630,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2632 EMACS_INT dummy; 2630 EMACS_INT dummy;
2633 int dummy2; 2631 int dummy2;
2634 bool multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; 2632 bool multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol;
2633 unsigned short int quit_count = 0;
2635 2634
2636 if (depth > 0) min_depth = 0; 2635 if (depth > 0) min_depth = 0;
2637 2636
@@ -2640,7 +2639,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2640 2639
2641 from_byte = CHAR_TO_BYTE (from); 2640 from_byte = CHAR_TO_BYTE (from);
2642 2641
2643 immediate_quit = true;
2644 maybe_quit (); 2642 maybe_quit ();
2645 2643
2646 SETUP_SYNTAX_TABLE (from, count); 2644 SETUP_SYNTAX_TABLE (from, count);
@@ -2648,6 +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 {
2649 rarely_quit (++quit_count);
2651 bool comstart_first, prefix; 2650 bool comstart_first, prefix;
2652 int syntax, other_syntax; 2651 int syntax, other_syntax;
2653 UPDATE_SYNTAX_TABLE_FORWARD (from); 2652 UPDATE_SYNTAX_TABLE_FORWARD (from);
@@ -2716,6 +2715,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2716 goto done; 2715 goto done;
2717 } 2716 }
2718 INC_BOTH (from, from_byte); 2717 INC_BOTH (from, from_byte);
2718 rarely_quit (++quit_count);
2719 } 2719 }
2720 goto done; 2720 goto done;
2721 2721
@@ -2787,6 +2787,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2787 if (c_code == Scharquote || c_code == Sescape) 2787 if (c_code == Scharquote || c_code == Sescape)
2788 INC_BOTH (from, from_byte); 2788 INC_BOTH (from, from_byte);
2789 INC_BOTH (from, from_byte); 2789 INC_BOTH (from, from_byte);
2790 rarely_quit (++quit_count);
2790 } 2791 }
2791 INC_BOTH (from, from_byte); 2792 INC_BOTH (from, from_byte);
2792 if (!depth && sexpflag) goto done; 2793 if (!depth && sexpflag) goto done;
@@ -2801,7 +2802,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2801 if (depth) 2802 if (depth)
2802 goto lose; 2803 goto lose;
2803 2804
2804 immediate_quit = false;
2805 return Qnil; 2805 return Qnil;
2806 2806
2807 /* End of object reached */ 2807 /* End of object reached */
@@ -2813,11 +2813,11 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2813 { 2813 {
2814 while (from > stop) 2814 while (from > stop)
2815 { 2815 {
2816 int syntax; 2816 rarely_quit (++quit_count);
2817 DEC_BOTH (from, from_byte); 2817 DEC_BOTH (from, from_byte);
2818 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2818 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2819 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2819 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2820 syntax= SYNTAX_WITH_FLAGS (c); 2820 int syntax = SYNTAX_WITH_FLAGS (c);
2821 code = syntax_multibyte (c, multibyte_symbol_p); 2821 code = syntax_multibyte (c, multibyte_symbol_p);
2822 if (depth == min_depth) 2822 if (depth == min_depth)
2823 last_good = from; 2823 last_good = from;
@@ -2889,6 +2889,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2889 default: goto done2; 2889 default: goto done2;
2890 } 2890 }
2891 DEC_BOTH (from, from_byte); 2891 DEC_BOTH (from, from_byte);
2892 rarely_quit (++quit_count);
2892 } 2893 }
2893 goto done2; 2894 goto done2;
2894 2895
@@ -2951,13 +2952,14 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2951 if (syntax_multibyte (c, multibyte_symbol_p) == code) 2952 if (syntax_multibyte (c, multibyte_symbol_p) == code)
2952 break; 2953 break;
2953 } 2954 }
2955 rarely_quit (++quit_count);
2954 } 2956 }
2955 if (code == Sstring_fence && !depth && sexpflag) goto done2; 2957 if (code == Sstring_fence && !depth && sexpflag) goto done2;
2956 break; 2958 break;
2957 2959
2958 case Sstring: 2960 case Sstring:
2959 stringterm = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2961 stringterm = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2960 while (1) 2962 while (true)
2961 { 2963 {
2962 if (from == stop) 2964 if (from == stop)
2963 goto lose; 2965 goto lose;
@@ -2971,6 +2973,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2971 == Sstring)) 2973 == Sstring))
2972 break; 2974 break;
2973 } 2975 }
2976 rarely_quit (++quit_count);
2974 } 2977 }
2975 if (!depth && sexpflag) goto done2; 2978 if (!depth && sexpflag) goto done2;
2976 break; 2979 break;
@@ -2984,7 +2987,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2984 if (depth) 2987 if (depth)
2985 goto lose; 2988 goto lose;
2986 2989
2987 immediate_quit = false;
2988 return Qnil; 2990 return Qnil;
2989 2991
2990 done2: 2992 done2:
@@ -2992,7 +2994,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2992 } 2994 }
2993 2995
2994 2996
2995 immediate_quit = false;
2996 XSETFASTINT (val, from); 2997 XSETFASTINT (val, from);
2997 return val; 2998 return val;
2998 2999
@@ -3085,6 +3086,7 @@ the prefix syntax flag (p). */)
3085 if (pos <= beg) 3086 if (pos <= beg)
3086 break; 3087 break;
3087 DEC_BOTH (pos, pos_byte); 3088 DEC_BOTH (pos, pos_byte);
3089 rarely_quit (pos);
3088 } 3090 }
3089 3091
3090 SET_PT_BOTH (opoint, opoint_byte); 3092 SET_PT_BOTH (opoint, opoint_byte);
@@ -3155,6 +3157,7 @@ scan_sexps_forward (struct lisp_parse_state *state,
3155 bool found; 3157 bool found;
3156 ptrdiff_t out_bytepos, out_charpos; 3158 ptrdiff_t out_bytepos, out_charpos;
3157 int temp; 3159 int temp;
3160 unsigned short int quit_count = 0;
3158 3161
3159 prev_from = from; 3162 prev_from = from;
3160 prev_from_byte = from_byte; 3163 prev_from_byte = from_byte;
@@ -3173,7 +3176,6 @@ do { prev_from = from; \
3173 UPDATE_SYNTAX_TABLE_FORWARD (from); \ 3176 UPDATE_SYNTAX_TABLE_FORWARD (from); \
3174 } while (0) 3177 } while (0)
3175 3178
3176 immediate_quit = true;
3177 maybe_quit (); 3179 maybe_quit ();
3178 3180
3179 depth = state->depth; 3181 depth = state->depth;
@@ -3225,6 +3227,7 @@ do { prev_from = from; \
3225 3227
3226 while (from < end) 3228 while (from < end)
3227 { 3229 {
3230 rarely_quit (++quit_count);
3228 INC_FROM; 3231 INC_FROM;
3229 3232
3230 if ((from < end) 3233 if ((from < end)
@@ -3281,6 +3284,7 @@ do { prev_from = from; \
3281 goto symdone; 3284 goto symdone;
3282 } 3285 }
3283 INC_FROM; 3286 INC_FROM;
3287 rarely_quit (++quit_count);
3284 } 3288 }
3285 symdone: 3289 symdone:
3286 curlevel->prev = curlevel->last; 3290 curlevel->prev = curlevel->last;
@@ -3391,6 +3395,7 @@ do { prev_from = from; \
3391 break; 3395 break;
3392 } 3396 }
3393 INC_FROM; 3397 INC_FROM;
3398 rarely_quit (++quit_count);
3394 } 3399 }
3395 } 3400 }
3396 string_end: 3401 string_end:
@@ -3432,7 +3437,6 @@ do { prev_from = from; \
3432 state->levelstarts); 3437 state->levelstarts);
3433 state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax) 3438 state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax)
3434 || state->quoted) ? prev_from_syntax : Smax; 3439 || state->quoted) ? prev_from_syntax : Smax;
3435 immediate_quit = false;
3436} 3440}
3437 3441
3438/* Convert a (lisp) parse state to the internal form used in 3442/* Convert a (lisp) parse state to the internal form used in