Mercurial > hg > xemacs-beta
comparison src/regex.c @ 185:3d6bfa290dbd r20-3b19
Import from CVS: tag r20-3b19
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:55:28 +0200 |
parents | e121b013d1f0 |
children | 850242ba4a81 |
comparison
equal
deleted
inserted
replaced
184:bcd2674570bf | 185:3d6bfa290dbd |
---|---|
186 static int done = 0; | 186 static int done = 0; |
187 | 187 |
188 if (done) | 188 if (done) |
189 return; | 189 return; |
190 | 190 |
191 bzero (re_syntax_table, sizeof re_syntax_table); | 191 memset (re_syntax_table, 0, sizeof (re_syntax_table)); |
192 | 192 |
193 for (c = 'a'; c <= 'z'; c++) | 193 for (c = 'a'; c <= 'z'; c++) |
194 re_syntax_table[c] = Sword; | 194 re_syntax_table[c] = Sword; |
195 | 195 |
196 for (c = 'A'; c <= 'Z'; c++) | 196 for (c = 'A'; c <= 'Z'; c++) |
246 one. We need to make sure there are no crashes, which would occur | 246 one. We need to make sure there are no crashes, which would occur |
247 otherwise due to out-of-bounds array references. */ | 247 otherwise due to out-of-bounds array references. */ |
248 #define ISASCII(c) (((unsigned EMACS_INT) (c)) < 0x100 && ISASCII_1 (c)) | 248 #define ISASCII(c) (((unsigned EMACS_INT) (c)) < 0x100 && ISASCII_1 (c)) |
249 #else | 249 #else |
250 #define ISASCII(c) ISASCII_1 (c) | 250 #define ISASCII(c) ISASCII_1 (c) |
251 #endif | 251 #endif /* MULE */ |
252 | 252 |
253 #ifdef isblank | 253 #ifdef isblank |
254 #define ISBLANK(c) (ISASCII (c) && isblank (c)) | 254 #define ISBLANK(c) (ISASCII (c) && isblank (c)) |
255 #else | 255 #else |
256 #define ISBLANK(c) ((c) == ' ' || (c) == '\t') | 256 #define ISBLANK(c) ((c) == ' ' || (c) == '\t') |
548 | 548 |
549 /* 97/2/17 jhod: The following two were merged back in from the Mule | 549 /* 97/2/17 jhod: The following two were merged back in from the Mule |
550 2.3 code to enable some language specific processing */ | 550 2.3 code to enable some language specific processing */ |
551 ,categoryspec, /* Matches entries in the character category tables */ | 551 ,categoryspec, /* Matches entries in the character category tables */ |
552 notcategoryspec /* The opposite of the above */ | 552 notcategoryspec /* The opposite of the above */ |
553 #endif | 553 #endif /* MULE */ |
554 | 554 |
555 } re_opcode_t; | 555 } re_opcode_t; |
556 | 556 |
557 /* Common operations on the compiled pattern. */ | 557 /* Common operations on the compiled pattern. */ |
558 | 558 |
1804 static reg_errcode_t compile_extended_range (CONST char **p_ptr, | 1804 static reg_errcode_t compile_extended_range (CONST char **p_ptr, |
1805 CONST char *pend, | 1805 CONST char *pend, |
1806 char *translate, | 1806 char *translate, |
1807 reg_syntax_t syntax, | 1807 reg_syntax_t syntax, |
1808 Lisp_Object rtab); | 1808 Lisp_Object rtab); |
1809 #endif | 1809 #endif /* MULE */ |
1810 static boolean group_match_null_string_p (unsigned char **p, | 1810 static boolean group_match_null_string_p (unsigned char **p, |
1811 unsigned char *end, | 1811 unsigned char *end, |
1812 register_info_type *reg_info); | 1812 register_info_type *reg_info); |
1813 static boolean alt_match_null_string_p (unsigned char *p, unsigned char *end, | 1813 static boolean alt_match_null_string_p (unsigned char *p, unsigned char *end, |
1814 register_info_type *reg_info); | 1814 register_info_type *reg_info); |
2056 else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | 2056 else if (!(syntax & RE_CONTEXT_INDEP_OPS)) |
2057 goto normal_char; | 2057 goto normal_char; |
2058 } | 2058 } |
2059 | 2059 |
2060 { | 2060 { |
2061 /* Are we optimizing this jump? */ | 2061 /* true means zero/many matches are allowed. */ |
2062 boolean keep_string_p = false; | 2062 boolean zero_times_ok = c != '+'; |
2063 | 2063 boolean many_times_ok = c != '?'; |
2064 /* 1 means zero (many) matches is allowed. */ | 2064 |
2065 char zero_times_ok = 0, many_times_ok = 0; | 2065 /* true means match shortest string possible. */ |
2066 boolean minimal = false; | |
2066 | 2067 |
2067 /* If there is a sequence of repetition chars, collapse it | 2068 /* If there is a sequence of repetition chars, collapse it |
2068 down to just one (the right one). We can't combine | 2069 down to just one (the right one). We can't combine |
2069 interval operators with these because of, e.g., `a{2}*', | 2070 interval operators with these because of, e.g., `a{2}*', |
2070 which should only match an even number of `a's. */ | 2071 which should only match an even number of `a's. */ |
2071 | 2072 while (p != pend) |
2072 for (;;) | |
2073 { | 2073 { |
2074 zero_times_ok |= c != '+'; | |
2075 many_times_ok |= c != '?'; | |
2076 | |
2077 if (p == pend) | |
2078 break; | |
2079 | |
2080 PATFETCH (c); | 2074 PATFETCH (c); |
2081 | 2075 |
2082 if (c == '*' | 2076 if (c == '*' || (!(syntax & RE_BK_PLUS_QM) |
2083 || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?'))) | 2077 && (c == '+' || c == '?'))) |
2084 ; | 2078 ; |
2085 | 2079 |
2086 else if (syntax & RE_BK_PLUS_QM && c == '\\') | 2080 else if (syntax & RE_BK_PLUS_QM && c == '\\') |
2087 { | 2081 { |
2088 if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | 2082 if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); |
2089 | 2083 |
2090 PATFETCH (c1); | 2084 PATFETCH (c1); |
2091 if (!(c1 == '+' || c1 == '?')) | 2085 if (!(c1 == '+' || c1 == '?')) |
2102 PATUNFETCH; | 2096 PATUNFETCH; |
2103 break; | 2097 break; |
2104 } | 2098 } |
2105 | 2099 |
2106 /* If we get here, we found another repeat character. */ | 2100 /* If we get here, we found another repeat character. */ |
2107 } | 2101 if (!(syntax & RE_NO_MINIMAL_MATCHING)) |
2102 { | |
2103 /* `*?' and `+?' and `??' are okay (and mean match | |
2104 minimally), but other sequences (such as `*??' and | |
2105 `+++') are rejected (reserved for future use). */ | |
2106 if (minimal || c != '?') | |
2107 FREE_STACK_RETURN (REG_BADRPT); | |
2108 minimal = true; | |
2109 } | |
2110 else | |
2111 { | |
2112 zero_times_ok |= c != '+'; | |
2113 many_times_ok |= c != '?'; | |
2114 } | |
2115 } | |
2108 | 2116 |
2109 /* Star, etc. applied to an empty pattern is equivalent | 2117 /* Star, etc. applied to an empty pattern is equivalent |
2110 to an empty pattern. */ | 2118 to an empty pattern. */ |
2111 if (!laststart) | 2119 if (!laststart) |
2112 break; | 2120 break; |
2113 | 2121 |
2114 /* Now we know whether or not zero matches is allowed | 2122 /* Now we know whether zero matches is allowed |
2115 and also whether or not two or more matches is allowed. */ | 2123 and whether two or more matches is allowed |
2116 if (many_times_ok) | 2124 and whether we want minimal or maximal matching. */ |
2117 { /* More than one repetition is allowed, so put in at the | 2125 if (minimal) |
2118 end a backward relative jump from `b' to before the next | 2126 { |
2119 jump we're going to put in below (which jumps from | 2127 if (!many_times_ok) |
2120 laststart to after this jump). | 2128 { |
2121 | 2129 /* "a??" becomes: |
2122 But if we are at the `*' in the exact sequence `.*\n', | 2130 0: /on_failure_jump to 6 |
2123 insert an unconditional jump backwards to the ., | 2131 3: /jump to 9 |
2124 instead of the beginning of the loop. This way we only | 2132 6: /exactn/1/A |
2125 push a failure point once, instead of every time | 2133 9: end of pattern. |
2126 through the loop. */ | 2134 */ |
2127 assert (p - 1 > pattern); | 2135 GET_BUFFER_SPACE (6); |
2128 | 2136 INSERT_JUMP (jump, laststart, b + 3); |
2129 /* Allocate the space for the jump. */ | 2137 b += 3; |
2130 GET_BUFFER_SPACE (3); | 2138 INSERT_JUMP (on_failure_jump, laststart, laststart + 6); |
2131 | 2139 b += 3; |
2132 /* We know we are not at the first character of the pattern, | 2140 } |
2133 because laststart was nonzero. And we've already | 2141 else if (zero_times_ok) |
2134 incremented `p', by the way, to be the character after | 2142 { |
2135 the `*'. Do we have to do something analogous here | 2143 /* "a*?" becomes: |
2136 for null bytes, because of RE_DOT_NOT_NULL? */ | 2144 0: /jump to 6 |
2137 if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') | 2145 3: /exactn/1/A |
2138 && zero_times_ok | 2146 6: /on_failure_jump to 3 |
2139 && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') | 2147 9: end of pattern. |
2140 && !(syntax & RE_DOT_NEWLINE)) | 2148 */ |
2141 { /* We have .*\n. */ | 2149 GET_BUFFER_SPACE (6); |
2142 STORE_JUMP (jump, b, laststart); | 2150 INSERT_JUMP (jump, laststart, b + 3); |
2143 keep_string_p = true; | 2151 b += 3; |
2152 STORE_JUMP (on_failure_jump, b, laststart + 3); | |
2153 b += 3; | |
2144 } | 2154 } |
2145 else | 2155 else |
2146 /* Anything else. */ | 2156 { |
2147 STORE_JUMP (maybe_pop_jump, b, laststart - 3); | 2157 /* "a+?" becomes: |
2148 | 2158 0: /exactn/1/A |
2149 /* We've added more stuff to the buffer. */ | 2159 3: /on_failure_jump to 0 |
2160 6: end of pattern. | |
2161 */ | |
2162 GET_BUFFER_SPACE (3); | |
2163 STORE_JUMP (on_failure_jump, b, laststart); | |
2164 b += 3; | |
2165 } | |
2166 } | |
2167 else | |
2168 { | |
2169 /* Are we optimizing this jump? */ | |
2170 boolean keep_string_p = false; | |
2171 | |
2172 if (many_times_ok) | |
2173 { /* More than one repetition is allowed, so put in at the | |
2174 end a backward relative jump from `b' to before the next | |
2175 jump we're going to put in below (which jumps from | |
2176 laststart to after this jump). | |
2177 | |
2178 But if we are at the `*' in the exact sequence `.*\n', | |
2179 insert an unconditional jump backwards to the ., | |
2180 instead of the beginning of the loop. This way we only | |
2181 push a failure point once, instead of every time | |
2182 through the loop. */ | |
2183 assert (p - 1 > pattern); | |
2184 | |
2185 /* Allocate the space for the jump. */ | |
2186 GET_BUFFER_SPACE (3); | |
2187 | |
2188 /* We know we are not at the first character of the | |
2189 pattern, because laststart was nonzero. And we've | |
2190 already incremented `p', by the way, to be the | |
2191 character after the `*'. Do we have to do something | |
2192 analogous here for null bytes, because of | |
2193 RE_DOT_NOT_NULL? */ | |
2194 if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') | |
2195 && zero_times_ok | |
2196 && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') | |
2197 && !(syntax & RE_DOT_NEWLINE)) | |
2198 { /* We have .*\n. */ | |
2199 STORE_JUMP (jump, b, laststart); | |
2200 keep_string_p = true; | |
2201 } | |
2202 else | |
2203 /* Anything else. */ | |
2204 STORE_JUMP (maybe_pop_jump, b, laststart - 3); | |
2205 | |
2206 /* We've added more stuff to the buffer. */ | |
2207 b += 3; | |
2208 } | |
2209 | |
2210 /* On failure, jump from laststart to b + 3, which will be the | |
2211 end of the buffer after this jump is inserted. */ | |
2212 GET_BUFFER_SPACE (3); | |
2213 INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | |
2214 : on_failure_jump, | |
2215 laststart, b + 3); | |
2150 b += 3; | 2216 b += 3; |
2217 | |
2218 if (!zero_times_ok) | |
2219 { | |
2220 /* At least one repetition is required, so insert a | |
2221 `dummy_failure_jump' before the initial | |
2222 `on_failure_jump' instruction of the loop. This | |
2223 effects a skip over that instruction the first time | |
2224 we hit that loop. */ | |
2225 GET_BUFFER_SPACE (3); | |
2226 INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | |
2227 b += 3; | |
2228 } | |
2151 } | 2229 } |
2152 | |
2153 /* On failure, jump from laststart to b + 3, which will be the | |
2154 end of the buffer after this jump is inserted. */ | |
2155 GET_BUFFER_SPACE (3); | |
2156 INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | |
2157 : on_failure_jump, | |
2158 laststart, b + 3); | |
2159 pending_exact = 0; | 2230 pending_exact = 0; |
2160 b += 3; | 2231 } |
2161 | |
2162 if (!zero_times_ok) | |
2163 { | |
2164 /* At least one repetition is required, so insert a | |
2165 `dummy_failure_jump' before the initial | |
2166 `on_failure_jump' instruction of the loop. This | |
2167 effects a skip over that instruction the first time | |
2168 we hit that loop. */ | |
2169 GET_BUFFER_SPACE (3); | |
2170 INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | |
2171 b += 3; | |
2172 } | |
2173 } | |
2174 break; | 2232 break; |
2175 | 2233 |
2176 | 2234 |
2177 case '.': | 2235 case '.': |
2178 laststart = b; | 2236 laststart = b; |
2500 case '(': | 2558 case '(': |
2501 if (syntax & RE_NO_BK_PARENS) | 2559 if (syntax & RE_NO_BK_PARENS) |
2502 goto normal_backslash; | 2560 goto normal_backslash; |
2503 | 2561 |
2504 handle_open: | 2562 handle_open: |
2505 bufp->re_nsub++; | 2563 { |
2506 regnum++; | 2564 regnum_t r; |
2507 | 2565 |
2508 if (COMPILE_STACK_FULL) | 2566 if (!(syntax & RE_NO_SHY_GROUPS) |
2509 { | 2567 && p != pend |
2510 RETALLOC (compile_stack.stack, compile_stack.size << 1, | 2568 && TRANSLATE(*p) == TRANSLATE('?')) |
2511 compile_stack_elt_t); | 2569 { |
2512 if (compile_stack.stack == NULL) return REG_ESPACE; | 2570 p++; |
2513 | 2571 PATFETCH(c); |
2514 compile_stack.size <<= 1; | 2572 switch (c) |
2515 } | 2573 { |
2516 | 2574 case ':': /* shy groups */ |
2517 /* These are the values to restore when we hit end of this | 2575 r = MAX_REGNUM + 1; |
2518 group. They are all relative offsets, so that if the | 2576 break; |
2519 whole pattern moves because of realloc, they will still | 2577 |
2520 be valid. */ | 2578 /* All others are reserved for future constructs. */ |
2521 COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | 2579 default: |
2522 COMPILE_STACK_TOP.fixup_alt_jump | 2580 FREE_STACK_RETURN (REG_BADPAT); |
2523 = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | 2581 } |
2524 COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer; | 2582 } |
2525 COMPILE_STACK_TOP.regnum = regnum; | 2583 else |
2526 | 2584 { |
2527 /* We will eventually replace the 0 with the number of | 2585 bufp->re_nsub++; |
2528 groups inner to this one. But do not push a | 2586 r = ++regnum; |
2529 start_memory for groups beyond the last one we can | 2587 } |
2530 represent in the compiled pattern. */ | 2588 |
2531 if (regnum <= MAX_REGNUM) | 2589 if (COMPILE_STACK_FULL) |
2532 { | 2590 { |
2533 COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2; | 2591 RETALLOC (compile_stack.stack, compile_stack.size << 1, |
2534 BUF_PUSH_3 (start_memory, regnum, 0); | 2592 compile_stack_elt_t); |
2535 } | 2593 if (compile_stack.stack == NULL) return REG_ESPACE; |
2536 | 2594 |
2537 compile_stack.avail++; | 2595 compile_stack.size <<= 1; |
2538 | 2596 } |
2539 fixup_alt_jump = 0; | 2597 |
2540 laststart = 0; | 2598 /* These are the values to restore when we hit end of this |
2541 begalt = b; | 2599 group. They are all relative offsets, so that if the |
2542 /* If we've reached MAX_REGNUM groups, then this open | 2600 whole pattern moves because of realloc, they will still |
2543 won't actually generate any code, so we'll have to | 2601 be valid. */ |
2544 clear pending_exact explicitly. */ | 2602 COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; |
2545 pending_exact = 0; | 2603 COMPILE_STACK_TOP.fixup_alt_jump |
2604 = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | |
2605 COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer; | |
2606 COMPILE_STACK_TOP.regnum = r; | |
2607 | |
2608 /* We will eventually replace the 0 with the number of | |
2609 groups inner to this one. But do not push a | |
2610 start_memory for groups beyond the last one we can | |
2611 represent in the compiled pattern. */ | |
2612 if (r <= MAX_REGNUM) | |
2613 { | |
2614 COMPILE_STACK_TOP.inner_group_offset | |
2615 = b - bufp->buffer + 2; | |
2616 BUF_PUSH_3 (start_memory, r, 0); | |
2617 } | |
2618 | |
2619 compile_stack.avail++; | |
2620 | |
2621 fixup_alt_jump = 0; | |
2622 laststart = 0; | |
2623 begalt = b; | |
2624 /* If we've reached MAX_REGNUM groups, then this open | |
2625 won't actually generate any code, so we'll have to | |
2626 clear pending_exact explicitly. */ | |
2627 pending_exact = 0; | |
2628 } | |
2546 break; | 2629 break; |
2547 | 2630 |
2548 | 2631 |
2549 case ')': | 2632 case ')': |
2550 if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | 2633 if (syntax & RE_NO_BK_PARENS) goto normal_backslash; |
3406 for (j = *p * BYTEWIDTH; j < 0x80; j++) | 3489 for (j = *p * BYTEWIDTH; j < 0x80; j++) |
3407 fastmap[j] = 1; | 3490 fastmap[j] = 1; |
3408 /* And all extended characters must be allowed, too. */ | 3491 /* And all extended characters must be allowed, too. */ |
3409 for (j = 0x80; j < 0xA0; j++) | 3492 for (j = 0x80; j < 0xA0; j++) |
3410 fastmap[j] = 1; | 3493 fastmap[j] = 1; |
3411 #else | 3494 #else /* ! MULE */ |
3412 for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | 3495 for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) |
3413 fastmap[j] = 1; | 3496 fastmap[j] = 1; |
3414 #endif | 3497 #endif /* ! MULE */ |
3415 | 3498 |
3416 for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | 3499 for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) |
3417 if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | 3500 if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) |
3418 fastmap[j] = 1; | 3501 fastmap[j] = 1; |
3419 break; | 3502 break; |
4297 #ifdef DEBUG | 4380 #ifdef DEBUG |
4298 /* Counts the total number of registers pushed. */ | 4381 /* Counts the total number of registers pushed. */ |
4299 unsigned num_regs_pushed = 0; | 4382 unsigned num_regs_pushed = 0; |
4300 #endif | 4383 #endif |
4301 | 4384 |
4385 /* 1 if this match ends in the same string (string1 or string2) | |
4386 as the best previous match. */ | |
4387 boolean same_str_p; | |
4388 | |
4389 /* 1 if this match is the best seen so far. */ | |
4390 boolean best_match_p; | |
4391 | |
4302 DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); | 4392 DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); |
4303 | 4393 |
4304 INIT_FAIL_STACK (); | 4394 INIT_FAIL_STACK (); |
4305 | 4395 |
4306 #ifdef MATCH_MAY_ALLOCATE | 4396 #ifdef MATCH_MAY_ALLOCATE |
4309 there are groups, we include space for register 0 (the whole | 4399 there are groups, we include space for register 0 (the whole |
4310 pattern), even though we never use it, since it simplifies the | 4400 pattern), even though we never use it, since it simplifies the |
4311 array indexing. We should fix this. */ | 4401 array indexing. We should fix this. */ |
4312 if (bufp->re_nsub) | 4402 if (bufp->re_nsub) |
4313 { | 4403 { |
4314 regstart = REGEX_TALLOC (num_regs, CONST char *); | 4404 regstart = REGEX_TALLOC (num_regs, CONST char *); |
4315 regend = REGEX_TALLOC (num_regs, CONST char *); | 4405 regend = REGEX_TALLOC (num_regs, CONST char *); |
4316 old_regstart = REGEX_TALLOC (num_regs, CONST char *); | 4406 old_regstart = REGEX_TALLOC (num_regs, CONST char *); |
4317 old_regend = REGEX_TALLOC (num_regs, CONST char *); | 4407 old_regend = REGEX_TALLOC (num_regs, CONST char *); |
4318 best_regstart = REGEX_TALLOC (num_regs, CONST char *); | 4408 best_regstart = REGEX_TALLOC (num_regs, CONST char *); |
4319 best_regend = REGEX_TALLOC (num_regs, CONST char *); | 4409 best_regend = REGEX_TALLOC (num_regs, CONST char *); |
4320 reg_info = REGEX_TALLOC (num_regs, register_info_type); | 4410 reg_info = REGEX_TALLOC (num_regs, register_info_type); |
4321 reg_dummy = REGEX_TALLOC (num_regs, CONST char *); | 4411 reg_dummy = REGEX_TALLOC (num_regs, CONST char *); |
4322 reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | 4412 reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); |
4323 | 4413 |
4324 if (!(regstart && regend && old_regstart && old_regend && reg_info | 4414 if (!(regstart && regend && old_regstart && old_regend && reg_info |
4325 && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | 4415 && best_regstart && best_regend && reg_dummy && reg_info_dummy)) |
4326 { | 4416 { |
4419 | 4509 |
4420 /* If we haven't matched the entire string, and we want the | 4510 /* If we haven't matched the entire string, and we want the |
4421 longest match, try backtracking. */ | 4511 longest match, try backtracking. */ |
4422 if (d != end_match_2) | 4512 if (d != end_match_2) |
4423 { | 4513 { |
4424 /* 1 if this match ends in the same string (string1 or string2) | 4514 same_str_p = (FIRST_STRING_P (match_end) |
4425 as the best previous match. */ | 4515 == MATCHING_IN_FIRST_STRING); |
4426 boolean same_str_p = (FIRST_STRING_P (match_end) | |
4427 == MATCHING_IN_FIRST_STRING); | |
4428 /* 1 if this match is the best seen so far. */ | |
4429 boolean best_match_p; | |
4430 | 4516 |
4431 /* AIX compiler got confused when this was combined | 4517 /* AIX compiler got confused when this was combined |
4432 with the previous declaration. */ | 4518 with the previous declaration. */ |
4433 if (same_str_p) | 4519 if (same_str_p) |
4434 best_match_p = d > match_end; | 4520 best_match_p = d > match_end; |
4685 | 4771 |
4686 SET_REGS_MATCHED (); | 4772 SET_REGS_MATCHED (); |
4687 INC_CHARPTR (d); | 4773 INC_CHARPTR (d); |
4688 break; | 4774 break; |
4689 } | 4775 } |
4690 #endif | 4776 #endif /* MULE */ |
4691 | 4777 |
4692 | 4778 |
4693 /* The beginning of a group is represented by start_memory. | 4779 /* The beginning of a group is represented by start_memory. |
4694 The arguments are the register number in the next byte, and the | 4780 The arguments are the register number in the next byte, and the |
4695 number of groups inner to this one in the next. The text | 4781 number of groups inner to this one in the next. The text |
5014 DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | 5100 DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); |
5015 | 5101 |
5016 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 5102 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
5017 DEBUG_PRINT3 (" %d (to 0x%p):\n", mcnt, p + mcnt); | 5103 DEBUG_PRINT3 (" %d (to 0x%p):\n", mcnt, p + mcnt); |
5018 | 5104 |
5019 PUSH_FAILURE_POINT (p + mcnt, (void *) 0, -2); | 5105 PUSH_FAILURE_POINT (p + mcnt, (char *) 0, -2); |
5020 break; | 5106 break; |
5021 | 5107 |
5022 | 5108 |
5023 /* Uses of on_failure_jump: | 5109 /* Uses of on_failure_jump: |
5024 | 5110 |
5270 something meaningless for pop_failure_jump to pop. */ | 5356 something meaningless for pop_failure_jump to pop. */ |
5271 case dummy_failure_jump: | 5357 case dummy_failure_jump: |
5272 DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n"); | 5358 DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n"); |
5273 /* It doesn't matter what we push for the string here. What | 5359 /* It doesn't matter what we push for the string here. What |
5274 the code at `fail' tests is the value for the pattern. */ | 5360 the code at `fail' tests is the value for the pattern. */ |
5275 PUSH_FAILURE_POINT ((void *) 0, (void *) 0, -2); | 5361 PUSH_FAILURE_POINT ((unsigned char *) 0, (char *) 0, -2); |
5276 goto unconditional_jump; | 5362 goto unconditional_jump; |
5277 | 5363 |
5278 | 5364 |
5279 /* At the end of an alternative, we need to push a dummy failure | 5365 /* At the end of an alternative, we need to push a dummy failure |
5280 point in case we are followed by a `pop_failure_jump', because | 5366 point in case we are followed by a `pop_failure_jump', because |
5283 requires that we match the `ab' alternative. */ | 5369 requires that we match the `ab' alternative. */ |
5284 case push_dummy_failure: | 5370 case push_dummy_failure: |
5285 DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); | 5371 DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); |
5286 /* See comments just above at `dummy_failure_jump' about the | 5372 /* See comments just above at `dummy_failure_jump' about the |
5287 two zeroes. */ | 5373 two zeroes. */ |
5288 PUSH_FAILURE_POINT ((void *) 0, (void *) 0, -2); | 5374 PUSH_FAILURE_POINT ((unsigned char *) 0, (char *) 0, -2); |
5289 break; | 5375 break; |
5290 | 5376 |
5291 /* Have to succeed matching what follows at least n times. | 5377 /* Have to succeed matching what follows at least n times. |
5292 After that, handle like `on_failure_jump'. */ | 5378 After that, handle like `on_failure_jump'. */ |
5293 case succeed_n: | 5379 case succeed_n: |