[#290] — Florian Frank <flori@...>
Hi all,
5 messages
2002/08/03
[#297] GC longjmp macros — Michal Rokos <m.rokos@...>
Hi,
5 messages
2002/08/05
[#308] Q: OSSL in std. distr? — Michal Rokos <m.rokos@...>
Hi,
4 messages
2002/08/08
[#326] Implications of a #force_free method in Object? — Matthew Bloch <mattbee@...>
Hello;
8 messages
2002/08/19
[#328] Int vs Long — Michal Rokos <m.rokos@...>
Hi,
7 messages
2002/08/21
[#337] Int vs Long (2nd part) — Michal Rokos <m.rokos@...>
Hi,
7 messages
2002/08/22
[#340] Int vs Long #3 — Michal Rokos <m.rokos@...>
Hi,
9 messages
2002/08/22
[#344] Re: [Cleanup] Int vs Long #3
— nobu.nokada@...
2002/08/22
Hi,
[#348] Re: [Cleanup] Int vs Long #3
— Michal Rokos <m.rokos@...>
2002/08/23
Hello,
[#353] File (struct stat handling) — Michal Rokos <m.rokos@...>
Hello,
6 messages
2002/08/23
[#358] node.h for eval.c — Michal Rokos <m.rokos@...>
Hi,
5 messages
2002/08/23
[#372] rb_class_path — Michal Rokos <m.rokos@...>
Hello,
7 messages
2002/08/27
[#382] Port match to new dup, clone framework — Michal Rokos <m.rokos@...>
Hi,
5 messages
2002/08/28
[#393] in dln.c — Michal Rokos <m.rokos@...>
Hi,
14 messages
2002/08/30
[#398] Re: [MemLeak] in dln.c
— nobu.nokada@...
2002/08/31
Hi,
[#403] Re: [MemLeak] in dln.c
— Michal Rokos <m.rokos@...>
2002/09/02
Hello,
[Update] Port match to new dup, clone framework
From:
Michal Rokos <m.rokos@...>
Date:
2002-08-28 14:42:53 UTC
List:
ruby-core #382
Hi,
I spotted that match (in re.c) is not updated to new clone, dup
framework.
This should fix it. :-) (I said should, but I know that nobu
will find at least 1 bug in it... :-))
Michal
Index: re.c
===================================================================
RCS file: /src/ruby/re.c,v
retrieving revision 1.77
diff -u -p -r1.77 re.c
--- re.c 2002/08/28 08:05:23 1.77
+++ re.c 2002/08/28 13:51:27
@@ -514,10 +514,11 @@ make_regexp(s, len, flags)
static VALUE rb_cMatch;
static VALUE
-match_alloc()
+match_alloc(klass)
+ VALUE klass;
{
NEWOBJ(match, struct RMatch);
- OBJSETUP(match, rb_cMatch, T_MATCH);
+ OBJSETUP(match, klass, T_MATCH);
match->str = 0;
match->regs = 0;
@@ -528,40 +529,17 @@ match_alloc()
}
static VALUE
-match_clone(match)
- VALUE match;
+match_become(obj, orig)
+ VALUE obj, orig;
{
- NEWOBJ(clone, struct RMatch);
- CLONESETUP(clone, match);
-
- clone->str = RMATCH(match)->str;
- clone->regs = 0;
-
- clone->regs = ALLOC(struct re_registers);
- clone->regs->allocated = 0;
- re_copy_registers(clone->regs, RMATCH(match)->regs);
+ RMATCH(obj)->str = RMATCH(orig)->str;
+ RMATCH(obj)->regs->allocated = 0;
+ re_copy_registers(RMATCH(obj)->regs, RMATCH(orig)->regs);
- return (VALUE)clone;
+ return obj;
}
static VALUE
-match_dup(match)
- VALUE match;
-{
- NEWOBJ(dup, struct RMatch);
- DUPSETUP(dup, match);
-
- dup->str = RMATCH(match)->str;
- dup->regs = 0;
-
- dup->regs = ALLOC(struct re_registers);
- dup->regs->allocated = 0;
- re_copy_registers(dup->regs, RMATCH(match)->regs);
-
- return (VALUE)dup;
-}
-
-static VALUE
match_size(match)
VALUE match;
{
@@ -741,7 +719,7 @@ rb_reg_search(re, str, pos, reverse)
match = rb_backref_get();
if (NIL_P(match) || FL_TEST(match, MATCH_BUSY)) {
- match = match_alloc();
+ match = match_alloc(rb_obj_class(re));
}
else {
if (rb_safe_level() >= 3)
@@ -1601,13 +1579,10 @@ Init_Regexp()
rb_cMatch = rb_define_class("MatchData", rb_cObject);
rb_define_global_const("MatchingData", rb_cMatch);
- rb_undef_method(CLASS_OF(rb_cMatch), "allocate");
+ rb_define_singleton_method(rb_cMatch, "allocate", match_alloc, 0);
rb_undef_method(CLASS_OF(rb_cMatch), "new");
-
- /* to be replaced by allocation framework */
- rb_define_method(rb_cMatch, "clone", match_clone, 0);
- rb_define_method(rb_cMatch, "dup", match_dup, 0);
+ rb_define_method(rb_cMatch, "become", match_become, 1);
rb_define_method(rb_cMatch, "size", match_size, 0);
rb_define_method(rb_cMatch, "length", match_size, 0);
rb_define_method(rb_cMatch, "offset", match_offset, 1);
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos Czech Technical University, Prague
E-mail:m.rokos@sh.cvut.cz ICQ:36118339 Jabber:majkl@jabber.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-