Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* enum.c (enum_all): now works without block.

* enum.c (enum_any): ditto.


git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit 4de3b460dd7683ae378c95e7425c1e6816ae188b 1 parent 9c90490
matz authored
Showing with 35 additions and 4 deletions.
  1. +6 −0 ChangeLog
  2. +28 −4 enum.c
  3. +1 −0  eval.c
View
6 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.
View
32 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;
View
1  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);
Please sign in to comment.
Something went wrong with that request. Please try again.