diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-04-19 05:59:45 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-04-19 05:59:45 +0000 |
commit | e7daa72a6a51539121c28a67ed5e7687f1e52a93 (patch) | |
tree | 575d3c8e170c3a1926e1cd46beeb72bf3f3d1c3d /re.c | |
parent | 8c3157e43fb507dfefe71949d619115644aa0927 (diff) |
* re.c (rb_reg_to_s): remove redundant shy group.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 26 |
1 files changed, 6 insertions, 20 deletions
@@ -368,7 +368,7 @@ rb_reg_to_s(re) ptr = RREGEXP(re)->str; len = RREGEXP(re)->len; if (len >= 4 && ptr[0] == '(' && ptr[1] == '?' && ptr[len-1] == ')') { - int nest = 0; + int err = 1; ptr += 2; if ((len -= 3) > 0) { do { @@ -403,28 +403,14 @@ rb_reg_to_s(re) } while (--len > 0); } if (*ptr == ':') { - const char* p = ++ptr; - long l = --len; + Regexp *rp = ALLOC(Regexp); + MEMZERO((char *)rp, Regexp, 1); kcode_set_option(re); - while (len > 0) { - int n; - if (*p == '(') { - ++nest; - } - else if (*p == ')') { - if (--nest < 0) break; - } - else if (*p == '\\') { - --l; - ++p; - } - n = mbclen(*p); - l -= n; - p += n; - } + err = re_compile_pattern(++ptr, --len, rp) != 0; kcode_reset_option(); + re_free_pattern(rp); } - if (nest) { + if (err) { options = RREGEXP(re)->ptr->options; ptr = RREGEXP(re)->str; len = RREGEXP(re)->len; |