зеркало из https://github.com/github/ruby.git
* time.c (rb_time_succ): make Time#succ obsolete since time is not
a discrete value. * range.c (discrete_object_p): treat time objects specially to determine discrete values, since time objects have #succ yet are discrete (for now at least). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a71d47a380
Коммит
9b192302ec
|
@ -415,6 +415,15 @@ Mon Sep 21 17:12:10 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
|
||||
* vm.c (collect_local_variables_in_env): block iseq can be NULL.
|
||||
|
||||
Mon Sep 21 10:50:37 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* time.c (rb_time_succ): make Time#succ obsolete since time is not
|
||||
a discrete value.
|
||||
|
||||
* range.c (discrete_object_p): treat time objects specially to
|
||||
determine discrete values, since time objects have #succ yet are
|
||||
discrete (for now at least).
|
||||
|
||||
Mon Sep 21 10:13:22 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* cont.c (cont_new, cont_capture, fiber_t_alloc): needs already
|
||||
|
|
13
range.c
13
range.c
|
@ -308,6 +308,15 @@ step_i(VALUE i, void *arg)
|
|||
|
||||
extern int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl);
|
||||
|
||||
static int
|
||||
discrete_object_p(obj)
|
||||
{
|
||||
if (rb_obj_is_kind_of(obj, rb_cTime)) return Qfalse; /* until Time#succ removed */
|
||||
if (rb_respond_to(obj, id_succ)) return Qtrue;
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* rng.step(n=1) {| obj | block } => rng
|
||||
|
@ -416,7 +425,7 @@ range_step(int argc, VALUE *argv, VALUE range)
|
|||
else {
|
||||
VALUE args[2];
|
||||
|
||||
if (!rb_respond_to(b, id_succ)) {
|
||||
if (!discrete_object_p(b)) {
|
||||
rb_raise(rb_eTypeError, "can't iterate from %s",
|
||||
rb_obj_classname(b));
|
||||
}
|
||||
|
@ -498,7 +507,7 @@ range_each(VALUE range)
|
|||
rb_block_call(tmp, rb_intern("upto"), 2, args, rb_yield, 0);
|
||||
}
|
||||
else {
|
||||
if (!rb_respond_to(beg, id_succ)) {
|
||||
if (!discrete_object_p(beg)) {
|
||||
rb_raise(rb_eTypeError, "can't iterate from %s",
|
||||
rb_obj_classname(beg));
|
||||
}
|
||||
|
|
13
time.c
13
time.c
|
@ -2948,17 +2948,19 @@ time_minus(VALUE time1, VALUE time2)
|
|||
* time.succ => new_time
|
||||
*
|
||||
* Return a new time object, one second later than <code>time</code>.
|
||||
* Time#succ is obsolete since 1.9.2 for time is not a discrete value.
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:23:57 -0600
|
||||
* t.succ #=> 2007-11-19 08:23:58 -0600
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
time_succ(VALUE time)
|
||||
VALUE
|
||||
rb_time_succ(VALUE time)
|
||||
{
|
||||
struct time_object *tobj;
|
||||
struct time_object *tobj2;
|
||||
|
||||
rb_warn("Time#succ is obsolete; use time + 1");
|
||||
GetTimeval(time, tobj);
|
||||
time = time_new_timexv(rb_cTime, add(tobj->timexv, INT2FIX(TIME_SCALE)));
|
||||
GetTimeval(time, tobj2);
|
||||
|
@ -2966,11 +2968,8 @@ time_succ(VALUE time)
|
|||
return time;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_time_succ(VALUE time)
|
||||
{
|
||||
return time_succ(time);
|
||||
}
|
||||
#define time_succ rb_time_succ
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
|
|
Загрузка…
Ссылка в новой задаче