summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-27 07:52:11 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-27 07:52:11 +0000
commit64fb417473889de0f03bee0f178293ce70623a92 (patch)
tree1a927def82e6c8c5e14ba34e41aa72f617cf16d6
parentdf2d69b49ab1c8b42dd6c18fb63df26aec95f364 (diff)
* 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
-rw-r--r--ChangeLog14
-rw-r--r--dir.c3
-rw-r--r--eval.c11
-rw-r--r--ruby.c4
-rw-r--r--time.c28
5 files changed, 33 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index c20d2d6..bc8e794 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/dir.c b/dir.c
index dd28537..617dad7 100644
--- a/dir.c
+++ b/dir.c
@@ -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;
diff --git a/eval.c b/eval.c
index 0008961..3501bc6 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
diff --git a/ruby.c b/ruby.c
index 5d92800..6c8bd8e 100644
--- a/ruby.c
+++ b/ruby.c
@@ -430,6 +430,10 @@ proc_options(argc, argv)
goto reswitch;
case 'v':
+ if (verbose) {
+ s++;
+ goto reswitch;
+ }
ruby_show_version();
verbose = 1;
case 'w':
diff --git a/time.c b/time.c
index 8da0daf..1b18859 100644
--- a/time.c
+++ b/time.c
@@ -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;