diff options
| author | Richard M. Stallman | 1994-12-24 23:40:43 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-12-24 23:40:43 +0000 |
| commit | eff52a4c6f9f2a18474e59a7a35c2a68ca73c2ba (patch) | |
| tree | 16e43909cd02a24a4d45cddb29a66b1ae5a80e42 /src | |
| parent | 5eb6298247925311e7ef8df351c1f1415fa96437 (diff) | |
| download | emacs-eff52a4c6f9f2a18474e59a7a35c2a68ca73c2ba.tar.gz emacs-eff52a4c6f9f2a18474e59a7a35c2a68ca73c2ba.zip | |
(SET_REGS_MATCHED): Do nothing if set_regs_matched_done is 1.
Set set_regs_matched_done to 1.
(re_match_2_internal): New local var set_regs_matched_done.
Set it to 0 when appropriate.
(POP_FAILURE_POINT): Set set_regs_matched_done to 0.
(re_match_2_internal, case duplicate): Call SET_REGS_MATCHED.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/src/regex.c b/src/regex.c index 2d291b323e1..2d10105a9bd 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -1196,6 +1196,7 @@ typedef struct | |||
| 1196 | DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ | 1196 | DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ |
| 1197 | } \ | 1197 | } \ |
| 1198 | \ | 1198 | \ |
| 1199 | set_regs_matched_done = 0; \ | ||
| 1199 | DEBUG_STATEMENT (nfailure_points_popped++); \ | 1200 | DEBUG_STATEMENT (nfailure_points_popped++); \ |
| 1200 | } /* POP_FAILURE_POINT */ | 1201 | } /* POP_FAILURE_POINT */ |
| 1201 | 1202 | ||
| @@ -1236,18 +1237,19 @@ typedef union | |||
| 1236 | /* Call this when have matched a real character; it sets `matched' flags | 1237 | /* Call this when have matched a real character; it sets `matched' flags |
| 1237 | for the subexpressions which we are currently inside. Also records | 1238 | for the subexpressions which we are currently inside. Also records |
| 1238 | that those subexprs have matched. */ | 1239 | that those subexprs have matched. */ |
| 1239 | #define SET_REGS_MATCHED() \ | 1240 | #define SET_REGS_MATCHED() \ |
| 1240 | do \ | 1241 | if (!set_regs_matched_done) \ |
| 1241 | { \ | 1242 | { \ |
| 1242 | unsigned r; \ | 1243 | unsigned r; \ |
| 1243 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | 1244 | set_regs_matched_done = 1; \ |
| 1244 | { \ | 1245 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ |
| 1245 | MATCHED_SOMETHING (reg_info[r]) \ | 1246 | { \ |
| 1246 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | 1247 | MATCHED_SOMETHING (reg_info[r]) \ |
| 1247 | = 1; \ | 1248 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ |
| 1248 | } \ | 1249 | = 1; \ |
| 1249 | } \ | 1250 | } \ |
| 1250 | while (0) | 1251 | } \ |
| 1252 | else | ||
| 1251 | 1253 | ||
| 1252 | 1254 | ||
| 1253 | /* Registers are set to a sentinel when they haven't yet matched. */ | 1255 | /* Registers are set to a sentinel when they haven't yet matched. */ |
| @@ -3482,6 +3484,9 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) | |||
| 3482 | and need to test it, it's not garbage. */ | 3484 | and need to test it, it's not garbage. */ |
| 3483 | const char *match_end = NULL; | 3485 | const char *match_end = NULL; |
| 3484 | 3486 | ||
| 3487 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ||
| 3488 | int set_regs_matched_done = 0; | ||
| 3489 | |||
| 3485 | /* Used when we pop values we don't care about. */ | 3490 | /* Used when we pop values we don't care about. */ |
| 3486 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | 3491 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ |
| 3487 | const char **reg_dummy; | 3492 | const char **reg_dummy; |
| @@ -3889,6 +3894,9 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) | |||
| 3889 | 3894 | ||
| 3890 | IS_ACTIVE (reg_info[*p]) = 1; | 3895 | IS_ACTIVE (reg_info[*p]) = 1; |
| 3891 | MATCHED_SOMETHING (reg_info[*p]) = 0; | 3896 | MATCHED_SOMETHING (reg_info[*p]) = 0; |
| 3897 | |||
| 3898 | /* Clear this whenever we change the register activity status. */ | ||
| 3899 | set_regs_matched_done = 0; | ||
| 3892 | 3900 | ||
| 3893 | /* This is the new highest active register. */ | 3901 | /* This is the new highest active register. */ |
| 3894 | highest_active_reg = *p; | 3902 | highest_active_reg = *p; |
| @@ -3901,6 +3909,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) | |||
| 3901 | /* Move past the register number and inner group count. */ | 3909 | /* Move past the register number and inner group count. */ |
| 3902 | p += 2; | 3910 | p += 2; |
| 3903 | just_past_start_mem = p; | 3911 | just_past_start_mem = p; |
| 3912 | |||
| 3904 | break; | 3913 | break; |
| 3905 | 3914 | ||
| 3906 | 3915 | ||
| @@ -3926,7 +3935,10 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) | |||
| 3926 | 3935 | ||
| 3927 | /* This register isn't active anymore. */ | 3936 | /* This register isn't active anymore. */ |
| 3928 | IS_ACTIVE (reg_info[*p]) = 0; | 3937 | IS_ACTIVE (reg_info[*p]) = 0; |
| 3929 | 3938 | ||
| 3939 | /* Clear this whenever we change the register activity status. */ | ||
| 3940 | set_regs_matched_done = 0; | ||
| 3941 | |||
| 3930 | /* If this was the only register active, nothing is active | 3942 | /* If this was the only register active, nothing is active |
| 3931 | anymore. */ | 3943 | anymore. */ |
| 3932 | if (lowest_active_reg == highest_active_reg) | 3944 | if (lowest_active_reg == highest_active_reg) |
| @@ -4094,6 +4106,9 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) | |||
| 4094 | : bcmp (d, d2, mcnt)) | 4106 | : bcmp (d, d2, mcnt)) |
| 4095 | goto fail; | 4107 | goto fail; |
| 4096 | d += mcnt, d2 += mcnt; | 4108 | d += mcnt, d2 += mcnt; |
| 4109 | |||
| 4110 | /* Do this because we've match some characters. */ | ||
| 4111 | SET_REGS_MATCHED (); | ||
| 4097 | } | 4112 | } |
| 4098 | } | 4113 | } |
| 4099 | break; | 4114 | break; |