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

ruby-changes:31028

From: nobu <ko1@a...>
Date: Tue, 1 Oct 2013 20:55:00 +0900 (JST)
Subject: [ruby-changes:31028] nobu:r43107 (trunk): file.c: export rb_stat_new

nobu	2013-10-01 20:54:53 +0900 (Tue, 01 Oct 2013)

  New Revision: 43107

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

  Log:
    file.c: export rb_stat_new
    
    * file.c (stat_new_0): constify.
    * file.c (rb_stat_new): constify and export.  based on a patch by
      Hanmac (Hans Mackowiak) at [ruby-core:53225].  [Feature #8050]

  Added directories:
    trunk/test/-ext-/file/
  Added files:
    trunk/test/-ext-/file/test_stat.rb
  Modified files:
    trunk/ChangeLog
    trunk/file.c
    trunk/include/ruby/io.h
Index: include/ruby/io.h
===================================================================
--- include/ruby/io.h	(revision 43106)
+++ include/ruby/io.h	(revision 43107)
@@ -197,6 +197,11 @@ void rb_io_read_check(rb_io_t*); https://github.com/ruby/ruby/blob/trunk/include/ruby/io.h#L197
 int rb_io_read_pending(rb_io_t*);
 DEPRECATED(void rb_read_check(FILE*));
 
+struct stat;
+VALUE rb_stat_new(const struct stat *);
+
+/* gc.c */
+
 RUBY_SYMBOL_EXPORT_END
 
 #if defined(__cplusplus)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43106)
+++ ChangeLog	(revision 43107)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct  1 20:54:33 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* file.c (stat_new_0): constify.
+
+	* file.c (rb_stat_new): constify and export.  based on a patch by
+	  Hanmac (Hans Mackowiak) at [ruby-core:53225].  [Feature #8050]
+
 Tue Oct  1 16:03:42 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* include/ruby/ruby.h (ruby_safe_level_4_warning): needed by extension
Index: test/-ext-/file/test_stat.rb
===================================================================
--- test/-ext-/file/test_stat.rb	(revision 0)
+++ test/-ext-/file/test_stat.rb	(revision 43107)
@@ -0,0 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/test/-ext-/file/test_stat.rb#L1
+require 'test/unit'
+require "-test-/file"
+
+class Test_FileStat < Test::Unit::TestCase
+  def test_stat_for_fd
+    st = open(__FILE__) {|f| Bug::File::Stat.for_fd(f.fileno)}
+    assert_equal(File.stat(__FILE__), st)
+  end
+
+  def test_stat_for_path
+    st = Bug::File::Stat.for_path(__FILE__)
+    assert_equal(File.stat(__FILE__), st)
+  end
+end

Property changes on: test/-ext-/file/test_stat.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: file.c
===================================================================
--- file.c	(revision 43106)
+++ file.c	(revision 43107)
@@ -365,7 +365,7 @@ static const rb_data_type_t stat_data_ty https://github.com/ruby/ruby/blob/trunk/file.c#L365
 };
 
 static VALUE
-stat_new_0(VALUE klass, struct stat *st)
+stat_new_0(VALUE klass, const struct stat *st)
 {
     struct stat *nst = 0;
 
@@ -376,8 +376,8 @@ stat_new_0(VALUE klass, struct stat *st) https://github.com/ruby/ruby/blob/trunk/file.c#L376
     return TypedData_Wrap_Struct(klass, &stat_data_type, nst);
 }
 
-static VALUE
-stat_new(struct stat *st)
+VALUE
+rb_stat_new(const struct stat *st)
 {
     return stat_new_0(rb_cStat, st);
 }
@@ -987,7 +987,7 @@ rb_file_s_stat(VALUE klass, VALUE fname) https://github.com/ruby/ruby/blob/trunk/file.c#L987
     if (rb_stat(fname, &st) < 0) {
 	rb_sys_fail_path(fname);
     }
-    return stat_new(&st);
+    return rb_stat_new(&st);
 }
 
 /*
@@ -1015,7 +1015,7 @@ rb_io_stat(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L1015
     if (fstat(fptr->fd, &st) == -1) {
 	rb_sys_fail_path(fptr->pathv);
     }
-    return stat_new(&st);
+    return rb_stat_new(&st);
 }
 
 /*
@@ -1044,7 +1044,7 @@ rb_file_s_lstat(VALUE klass, VALUE fname https://github.com/ruby/ruby/blob/trunk/file.c#L1044
     if (lstat(StringValueCStr(fname), &st) == -1) {
 	rb_sys_fail_path(fname);
     }
-    return stat_new(&st);
+    return rb_stat_new(&st);
 #else
     return rb_file_s_stat(klass, fname);
 #endif
@@ -1079,7 +1079,7 @@ rb_file_lstat(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L1079
     if (lstat(RSTRING_PTR(path), &st) == -1) {
 	rb_sys_fail_path(fptr->pathv);
     }
-    return stat_new(&st);
+    return rb_stat_new(&st);
 #else
     return rb_io_stat(obj);
 #endif

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

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