1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* time.c (time_timeval): negative time interval shoule not be

allowed.

* eval.c (proc_call): ignore block to `call' always, despite of
  being orphan or not.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-02-27 07:52:11 +00:00
parent df2d69b49a
commit 64fb417473
5 changed files with 33 additions and 27 deletions

View file

@ -1,3 +1,17 @@
Tue Feb 27 16:38:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* time.c (time_timeval): negative time interval shoule not be
allowed.
* eval.c (proc_call): ignore block to `call' always, despite of
being orphan or not.
Mon Feb 26 16:20:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* ruby.c (proc_options): call ruby_show_version() just once.
* dir.c (dir_s_open): returns the value from a block (if given).
Mon Feb 26 00:04:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (proc_call): should not modify ruby_block->frame.iter

3
dir.c
View file

@ -280,8 +280,7 @@ dir_s_open(klass, dirname)
dir_initialize(dir, dirname);
if (rb_block_given_p()) {
rb_ensure(rb_yield, dir, dir_close, dir);
return Qnil;
return rb_ensure(rb_yield, dir, dir_close, dir);
}
return dir;

11
eval.c
View file

@ -198,7 +198,6 @@ print_undef(klass, id)
rb_class2name(klass));
}
#define CACHE_SIZE 0x800
#define CACHE_MASK 0x7ff
#define EXPR1(c,m) ((((c)>>3)^(m))&CACHE_MASK)
@ -6261,19 +6260,11 @@ proc_call(proc, args)
Data_Get_Struct(proc, struct BLOCK, data);
orphan = blk_orphan(data);
if (orphan) {/* orphan procedure */
if (rb_block_given_p()) {
ruby_block->frame.iter = ITER_CUR;
}
else {
ruby_block->frame.iter = ITER_NOT;
}
}
/* PUSH BLOCK from data */
old_block = ruby_block;
_block = *data;
ruby_block = &_block;
ruby_block->frame.iter = ITER_NOT;
PUSH_ITER(ITER_CUR);
ruby_frame->iter = ITER_CUR;

4
ruby.c
View file

@ -430,6 +430,10 @@ proc_options(argc, argv)
goto reswitch;
case 'v':
if (verbose) {
s++;
goto reswitch;
}
ruby_show_version();
verbose = 1;
case 'w':

28
time.c
View file

@ -106,39 +106,37 @@ time_timeval(time, interval)
int interval;
{
struct timeval t;
char *tstr = interval ? "time interval" : "time";
#ifndef NEGATIVE_TIME_T
interval = 1;
#endif
switch (TYPE(time)) {
case T_FIXNUM:
t.tv_sec = FIX2LONG(time);
#ifndef NEGATIVE_TIME_T
if (t.tv_sec < 0)
rb_raise(rb_eArgError, "time must be positive");
#endif
if (interval && t.tv_sec < 0)
rb_raise(rb_eArgError, "%s must be positive", tstr);
t.tv_usec = 0;
break;
case T_FLOAT:
#ifndef NEGATIVE_TIME_T
if (RFLOAT(time)->value < 0.0)
rb_raise(rb_eArgError, "time must be positive");
#endif
if (interval && RFLOAT(time)->value < 0.0)
rb_raise(rb_eArgError, "%s must be positive", tstr);
t.tv_sec = (time_t)RFLOAT(time)->value;
t.tv_usec = (time_t)((RFLOAT(time)->value - (double)t.tv_sec)*1e6);
break;
case T_BIGNUM:
t.tv_sec = NUM2LONG(time);
#ifndef NEGATIVE_TIME_T
if (t.tv_sec < 0)
rb_raise(rb_eArgError, "time must be positive");
#endif
if (interval && t.tv_sec < 0)
rb_raise(rb_eArgError, "%s must be positive", tstr);
t.tv_usec = 0;
break;
default:
rb_raise(rb_eTypeError, "can't convert %s into Time%s",
rb_class2name(CLASS_OF(time)),
interval ? " interval" : "");
rb_raise(rb_eTypeError, "can't convert %s into %s",
rb_class2name(CLASS_OF(time)), tstr);
break;
}
return t;