diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | class.c | 2 | ||||
-rw-r--r-- | range.c | 29 |
4 files changed, 30 insertions, 9 deletions
@@ -1,3 +1,10 @@ +Thu Mar 12 15:33:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * range.c (range_s_new): check values by `first <= last'. + + * parse.y (lastline_set): fixed offset for $_ and $~ in the local + variable space. + Wed Mar 11 02:14:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * io.c (io_gets): handle normal case specially for speed. @@ -168,6 +168,7 @@ sample/freq.rb sample/from.rb sample/fullpath.rb sample/getopts.test +sample/goodfriday.rb sample/less.rb sample/list.rb sample/list2.rb @@ -444,7 +444,7 @@ rb_undef_method(klass, name) VALUE klass; char *name; { - rb_add_method(klass, rb_intern(name), 0, NOEX_PUBLIC); + rb_add_method(klass, rb_intern(name), 0, NOEX_UNDEF); } VALUE @@ -18,19 +18,32 @@ extern VALUE cNumeric; static ID upto; static VALUE +range_check(args) + VALUE *args; +{ + VALUE v = rb_funcall(args[0], rb_intern("<="), 1, args[1]); + + if (!RTEST(v)) { + Fail(""); /* no ascending values */ + } + return Qnil; +} + +static VALUE +range_failed() +{ + ArgError("bad value for range"); +} + +static VALUE range_s_new(klass, first, last) VALUE klass, first, last; { VALUE obj; + VALUE args[2]; - if (!(FIXNUM_P(first) && FIXNUM_P(last)) - && (TYPE(first) != TYPE(last) - || CLASS_OF(first) != CLASS_OF(last) - || !rb_respond_to(first, upto)) - && !(obj_is_kind_of(first, cNumeric) - && obj_is_kind_of(last, cNumeric))) { - ArgError("bad value for range"); - } + args[0] = first; args[1] = last; + rb_rescue(range_check, args, range_failed, 0); obj = obj_alloc(klass); |