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

ruby-changes:31029

From: nobu <ko1@a...>
Date: Tue, 1 Oct 2013 20:57:08 +0900 (JST)
Subject: [ruby-changes:31029] nobu:r43108 (trunk): file/stat.c: fix commit miss

nobu	2013-10-01 20:57:02 +0900 (Tue, 01 Oct 2013)

  New Revision: 43108

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

  Log:
    file/stat.c: fix commit miss
    
    * ext/-test-/file/stat.c: extension library to test [Feature #8050].

  Added directories:
    trunk/ext/-test-/file/
  Added files:
    trunk/ext/-test-/file/extconf.rb
    trunk/ext/-test-/file/init.c
    trunk/ext/-test-/file/stat.c
Index: ext/-test-/file/init.c
===================================================================
--- ext/-test-/file/init.c	(revision 0)
+++ ext/-test-/file/init.c	(revision 43108)
@@ -0,0 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/file/init.c#L1
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(module);}
+
+void
+Init_file(void)
+{
+    VALUE mBug = rb_define_module("Bug");
+    VALUE module = rb_define_module_under(mBug, "File");
+    TEST_INIT_FUNCS(init);
+}

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

Index: ext/-test-/file/extconf.rb
===================================================================
--- ext/-test-/file/extconf.rb	(revision 0)
+++ ext/-test-/file/extconf.rb	(revision 43108)
@@ -0,0 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/file/extconf.rb#L1
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/file")

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

Index: ext/-test-/file/stat.c
===================================================================
--- ext/-test-/file/stat.c	(revision 0)
+++ ext/-test-/file/stat.c	(revision 43108)
@@ -0,0 +1,27 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/file/stat.c#L1
+#include "ruby/ruby.h"
+#include "ruby/io.h"
+
+static VALUE
+stat_for_fd(VALUE self, VALUE fileno)
+{
+    struct stat st;
+    if (fstat(NUM2INT(fileno), &st)) rb_sys_fail(0);
+    return rb_stat_new(&st);
+}
+
+static VALUE
+stat_for_path(VALUE self, VALUE path)
+{
+    struct stat st;
+    FilePathValue(path);
+    if (stat(RSTRING_PTR(path), &st)) rb_sys_fail(0);
+    return rb_stat_new(&st);
+}
+
+void
+Init_stat(VALUE module)
+{
+    VALUE st = rb_define_module_under(module, "Stat");
+    rb_define_module_function(st, "for_fd", stat_for_fd, 1);
+    rb_define_module_function(st, "for_path", stat_for_path, 1);
+}

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


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

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