summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-26 12:50:13 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-26 12:50:13 +0000
commitbafaff1f43cf44430fed590dda00928b61821b6e (patch)
treec3e9a9560064f06da7c892e3d90834eb1c3675f3
parent0eb31be6818ee400b30899f77f6bcbe0722ea35f (diff)
* ext/pathname/pathname.c (path_readlines): Pathname#readlines
translated from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/pathname/lib/pathname.rb3
-rw-r--r--ext/pathname/pathname.c21
3 files changed, 26 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a62ea61211..415bb4b275 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Aug 26 21:49:46 2010 Tanaka Akira <akr@fsij.org>
+
+ * ext/pathname/pathname.c (path_readlines): Pathname#readlines
+ translated from pathname.rb.
+
Thu Aug 26 10:37:00 2010 NARUSE, Yui <naruse@ruby-lang.org>
* regint.h (OnigStackIndex): the type should be intptr_t.
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb
index 0bc8e3bfa5..b4c701a084 100644
--- a/ext/pathname/lib/pathname.rb
+++ b/ext/pathname/lib/pathname.rb
@@ -485,9 +485,6 @@ end
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
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 874581dfbd..2918ef0ecb 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -301,6 +301,26 @@ path_binread(int argc, VALUE *argv, VALUE self)
}
/*
+ * 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 @@ Init_pathname()
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);