Re: [Update] Port match to new dup, clone framework

From: matz@... (Yukihiro Matsumoto)
Date: 2002-08-28 16:22:18 UTC
List: ruby-core #389
Hi,

In message "Re: [Update] Port match to new dup, clone framework"
    on 02/08/29, Michal Rokos <m.rokos@sh.cvut.cz> writes:

|> > -    re_copy_registers(clone->regs, RMATCH(match)->regs);
|>   +    if (obj == orig) return obj;
|> > +    RMATCH(obj)->str = RMATCH(orig)->str;
|>   +    re_free_registers(RMATCH(obj)->regs);
|> > +    RMATCH(obj)->regs->allocated = 0;
|> > +    re_copy_registers(RMATCH(obj)->regs, RMATCH(orig)->regs);
|
|	Is it OK to commit patch with these changes?

OK if you add class check to become method (orig may not be MatchData),
like this:

    if (!rb_obj_is_instance_of(orig, rb_obj_class(obj))) {
	rb_raise(rb_eTypeError, "wrong argument class");
    }

							matz.

In This Thread