summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2023-12-23 14:51:43 -0500
committerPeter Zhu <[email protected]>2023-12-23 16:52:05 -0500
commitfadda88903d9fe764ae53eca07aaf85f08e162a7 ()
treeaa7dc15578a064e7db9b1c5b2003ccced639157e /re.c
parent688a1314e60b0e58d5325f50c02552e3018c5025 (diff)
Fix Regexp#to_s for GC compaction
The test fails when RGENGC_CHECK_MODE is turned on: TestRegexp#test_to_s_under_gc_compact_stress = 13.46 s 1) Failure: TestRegexp#test_to_s_under_gc_compact_stress [test/ruby/test_regexp.rb:81]: <"(?-mix:abcd\u3042)"> expected but was <"(?-mix:\u5C78\u3030\u5C78\u3030\u5C78\u3030\u5C78\u3030\u5C78\u3030)">.
-rw-r--r--re.c9
1 files changed, 5 insertions, 4 deletions
@@ -565,8 +565,6 @@ rb_reg_str_with_term(VALUE re, int term)
{
int options, opt;
const int embeddable = ONIG_OPTION_MULTILINE|ONIG_OPTION_IGNORECASE|ONIG_OPTION_EXTEND;
- long len;
- const UChar* ptr;
VALUE str = rb_str_buf_new2("(?");
char optbuf[OPTBUF_SIZE + 1]; /* for '-' */
rb_encoding *enc = rb_enc_get(re);
@@ -575,8 +573,9 @@ rb_reg_str_with_term(VALUE re, int term)
rb_enc_copy(str, re);
options = RREGEXP_PTR(re)->options;
- ptr = (UChar*)RREGEXP_SRC_PTR(re);
- len = RREGEXP_SRC_LEN(re);
again:
if (len >= 4 && ptr[0] == '(' && ptr[1] == '?') {
int err = 1;
@@ -666,6 +665,8 @@ rb_reg_str_with_term(VALUE re, int term)
}
rb_enc_copy(str, re);
return str;
}