From e7daa72a6a51539121c28a67ed5e7687f1e52a93 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 19 Apr 2002 05:59:45 +0000 Subject: [PATCH] * 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 --- ChangeLog | 4 ++++ re.c | 26 ++++++-------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e9ba373ed..f3e565f3a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Apr 19 14:57:44 2002 Nobuyoshi Nakada + + * re.c (rb_reg_to_s): remove redundant shy group. + Fri Apr 19 01:08:20 2002 Yukihiro Matsumoto * eval.c (rb_thread_cleanup): current thread may be THREAD_STOPPED, diff --git a/re.c b/re.c index a1f69c489e..fa048cb210 100644 --- a/re.c +++ b/re.c @@ -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;