ruby-changes:1934
From: ko1@a...
Date: 10 Sep 2007 15:25:50 +0900
Subject: [ruby-changes:1934] akr - Ruby:r13425 (trunk): * range.c: represent initialized state using EXCL instead of FL_USER3.
akr 2007-09-10 15:25:40 +0900 (Mon, 10 Sep 2007) New Revision: 13425 Modified files: trunk/ChangeLog trunk/range.c trunk/test/ruby/test_range.rb Log: * range.c: represent initialized state using EXCL instead of FL_USER3. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13425&r2=13424 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_range.rb?r1=13425&r2=13424 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/range.c?r1=13425&r2=13424 Index: ChangeLog =================================================================== --- ChangeLog (revision 13424) +++ ChangeLog (revision 13425) @@ -1,3 +1,7 @@ +Mon Sep 10 15:22:24 2007 Tanaka Akira <akr@f...> + + * range.c: represent initialized state using EXCL instead of FL_USER3. + Mon Sep 10 13:44:37 2007 Yukihiro Matsumoto <matz@r...> * array.c (rb_ary_cycle): avoid infinite loop for empty array. Index: range.c =================================================================== --- range.c (revision 13424) +++ range.c (revision 13425) @@ -22,8 +22,6 @@ #define EXCL(r) RTEST(RANGE_EXCL(r)) #define SET_EXCL(r,v) (RSTRUCT(r)->as.ary[2] = (v) ? Qtrue : Qfalse) -#define FL_INITIALIZED FL_USER3 - static VALUE range_alloc(VALUE klass) { @@ -37,8 +35,6 @@ RBASIC(r)->flags |= n << RSTRUCT_EMBED_LEN_SHIFT; rb_mem_clear(r->as.ary, n); - RBASIC(r)->flags &= ~FL_INITIALIZED; - return (VALUE)r; } @@ -101,10 +97,9 @@ rb_scan_args(argc, argv, "21", &beg, &end, &flags); /* Ranges are immutable, so that they should be initialized only once. */ - if (RBASIC(range)->flags & FL_INITIALIZED) { + if (RANGE_EXCL(range) != Qnil) { rb_name_error(rb_intern("initialize"), "`initialize' called twice"); } - RBASIC(range)->flags |= FL_INITIALIZED; range_init(range, beg, end, RTEST(flags)); return Qnil; } Index: test/ruby/test_range.rb =================================================================== --- test/ruby/test_range.rb (revision 13424) +++ test/ruby/test_range.rb (revision 13425) @@ -59,4 +59,9 @@ assert_equal(0, (0..0).max) assert_equal(nil, (0...0).max) end + + def test_initialize_twice + r = eval("1..2") + assert_raise(NameError) { r.instance_eval { initialize 3, 4 } } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml