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

ruby-changes:6850

From: nobu <ko1@a...>
Date: Tue, 5 Aug 2008 14:20:17 +0900 (JST)
Subject: [ruby-changes:6850] Ruby:r18365 (trunk, ruby_1_8): * file.c (rb_stat_mode): generalized st_mode mask.

nobu	2008-08-05 14:19:45 +0900 (Tue, 05 Aug 2008)

  New Revision: 18365

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

  Log:
    * file.c (rb_stat_mode): generalized st_mode mask.

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/file.c
    trunk/ChangeLog
    trunk/file.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18364)
+++ ChangeLog	(revision 18365)
@@ -1,3 +1,7 @@
+Tue Aug  5 14:19:22 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* file.c (rb_stat_mode): generalized st_mode mask.
+
 Tue Aug  5 12:43:47 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* io.c (retry_sendfile, retry_read): ENOSYS and EWOULDBLOCK are not
Index: file.c
===================================================================
--- file.c	(revision 18364)
+++ file.c	(revision 18365)
@@ -233,6 +233,8 @@
     return Qnil;
 }
 
+#define ST2UINT(val) ((val) & ~(~1UL << (sizeof(val) * CHAR_BIT - 1)))
+
 /*
  *  call-seq:
  *     stat.dev    => fixnum
@@ -330,11 +332,7 @@
 static VALUE
 rb_stat_mode(VALUE self)
 {
-#ifdef __BORLANDC__
-    return UINT2NUM((unsigned short)(get_stat(self)->st_mode));
-#else
-    return UINT2NUM(get_stat(self)->st_mode);
-#endif
+    return UINT2NUM(ST2UINT(get_stat(self)->st_mode));
 }
 
 /*
@@ -4034,10 +4032,10 @@
 {
 #ifdef S_IROTH
     if ((get_stat(obj)->st_mode & (S_IROTH)) == S_IROTH) {
-      return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
+	return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
     }
     else {
-      return Qnil;
+	return Qnil;
     }
 #endif
 }
@@ -4126,10 +4124,10 @@
 {
 #ifdef S_IROTH
     if ((get_stat(obj)->st_mode & (S_IWOTH)) == S_IWOTH) {
-      return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
+	return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
     }
     else {
-      return Qnil;
+	return Qnil;
     }
 #endif
 }
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 18364)
+++ ruby_1_8/ChangeLog	(revision 18365)
@@ -1,3 +1,7 @@
+Tue Aug  5 14:19:22 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* file.c (rb_stat_mode): generalized st_mode mask.
+
 Mon Aug  4 16:48:50 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (deferred_nodes, compstmt, arg, fixup_nodes, range_op): fix
Index: ruby_1_8/file.c
===================================================================
--- ruby_1_8/file.c	(revision 18364)
+++ ruby_1_8/file.c	(revision 18365)
@@ -225,6 +225,8 @@
 static VALUE rb_stat_mtime _((VALUE));
 static VALUE rb_stat_ctime _((VALUE));
 
+#define ST2UINT(val) ((val) & ~(~1UL << (sizeof(val) * CHAR_BIT - 1)))
+
 /*
  *  call-seq:
  *     stat.dev    => fixnum
@@ -327,11 +329,7 @@
 rb_stat_mode(self)
     VALUE self;
 {
-#ifdef __BORLANDC__
-    return UINT2NUM((unsigned short)(get_stat(self)->st_mode));
-#else
-    return UINT2NUM(get_stat(self)->st_mode);
-#endif
+    return UINT2NUM(ST2UINT(get_stat(self)->st_mode));
 }
 
 /*
@@ -979,14 +977,6 @@
 #ifndef S_ISLNK
 #  ifdef _S_ISLNK
 #    define S_ISLNK(m) _S_ISLNK(m)
-#  elif defined __BORLANDC__
-#    ifdef _S_IFLNK
-#      define S_ISLNK(m) (((unsigned short)(m) & S_IFMT) == _S_IFLNK)
-#    else
-#      ifdef S_IFLNK
-#        define S_ISLNK(m) (((unsigned short)(m) & S_IFMT) == S_IFLNK)
-#      endif
-#    endif
 #  else
 #    ifdef _S_IFLNK
 #      define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
@@ -1023,14 +1013,6 @@
 #ifndef S_ISSOCK
 #  ifdef _S_ISSOCK
 #    define S_ISSOCK(m) _S_ISSOCK(m)
-#  elif defined __BORLANDC__
-#    ifdef _S_IFSOCK
-#      define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == _S_IFSOCK)
-#    else
-#      ifdef S_IFSOCK
-#        define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == S_IFSOCK)
-#      endif
-#    endif
 #  else
 #    ifdef _S_IFSOCK
 #      define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)

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

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