mark regex internal to string scanner
This commit is contained in:
parent
873c8a14f0
commit
6aa466ba9c
Notes:
git
2020-10-03 04:02:26 +09:00
@ -176,6 +176,7 @@ strscan_mark(void *ptr)
|
|||||||
{
|
{
|
||||||
struct strscanner *p = ptr;
|
struct strscanner *p = ptr;
|
||||||
rb_gc_mark(p->str);
|
rb_gc_mark(p->str);
|
||||||
|
rb_gc_mark(p->regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -212,6 +213,7 @@ strscan_s_allocate(VALUE klass)
|
|||||||
CLEAR_MATCH_STATUS(p);
|
CLEAR_MATCH_STATUS(p);
|
||||||
onig_region_init(&(p->regs));
|
onig_region_init(&(p->regs));
|
||||||
p->str = Qnil;
|
p->str = Qnil;
|
||||||
|
p->regex = Qnil;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1168,7 +1170,7 @@ strscan_aref(VALUE self, VALUE idx)
|
|||||||
idx = rb_sym2str(idx);
|
idx = rb_sym2str(idx);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case T_STRING:
|
case T_STRING:
|
||||||
if (!p->regex) return Qnil;
|
if (!RTEST(p->regex)) return Qnil;
|
||||||
RSTRING_GETMEM(idx, name, i);
|
RSTRING_GETMEM(idx, name, i);
|
||||||
i = name_to_backref_number(&(p->regs), p->regex, name, name + i, rb_enc_get(idx));
|
i = name_to_backref_number(&(p->regs), p->regex, name, name + i, rb_enc_get(idx));
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user