summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-29 08:59:39 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-29 08:59:39 +0000
commit8e73a6ce75a115b1fd411d5a3a987d599a7dcc4b (patch)
treee5e320e2ce9e6fbc0cc00927dffa60894f87b709 /regex.c
parentf2a1269383c19a2d6d9fd475681b34e5e81e65e3 (diff)
* regex.c (re_compile_pattern): no back reference to a
subexpression if inside of it. * eval.c (rb_yield_0): preserve and restore ruby_cref as well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/regex.c b/regex.c
index d8cbfc0990..8d665471a8 100644
--- a/regex.c
+++ b/regex.c
@@ -2258,6 +2258,7 @@ re_compile_pattern(pattern, size, bufp)
if (!ISDIGIT(c)) PATUNFETCH;
if (c1 >= regnum) {
+ need_to_get_octal:
/* need to get octal */
p = p_save;
c = scan_oct(p_save, 3, &numlen) & 0xff;
@@ -2269,9 +2270,24 @@ re_compile_pattern(pattern, size, bufp)
}
/* Can't back reference to a subexpression if inside of it. */
- for (stackt = stackp - 2; stackt > stackb; stackt -= 5)
- if (*stackt == c1)
- goto normal_char;
+ for (stackt = stackp - 2; stackt > stackb; ) {
+ switch (*stackt) {
+ case '(':
+ if (stackt[-2] == c1)
+ goto need_to_get_octal;
+ stackt -= 5;
+ break;
+ case '!':
+ stackt--;
+ case '=':
+ case '>':
+ stackt -= 4;
+ break;
+ default:
+ stackt -= 3;
+ break;
+ }
+ }
laststart = b;
BUFPUSH(duplicate);
BUFPUSH(c1);