diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-05 05:19:45 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-05 05:19:45 +0000 |
| commit | 3b5974bf308bd6b26236e5bd0972823a8191d533 (patch) | |
| tree | 11f7bb55fc088fe08beb794bc5583ffec8250f5c | |
| parent | 20ce211af49a82dc210bf968b5b9ca95b09ba083 (diff) | |
| download | ruby-3b5974bf308bd6b26236e5bd0972823a8191d533.tar.gz ruby-3b5974bf308bd6b26236e5bd0972823a8191d533.tar.xz ruby-3b5974bf308bd6b26236e5bd0972823a8191d533.zip | |
* file.c (rb_stat_mode): generalized st_mode mask.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | file.c | 16 |
2 files changed, 11 insertions, 9 deletions
@@ -1,3 +1,7 @@ +Tue Aug 5 14:19:22 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (rb_stat_mode): generalized st_mode mask. + Tue Aug 5 12:43:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> * io.c (retry_sendfile, retry_read): ENOSYS and EWOULDBLOCK are not @@ -233,6 +233,8 @@ rb_stat_cmp(VALUE self, VALUE other) return Qnil; } +#define ST2UINT(val) ((val) & ~(~1UL << (sizeof(val) * CHAR_BIT - 1))) + /* * call-seq: * stat.dev => fixnum @@ -330,11 +332,7 @@ rb_stat_ino(VALUE self) 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 @@ rb_stat_wr(VALUE obj) { #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 @@ rb_stat_ww(VALUE obj) { #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 } |
