[前][次][番号順一覧][スレッド一覧]

ruby-changes:27168

From: nobu <ko1@a...>
Date: Wed, 13 Feb 2013 17:51:36 +0900 (JST)
Subject: [ruby-changes:27168] nobu:r39220 (trunk): io.c: FOREACH_ARGF

nobu	2013-02-13 17:51:27 +0900 (Wed, 13 Feb 2013)

  New Revision: 39220

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39220

  Log:
    io.c: FOREACH_ARGF
    
    * io.c (FOREACH_ARGF): loop for ARGF.

  Modified files:
    trunk/io.c

Index: io.c
===================================================================
--- io.c	(revision 39219)
+++ io.c	(revision 39220)
@@ -10904,6 +10904,8 @@ argf_readbyte(VALUE argf) https://github.com/ruby/ruby/blob/trunk/io.c#L10904
     return c;
 }
 
+#define FOREACH_ARGF() for (; next_argv(); ARGF.next_p = 1)
+
 /*
  *  call-seq:
  *     ARGF.each(sep=$/)            {|line| block }  -> ARGF
@@ -10940,11 +10942,10 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/io.c#L10942
 argf_each_line(int argc, VALUE *argv, VALUE argf)
 {
     RETURN_ENUMERATOR(argf, argc, argv);
-    for (;;) {
-	if (!next_argv()) return argf;
+    FOREACH_ARGF() {
 	rb_block_call(ARGF.current_file, rb_intern("each_line"), argc, argv, 0, 0);
-	ARGF.next_p = 1;
     }
+    return argf;
 }
 
 /*
@@ -10988,11 +10989,10 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/io.c#L10989
 argf_each_byte(VALUE argf)
 {
     RETURN_ENUMERATOR(argf, 0, 0);
-    for (;;) {
-	if (!next_argv()) return argf;
+    FOREACH_ARGF() {
 	rb_block_call(ARGF.current_file, rb_intern("each_byte"), 0, 0, 0, 0);
-	ARGF.next_p = 1;
     }
+    return argf;
 }
 
 /*
@@ -11028,11 +11028,10 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/io.c#L11028
 argf_each_char(VALUE argf)
 {
     RETURN_ENUMERATOR(argf, 0, 0);
-    for (;;) {
-	if (!next_argv()) return argf;
+    FOREACH_ARGF() {
 	rb_block_call(ARGF.current_file, rb_intern("each_char"), 0, 0, 0, 0);
-	ARGF.next_p = 1;
     }
+    return argf;
 }
 
 /*
@@ -11068,11 +11067,10 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/io.c#L11067
 argf_each_codepoint(VALUE argf)
 {
     RETURN_ENUMERATOR(argf, 0, 0);
-    for (;;) {
-	if (!next_argv()) return argf;
+    FOREACH_ARGF() {
 	rb_block_call(ARGF.current_file, rb_intern("each_codepoint"), 0, 0, 0, 0);
-	ARGF.next_p = 1;
     }
+    return argf;
 }
 
 /*

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]