summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--enum.c32
-rw-r--r--eval.c1
3 files changed, 35 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 917755c..9c0d86c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,12 @@ Tue Jan 14 21:47:56 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
the suffix specifiched. [ruby-dev:18702]
http://moonrock.jp/~don/d/200211.html#d08_t1
+Tue Jan 14 18:36:41 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_all): now works without block.
+
+ * enum.c (enum_any): ditto.
+
Tue Jan 14 01:21:32 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* io.c (next_argv): not always set binmode.
diff --git a/enum.c b/enum.c
index 24b6e9e..f440292 100644
--- a/enum.c
+++ b/enum.c
@@ -287,7 +287,7 @@ enum_sort_by(obj)
}
static VALUE
-all_i(i, memo)
+all_iter_i(i, memo)
VALUE i;
NODE *memo;
{
@@ -299,6 +299,18 @@ all_i(i, memo)
}
static VALUE
+all_i(i, memo)
+ VALUE i;
+ NODE *memo;
+{
+ if (!RTEST(i)) {
+ memo->u1.value = Qfalse;
+ rb_iter_break();
+ }
+ return Qnil;
+}
+
+static VALUE
enum_all(obj)
VALUE obj;
{
@@ -306,14 +318,14 @@ enum_all(obj)
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
memo->u1.value = Qtrue;
- rb_iterate(rb_each, obj, all_i, (VALUE)memo);
+ rb_iterate(rb_each, obj, rb_block_given_p() ? all_iter_i : all_i, (VALUE)memo);
result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return result;
}
static VALUE
-any_i(i, memo)
+any_iter_i(i, memo)
VALUE i;
NODE *memo;
{
@@ -325,6 +337,18 @@ any_i(i, memo)
}
static VALUE
+any_i(i, memo)
+ VALUE i;
+ NODE *memo;
+{
+ if (RTEST(i)) {
+ memo->u1.value = Qtrue;
+ rb_iter_break();
+ }
+ return Qnil;
+}
+
+static VALUE
enum_any(obj)
VALUE obj;
{
@@ -332,7 +356,7 @@ enum_any(obj)
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
memo->u1.value = Qfalse;
- rb_iterate(rb_each, obj, any_i, (VALUE)memo);
+ rb_iterate(rb_each, obj, rb_block_given_p() ? any_iter_i : any_i, (VALUE)memo);
result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return result;
diff --git a/eval.c b/eval.c
index 5b0dfb5..adc04d9 100644
--- a/eval.c
+++ b/eval.c
@@ -5613,6 +5613,7 @@ rb_f_require(obj, fname)
SafeStringValue(fname);
ext = strrchr(RSTRING(fname)->ptr, '.');
+ if (ext && strchr(ext, '/')) ext = 0;
if (ext) {
if (strcmp(".rb", ext) == 0) {
feature = rb_str_dup(fname);