aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1993-06-07 08:06:10 +0000
committerRichard M. Stallman1993-06-07 08:06:10 +0000
commit4f9d3ad8807990cccf8df791af556b628dfcc9de (patch)
tree8cb19fe903b2e85fd9d9077956877055ec42e221 /src
parent849056cc4c75dfc22c89b76246459e1c909fad19 (diff)
downloademacs-4f9d3ad8807990cccf8df791af556b628dfcc9de.tar.gz
emacs-4f9d3ad8807990cccf8df791af556b628dfcc9de.zip
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/regex.c78
1 files changed, 69 insertions, 9 deletions
diff --git a/src/regex.c b/src/regex.c
index bf3e96855d4..4bb30f7e214 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -4130,11 +4130,27 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
4130 detect that here, the alternative has put on a dummy 4130 detect that here, the alternative has put on a dummy
4131 failure point which is what we will end up popping. */ 4131 failure point which is what we will end up popping. */
4132 4132
4133 /* Skip over open/close-group commands. */ 4133 /* Skip over open/close-group commands.
4134 while (p2 + 2 < pend 4134 If what follows this loop is a ...+ construct,
4135 && ((re_opcode_t) *p2 == stop_memory 4135 look at what begins its body, since we will have to
4136 || (re_opcode_t) *p2 == start_memory)) 4136 match at least one of that. */
4137 p2 += 3; /* Skip over args, too. */ 4137 while (1)
4138 {
4139 if (p2 + 2 < pend
4140 && ((re_opcode_t) *p2 == stop_memory
4141 || (re_opcode_t) *p2 == start_memory))
4142 p2 += 3;
4143 else if (p2 + 6 < pend
4144 && (re_opcode_t) *p2 == dummy_failure_jump)
4145 p2 += 6;
4146 else
4147 break;
4148 }
4149
4150 p1 = p + mcnt;
4151 /* p1[0] ... p1[2] are the `on_failure_jump' corresponding
4152 to the `maybe_finalize_jump' of this case. Examine what
4153 follows. */
4138 4154
4139 /* If we're at the end of the pattern, we can change. */ 4155 /* If we're at the end of the pattern, we can change. */
4140 if (p2 == pend) 4156 if (p2 == pend)
@@ -4152,11 +4168,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
4152 { 4168 {
4153 register unsigned char c 4169 register unsigned char c
4154 = *p2 == (unsigned char) endline ? '\n' : p2[2]; 4170 = *p2 == (unsigned char) endline ? '\n' : p2[2];
4155 p1 = p + mcnt;
4156 4171
4157 /* p1[0] ... p1[2] are the `on_failure_jump' corresponding
4158 to the `maybe_finalize_jump' of this case. Examine what
4159 follows. */
4160 if ((re_opcode_t) p1[3] == exactn && p1[5] != c) 4172 if ((re_opcode_t) p1[3] == exactn && p1[5] != c)
4161 { 4173 {
4162 p[-3] = (unsigned char) pop_failure_jump; 4174 p[-3] = (unsigned char) pop_failure_jump;
@@ -4182,6 +4194,54 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
4182 } 4194 }
4183 } 4195 }
4184 } 4196 }
4197 else if ((re_opcode_t) *p2 == charset)
4198 {
4199 register unsigned char c
4200 = *p2 == (unsigned char) endline ? '\n' : p2[2];
4201
4202 if ((re_opcode_t) p1[3] == exactn
4203 && ! (p2[1] * BYTEWIDTH > p1[4]
4204 && (p2[1 + p1[4] / BYTEWIDTH]
4205 & (1 << (p1[4] % BYTEWIDTH)))))
4206 {
4207 p[-3] = (unsigned char) pop_failure_jump;
4208 DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n",
4209 c, p1[5]);
4210 }
4211
4212 else if ((re_opcode_t) p1[3] == charset_not)
4213 {
4214 int idx;
4215 /* We win if the charset_not inside the loop
4216 lists every character listed in the charset after. */
4217 for (idx = 0; idx < p2[1]; idx++)
4218 if (! (p2[2 + idx] == 0
4219 || (idx < p1[4]
4220 && ((p2[2 + idx] & ~ p1[5 + idx]) == 0))))
4221 break;
4222
4223 if (idx == p2[1])
4224 {
4225 p[-3] = (unsigned char) pop_failure_jump;
4226 DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
4227 }
4228 }
4229 else if ((re_opcode_t) p1[3] == charset)
4230 {
4231 int idx;
4232 /* We win if the charset inside the loop
4233 has no overlap with the one after the loop. */
4234 for (idx = 0; idx < p2[1] && idx < p1[4]; idx++)
4235 if ((p2[2 + idx] & p1[5 + idx]) != 0)
4236 break;
4237
4238 if (idx == p2[1] || idx == p1[4])
4239 {
4240 p[-3] = (unsigned char) pop_failure_jump;
4241 DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
4242 }
4243 }
4244 }
4185 } 4245 }
4186 p -= 2; /* Point at relative address again. */ 4246 p -= 2; /* Point at relative address again. */
4187 if ((re_opcode_t) p[-1] != pop_failure_jump) 4247 if ((re_opcode_t) p[-1] != pop_failure_jump)