Mercurial > emacs
comparison src/regex.c @ 32823:2a7f61d7ae12
(IMMEDIATE_QUIT_CHECK): New macro, which does QUIT on
NT-Emacs only.
(re_match_2_internal): Use IMMEDIATE_QUIT_CHECK instead of QUIT,
so that re_search functions only quit when callers expect them to.
author | Andrew Innes <andrewi@gnu.org> |
---|---|
date | Tue, 24 Oct 2000 14:00:55 +0000 |
parents | 112b31ea0526 |
children | 56a4ce418f35 |
comparison
equal
deleted
inserted
replaced
32822:2b3e80a729bd | 32823:2a7f61d7ae12 |
---|---|
2032 case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | 2032 case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; |
2033 } | 2033 } |
2034 } | 2034 } |
2035 #endif | 2035 #endif |
2036 | 2036 |
2037 /* QUIT is only used on NTemacs. */ | 2037 /* Explicit quit checking is only used on NTemacs. */ |
2038 #if !defined WINDOWSNT || !defined emacs || !defined QUIT | 2038 #if defined WINDOWSNT && defined emacs && defined QUIT |
2039 # undef QUIT | 2039 extern int immediate_quit; |
2040 # define QUIT | 2040 # define IMMEDIATE_QUIT_CHECK \ |
2041 do { \ | |
2042 if (immediate_quit) QUIT; \ | |
2043 } while (0) | |
2044 #else | |
2045 # define IMMEDIATE_QUIT_CHECK (0) | |
2041 #endif | 2046 #endif |
2042 | 2047 |
2043 #ifndef MATCH_MAY_ALLOCATE | 2048 #ifndef MATCH_MAY_ALLOCATE |
2044 | 2049 |
2045 /* If we cannot allocate large objects within re_match_2_internal, | 2050 /* If we cannot allocate large objects within re_match_2_internal, |
5289 | 5294 |
5290 Repeats start with an on_failure_jump that points past both | 5295 Repeats start with an on_failure_jump that points past both |
5291 the repetition text and either the following jump or | 5296 the repetition text and either the following jump or |
5292 pop_failure_jump back to this on_failure_jump. */ | 5297 pop_failure_jump back to this on_failure_jump. */ |
5293 case on_failure_jump: | 5298 case on_failure_jump: |
5294 QUIT; | 5299 IMMEDIATE_QUIT_CHECK; |
5295 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 5300 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
5296 DEBUG_PRINT3 ("EXECUTING on_failure_jump %d (to %p):\n", | 5301 DEBUG_PRINT3 ("EXECUTING on_failure_jump %d (to %p):\n", |
5297 mcnt, p + mcnt); | 5302 mcnt, p + mcnt); |
5298 | 5303 |
5299 PUSH_FAILURE_POINT (p -3, d); | 5304 PUSH_FAILURE_POINT (p -3, d); |
5305 is nothing that they would both match, i.e., that we | 5310 is nothing that they would both match, i.e., that we |
5306 would have to backtrack because of (as in, e.g., `a*a') | 5311 would have to backtrack because of (as in, e.g., `a*a') |
5307 then we can use a non-backtracking loop based on | 5312 then we can use a non-backtracking loop based on |
5308 on_failure_keep_string_jump instead of on_failure_jump. */ | 5313 on_failure_keep_string_jump instead of on_failure_jump. */ |
5309 case on_failure_jump_smart: | 5314 case on_failure_jump_smart: |
5310 QUIT; | 5315 IMMEDIATE_QUIT_CHECK; |
5311 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 5316 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
5312 DEBUG_PRINT3 ("EXECUTING on_failure_jump_smart %d (to %p).\n", | 5317 DEBUG_PRINT3 ("EXECUTING on_failure_jump_smart %d (to %p).\n", |
5313 mcnt, p + mcnt); | 5318 mcnt, p + mcnt); |
5314 { | 5319 { |
5315 unsigned char *p1 = p; /* Next operation. */ | 5320 unsigned char *p1 = p; /* Next operation. */ |
5343 break; | 5348 break; |
5344 | 5349 |
5345 /* Unconditionally jump (without popping any failure points). */ | 5350 /* Unconditionally jump (without popping any failure points). */ |
5346 case jump: | 5351 case jump: |
5347 unconditional_jump: | 5352 unconditional_jump: |
5348 QUIT; | 5353 IMMEDIATE_QUIT_CHECK; |
5349 EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ | 5354 EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ |
5350 DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); | 5355 DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); |
5351 p += mcnt; /* Do the jump. */ | 5356 p += mcnt; /* Do the jump. */ |
5352 DEBUG_PRINT2 ("(to %p).\n", p); | 5357 DEBUG_PRINT2 ("(to %p).\n", p); |
5353 break; | 5358 break; |
5597 continue; /* Successfully executed one pattern command; keep going. */ | 5602 continue; /* Successfully executed one pattern command; keep going. */ |
5598 | 5603 |
5599 | 5604 |
5600 /* We goto here if a matching operation fails. */ | 5605 /* We goto here if a matching operation fails. */ |
5601 fail: | 5606 fail: |
5602 QUIT; | 5607 IMMEDIATE_QUIT_CHECK; |
5603 if (!FAIL_STACK_EMPTY ()) | 5608 if (!FAIL_STACK_EMPTY ()) |
5604 { | 5609 { |
5605 re_char *str; | 5610 re_char *str; |
5606 unsigned char *pat; | 5611 unsigned char *pat; |
5607 /* A restart point is known. Restore to that state. */ | 5612 /* A restart point is known. Restore to that state. */ |