summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-04 09:01:10 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-04 09:01:10 +0000
commit50c0edaa491c237290493f16bfe91d1df1a617be (patch)
treeae0c0f4d28297e313b53aea628dad23225212699 /regex.c
parent2f6cc44f0648435b3256d49d424daa157cccb7ea (diff)
* regex.c (re_compile_pattern): should push option modifier at the
right place. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/regex.c b/regex.c
index dd635b97ba..a3d8e2c243 100644
--- a/regex.c
+++ b/regex.c
@@ -3355,7 +3355,7 @@ re_search(bufp, string, size, startpos, range, regs)
#define NUM_COUNT_ITEMS 2
/* Individual items aside from the registers. */
-#define NUM_NONREG_ITEMS 3
+#define NUM_NONREG_ITEMS 4
/* We push at most this many things on the stack whenever we
fail. The `+ 2' refers to PATTERN_PLACE and STRING_PLACE, which are
@@ -3405,6 +3405,7 @@ re_search(bufp, string, size, startpos, range, regs)
\
*stackp++ = pattern_place; \
*stackp++ = string_place; \
+ *stackp++ = (unsigned char*)options; /* current option status */ \
*stackp++ = (unsigned char*)0; /* non-greedy flag */ \
} while(0)
@@ -3780,7 +3781,7 @@ re_match(bufp, string_arg, size, pos, regs)
case stop_nowidth:
EXTRACT_NUMBER_AND_INCR(mcnt, p);
stackp = stackb + mcnt;
- d = stackp[-2];
+ d = stackp[-3];
POP_FAILURE_POINT();
continue;
@@ -4004,8 +4005,8 @@ re_match(bufp, string_arg, size, pos, regs)
because didn't fail. Also remove the register information
put on by the on_failure_jump. */
case finalize_jump:
- if (stackp > stackb && stackp[-2] == d) {
- p = stackp[-3];
+ if (stackp > stackb && stackp[-3] == d) {
+ p = stackp[-4];
POP_FAILURE_POINT();
continue;
}
@@ -4021,7 +4022,7 @@ re_match(bufp, string_arg, size, pos, regs)
case jump:
nofinalize:
EXTRACT_NUMBER_AND_INCR(mcnt, p);
- if (mcnt < 0 && stackp > stackb && stackp[-2] == d) /* avoid infinite loop */
+ if (mcnt < 0 && stackp > stackb && stackp[-3] == d) /* avoid infinite loop */
goto fail;
p += mcnt;
continue;
@@ -4112,7 +4113,7 @@ re_match(bufp, string_arg, size, pos, regs)
case finalize_push:
POP_FAILURE_POINT();
EXTRACT_NUMBER_AND_INCR(mcnt, p);
- if (mcnt < 0 && stackp > stackb && stackp[-2] == d) /* avoid infinite loop */
+ if (mcnt < 0 && stackp > stackb && stackp[-3] == d) /* avoid infinite loop */
goto fail;
PUSH_FAILURE_POINT(p + mcnt, d);
stackp[-1] = NON_GREEDY;
@@ -4277,11 +4278,12 @@ re_match(bufp, string_arg, size, pos, regs)
/* If this failure point is from a dummy_failure_point, just
skip it. */
- if (stackp[-3] == 0 || (best_regs_set && stackp[-1] == NON_GREEDY)) {
+ if (stackp[-4] == 0 || (best_regs_set && stackp[-1] == NON_GREEDY)) {
POP_FAILURE_POINT();
goto fail;
}
- stackp--; /* discard flag */
+ stackp--; /* discard greedy flag */
+ options = (int)*--stackp;
d = *--stackp;
p = *--stackp;
/* Restore register info. */