* 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> Mon Feb 26 00:04:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (proc_call): should not modify ruby_block->frame.iter * 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); dir_initialize(dir, dirname);
if (rb_block_given_p()) { if (rb_block_given_p()) {
rb_ensure(rb_yield, dir, dir_close, dir); return rb_ensure(rb_yield, dir, dir_close, dir);
return Qnil;
} }
return dir; return dir;

11
eval.c
View File

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

4
ruby.c
View File

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

28
time.c
View File

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