diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-29 09:47:36 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-29 09:47:36 +0000 |
commit | 42507173c73d4b1211500b3da008827964e8a78c (patch) | |
tree | 9b77e14e4ee71fe810fe8e79828495f83fd1389d | |
parent | 8e73a6ce75a115b1fd411d5a3a987d599a7dcc4b (diff) |
* regex.c (re_compile_pattern): * \1 .. \9 should be
backreferences always.
* regex.c (re_match): backreferences corresponding to
unclosed/unmatched parentheses should fail always.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | regex.c | 41 |
2 files changed, 17 insertions, 37 deletions
@@ -1,3 +1,11 @@ +Tue May 29 18:46:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * regex.c (re_compile_pattern): * \1 .. \9 should be + backreferences always. + + * regex.c (re_match): backreferences corresponding to + unclosed/unmatched parentheses should fail always. + Mon May 28 23:20:43 2001 WATANABE Hirofumi <eban@ruby-lang.org> * configure.in: remove unnecessary AC_CANONICAL_BUILD @@ -140,11 +148,6 @@ Thu May 17 05:23:52 2001 Keiju Ishitsuka <keiju@ishitsuka.com> * lib/irb.rb lib/irb/multi-irb.rb lib/irb/ruby-lex.rb lib/irb/version.rb resolve ctrl-c problem -Wed May 16 01:48:34 2001 Guy Decoux <decoux@moulon.inra.fr> - - * regex.c (re_compile_pattern): no back reference to a - subexpression if inside of it. - Tue May 15 17:46:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org> * array.c (rb_ary_and): should not push frozen key string. @@ -370,6 +370,7 @@ enum regexpcode duplicate, /* Match a duplicate of something remembered. Followed by one byte containing the index of the memory register. */ + fail, /* always fails. */ wordchar, /* Matches any word-constituent character. */ notwordchar, /* Matches any char that is not a word-constituent. */ wordbeg, /* Succeeds if at word beginning. */ @@ -2246,48 +2247,23 @@ re_compile_pattern(pattern, size, bufp) case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - { - const char *p_save; - PATUNFETCH; - p_save = p; + p0 = p; had_mbchar = 0; c1 = 0; GET_UNSIGNED_NUMBER(c1); if (!ISDIGIT(c)) PATUNFETCH; - if (c1 >= regnum) { - need_to_get_octal: + if (9 < c1 && c1 >= regnum) { /* need to get octal */ - p = p_save; - c = scan_oct(p_save, 3, &numlen) & 0xff; - p = p_save + numlen; + c = scan_oct(p0, 3, &numlen) & 0xff; + p = p0 + numlen; c1 = 0; had_num_literal = 1; goto numeric_char; } - } - /* Can't back reference to a subexpression if inside of it. */ - 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); @@ -3752,11 +3728,12 @@ re_match(bufp, string_arg, size, pos, regs) int regno = *p++; /* Get which register to match against */ register unsigned char *d2, *dend2; - if (IS_ACTIVE(reg_info[regno])) break; + /* Check if corresponding group is still open */ + if (IS_ACTIVE(reg_info[regno])) goto fail; /* Where in input to try to start matching. */ d2 = regstart[regno]; - if (REG_UNSET(d2)) break; + if (REG_UNSET(d2)) goto fail; /* Where to stop matching; if both the place to start and the place to stop matching are in the same string, then @@ -3764,7 +3741,7 @@ re_match(bufp, string_arg, size, pos, regs) the end of the first string. */ dend2 = regend[regno]; - if (REG_UNSET(dend2)) break; + if (REG_UNSET(dend2)) goto fail; for (;;) { /* At end of register contents => success */ if (d2 == dend2) break; |