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

ruby-changes:33654

From: nobu <ko1@a...>
Date: Mon, 28 Apr 2014 23:10:37 +0900 (JST)
Subject: [ruby-changes:33654] nobu:r45735 (trunk): file.c: fix errors on Windows

nobu	2014-04-28 23:10:28 +0900 (Mon, 28 Apr 2014)

  New Revision: 45735

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

  Log:
    file.c: fix errors on Windows
    
    * file.c (rb_io_statfs, rb_statfs_init, statfs_inspect): fix
      compilation errors on Windows.

  Modified files:
    trunk/file.c
Index: file.c
===================================================================
--- file.c	(revision 45734)
+++ file.c	(revision 45735)
@@ -71,13 +71,20 @@ int flock(int, int); https://github.com/ruby/ruby/blob/trunk/file.c#L71
 #endif
 #ifdef HAVE_STRUCT_STATFS
 typedef struct statfs statfs_t;
+#define STATFS(f, s) statfs((f), (s))
 #elif defined(HAVE_STRUCT_STATVFS)
 typedef struct statvfs statfs_t;
+#define STATFS(f, s) statvfs((f), (s))
 #else
 # define WITHOUT_STATFS
 #endif
 #ifndef WITHOUT_STATFS
 static VALUE rb_statfs_new(const statfs_t *st);
+#if defined(HAVE_FSTATFS)
+#define FSTATFS(f, s) Fstatfs((f), (s))
+#elif !defined(HAVE_FSTATVFS)
+#define FSTATFS(f, s) Fstatvfs((f), (s))
+#endif
 #endif
 
 #if defined(__native_client__) && defined(NACL_NEWLIB)
@@ -122,8 +129,9 @@ static VALUE rb_statfs_new(const statfs_ https://github.com/ruby/ruby/blob/trunk/file.c#L129
 #define unlink(p)	rb_w32_uunlink(p)
 #undef rename
 #define rename(f, t)	rb_w32_urename((f), (t))
-#undef statfs
-#define statfs(f, s)	ustatfs((f), (s))
+#undef STATFS
+#define STATFS(f, s)	ustatfs((f), (s))
+#define HAVE_STATFS 1
 #else
 #define STAT(p, s)	stat((p), (s))
 #endif
@@ -1130,16 +1138,16 @@ rb_io_statfs(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L1138
 #if !defined(HAVE_FSTATFS) && !defined(HAVE_FSTATVFS)
     VALUE path;
 #endif
+    int ret;
 
     GetOpenFile(obj, fptr);
-#ifdef HAVE_FSTATFS
-    if (fstatfs(fptr->fd, &st) == -1)
-#elif defined(HAVE_FSTATVFS)
-    if (fstatvfs(fptr->fd, &st) == -1)
+#if defined(HAVE_FSTATFS) || defined(HAVE_FSTATVFS)
+    ret = FSTATFS(fptr->fd, &st);
 #else
-    if (statfs(StringValueCStr(rb_str_encode_ospath(fptr->pathv)), &st) == -1)
+    path = rb_str_encode_ospath(fptr->pathv);
+    ret = STATFS(StringValueCStr(path), &st);
 #endif
-    {
+    if (ret == -1) {
 	rb_sys_fail_path(fptr->pathv);
     }
     return rb_statfs_new(&st);
@@ -5401,11 +5409,7 @@ rb_statfs_init(VALUE obj, VALUE fname) https://github.com/ruby/ruby/blob/trunk/file.c#L5409
     rb_secure(2);
     FilePathValue(fname);
     fname = rb_str_encode_ospath(fname);
-#ifdef HAVE_FSTATFS
-    if (statfs(StringValueCStr(fname), &st) == -1) {
-#elif HAVE_FSTATVFS
-    if (statvfs(StringValueCStr(fname), &st) == -1) {
-#endif
+    if (STATFS(StringValueCStr(fname), &st) == -1) {
 	rb_sys_fail_path(fname);
     }
     if (DATA_PTR(obj)) {
@@ -5598,7 +5602,7 @@ statfs_inspect(VALUE self) https://github.com/ruby/ruby/blob/trunk/file.c#L5602
 		      ", files=%"PRI_LL_PREFIX"d/%"PRI_LL_PREFIX"d"
 		      ">",
 		      rb_obj_class(self),
-#ifdef HAVE_STRUCT_STATFS
+#ifdef HAVE_STRUCT_STATFS_F_TYPE
 		      (long)st->f_type,
 #endif
 #if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME)

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

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