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

ruby-changes:17104

From: akr <ko1@a...>
Date: Thu, 26 Aug 2010 21:50:22 +0900 (JST)
Subject: [ruby-changes:17104] Ruby:r29104 (trunk): * ext/pathname/pathname.c (path_readlines): Pathname#readlines

akr	2010-08-26 21:50:13 +0900 (Thu, 26 Aug 2010)

  New Revision: 29104

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

  Log:
    * ext/pathname/pathname.c (path_readlines): Pathname#readlines
      translated from pathname.rb.

  Modified files:
    trunk/ChangeLog
    trunk/ext/pathname/lib/pathname.rb
    trunk/ext/pathname/pathname.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29103)
+++ ChangeLog	(revision 29104)
@@ -1,3 +1,8 @@
+Thu Aug 26 21:49:46 2010  Tanaka Akira  <akr@f...>
+
+	* ext/pathname/pathname.c (path_readlines): Pathname#readlines
+	  translated from pathname.rb.
+
 Thu Aug 26 10:37:00 2010  NARUSE, Yui  <naruse@r...>
 
 	* regint.h (OnigStackIndex): the type should be intptr_t.
Index: ext/pathname/lib/pathname.rb
===================================================================
--- ext/pathname/lib/pathname.rb	(revision 29103)
+++ ext/pathname/lib/pathname.rb	(revision 29104)
@@ -485,9 +485,6 @@
 
 class Pathname    # * IO *
 
-  # See <tt>IO.readlines</tt>.  Returns all the lines from the file.
-  def readlines(*args) IO.readlines(@path, *args) end
-
   # See <tt>IO.sysopen</tt>.
   def sysopen(*args) IO.sysopen(@path, *args) end
 end
Index: ext/pathname/pathname.c
===================================================================
--- ext/pathname/pathname.c	(revision 29103)
+++ ext/pathname/pathname.c	(revision 29104)
@@ -301,6 +301,26 @@
 }
 
 /*
+ * call-seq:
+ *   pathname.readlines(sep=$/ [, open_args])     -> array
+ *   pathname.readlines(limit [, open_args])      -> array
+ *   pathname.readlines(sep, limit [, open_args]) -> array
+ *        
+ * See <tt>IO.readlines</tt>.  Returns all the lines from the file.
+ *
+ */
+static VALUE
+path_readlines(int argc, VALUE *argv, VALUE self)
+{
+    VALUE args[4];
+    int n;
+
+    args[0] = get_strpath(self);
+    n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
+    return rb_funcall2(rb_cIO, rb_intern("readlines"), 1+n, args);
+}
+
+/*
  * See <tt>File.atime</tt>.  Returns last access time.
  */
 static VALUE
@@ -762,6 +782,7 @@
     rb_define_method(rb_cPathname, "each_line", path_each_line, -1);
     rb_define_method(rb_cPathname, "read", path_read, -1);
     rb_define_method(rb_cPathname, "binread", path_binread, -1);
+    rb_define_method(rb_cPathname, "readlines", path_readlines, -1);
     rb_define_method(rb_cPathname, "atime", path_atime, 0);
     rb_define_method(rb_cPathname, "ctime", path_ctime, 0);
     rb_define_method(rb_cPathname, "mtime", path_mtime, 0);

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

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